fix: include legacy and new open groups in server ID tracking (#941)

This commit is contained in:
Harris 2022-08-17 11:03:12 +10:00 committed by GitHub
parent c65feba683
commit e7ca53ff72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,5 @@
package org.session.libsession.messaging.sending_receiving
import com.goterl.lazysodium.utils.KeyPair
import nl.komponents.kovenant.Promise
import nl.komponents.kovenant.deferred
import org.session.libsession.messaging.MessagingModuleConfiguration
@ -338,8 +337,23 @@ object MessageSender {
storage.setMessageServerHash(messageID, it)
}
// Track the open group server message ID
if (message.openGroupServerMessageID != null && destination is Destination.LegacyOpenGroup) {
val encoded = GroupUtil.getEncodedOpenGroupID("${destination.server}.${destination.roomToken}".toByteArray())
if (message.openGroupServerMessageID != null && (destination is Destination.LegacyOpenGroup || destination is Destination.OpenGroup)) {
val server: String
val room: String
when (destination) {
is Destination.LegacyOpenGroup -> {
server = destination.server
room = destination.roomToken
}
is Destination.OpenGroup -> {
server = destination.server
room = destination.roomToken
}
else -> {
throw Exception("Destination was a different destination than we were expecting")
}
}
val encoded = GroupUtil.getEncodedOpenGroupID("$server.$room".toByteArray())
val threadID = storage.getThreadId(Address.fromSerialized(encoded))
if (threadID != null && threadID >= 0) {
storage.setOpenGroupServerMessageID(messageID, message.openGroupServerMessageID!!, threadID, !(message as VisibleMessage).isMediaMessage())