mirror of
https://github.com/element-hq/element-android
synced 2024-12-21 00:42:04 +03:00
crypto: Use a when instead of a big if/else statement
This commit is contained in:
parent
948aa1a141
commit
b53b0a0093
1 changed files with 16 additions and 12 deletions
|
@ -706,22 +706,26 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
// Notify the our listeners about room keys so decryption is retried.
|
||||
if (toDeviceEvents.events != null) {
|
||||
toDeviceEvents.events.forEach { event ->
|
||||
if (event.type == EventType.ROOM_KEY) {
|
||||
val content = event.getClearContent().toModel<RoomKeyContent>() ?: return@forEach
|
||||
when (event.type) {
|
||||
EventType.ROOM_KEY -> {
|
||||
val content = event.getClearContent().toModel<RoomKeyContent>() ?: return@forEach
|
||||
|
||||
val roomId = content.sessionId ?: return@forEach
|
||||
val sessionId = content.sessionId
|
||||
val roomId = content.sessionId ?: return@forEach
|
||||
val sessionId = content.sessionId
|
||||
|
||||
notifyRoomKeyReceival(roomId, sessionId)
|
||||
} else if (event.type == EventType.FORWARDED_ROOM_KEY) {
|
||||
val content = event.getClearContent().toModel<ForwardedRoomKeyContent>() ?: return@forEach
|
||||
notifyRoomKeyReceived(roomId, sessionId)
|
||||
}
|
||||
EventType.FORWARDED_ROOM_KEY -> {
|
||||
val content = event.getClearContent().toModel<ForwardedRoomKeyContent>() ?: return@forEach
|
||||
|
||||
val roomId = content.sessionId ?: return@forEach
|
||||
val sessionId = content.sessionId
|
||||
val roomId = content.sessionId ?: return@forEach
|
||||
val sessionId = content.sessionId
|
||||
|
||||
notifyRoomKeyReceival(roomId, sessionId)
|
||||
} else {
|
||||
this.verificationService?.onEvent(event)
|
||||
notifyRoomKeyReceived(roomId, sessionId)
|
||||
}
|
||||
else -> {
|
||||
this.verificationService?.onEvent(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue