fix: self sync sync message failures for default values

This commit is contained in:
0x330a
2023-05-15 15:03:44 +10:00
parent 9646ea580f
commit dcbe548891
6 changed files with 24 additions and 21 deletions

View File

@@ -64,7 +64,8 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
return
} // Wait for all attachments to upload before continuing
}
val promise = MessageSender.send(this.message, this.destination).success {
val isSync = destination is Destination.Contact && destination.publicKey == sender
val promise = MessageSender.send(this.message, this.destination, isSync).success {
this.handleSuccess(dispatcherName)
}.fail { exception ->
var logStacktrace = true

View File

@@ -62,7 +62,7 @@ object MessageSender {
}
// Convenience
fun send(message: Message, destination: Destination, isSyncMessage: Boolean = false): Promise<Unit, Exception> {
fun send(message: Message, destination: Destination, isSyncMessage: Boolean): Promise<Unit, Exception> {
return if (destination is Destination.LegacyOpenGroup || destination is Destination.OpenGroup || destination is Destination.OpenGroupInbox) {
sendToOpenGroupDestination(destination, message)
} else {
@@ -440,17 +440,17 @@ object MessageSender {
JobQueue.shared.add(job)
}
fun sendNonDurably(message: VisibleMessage, attachments: List<SignalAttachment>, address: Address): Promise<Unit, Exception> {
fun sendNonDurably(message: VisibleMessage, attachments: List<SignalAttachment>, address: Address, isSyncMessage: Boolean): Promise<Unit, Exception> {
val attachmentIDs = MessagingModuleConfiguration.shared.messageDataProvider.getAttachmentIDsFor(message.id!!)
message.attachmentIDs.addAll(attachmentIDs)
return sendNonDurably(message, address)
return sendNonDurably(message, address, isSyncMessage)
}
fun sendNonDurably(message: Message, address: Address): Promise<Unit, Exception> {
fun sendNonDurably(message: Message, address: Address, isSyncMessage: Boolean): Promise<Unit, Exception> {
val threadID = MessagingModuleConfiguration.shared.storage.getThreadId(address)
message.threadID = threadID
val destination = Destination.from(address)
return send(message, destination)
return send(message, destination, isSyncMessage)
}
// Closed groups

View File

@@ -55,11 +55,12 @@ fun MessageSender.create(name: String, members: Collection<String>): Promise<Str
// Send a closed group update message to all members individually
val closedGroupUpdateKind = ClosedGroupControlMessage.Kind.New(ByteString.copyFrom(Hex.fromStringCondensed(groupPublicKey)), name, encryptionKeyPair, membersAsData, adminsAsData, 0)
val sentTime = SnodeAPI.nowWithOffset
val ourPubKey = storage.getUserPublicKey()
for (member in members) {
val closedGroupControlMessage = ClosedGroupControlMessage(closedGroupUpdateKind)
closedGroupControlMessage.sentTimestamp = sentTime
try {
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(member)).get()
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(member), member == ourPubKey).get()
} catch (e: Exception) {
deferred.reject(e)
return@queue
@@ -225,7 +226,7 @@ fun MessageSender.leave(groupPublicKey: String, notifyUser: Boolean = true): Pro
val sentTime = SnodeAPI.nowWithOffset
closedGroupControlMessage.sentTimestamp = sentTime
storage.setActive(groupID, false)
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(groupID)).success {
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(groupID), isSyncMessage = false).success {
// Notify the user
val infoType = SignalServiceGroup.Type.QUIT
if (notifyUser) {
@@ -285,7 +286,8 @@ fun MessageSender.sendEncryptionKeyPair(groupPublicKey: String, newKeyPair: ECKe
val closedGroupControlMessage = ClosedGroupControlMessage(kind)
closedGroupControlMessage.sentTimestamp = sentTime
return if (force) {
MessageSender.sendNonDurably(closedGroupControlMessage, Address.fromSerialized(destination))
val isSync = MessagingModuleConfiguration.shared.storage.getUserPublicKey() == destination
MessageSender.sendNonDurably(closedGroupControlMessage, Address.fromSerialized(destination), isSyncMessage = isSync)
} else {
MessageSender.send(closedGroupControlMessage, Address.fromSerialized(destination))
null