store server hash

This commit is contained in:
ryanzhao
2021-08-10 16:42:15 +10:00
parent bf83f9b391
commit c3e45a308a
7 changed files with 41 additions and 1 deletions

View File

@@ -93,6 +93,7 @@ interface StorageProtocol {
fun markAsSent(timestamp: Long, author: String)
fun markUnidentified(timestamp: Long, author: String)
fun setErrorMessage(timestamp: Long, author: String, error: Exception)
fun setMessageServerHash(messageID: Long, serverHash: String)
// Closed Groups
fun getGroup(groupID: String): GroupRecord?

View File

@@ -13,6 +13,7 @@ abstract class Message {
var sender: String? = null
var groupPublicKey: String? = null
var openGroupServerMessageID: Long? = null
var serverHash: String? = null
open val ttl: Long = 14 * 24 * 60 * 60 * 1000
open val isSelfSendValid: Boolean = false

View File

@@ -161,6 +161,8 @@ object MessageSender {
if (destination is Destination.Contact && message is VisibleMessage && !isSelfSend) {
SnodeModule.shared.broadcaster.broadcast("messageSent", message.sentTimestamp!!)
}
val hash = it["hash"] as? String
message.serverHash = hash
handleSuccessfulMessageSend(message, destination, isSyncMessage)
var shouldNotify = (message is VisibleMessage && !isSyncMessage)
/*
@@ -259,6 +261,12 @@ object MessageSender {
storage.updateSentTimestamp(messageID, message.isMediaMessage(), openGroupSentTimestamp, message.threadID!!)
message.sentTimestamp = openGroupSentTimestamp
}
// When the sync message is successfully sent, the hash value of this TSOutgoingMessage
// will be replaced by the hash value of the sync message. Since the hash value of the
// real message has no use when we delete a message. It is OK to let it be.
message.serverHash?.let {
storage.setMessageServerHash(messageID, it)
}
// Track the open group server message ID
if (message.openGroupServerMessageID != null && destination is Destination.OpenGroupV2) {
val encoded = GroupUtil.getEncodedOpenGroupID("${destination.server}.${destination.room}".toByteArray())