mirror of
https://github.com/element-hq/element-android
synced 2024-09-29 21:04:42 +00:00
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 ENABLE_LOCATION_SHARING = true
|
||||||
const val LOCATION_MAP_TILER_KEY = "fU3vlMsMn4Jb6dnEIFsx"
|
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
|
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)
|
@JsonClass(generateAdapter = true)
|
||||||
data class FunctionalMembersContent(
|
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> {
|
fun StateService.getFunctionalMembers(): List<String> {
|
||||||
return getStateEvent(FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE, QueryStringValue.IsEmpty)?.let {
|
return getStateEvent(FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE, QueryStringValue.IsEmpty)
|
||||||
it.content.toModel<FunctionalMembersContent>()?.userIds
|
?.content
|
||||||
}.orEmpty()
|
?.toModel<FunctionalMembersContent>()
|
||||||
|
?.userIds
|
||||||
|
.orEmpty()
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,12 @@ class VectorRoomDisplayNameFallbackProvider @Inject constructor(
|
||||||
|
|
||||||
override fun excludedUserIds(roomId: String): List<String> {
|
override fun excludedUserIds(roomId: String): List<String> {
|
||||||
if (!Config.SUPPORT_FUNCTIONAL_MEMBERS) return emptyList()
|
if (!Config.SUPPORT_FUNCTIONAL_MEMBERS) return emptyList()
|
||||||
return activeSessionHolder.get().getSafeActiveSession()
|
return activeSessionHolder.get()
|
||||||
?.getRoom(roomId)?.let { room ->
|
.getSafeActiveSession()
|
||||||
room.stateService().getFunctionalMembers()
|
?.getRoom(roomId)
|
||||||
}.orEmpty()
|
?.stateService()
|
||||||
|
?.getFunctionalMembers()
|
||||||
|
.orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getNameForRoomInvite(): String {
|
override fun getNameForRoomInvite(): String {
|
||||||
|
|
Loading…
Reference in a new issue