diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt index d324cff246..78a79dedb2 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt @@ -59,7 +59,8 @@ data class RoomSummary constructor( val roomType: String? = null, val spaceParents: List? = null, val spaceChildren: List? = null, - val flattenParentIds: List = emptyList() + val flattenParentIds: List = emptyList(), + val joinRules: RoomJoinRules? = null ) { val isVersioned: Boolean diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt index 92aff0a140..e7f1e67c0a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt @@ -91,7 +91,8 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa parentRoomId = roomSummaryEntity.roomId ) }, - flattenParentIds = roomSummaryEntity.flattenParentIds?.split("|") ?: emptyList() + flattenParentIds = roomSummaryEntity.flattenParentIds?.split("|") ?: emptyList(), + joinRules = roomSummaryEntity.joinnRules ) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt index 4f47032c4d..d5e847f362 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomSummaryEntity.kt @@ -22,6 +22,7 @@ import io.realm.annotations.Index import io.realm.annotations.PrimaryKey import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel import org.matrix.android.sdk.api.session.room.model.Membership +import org.matrix.android.sdk.api.session.room.model.RoomJoinRules import org.matrix.android.sdk.api.session.room.model.RoomSummary import org.matrix.android.sdk.api.session.room.model.VersioningState import org.matrix.android.sdk.api.session.room.model.tag.RoomTag @@ -242,6 +243,23 @@ internal open class RoomSummaryEntity( } } + private var joinnRulesStr: String? = null + var joinnRules: RoomJoinRules? + get() { + return joinnRulesStr?.let { + try { + RoomJoinRules.valueOf(it) + } catch (failure: Throwable) { + null + } + } + } + set(value) { + if (value?.name != joinnRulesStr) { + joinnRulesStr = value?.name + } + } + var roomEncryptionTrustLevel: RoomEncryptionTrustLevel? get() { return roomEncryptionTrustLevelStr?.let { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt index f580a7f354..45cf3248cd 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt @@ -24,6 +24,7 @@ import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.RoomAliasesContent import org.matrix.android.sdk.api.session.room.model.RoomCanonicalAliasContent +import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesContent import org.matrix.android.sdk.api.session.room.model.RoomNameContent import org.matrix.android.sdk.api.session.room.model.RoomTopicContent import org.matrix.android.sdk.api.session.room.model.RoomType @@ -104,6 +105,7 @@ internal class RoomSummaryUpdater @Inject constructor( val lastCanonicalAliasEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_CANONICAL_ALIAS, stateKey = "")?.root val lastAliasesEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_ALIASES, stateKey = "")?.root val roomCreateEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_CREATE, stateKey = "")?.root + val joinRulesEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_JOIN_RULES, stateKey = "")?.root val roomType = ContentMapper.map(roomCreateEvent?.content).toModel()?.type roomSummaryEntity.roomType = roomType @@ -171,6 +173,8 @@ internal class RoomSummaryUpdater @Inject constructor( crossSigningService.onUsersDeviceUpdate(otherRoomMembers) } } + + roomSummaryEntity.joinnRules = ContentMapper.map(joinRulesEvent?.content).toModel()?.joinRules } private fun RoomSummaryEntity.updateHasFailedSending() { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt index 8fdc563edb..3e58c51a6f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt @@ -123,7 +123,8 @@ internal class DefaultSpaceService @Inject constructor( encryptionEventTs = null, typingUsers = emptyList(), isEncrypted = false, - flattenParentIds = emptyList() + flattenParentIds = emptyList(), + joinRules = null ), second = response.rooms ?.filter { it.roomId != spaceId }