diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomGuestAccessContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomGuestAccessContent.kt index 99b035d30e..8eea0d3d06 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomGuestAccessContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomGuestAccessContent.kt @@ -18,6 +18,7 @@ package org.matrix.android.sdk.api.session.room.model import com.squareup.moshi.Json import com.squareup.moshi.JsonClass +import timber.log.Timber /** * Class representing the EventType.STATE_ROOM_GUEST_ACCESS state event content @@ -26,8 +27,17 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class RoomGuestAccessContent( // Required. Whether guests can join the room. One of: ["can_join", "forbidden"] - @Json(name = "guest_access") val guestAccess: GuestAccess? = null -) + @Json(name = "guest_access") private val _guestAccess: String? = null +) { + val guestAccess: GuestAccess? = when (_guestAccess) { + "can_join" -> GuestAccess.CanJoin + "forbidden" -> GuestAccess.Forbidden + else -> { + Timber.w("Invalid value for GuestAccess: `$_guestAccess`") + null + } + } +} @JsonClass(generateAdapter = false) enum class GuestAccess(val value: String) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt index f2640fd1e7..3c42b77ae8 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt @@ -138,7 +138,7 @@ internal class DefaultStateService @AssistedInject constructor(@Assisted private if (guestAccess != null) { sendStateEvent( eventType = EventType.STATE_ROOM_GUEST_ACCESS, - body = RoomGuestAccessContent(guestAccess).toContent(), + body = mapOf("guest_access" to guestAccess), stateKey = null ) }