Add joinRules to RoomSummary

This commit is contained in:
yostyle 2021-05-06 18:41:26 +02:00
parent fb0205e903
commit 64f1834913
5 changed files with 28 additions and 3 deletions

View File

@ -59,7 +59,8 @@ data class RoomSummary constructor(
val roomType: String? = null,
val spaceParents: List<SpaceParentInfo>? = null,
val spaceChildren: List<SpaceChildInfo>? = null,
val flattenParentIds: List<String> = emptyList()
val flattenParentIds: List<String> = emptyList(),
val joinRules: RoomJoinRules? = null
) {
val isVersioned: Boolean

View File

@ -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
)
}
}

View File

@ -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 {

View File

@ -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<RoomCreateContent>()?.type
roomSummaryEntity.roomType = roomType
@ -171,6 +173,8 @@ internal class RoomSummaryUpdater @Inject constructor(
crossSigningService.onUsersDeviceUpdate(otherRoomMembers)
}
}
roomSummaryEntity.joinnRules = ContentMapper.map(joinRulesEvent?.content).toModel<RoomJoinRulesContent>()?.joinRules
}
private fun RoomSummaryEntity.updateHasFailedSending() {

View File

@ -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 }