-
Notifications
You must be signed in to change notification settings - Fork 742
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 #3479 from vector-im/feature/fga/account_data_rework
Feature/fga/account data rework
- Loading branch information
Showing
32 changed files
with
276 additions
and
141 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
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
66 changes: 66 additions & 0 deletions
66
...src/main/java/org/matrix/android/sdk/api/session/accountdata/SessionAccountDataService.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,66 @@ | ||
/* | ||
* Copyright 2020 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 org.matrix.android.sdk.api.session.accountdata | ||
|
||
import androidx.lifecycle.LiveData | ||
import org.matrix.android.sdk.api.session.events.model.Content | ||
import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataEvent | ||
import org.matrix.android.sdk.api.util.Optional | ||
|
||
/** | ||
* This service is attached globally to the session. | ||
*/ | ||
interface SessionAccountDataService { | ||
/** | ||
* Retrieve the account data with the provided type or null if not found | ||
*/ | ||
fun getUserAccountDataEvent(type: String): UserAccountDataEvent? | ||
|
||
/** | ||
* Observe the account data with the provided type | ||
*/ | ||
fun getLiveUserAccountDataEvent(type: String): LiveData<Optional<UserAccountDataEvent>> | ||
|
||
/** | ||
* Retrieve the account data with the provided types. The return list can have a different size that | ||
* the size of the types set, because some AccountData may not exist. | ||
* If an empty set is provided, all the AccountData are retrieved | ||
*/ | ||
fun getUserAccountDataEvents(types: Set<String>): List<UserAccountDataEvent> | ||
|
||
/** | ||
* Observe the account data with the provided types. If an empty set is provided, all the AccountData are observed | ||
*/ | ||
fun getLiveUserAccountDataEvents(types: Set<String>): LiveData<List<UserAccountDataEvent>> | ||
|
||
/** | ||
* Retrieve the room account data with the provided types. The return list can have a different size that | ||
* the size of the types set, because some AccountData may not exist. | ||
* If an empty set is provided, all the room AccountData are retrieved | ||
*/ | ||
fun getRoomAccountDataEvents(types: Set<String>): List<RoomAccountDataEvent> | ||
|
||
/** | ||
* Observe the room account data with the provided types. If an empty set is provided, AccountData of every room are observed | ||
*/ | ||
fun getLiveRoomAccountDataEvents(types: Set<String>): LiveData<List<RoomAccountDataEvent>> | ||
|
||
/** | ||
* Update the account data with the provided type and the provided account data content | ||
*/ | ||
suspend fun updateUserAccountData(type: String, content: Content) | ||
} |
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
29 changes: 29 additions & 0 deletions
29
...src/main/java/org/matrix/android/sdk/api/session/room/accountdata/RoomAccountDataEvent.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,29 @@ | ||
/* | ||
* Copyright 2020 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 org.matrix.android.sdk.api.session.room.accountdata | ||
|
||
import org.matrix.android.sdk.api.session.events.model.Content | ||
|
||
/** | ||
* This is a simplified Event with just a roomId, a type and a content. | ||
* Currently used types are defined in [RoomAccountDataTypes]. | ||
*/ | ||
data class RoomAccountDataEvent( | ||
val roomId: String, | ||
val type: String, | ||
val content: Content | ||
) |
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
Oops, something went wrong.