-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8700 from vector-im/feature/fga/handle_functional…
…_members Support Functional members #3736
- Loading branch information
Showing
10 changed files
with
134 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Support Functional members (https://github.com/vector-im/element-meta/blob/develop/spec/functional_members.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...-app/src/androidTest/java/im/vector/app/core/utils/TestRoomDisplayNameFallbackProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2021 The Matrix.org Foundation C.I.C. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.core.utils | ||
|
||
import org.matrix.android.sdk.api.provider.RoomDisplayNameFallbackProvider | ||
|
||
class TestRoomDisplayNameFallbackProvider : RoomDisplayNameFallbackProvider { | ||
|
||
override fun excludedUserIds(roomId: String) = emptyList<String>() | ||
|
||
override fun getNameForRoomInvite() = | ||
"Room invite" | ||
|
||
override fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List<String>) = | ||
"Empty room" | ||
|
||
override fun getNameFor1member(name: String) = | ||
name | ||
|
||
override fun getNameFor2members(name1: String, name2: String) = | ||
"$name1 and $name2" | ||
|
||
override fun getNameFor3members(name1: String, name2: String, name3: String) = | ||
"$name1, $name2 and $name3" | ||
|
||
override fun getNameFor4members(name1: String, name2: String, name3: String, name4: String) = | ||
"$name1, $name2, $name3 and $name4" | ||
|
||
override fun getNameFor4membersAndMore(name1: String, name2: String, name3: String, remainingCount: Int) = | ||
"$name1, $name2, $name3 and $remainingCount others" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
vector/src/main/java/im/vector/app/features/room/FunctionalMembersState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2023 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.room | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
import org.matrix.android.sdk.api.query.QueryStringValue | ||
import org.matrix.android.sdk.api.session.events.model.toModel | ||
import org.matrix.android.sdk.api.session.room.state.StateService | ||
|
||
private const val FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE = "io.element.functional_members" | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class FunctionalMembersContent( | ||
@Json(name = "service_members") val userIds: List<String>? = null | ||
) | ||
|
||
fun StateService.getFunctionalMembers(): List<String> { | ||
return getStateEvent(FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE, QueryStringValue.IsEmpty) | ||
?.content | ||
?.toModel<FunctionalMembersContent>() | ||
?.userIds | ||
.orEmpty() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters