mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 17:48:23 +00:00
Sync disappear after read with other devices
This commit is contained in:
@@ -25,7 +25,7 @@ class ReadReceipt() : ControlMessage() {
|
||||
}
|
||||
}
|
||||
|
||||
internal constructor(timestamps: List<Long>?) : this() {
|
||||
constructor(timestamps: List<Long>?) : this() {
|
||||
this.timestamps = timestamps
|
||||
}
|
||||
|
||||
|
@@ -533,14 +533,10 @@ object SnodeAPI {
|
||||
|
||||
fun getExpiries(messageHashes: List<String>, publicKey: String) : RawResponsePromise {
|
||||
val userEd25519KeyPair = MessagingModuleConfiguration.shared.getUserED25519KeyPair() ?: return Promise.ofFail(NullPointerException("No user key pair"))
|
||||
val hashes = messageHashes.takeIf { it.size != 1 } ?: (messageHashes + "") // TODO remove this when bug is fixed on nodes.
|
||||
return retryIfNeeded(maxRetryCount) {
|
||||
val timestamp = System.currentTimeMillis() + clockOffset
|
||||
val params = mutableMapOf(
|
||||
"pubkey" to publicKey,
|
||||
"messages" to messageHashes,
|
||||
"timestamp" to timestamp
|
||||
)
|
||||
val signData = "${Snode.Method.GetExpiries.rawValue}$timestamp${messageHashes.joinToString(separator = "")}".toByteArray()
|
||||
val signData = "${Snode.Method.GetExpiries.rawValue}$timestamp${hashes.joinToString(separator = "")}".toByteArray()
|
||||
|
||||
val ed25519PublicKey = userEd25519KeyPair.publicKey.asHexString
|
||||
val signature = ByteArray(Sign.BYTES)
|
||||
@@ -555,9 +551,14 @@ object SnodeAPI {
|
||||
Log.e("Loki", "Signing data failed with user secret key", e)
|
||||
return@retryIfNeeded Promise.ofFail(e)
|
||||
}
|
||||
params["pubkey_ed25519"] = ed25519PublicKey
|
||||
params["signature"] = Base64.encodeBytes(signature)
|
||||
getSingleTargetSnode(publicKey).bind { snode ->
|
||||
val params = mapOf(
|
||||
"pubkey" to publicKey,
|
||||
"messages" to hashes,
|
||||
"timestamp" to timestamp,
|
||||
"pubkey_ed25519" to ed25519PublicKey,
|
||||
"signature" to Base64.encodeBytes(signature)
|
||||
)
|
||||
getSingleTargetSnode(publicKey) bind { snode ->
|
||||
invoke(Snode.Method.GetExpiries, snode, params, publicKey)
|
||||
}
|
||||
}
|
||||
|
@@ -365,4 +365,19 @@ object Util {
|
||||
val digitGroups = (Math.log10(sizeBytes.toDouble()) / Math.log10(1024.0)).toInt()
|
||||
return DecimalFormat("#,##0.#").format(sizeBytes / Math.pow(1024.0, digitGroups.toDouble())) + " " + units[digitGroups]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T, K: Any> Iterable<T>.associateByNotNull(
|
||||
keySelector: (T) -> K?
|
||||
) = associateByNotNull(keySelector) { it }
|
||||
|
||||
fun <T, K: Any, V: Any> Iterable<T>.associateByNotNull(
|
||||
keySelector: (T) -> K?,
|
||||
valueTransform: (T) -> V?,
|
||||
): Map<K, V> = buildMap {
|
||||
for (item in this@associateByNotNull) {
|
||||
val key = keySelector(item) ?: continue
|
||||
val value = valueTransform(item) ?: continue
|
||||
this[key] = value
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user