Remove hack because quarz didn't persist the secretTree in an older version.

This commit is contained in:
Kgothatso Ngako
2026-08-29 16:57:26 +02:00
parent 9b3044f6fb
commit ea8b2b276a
3 changed files with 4 additions and 25 deletions

View File

@@ -131,15 +131,10 @@ abstract class MarmotOutboundDao(
peerPublicKey: HexKey,
peerKeyPackage: MarmotKeyPackage,
) {
val sentGenerations: Int = database.chatMessageDao().countChatMessagesBySenderPublicKey(
chatRoomId = localChatRoom.chatRoom.id,
senderPublicKey = localChatRoom.chatRoom.userPublicKey
)
// A room restored from an inbound gift wrap has no persisted MLS state, so there is
// nothing to add a member to. Say so instead of silently doing nothing and letting the
// caller report success.
val mlsGroup = localChatRoom.chatRoom.toMlsGroup(sentGenerations)
val mlsGroup = localChatRoom.chatRoom.toMlsGroup()
?: throw MarmotMissingChatGroupException(
"No MLS group state for chat room ${localChatRoom.chatRoom.id}; cannot invite $peerPublicKey"
)

View File

@@ -129,24 +129,13 @@ data class ChatRoom(
}
fun toMlsGroup(pastGenerations: Int): MlsGroup? {
fun toMlsGroup(): MlsGroup? {
return mlsGroupState?.let {
val mlsGroup = MlsGroup.restore(
return MlsGroup.restore(
MlsGroupState.decodeTls(
mlsGroupState.hexToByteArray()
)
)
mlsGroup.skipGenerations(pastGenerations)
mlsGroup
}
}
}
private fun MlsGroup.skipGenerations(generations: Int) {
val plainByteArray = ByteArray(0)
(0 until generations).forEach { _ ->
encrypt(plainByteArray)
}
}

View File

@@ -133,12 +133,7 @@ class DatabaseMarmotRepository(
nostrSignerSync: NostrSignerSync
) {
database.chatRoomDao().findChatRoomById(marmotInnerEvent.chatRoomId)?.let { localChatRoom ->
val sentGenerations: Int = database.chatMessageDao().countChatMessagesBySenderPublicKey(
chatRoomId = localChatRoom.chatRoom.id,
senderPublicKey = nostrSignerSync.pubKey
)
localChatRoom.chatRoom.toMlsGroup(sentGenerations)?.let { mlsGroup ->
localChatRoom.chatRoom.toMlsGroup()?.let { mlsGroup ->
logger.d("mlsGroup: $mlsGroup")
database.marmotOutboundDao().encryptAndSendMarmotInnerEvent(