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,
|
peerPublicKey: HexKey,
|
||||||
peerKeyPackage: MarmotKeyPackage,
|
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
|
// 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
|
// nothing to add a member to. Say so instead of silently doing nothing and letting the
|
||||||
// caller report success.
|
// caller report success.
|
||||||
val mlsGroup = localChatRoom.chatRoom.toMlsGroup(sentGenerations)
|
val mlsGroup = localChatRoom.chatRoom.toMlsGroup()
|
||||||
?: throw MarmotMissingChatGroupException(
|
?: throw MarmotMissingChatGroupException(
|
||||||
"No MLS group state for chat room ${localChatRoom.chatRoom.id}; cannot invite $peerPublicKey"
|
"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 {
|
return mlsGroupState?.let {
|
||||||
val mlsGroup = MlsGroup.restore(
|
return MlsGroup.restore(
|
||||||
MlsGroupState.decodeTls(
|
MlsGroupState.decodeTls(
|
||||||
mlsGroupState.hexToByteArray()
|
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
|
nostrSignerSync: NostrSignerSync
|
||||||
) {
|
) {
|
||||||
database.chatRoomDao().findChatRoomById(marmotInnerEvent.chatRoomId)?.let { localChatRoom ->
|
database.chatRoomDao().findChatRoomById(marmotInnerEvent.chatRoomId)?.let { localChatRoom ->
|
||||||
val sentGenerations: Int = database.chatMessageDao().countChatMessagesBySenderPublicKey(
|
localChatRoom.chatRoom.toMlsGroup()?.let { mlsGroup ->
|
||||||
chatRoomId = localChatRoom.chatRoom.id,
|
|
||||||
senderPublicKey = nostrSignerSync.pubKey
|
|
||||||
)
|
|
||||||
|
|
||||||
localChatRoom.chatRoom.toMlsGroup(sentGenerations)?.let { mlsGroup ->
|
|
||||||
logger.d("mlsGroup: $mlsGroup")
|
logger.d("mlsGroup: $mlsGroup")
|
||||||
|
|
||||||
database.marmotOutboundDao().encryptAndSendMarmotInnerEvent(
|
database.marmotOutboundDao().encryptAndSendMarmotInnerEvent(
|
||||||
|
|||||||
Reference in New Issue
Block a user