Fix assignment issue. sessionId was used instead of roomId.

This may fix issue of Event not decrypted if the key is coming late for the last Event displayed in the Room list.
This commit is contained in:
Benoit Marty 2024-02-01 18:03:34 +01:00
parent e04bfe8981
commit ec96f4e0ae

View file

@ -627,7 +627,7 @@ internal class RustCryptoService @Inject constructor(
} }
private fun notifyRoomKeyReceived( private fun notifyRoomKeyReceived(
roomId: String, roomId: String?,
sessionId: String, sessionId: String,
) { ) {
megolmSessionImportManager.dispatchNewSession(roomId, sessionId) megolmSessionImportManager.dispatchNewSession(roomId, sessionId)
@ -665,8 +665,8 @@ internal class RustCryptoService @Inject constructor(
EventType.ROOM_KEY -> { EventType.ROOM_KEY -> {
val content = event.getClearContent().toModel<RoomKeyContent>() ?: return@forEach val content = event.getClearContent().toModel<RoomKeyContent>() ?: return@forEach
val roomId = content.sessionId ?: return@forEach val roomId = content.roomId
val sessionId = content.sessionId val sessionId = content.sessionId ?: return@forEach
notifyRoomKeyReceived(roomId, sessionId) notifyRoomKeyReceived(roomId, sessionId)
matrixConfiguration.cryptoAnalyticsPlugin?.onRoomKeyImported(sessionId, EventType.ROOM_KEY) matrixConfiguration.cryptoAnalyticsPlugin?.onRoomKeyImported(sessionId, EventType.ROOM_KEY)
@ -674,8 +674,8 @@ internal class RustCryptoService @Inject constructor(
EventType.FORWARDED_ROOM_KEY -> { EventType.FORWARDED_ROOM_KEY -> {
val content = event.getClearContent().toModel<ForwardedRoomKeyContent>() ?: return@forEach val content = event.getClearContent().toModel<ForwardedRoomKeyContent>() ?: return@forEach
val roomId = content.sessionId ?: return@forEach val roomId = content.roomId
val sessionId = content.sessionId val sessionId = content.sessionId ?: return@forEach
notifyRoomKeyReceived(roomId, sessionId) notifyRoomKeyReceived(roomId, sessionId)
matrixConfiguration.cryptoAnalyticsPlugin?.onRoomKeyImported(sessionId, EventType.FORWARDED_ROOM_KEY) matrixConfiguration.cryptoAnalyticsPlugin?.onRoomKeyImported(sessionId, EventType.FORWARDED_ROOM_KEY)