mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
fix: self sync sync message failures for default values
This commit is contained in:
parent
9646ea580f
commit
dcbe548891
@ -281,7 +281,7 @@ class DefaultConversationRepository @Inject constructor(
|
|||||||
override suspend fun acceptMessageRequest(threadId: Long, recipient: Recipient): ResultOf<Unit> = suspendCoroutine { continuation ->
|
override suspend fun acceptMessageRequest(threadId: Long, recipient: Recipient): ResultOf<Unit> = suspendCoroutine { continuation ->
|
||||||
storage.setRecipientApproved(recipient, true)
|
storage.setRecipientApproved(recipient, true)
|
||||||
val message = MessageRequestResponse(true)
|
val message = MessageRequestResponse(true)
|
||||||
MessageSender.send(message, Destination.from(recipient.address))
|
MessageSender.send(message, Destination.from(recipient.address), isSyncMessage = recipient.isLocalNumber)
|
||||||
.success {
|
.success {
|
||||||
threadDb.setHasSent(threadId, true)
|
threadDb.setHasSent(threadId, true)
|
||||||
continuation.resume(ResultOf.Success(Unit))
|
continuation.resume(ResultOf.Success(Unit))
|
||||||
|
@ -98,7 +98,7 @@ object ConfigurationMessageUtilities {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
val configurationMessage = ConfigurationMessage.getCurrent(contacts) ?: return Promise.ofSuccess(Unit)
|
val configurationMessage = ConfigurationMessage.getCurrent(contacts) ?: return Promise.ofSuccess(Unit)
|
||||||
val promise = MessageSender.send(configurationMessage, Destination.from(Address.fromSerialized(userPublicKey)))
|
val promise = MessageSender.send(configurationMessage, Destination.from(Address.fromSerialized(userPublicKey)), isSyncMessage = true)
|
||||||
TextSecurePreferences.setLastConfigurationSyncTime(context, System.currentTimeMillis())
|
TextSecurePreferences.setLastConfigurationSyncTime(context, System.currentTimeMillis())
|
||||||
return promise
|
return promise
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ class CallManager(context: Context, audioManager: AudioManagerCompat, private va
|
|||||||
sdpMLineIndexes = sdpMLineIndexes,
|
sdpMLineIndexes = sdpMLineIndexes,
|
||||||
sdpMids = sdpMids,
|
sdpMids = sdpMids,
|
||||||
currentCallId
|
currentCallId
|
||||||
), currentRecipient.address)
|
), currentRecipient.address, isSyncMessage = currentRecipient.isLocalNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -433,7 +433,7 @@ class CallManager(context: Context, audioManager: AudioManagerCompat, private va
|
|||||||
pendingIncomingIceUpdates.clear()
|
pendingIncomingIceUpdates.clear()
|
||||||
val answerMessage = CallMessage.answer(answer.description, callId)
|
val answerMessage = CallMessage.answer(answer.description, callId)
|
||||||
Log.i("Loki", "Posting new answer")
|
Log.i("Loki", "Posting new answer")
|
||||||
MessageSender.sendNonDurably(answerMessage, recipient.address)
|
MessageSender.sendNonDurably(answerMessage, recipient.address, isSyncMessage = recipient.isLocalNumber)
|
||||||
} else {
|
} else {
|
||||||
Promise.ofFail(Exception("Couldn't reconnect from current state"))
|
Promise.ofFail(Exception("Couldn't reconnect from current state"))
|
||||||
}
|
}
|
||||||
@ -477,11 +477,11 @@ class CallManager(context: Context, audioManager: AudioManagerCompat, private va
|
|||||||
connection.setLocalDescription(answer)
|
connection.setLocalDescription(answer)
|
||||||
val answerMessage = CallMessage.answer(answer.description, callId)
|
val answerMessage = CallMessage.answer(answer.description, callId)
|
||||||
val userAddress = storage.getUserPublicKey() ?: return Promise.ofFail(NullPointerException("No user public key"))
|
val userAddress = storage.getUserPublicKey() ?: return Promise.ofFail(NullPointerException("No user public key"))
|
||||||
MessageSender.sendNonDurably(answerMessage, Address.fromSerialized(userAddress))
|
MessageSender.sendNonDurably(answerMessage, Address.fromSerialized(userAddress), isSyncMessage = true)
|
||||||
val sendAnswerMessage = MessageSender.sendNonDurably(CallMessage.answer(
|
val sendAnswerMessage = MessageSender.sendNonDurably(CallMessage.answer(
|
||||||
answer.description,
|
answer.description,
|
||||||
callId
|
callId
|
||||||
), recipient.address)
|
), recipient.address, isSyncMessage = recipient.isLocalNumber)
|
||||||
|
|
||||||
insertCallMessage(recipient.address.serialize(), CallMessageType.CALL_INCOMING, false)
|
insertCallMessage(recipient.address.serialize(), CallMessageType.CALL_INCOMING, false)
|
||||||
|
|
||||||
@ -531,13 +531,13 @@ class CallManager(context: Context, audioManager: AudioManagerCompat, private va
|
|||||||
Log.d("Loki", "Sending pre-offer")
|
Log.d("Loki", "Sending pre-offer")
|
||||||
return MessageSender.sendNonDurably(CallMessage.preOffer(
|
return MessageSender.sendNonDurably(CallMessage.preOffer(
|
||||||
callId
|
callId
|
||||||
), recipient.address).bind {
|
), recipient.address, isSyncMessage = recipient.isLocalNumber).bind {
|
||||||
Log.d("Loki", "Sent pre-offer")
|
Log.d("Loki", "Sent pre-offer")
|
||||||
Log.d("Loki", "Sending offer")
|
Log.d("Loki", "Sending offer")
|
||||||
MessageSender.sendNonDurably(CallMessage.offer(
|
MessageSender.sendNonDurably(CallMessage.offer(
|
||||||
offer.description,
|
offer.description,
|
||||||
callId
|
callId
|
||||||
), recipient.address).success {
|
), recipient.address, isSyncMessage = recipient.isLocalNumber).success {
|
||||||
Log.d("Loki", "Sent offer")
|
Log.d("Loki", "Sent offer")
|
||||||
}.fail {
|
}.fail {
|
||||||
Log.e("Loki", "Failed to send offer", it)
|
Log.e("Loki", "Failed to send offer", it)
|
||||||
@ -551,8 +551,8 @@ class CallManager(context: Context, audioManager: AudioManagerCompat, private va
|
|||||||
val recipient = recipient ?: return
|
val recipient = recipient ?: return
|
||||||
val userAddress = storage.getUserPublicKey() ?: return
|
val userAddress = storage.getUserPublicKey() ?: return
|
||||||
stateProcessor.processEvent(Event.DeclineCall) {
|
stateProcessor.processEvent(Event.DeclineCall) {
|
||||||
MessageSender.sendNonDurably(CallMessage.endCall(callId), Address.fromSerialized(userAddress))
|
MessageSender.sendNonDurably(CallMessage.endCall(callId), Address.fromSerialized(userAddress), isSyncMessage = true)
|
||||||
MessageSender.sendNonDurably(CallMessage.endCall(callId), recipient.address)
|
MessageSender.sendNonDurably(CallMessage.endCall(callId), recipient.address, isSyncMessage = recipient.isLocalNumber)
|
||||||
insertCallMessage(recipient.address.serialize(), CallMessageType.CALL_MISSED)
|
insertCallMessage(recipient.address.serialize(), CallMessageType.CALL_MISSED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -571,7 +571,7 @@ class CallManager(context: Context, audioManager: AudioManagerCompat, private va
|
|||||||
val buffer = DataChannel.Buffer(ByteBuffer.wrap(HANGUP_JSON.toString().encodeToByteArray()), false)
|
val buffer = DataChannel.Buffer(ByteBuffer.wrap(HANGUP_JSON.toString().encodeToByteArray()), false)
|
||||||
channel.send(buffer)
|
channel.send(buffer)
|
||||||
}
|
}
|
||||||
MessageSender.sendNonDurably(CallMessage.endCall(callId), recipient.address)
|
MessageSender.sendNonDurably(CallMessage.endCall(callId), recipient.address, isSyncMessage = recipient.isLocalNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,7 +722,7 @@ class CallManager(context: Context, audioManager: AudioManagerCompat, private va
|
|||||||
})
|
})
|
||||||
connection.setLocalDescription(offer)
|
connection.setLocalDescription(offer)
|
||||||
|
|
||||||
MessageSender.sendNonDurably(CallMessage.offer(offer.description, callId), recipient.address)
|
MessageSender.sendNonDurably(CallMessage.offer(offer.description, callId), recipient.address, isSyncMessage = recipient.isLocalNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
|
|||||||
return
|
return
|
||||||
} // Wait for all attachments to upload before continuing
|
} // 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)
|
this.handleSuccess(dispatcherName)
|
||||||
}.fail { exception ->
|
}.fail { exception ->
|
||||||
var logStacktrace = true
|
var logStacktrace = true
|
||||||
|
@ -62,7 +62,7 @@ object MessageSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convenience
|
// 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) {
|
return if (destination is Destination.LegacyOpenGroup || destination is Destination.OpenGroup || destination is Destination.OpenGroupInbox) {
|
||||||
sendToOpenGroupDestination(destination, message)
|
sendToOpenGroupDestination(destination, message)
|
||||||
} else {
|
} else {
|
||||||
@ -440,17 +440,17 @@ object MessageSender {
|
|||||||
JobQueue.shared.add(job)
|
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!!)
|
val attachmentIDs = MessagingModuleConfiguration.shared.messageDataProvider.getAttachmentIDsFor(message.id!!)
|
||||||
message.attachmentIDs.addAll(attachmentIDs)
|
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)
|
val threadID = MessagingModuleConfiguration.shared.storage.getThreadId(address)
|
||||||
message.threadID = threadID
|
message.threadID = threadID
|
||||||
val destination = Destination.from(address)
|
val destination = Destination.from(address)
|
||||||
return send(message, destination)
|
return send(message, destination, isSyncMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closed groups
|
// Closed groups
|
||||||
|
@ -55,11 +55,12 @@ fun MessageSender.create(name: String, members: Collection<String>): Promise<Str
|
|||||||
// Send a closed group update message to all members individually
|
// 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 closedGroupUpdateKind = ClosedGroupControlMessage.Kind.New(ByteString.copyFrom(Hex.fromStringCondensed(groupPublicKey)), name, encryptionKeyPair, membersAsData, adminsAsData, 0)
|
||||||
val sentTime = SnodeAPI.nowWithOffset
|
val sentTime = SnodeAPI.nowWithOffset
|
||||||
|
val ourPubKey = storage.getUserPublicKey()
|
||||||
for (member in members) {
|
for (member in members) {
|
||||||
val closedGroupControlMessage = ClosedGroupControlMessage(closedGroupUpdateKind)
|
val closedGroupControlMessage = ClosedGroupControlMessage(closedGroupUpdateKind)
|
||||||
closedGroupControlMessage.sentTimestamp = sentTime
|
closedGroupControlMessage.sentTimestamp = sentTime
|
||||||
try {
|
try {
|
||||||
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(member)).get()
|
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(member), member == ourPubKey).get()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
deferred.reject(e)
|
deferred.reject(e)
|
||||||
return@queue
|
return@queue
|
||||||
@ -225,7 +226,7 @@ fun MessageSender.leave(groupPublicKey: String, notifyUser: Boolean = true): Pro
|
|||||||
val sentTime = SnodeAPI.nowWithOffset
|
val sentTime = SnodeAPI.nowWithOffset
|
||||||
closedGroupControlMessage.sentTimestamp = sentTime
|
closedGroupControlMessage.sentTimestamp = sentTime
|
||||||
storage.setActive(groupID, false)
|
storage.setActive(groupID, false)
|
||||||
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(groupID)).success {
|
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(groupID), isSyncMessage = false).success {
|
||||||
// Notify the user
|
// Notify the user
|
||||||
val infoType = SignalServiceGroup.Type.QUIT
|
val infoType = SignalServiceGroup.Type.QUIT
|
||||||
if (notifyUser) {
|
if (notifyUser) {
|
||||||
@ -285,7 +286,8 @@ fun MessageSender.sendEncryptionKeyPair(groupPublicKey: String, newKeyPair: ECKe
|
|||||||
val closedGroupControlMessage = ClosedGroupControlMessage(kind)
|
val closedGroupControlMessage = ClosedGroupControlMessage(kind)
|
||||||
closedGroupControlMessage.sentTimestamp = sentTime
|
closedGroupControlMessage.sentTimestamp = sentTime
|
||||||
return if (force) {
|
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 {
|
} else {
|
||||||
MessageSender.send(closedGroupControlMessage, Address.fromSerialized(destination))
|
MessageSender.send(closedGroupControlMessage, Address.fromSerialized(destination))
|
||||||
null
|
null
|
||||||
|
Loading…
Reference in New Issue
Block a user