mirror of
https://github.com/element-hq/element-android
synced 2024-12-21 08:54:12 +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,26 +706,30 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
// Notify the our listeners about room keys so decryption is retried.
|
// Notify the our listeners about room keys so decryption is retried.
|
||||||
if (toDeviceEvents.events != null) {
|
if (toDeviceEvents.events != null) {
|
||||||
toDeviceEvents.events.forEach { event ->
|
toDeviceEvents.events.forEach { event ->
|
||||||
if (event.type == EventType.ROOM_KEY) {
|
when (event.type) {
|
||||||
|
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.sessionId ?: return@forEach
|
||||||
val sessionId = content.sessionId
|
val sessionId = content.sessionId
|
||||||
|
|
||||||
notifyRoomKeyReceival(roomId, sessionId)
|
notifyRoomKeyReceived(roomId, sessionId)
|
||||||
} else if (event.type == 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.sessionId ?: return@forEach
|
||||||
val sessionId = content.sessionId
|
val sessionId = content.sessionId
|
||||||
|
|
||||||
notifyRoomKeyReceival(roomId, sessionId)
|
notifyRoomKeyReceived(roomId, sessionId)
|
||||||
} else {
|
}
|
||||||
|
else -> {
|
||||||
this.verificationService?.onEvent(event)
|
this.verificationService?.onEvent(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun preshareRoomKey(roomId: String, roomMembers: List<String>) {
|
private suspend fun preshareRoomKey(roomId: String, roomMembers: List<String>) {
|
||||||
keyClaimLock.withLock {
|
keyClaimLock.withLock {
|
||||||
|
|
Loading…
Reference in a new issue