mirror of
https://github.com/oxen-io/session-android.git
synced 2025-05-01 12:00:46 +00:00
Use current time + offset in snode message timestamps (#904)
* fix: use current time in message sender's snode message timestamps to prevent 406 from repeat failed message sends * build: update build number
This commit is contained in:
parent
c677431867
commit
daca3e2531
@ -159,8 +159,8 @@ dependencies {
|
|||||||
testImplementation 'org.robolectric:shadows-multidex:4.4'
|
testImplementation 'org.robolectric:shadows-multidex:4.4'
|
||||||
}
|
}
|
||||||
|
|
||||||
def canonicalVersionCode = 283
|
def canonicalVersionCode = 285
|
||||||
def canonicalVersionName = "1.13.4"
|
def canonicalVersionName = "1.13.5"
|
||||||
|
|
||||||
def postFixSize = 10
|
def postFixSize = 10
|
||||||
def abiPostFix = ['armeabi-v7a' : 1,
|
def abiPostFix = ['armeabi-v7a' : 1,
|
||||||
|
@ -79,6 +79,9 @@ object MessageSender {
|
|||||||
if (message.sentTimestamp == null) {
|
if (message.sentTimestamp == null) {
|
||||||
message.sentTimestamp = System.currentTimeMillis() // Visible messages will already have their sent timestamp set
|
message.sentTimestamp = System.currentTimeMillis() // Visible messages will already have their sent timestamp set
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val messageSendTime = System.currentTimeMillis()
|
||||||
|
|
||||||
message.sender = userPublicKey
|
message.sender = userPublicKey
|
||||||
val isSelfSend = (message.recipient == userPublicKey)
|
val isSelfSend = (message.recipient == userPublicKey)
|
||||||
// Set the failure handler (need it here already for precondition failure handling)
|
// Set the failure handler (need it here already for precondition failure handling)
|
||||||
@ -159,14 +162,14 @@ object MessageSender {
|
|||||||
val wrappedMessage = MessageWrapper.wrap(kind, message.sentTimestamp!!, senderPublicKey, ciphertext)
|
val wrappedMessage = MessageWrapper.wrap(kind, message.sentTimestamp!!, senderPublicKey, ciphertext)
|
||||||
// Send the result
|
// Send the result
|
||||||
if (destination is Destination.Contact && message is VisibleMessage && !isSelfSend) {
|
if (destination is Destination.Contact && message is VisibleMessage && !isSelfSend) {
|
||||||
SnodeModule.shared.broadcaster.broadcast("calculatingPoW", message.sentTimestamp!!)
|
SnodeModule.shared.broadcaster.broadcast("calculatingPoW", messageSendTime)
|
||||||
}
|
}
|
||||||
val base64EncodedData = Base64.encodeBytes(wrappedMessage)
|
val base64EncodedData = Base64.encodeBytes(wrappedMessage)
|
||||||
// Send the result
|
// Send the result
|
||||||
val timestamp = message.sentTimestamp!! + SnodeAPI.clockOffset
|
val timestamp = messageSendTime + SnodeAPI.clockOffset
|
||||||
val snodeMessage = SnodeMessage(message.recipient!!, base64EncodedData, message.ttl, timestamp)
|
val snodeMessage = SnodeMessage(message.recipient!!, base64EncodedData, message.ttl, timestamp)
|
||||||
if (destination is Destination.Contact && message is VisibleMessage && !isSelfSend) {
|
if (destination is Destination.Contact && message is VisibleMessage && !isSelfSend) {
|
||||||
SnodeModule.shared.broadcaster.broadcast("sendingMessage", message.sentTimestamp!!)
|
SnodeModule.shared.broadcaster.broadcast("sendingMessage", messageSendTime)
|
||||||
}
|
}
|
||||||
namespaces.map { namespace -> SnodeAPI.sendMessage(snodeMessage, requiresAuth = false, namespace = namespace) }.let { promises ->
|
namespaces.map { namespace -> SnodeAPI.sendMessage(snodeMessage, requiresAuth = false, namespace = namespace) }.let { promises ->
|
||||||
var isSuccess = false
|
var isSuccess = false
|
||||||
@ -177,7 +180,7 @@ object MessageSender {
|
|||||||
if (isSuccess) { return@success } // Succeed as soon as the first promise succeeds
|
if (isSuccess) { return@success } // Succeed as soon as the first promise succeeds
|
||||||
isSuccess = true
|
isSuccess = true
|
||||||
if (destination is Destination.Contact && message is VisibleMessage && !isSelfSend) {
|
if (destination is Destination.Contact && message is VisibleMessage && !isSelfSend) {
|
||||||
SnodeModule.shared.broadcaster.broadcast("messageSent", message.sentTimestamp!!)
|
SnodeModule.shared.broadcaster.broadcast("messageSent", messageSendTime)
|
||||||
}
|
}
|
||||||
val hash = it["hash"] as? String
|
val hash = it["hash"] as? String
|
||||||
message.serverHash = hash
|
message.serverHash = hash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user