mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
WIP: clean up signal protocol
This commit is contained in:
parent
1a907fcf54
commit
13c2995746
@ -153,7 +153,7 @@ class PublicChatPoller(private val context: Context, private val group: PublicCh
|
|||||||
signalLinkPreviews.add(SignalServiceDataMessage.Preview(linkPreview.linkPreviewURL!!, linkPreview.linkPreviewTitle!!, Optional.of(attachment)))
|
signalLinkPreviews.add(SignalServiceDataMessage.Preview(linkPreview.linkPreviewURL!!, linkPreview.linkPreviewTitle!!, Optional.of(attachment)))
|
||||||
}
|
}
|
||||||
val body = if (message.body == message.timestamp.toString()) "" else message.body // Workaround for the fact that the back-end doesn't accept messages without a body
|
val body = if (message.body == message.timestamp.toString()) "" else message.body // Workaround for the fact that the back-end doesn't accept messages without a body
|
||||||
return SignalServiceDataMessage(message.timestamp, serviceGroup, attachments, body, false, 0, false, null, false, quote, null, signalLinkPreviews, null)
|
return SignalServiceDataMessage(message.timestamp, serviceGroup, attachments, body, 0, false, null, quote, null, signalLinkPreviews)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pollForNewMessages(): Promise<Unit, Exception> {
|
fun pollForNewMessages(): Promise<Unit, Exception> {
|
||||||
|
@ -12,6 +12,7 @@ import org.session.libsignal.libsignal.ecc.ECKeyPair
|
|||||||
import org.session.libsignal.libsignal.util.guava.Optional
|
import org.session.libsignal.libsignal.util.guava.Optional
|
||||||
import org.session.libsignal.service.api.push.SignalServiceAddress
|
import org.session.libsignal.service.api.push.SignalServiceAddress
|
||||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||||
|
import org.session.libsignal.service.internal.push.SignalServiceProtos.DataMessage
|
||||||
import org.session.libsignal.service.loki.protocol.meta.TTLUtilities
|
import org.session.libsignal.service.loki.protocol.meta.TTLUtilities
|
||||||
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
||||||
import org.session.libsignal.service.loki.utilities.toHexString
|
import org.session.libsignal.service.loki.utilities.toHexString
|
||||||
@ -48,13 +49,13 @@ class ClosedGroupUpdateMessageSendJobV2 private constructor(parameters: Paramete
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun fromProto(proto: SignalServiceProtos.ClosedGroupUpdateV2.KeyPairWrapper): KeyPairWrapper {
|
fun fromProto(proto: DataMessage.ClosedGroupControlMessage.KeyPairWrapper): KeyPairWrapper {
|
||||||
return KeyPairWrapper(proto.publicKey.toString(), proto.encryptedKeyPair.toByteArray())
|
return KeyPairWrapper(proto.publicKey.toString(), proto.encryptedKeyPair.toByteArray())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toProto(): SignalServiceProtos.ClosedGroupUpdateV2.KeyPairWrapper {
|
fun toProto(): DataMessage.ClosedGroupControlMessage.KeyPairWrapper {
|
||||||
val result = SignalServiceProtos.ClosedGroupUpdateV2.KeyPairWrapper.newBuilder()
|
val result = DataMessage.ClosedGroupControlMessage.KeyPairWrapper.newBuilder()
|
||||||
result.publicKey = ByteString.copyFrom(Hex.fromStringCondensed(publicKey))
|
result.publicKey = ByteString.copyFrom(Hex.fromStringCondensed(publicKey))
|
||||||
result.encryptedKeyPair = ByteString.copyFrom(encryptedKeyPair)
|
result.encryptedKeyPair = ByteString.copyFrom(encryptedKeyPair)
|
||||||
return result.build()
|
return result.build()
|
||||||
@ -171,11 +172,11 @@ class ClosedGroupUpdateMessageSendJobV2 private constructor(parameters: Paramete
|
|||||||
|
|
||||||
public override fun onRun() {
|
public override fun onRun() {
|
||||||
val contentMessage = SignalServiceProtos.Content.newBuilder()
|
val contentMessage = SignalServiceProtos.Content.newBuilder()
|
||||||
val dataMessage = SignalServiceProtos.DataMessage.newBuilder()
|
val dataMessage = DataMessage.newBuilder()
|
||||||
val closedGroupUpdate = SignalServiceProtos.ClosedGroupUpdateV2.newBuilder()
|
val closedGroupUpdate = DataMessage.ClosedGroupControlMessage.newBuilder()
|
||||||
when (kind) {
|
when (kind) {
|
||||||
is Kind.New -> {
|
is Kind.New -> {
|
||||||
closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.NEW
|
closedGroupUpdate.type = DataMessage.ClosedGroupControlMessage.Type.NEW
|
||||||
closedGroupUpdate.publicKey = ByteString.copyFrom(kind.publicKey)
|
closedGroupUpdate.publicKey = ByteString.copyFrom(kind.publicKey)
|
||||||
closedGroupUpdate.name = kind.name
|
closedGroupUpdate.name = kind.name
|
||||||
val encryptionKeyPair = SignalServiceProtos.KeyPair.newBuilder()
|
val encryptionKeyPair = SignalServiceProtos.KeyPair.newBuilder()
|
||||||
@ -186,31 +187,31 @@ class ClosedGroupUpdateMessageSendJobV2 private constructor(parameters: Paramete
|
|||||||
closedGroupUpdate.addAllAdmins(kind.admins.map { ByteString.copyFrom(it) })
|
closedGroupUpdate.addAllAdmins(kind.admins.map { ByteString.copyFrom(it) })
|
||||||
}
|
}
|
||||||
is Kind.Update -> {
|
is Kind.Update -> {
|
||||||
closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.UPDATE
|
closedGroupUpdate.type = DataMessage.ClosedGroupControlMessage.Type.UPDATE
|
||||||
closedGroupUpdate.name = kind.name
|
closedGroupUpdate.name = kind.name
|
||||||
closedGroupUpdate.addAllMembers(kind.members.map { ByteString.copyFrom(it) })
|
closedGroupUpdate.addAllMembers(kind.members.map { ByteString.copyFrom(it) })
|
||||||
}
|
}
|
||||||
is Kind.EncryptionKeyPair -> {
|
is Kind.EncryptionKeyPair -> {
|
||||||
closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.ENCRYPTION_KEY_PAIR
|
closedGroupUpdate.type = DataMessage.ClosedGroupControlMessage.Type.ENCRYPTION_KEY_PAIR
|
||||||
closedGroupUpdate.addAllWrappers(kind.wrappers.map { it.toProto() })
|
closedGroupUpdate.addAllWrappers(kind.wrappers.map { it.toProto() })
|
||||||
}
|
}
|
||||||
Kind.Leave -> {
|
Kind.Leave -> {
|
||||||
closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.MEMBER_LEFT
|
closedGroupUpdate.type = DataMessage.ClosedGroupControlMessage.Type.MEMBER_LEFT
|
||||||
}
|
}
|
||||||
is Kind.RemoveMembers -> {
|
is Kind.RemoveMembers -> {
|
||||||
closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.MEMBERS_REMOVED
|
closedGroupUpdate.type = DataMessage.ClosedGroupControlMessage.Type.MEMBERS_REMOVED
|
||||||
closedGroupUpdate.addAllMembers(kind.members.map { ByteString.copyFrom(it) })
|
closedGroupUpdate.addAllMembers(kind.members.map { ByteString.copyFrom(it) })
|
||||||
}
|
}
|
||||||
is Kind.AddMembers -> {
|
is Kind.AddMembers -> {
|
||||||
closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.MEMBERS_ADDED
|
closedGroupUpdate.type = DataMessage.ClosedGroupControlMessage.Type.MEMBERS_ADDED
|
||||||
closedGroupUpdate.addAllMembers(kind.members.map { ByteString.copyFrom(it) })
|
closedGroupUpdate.addAllMembers(kind.members.map { ByteString.copyFrom(it) })
|
||||||
}
|
}
|
||||||
is Kind.NameChange -> {
|
is Kind.NameChange -> {
|
||||||
closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.NAME_CHANGE
|
closedGroupUpdate.type = DataMessage.ClosedGroupControlMessage.Type.NAME_CHANGE
|
||||||
closedGroupUpdate.name = kind.name
|
closedGroupUpdate.name = kind.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dataMessage.closedGroupUpdateV2 = closedGroupUpdate.build()
|
dataMessage.closedGroupControlMessage = closedGroupUpdate.build()
|
||||||
contentMessage.dataMessage = dataMessage.build()
|
contentMessage.dataMessage = dataMessage.build()
|
||||||
val serializedContentMessage = contentMessage.build().toByteArray()
|
val serializedContentMessage = contentMessage.build().toByteArray()
|
||||||
val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender()
|
val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user