Cleanup and safer Json model.
This commit is contained in:
parent
8e0c503b45
commit
778dab7bb7
|
@ -42,8 +42,10 @@ object Config {
|
|||
const val ENABLE_LOCATION_SHARING = true
|
||||
const val LOCATION_MAP_TILER_KEY = "fU3vlMsMn4Jb6dnEIFsx"
|
||||
|
||||
/// Whether to read the `io.element.functional_members` state event
|
||||
// and exclude any service members when computing a room's name and avatar.
|
||||
/**
|
||||
* Whether to read the `io.element.functional_members` state event
|
||||
* and exclude any service members when computing a room's name and avatar.
|
||||
*/
|
||||
const val SUPPORT_FUNCTIONAL_MEMBERS = true
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,11 +26,13 @@ private const val FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE = "io.element.functional_m
|
|||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class FunctionalMembersContent(
|
||||
@Json(name = "service_members") val userIds: List<String>
|
||||
@Json(name = "service_members") val userIds: List<String>? = null
|
||||
)
|
||||
|
||||
fun StateService.getFunctionalMembers(): List<String> {
|
||||
return getStateEvent(FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE, QueryStringValue.IsEmpty)?.let {
|
||||
it.content.toModel<FunctionalMembersContent>()?.userIds
|
||||
}.orEmpty()
|
||||
return getStateEvent(FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE, QueryStringValue.IsEmpty)
|
||||
?.content
|
||||
?.toModel<FunctionalMembersContent>()
|
||||
?.userIds
|
||||
.orEmpty()
|
||||
}
|
||||
|
|
|
@ -32,10 +32,12 @@ class VectorRoomDisplayNameFallbackProvider @Inject constructor(
|
|||
|
||||
override fun excludedUserIds(roomId: String): List<String> {
|
||||
if (!Config.SUPPORT_FUNCTIONAL_MEMBERS) return emptyList()
|
||||
return activeSessionHolder.get().getSafeActiveSession()
|
||||
?.getRoom(roomId)?.let { room ->
|
||||
room.stateService().getFunctionalMembers()
|
||||
}.orEmpty()
|
||||
return activeSessionHolder.get()
|
||||
.getSafeActiveSession()
|
||||
?.getRoom(roomId)
|
||||
?.stateService()
|
||||
?.getFunctionalMembers()
|
||||
.orEmpty()
|
||||
}
|
||||
|
||||
override fun getNameForRoomInvite(): String {
|
||||
|
|
Loading…
Reference in New Issue