mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-26 17:43:11 +01: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"]
|
||||
@Json(name = "guest_access") val guestAccessStr: String? = null
|
||||
) {
|
||||
val guestAccess: GuestAccess? = when (guestAccessStr) {
|
||||
"can_join" -> GuestAccess.CanJoin
|
||||
"forbidden" -> GuestAccess.Forbidden
|
||||
else -> {
|
||||
Timber.w("Invalid value for GuestAccess: `$guestAccessStr`")
|
||||
null
|
||||
}
|
||||
}
|
||||
val guestAccess: GuestAccess? = GuestAccess.values()
|
||||
.find { it.value == guestAccessStr }
|
||||
?: run {
|
||||
Timber.w("Invalid value for GuestAccess: `$guestAccessStr`")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = false)
|
||||
|
Loading…
Reference in New Issue
Block a user