Remove hack because quarz didn't persist the secretTree in an older version.
This commit is contained in:
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user