mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Improve GuestAccess enum mapping
This commit is contained in:
parent
969689cdb9
commit
a124b514b8
@ -29,14 +29,12 @@ data class RoomGuestAccessContent(
|
|||||||
// Required. Whether guests can join the room. One of: ["can_join", "forbidden"]
|
// Required. Whether guests can join the room. One of: ["can_join", "forbidden"]
|
||||||
@Json(name = "guest_access") val guestAccessStr: String? = null
|
@Json(name = "guest_access") val guestAccessStr: String? = null
|
||||||
) {
|
) {
|
||||||
val guestAccess: GuestAccess? = when (guestAccessStr) {
|
val guestAccess: GuestAccess? = GuestAccess.values()
|
||||||
"can_join" -> GuestAccess.CanJoin
|
.find { it.value == guestAccessStr }
|
||||||
"forbidden" -> GuestAccess.Forbidden
|
?: run {
|
||||||
else -> {
|
Timber.w("Invalid value for GuestAccess: `$guestAccessStr`")
|
||||||
Timber.w("Invalid value for GuestAccess: `$guestAccessStr`")
|
null
|
||||||
null
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonClass(generateAdapter = false)
|
@JsonClass(generateAdapter = false)
|
||||||
|
Loading…
Reference in New Issue
Block a user