diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt index d17fbe6aff..c0f98d34dc 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt @@ -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())