Merge branch 'develop' into feature/aris/fix_account_deactivation_issue
# Conflicts: # vector/src/main/java/im/vector/app/features/settings/account/deactivation/DeactivateAccountViewModel.kt
This commit is contained in:
commit
780f1ffc8c
27
.github/workflows/triage-labelled.yml
vendored
27
.github/workflows/triage-labelled.yml
vendored
@ -251,3 +251,30 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
PROJECT_ID: "PN_kwDOAM0swc4AArk0"
|
PROJECT_ID: "PN_kwDOAM0swc4AArk0"
|
||||||
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
|
||||||
|
|
||||||
|
move_element_x_issues:
|
||||||
|
name: ElementX issues to ElementX project board
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Skip in forks
|
||||||
|
if: >
|
||||||
|
github.repository == 'vector-im/element-android' &&
|
||||||
|
(contains(github.event.issue.labels.*.name, 'Z-ElementX-Alpha') ||
|
||||||
|
contains(github.event.issue.labels.*.name, 'Z-ElementX-Beta') ||
|
||||||
|
contains(github.event.issue.labels.*.name, 'Z-ElementX'))
|
||||||
|
steps:
|
||||||
|
- uses: octokit/graphql-action@v2.x
|
||||||
|
with:
|
||||||
|
headers: '{"GraphQL-Features": "projects_next_graphql"}'
|
||||||
|
query: |
|
||||||
|
mutation add_to_project($projectid:ID!,$contentid:ID!) {
|
||||||
|
addProjectNextItem(input:{projectId:$projectid contentId:$contentid}) {
|
||||||
|
projectNextItem {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
projectid: ${{ env.PROJECT_ID }}
|
||||||
|
contentid: ${{ github.event.issue.node_id }}
|
||||||
|
env:
|
||||||
|
PROJECT_ID: "PN_kwDOAM0swc4ABTXY"
|
||||||
|
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
|
||||||
|
2
.github/workflows/update-gradle-wrapper.yml
vendored
2
.github/workflows/update-gradle-wrapper.yml
vendored
@ -13,6 +13,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Update Gradle Wrapper
|
- name: Update Gradle Wrapper
|
||||||
uses: gradle-update/update-gradle-wrapper-action@v1
|
uses: gradle-update/update-gradle-wrapper-action@v1
|
||||||
|
# Skip in forks
|
||||||
|
if: github.repository == 'vector-im/element-android'
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
target-branch: develop
|
target-branch: develop
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
Changes in Element 1.4.13 (2022-04-26)
|
||||||
|
======================================
|
||||||
|
|
||||||
|
Bugfixes 🐛
|
||||||
|
----------
|
||||||
|
- Fix UI freeze observed after each incremental sync ([#5835](https://github.com/vector-im/element-android/issues/5835))
|
||||||
|
|
||||||
|
|
||||||
Changes in Element v1.4.12 (2022-04-20)
|
Changes in Element v1.4.12 (2022-04-20)
|
||||||
=======================================
|
=======================================
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ buildscript {
|
|||||||
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3'
|
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3'
|
||||||
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
|
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
|
||||||
classpath "com.likethesalad.android:stem-plugin:2.0.0"
|
classpath "com.likethesalad.android:stem-plugin:2.0.0"
|
||||||
classpath 'org.owasp:dependency-check-gradle:7.0.4.1'
|
classpath 'org.owasp:dependency-check-gradle:7.1.0.1'
|
||||||
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.6.20"
|
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.6.21"
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
2
changelog.d/5816.sdk
Normal file
2
changelog.d/5816.sdk
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Some `Session` apis are now available by requesting the service first. For instance `Session.updateAvatar(...)` is now `Session.profileService().updateAvatar(...)`
|
||||||
|
The shortcut `Room.search()` has been removed, you have to use `Session.searchService().search()`
|
1
changelog.d/5832.misc
Normal file
1
changelog.d/5832.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Add a GH workflow to push ElementX issues to the global board.
|
1
changelog.d/5836.doc
Normal file
1
changelog.d/5836.doc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Update the PR process doc with 2 reviewers and a new reviewer team.
|
1
changelog.d/5847.bugfix
Normal file
1
changelog.d/5847.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fixes missing call icons when threads are enabled
|
@ -32,14 +32,15 @@ Also, draft PR should not stay indefinitely in this state. It may be removed if
|
|||||||
|
|
||||||
##### PR Review Assignment
|
##### PR Review Assignment
|
||||||
|
|
||||||
We use automatic assignment for PR reviews. A PR is automatically routed by GitHub to a team member using the round robin algorithm. The process is the following:
|
We use automatic assignment for PR reviews. A PR is automatically routed by GitHub to 2 team members using the round robin algorithm. The process is the following:
|
||||||
|
|
||||||
- The PR creator assigns the [element-android](https://github.com/orgs/vector-im/teams/element-android) team as a reviewer. They can skip this process and assign directly a specific member if they think they should take a look at it.
|
- The PR creator can assign specific people if they have another Android developer in their team or they think a specific reviewer should take a look at the PR.
|
||||||
- GitHub automatically assigns one reviewer. If the chosen reviewer is not available (holiday, etc.), remove them and set again the team, GitHub will select another reviewer.
|
- If there are missing reviewers, the PR creator assigns the [element-android-reviewers](https://github.com/orgs/vector-im/teams/element-android-reviewers) team as a reviewer.
|
||||||
- The reviewer gets a notification to make the review: they review the code following the good practice (see the rest of this document).
|
- GitHub automatically assigns other reviewers. If one of the chosen reviewers is not available (holiday, etc.), remove them and set again the team, GitHub will select another reviewer.
|
||||||
|
- Reviewers get a notification to make the review: they review the code following the good practice (see the rest of this document).
|
||||||
- After making their own review, if they feel not confident enough, they can ask another person for a full review, or they can tag someone within a PR comment to check specific lines.
|
- After making their own review, if they feel not confident enough, they can ask another person for a full review, or they can tag someone within a PR comment to check specific lines.
|
||||||
|
|
||||||
For PRs coming from the community, the issue wrangler can assign either the team [element-android](https://github.com/orgs/vector-im/teams/element-android) or any member directly.
|
For PRs coming from the community, the issue wrangler can assign either the team [element-android-reviewers](https://github.com/orgs/vector-im/teams/element-android-reviewers) or any members directly.
|
||||||
|
|
||||||
##### PR review time
|
##### PR review time
|
||||||
|
|
||||||
|
2
fastlane/metadata/android/en-US/changelogs/40104130.txt
Normal file
2
fastlane/metadata/android/en-US/changelogs/40104130.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Main changes in this version: Allows users to appear offline and adds an audio player for audio attachments
|
||||||
|
Full changelog: https://github.com/vector-im/element-android/releases
|
@ -46,16 +46,16 @@ import org.matrix.android.sdk.api.util.toOptional
|
|||||||
class FlowSession(private val session: Session) {
|
class FlowSession(private val session: Session) {
|
||||||
|
|
||||||
fun liveRoomSummaries(queryParams: RoomSummaryQueryParams, sortOrder: RoomSortOrder = RoomSortOrder.NONE): Flow<List<RoomSummary>> {
|
fun liveRoomSummaries(queryParams: RoomSummaryQueryParams, sortOrder: RoomSortOrder = RoomSortOrder.NONE): Flow<List<RoomSummary>> {
|
||||||
return session.getRoomSummariesLive(queryParams, sortOrder).asFlow()
|
return session.roomService().getRoomSummariesLive(queryParams, sortOrder).asFlow()
|
||||||
.startWith(session.coroutineDispatchers.io) {
|
.startWith(session.coroutineDispatchers.io) {
|
||||||
session.getRoomSummaries(queryParams, sortOrder)
|
session.roomService().getRoomSummaries(queryParams, sortOrder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveGroupSummaries(queryParams: GroupSummaryQueryParams): Flow<List<GroupSummary>> {
|
fun liveGroupSummaries(queryParams: GroupSummaryQueryParams): Flow<List<GroupSummary>> {
|
||||||
return session.getGroupSummariesLive(queryParams).asFlow()
|
return session.groupService().getGroupSummariesLive(queryParams).asFlow()
|
||||||
.startWith(session.coroutineDispatchers.io) {
|
.startWith(session.coroutineDispatchers.io) {
|
||||||
session.getGroupSummaries(queryParams)
|
session.groupService().getGroupSummaries(queryParams)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,9 +67,9 @@ class FlowSession(private val session: Session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun liveBreadcrumbs(queryParams: RoomSummaryQueryParams): Flow<List<RoomSummary>> {
|
fun liveBreadcrumbs(queryParams: RoomSummaryQueryParams): Flow<List<RoomSummary>> {
|
||||||
return session.getBreadcrumbsLive(queryParams).asFlow()
|
return session.roomService().getBreadcrumbsLive(queryParams).asFlow()
|
||||||
.startWith(session.coroutineDispatchers.io) {
|
.startWith(session.coroutineDispatchers.io) {
|
||||||
session.getBreadcrumbs(queryParams)
|
session.roomService().getBreadcrumbs(queryParams)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,43 +85,47 @@ class FlowSession(private val session: Session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun livePushers(): Flow<List<Pusher>> {
|
fun livePushers(): Flow<List<Pusher>> {
|
||||||
return session.getPushersLive().asFlow()
|
return session.pushersService().getPushersLive().asFlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveUser(userId: String): Flow<Optional<User>> {
|
fun liveUser(userId: String): Flow<Optional<User>> {
|
||||||
return session.getUserLive(userId).asFlow()
|
return session.userService().getUserLive(userId).asFlow()
|
||||||
.startWith(session.coroutineDispatchers.io) {
|
.startWith(session.coroutineDispatchers.io) {
|
||||||
session.getUser(userId).toOptional()
|
session.userService().getUser(userId).toOptional()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveRoomMember(userId: String, roomId: String): Flow<Optional<RoomMemberSummary>> {
|
fun liveRoomMember(userId: String, roomId: String): Flow<Optional<RoomMemberSummary>> {
|
||||||
return session.getRoomMemberLive(userId, roomId).asFlow()
|
return session.roomService().getRoomMemberLive(userId, roomId).asFlow()
|
||||||
.startWith(session.coroutineDispatchers.io) {
|
.startWith(session.coroutineDispatchers.io) {
|
||||||
session.getRoomMember(userId, roomId).toOptional()
|
session.roomService().getRoomMember(userId, roomId).toOptional()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveUsers(): Flow<List<User>> {
|
fun liveUsers(): Flow<List<User>> {
|
||||||
return session.getUsersLive().asFlow()
|
return session.userService().getUsersLive().asFlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveIgnoredUsers(): Flow<List<User>> {
|
fun liveIgnoredUsers(): Flow<List<User>> {
|
||||||
return session.getIgnoredUsersLive().asFlow()
|
return session.userService().getIgnoredUsersLive().asFlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun livePagedUsers(filter: String? = null, excludedUserIds: Set<String>? = null): Flow<PagedList<User>> {
|
fun livePagedUsers(filter: String? = null, excludedUserIds: Set<String>? = null): Flow<PagedList<User>> {
|
||||||
return session.getPagedUsersLive(filter, excludedUserIds).asFlow()
|
return session.userService().getPagedUsersLive(filter, excludedUserIds).asFlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveThreePIds(refreshData: Boolean): Flow<List<ThreePid>> {
|
fun liveThreePIds(refreshData: Boolean): Flow<List<ThreePid>> {
|
||||||
return session.getThreePidsLive(refreshData).asFlow()
|
return session.profileService().getThreePidsLive(refreshData).asFlow()
|
||||||
.startWith(session.coroutineDispatchers.io) { session.getThreePids() }
|
.startWith(session.coroutineDispatchers.io) {
|
||||||
|
session.profileService().getThreePids()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun livePendingThreePIds(): Flow<List<ThreePid>> {
|
fun livePendingThreePIds(): Flow<List<ThreePid>> {
|
||||||
return session.getPendingThreePidsLive().asFlow()
|
return session.profileService().getPendingThreePidsLive().asFlow()
|
||||||
.startWith(session.coroutineDispatchers.io) { session.getPendingThreePids() }
|
.startWith(session.coroutineDispatchers.io) {
|
||||||
|
session.profileService().getPendingThreePids()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveUserCryptoDevices(userId: String): Flow<List<CryptoDeviceInfo>> {
|
fun liveUserCryptoDevices(userId: String): Flow<List<CryptoDeviceInfo>> {
|
||||||
@ -179,7 +183,7 @@ class FlowSession(private val session: Session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun liveRoomChangeMembershipState(): Flow<Map<String, ChangeMembershipState>> {
|
fun liveRoomChangeMembershipState(): Flow<Map<String, ChangeMembershipState>> {
|
||||||
return session.getChangeMembershipsLive().asFlow()
|
return session.roomService().getChangeMembershipsLive().asFlow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,22 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dokkaHtml {
|
||||||
|
dokkaSourceSets {
|
||||||
|
configureEach {
|
||||||
|
// Emit warnings about not documented members.
|
||||||
|
reportUndocumented.set(true)
|
||||||
|
// Suppress package legacy riot. Sadly this does not work
|
||||||
|
/*
|
||||||
|
perPackageOption {
|
||||||
|
prefix.set("org.matrix.android.sdk.internal.legacy.riot")
|
||||||
|
suppress.set(true)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
testOptions.unitTests.includeAndroidResources = true
|
testOptions.unitTests.includeAndroidResources = true
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class ChangePasswordTest : InstrumentedTest {
|
|||||||
|
|
||||||
// Change password
|
// Change password
|
||||||
commonTestHelper.runBlockingTest {
|
commonTestHelper.runBlockingTest {
|
||||||
session.changePassword(TestConstants.PASSWORD, NEW_PASSWORD)
|
session.accountService().changePassword(TestConstants.PASSWORD, NEW_PASSWORD)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to login with the previous password, it will fail
|
// Try to login with the previous password, it will fail
|
||||||
|
@ -47,7 +47,7 @@ class DeactivateAccountTest : InstrumentedTest {
|
|||||||
|
|
||||||
// Deactivate the account
|
// Deactivate the account
|
||||||
commonTestHelper.runBlockingTest {
|
commonTestHelper.runBlockingTest {
|
||||||
session.deactivateAccount(
|
session.accountService().deactivateAccount(
|
||||||
eraseAllData = false,
|
eraseAllData = false,
|
||||||
userInteractiveAuthInterceptor = object : UserInteractiveAuthInterceptor {
|
userInteractiveAuthInterceptor = object : UserInteractiveAuthInterceptor {
|
||||||
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
|
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
|
||||||
|
@ -431,7 +431,7 @@ class CommonTestHelper(context: Context) {
|
|||||||
|
|
||||||
fun signOutAndClose(session: Session) {
|
fun signOutAndClose(session: Session) {
|
||||||
runBlockingTest(timeout = 60_000) {
|
runBlockingTest(timeout = 60_000) {
|
||||||
session.signOut(true)
|
session.signOutService().signOut(true)
|
||||||
}
|
}
|
||||||
// no need signout will close
|
// no need signout will close
|
||||||
// session.close()
|
// session.close()
|
||||||
|
@ -40,6 +40,7 @@ import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxStat
|
|||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
@ -64,7 +65,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
val aliceSession = testHelper.createAccount(TestConstants.USER_ALICE, defaultSessionParams)
|
val aliceSession = testHelper.createAccount(TestConstants.USER_ALICE, defaultSessionParams)
|
||||||
|
|
||||||
val roomId = testHelper.runBlockingTest {
|
val roomId = testHelper.runBlockingTest {
|
||||||
aliceSession.createRoom(CreateRoomParams().apply { name = "MyRoom" })
|
aliceSession.roomService().createRoom(CreateRoomParams().apply { name = "MyRoom" })
|
||||||
}
|
}
|
||||||
if (encryptedRoom) {
|
if (encryptedRoom) {
|
||||||
testHelper.waitWithLatch { latch ->
|
testHelper.waitWithLatch { latch ->
|
||||||
@ -98,7 +99,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
val bobSession = testHelper.createAccount(TestConstants.USER_BOB, defaultSessionParams)
|
val bobSession = testHelper.createAccount(TestConstants.USER_BOB, defaultSessionParams)
|
||||||
|
|
||||||
testHelper.waitWithLatch { latch ->
|
testHelper.waitWithLatch { latch ->
|
||||||
val bobRoomSummariesLive = bobSession.getRoomSummariesLive(roomSummaryQueryParams { })
|
val bobRoomSummariesLive = bobSession.roomService().getRoomSummariesLive(roomSummaryQueryParams { })
|
||||||
val newRoomObserver = object : Observer<List<RoomSummary>> {
|
val newRoomObserver = object : Observer<List<RoomSummary>> {
|
||||||
override fun onChanged(t: List<RoomSummary>?) {
|
override fun onChanged(t: List<RoomSummary>?) {
|
||||||
if (t?.isNotEmpty() == true) {
|
if (t?.isNotEmpty() == true) {
|
||||||
@ -112,7 +113,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testHelper.waitWithLatch { latch ->
|
testHelper.waitWithLatch { latch ->
|
||||||
val bobRoomSummariesLive = bobSession.getRoomSummariesLive(roomSummaryQueryParams { })
|
val bobRoomSummariesLive = bobSession.roomService().getRoomSummariesLive(roomSummaryQueryParams { })
|
||||||
val roomJoinedObserver = object : Observer<List<RoomSummary>> {
|
val roomJoinedObserver = object : Observer<List<RoomSummary>> {
|
||||||
override fun onChanged(t: List<RoomSummary>?) {
|
override fun onChanged(t: List<RoomSummary>?) {
|
||||||
if (bobSession.getRoom(aliceRoomId)
|
if (bobSession.getRoom(aliceRoomId)
|
||||||
@ -124,7 +125,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bobRoomSummariesLive.observeForever(roomJoinedObserver)
|
bobRoomSummariesLive.observeForever(roomJoinedObserver)
|
||||||
bobSession.joinRoom(aliceRoomId)
|
bobSession.roomService().joinRoom(aliceRoomId)
|
||||||
}
|
}
|
||||||
// Ensure bob can send messages to the room
|
// Ensure bob can send messages to the room
|
||||||
// val roomFromBobPOV = bobSession.getRoom(aliceRoomId)!!
|
// val roomFromBobPOV = bobSession.getRoom(aliceRoomId)!!
|
||||||
@ -164,7 +165,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testHelper.runBlockingTest {
|
testHelper.runBlockingTest {
|
||||||
samSession.joinRoom(room.roomId, null, emptyList())
|
samSession.roomService().joinRoom(room.roomId, null, emptyList())
|
||||||
}
|
}
|
||||||
|
|
||||||
return samSession
|
return samSession
|
||||||
@ -242,8 +243,8 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
fun createDM(alice: Session, bob: Session): String {
|
fun createDM(alice: Session, bob: Session): String {
|
||||||
var roomId: String = ""
|
var roomId: String = ""
|
||||||
testHelper.waitWithLatch { latch ->
|
testHelper.waitWithLatch { latch ->
|
||||||
roomId = alice.createDirectRoom(bob.myUserId)
|
roomId = alice.roomService().createDirectRoom(bob.myUserId)
|
||||||
val bobRoomSummariesLive = bob.getRoomSummariesLive(roomSummaryQueryParams { })
|
val bobRoomSummariesLive = bob.roomService().getRoomSummariesLive(roomSummaryQueryParams { })
|
||||||
val newRoomObserver = object : Observer<List<RoomSummary>> {
|
val newRoomObserver = object : Observer<List<RoomSummary>> {
|
||||||
override fun onChanged(t: List<RoomSummary>?) {
|
override fun onChanged(t: List<RoomSummary>?) {
|
||||||
if (t?.any { it.roomId == roomId }.orFalse()) {
|
if (t?.any { it.roomId == roomId }.orFalse()) {
|
||||||
@ -256,7 +257,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testHelper.waitWithLatch { latch ->
|
testHelper.waitWithLatch { latch ->
|
||||||
val bobRoomSummariesLive = bob.getRoomSummariesLive(roomSummaryQueryParams { })
|
val bobRoomSummariesLive = bob.roomService().getRoomSummariesLive(roomSummaryQueryParams { })
|
||||||
val newRoomObserver = object : Observer<List<RoomSummary>> {
|
val newRoomObserver = object : Observer<List<RoomSummary>> {
|
||||||
override fun onChanged(t: List<RoomSummary>?) {
|
override fun onChanged(t: List<RoomSummary>?) {
|
||||||
if (bob.getRoom(roomId)
|
if (bob.getRoom(roomId)
|
||||||
@ -268,7 +269,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bobRoomSummariesLive.observeForever(newRoomObserver)
|
bobRoomSummariesLive.observeForever(newRoomObserver)
|
||||||
bob.joinRoom(roomId)
|
bob.roomService().joinRoom(roomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
return roomId
|
return roomId
|
||||||
@ -367,7 +368,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
aliceSession.cryptoService().setWarnOnUnknownDevices(false)
|
aliceSession.cryptoService().setWarnOnUnknownDevices(false)
|
||||||
|
|
||||||
val roomId = testHelper.runBlockingTest {
|
val roomId = testHelper.runBlockingTest {
|
||||||
aliceSession.createRoom(CreateRoomParams().apply { name = "MyRoom" })
|
aliceSession.roomService().createRoom(CreateRoomParams().apply { name = "MyRoom" })
|
||||||
}
|
}
|
||||||
val room = aliceSession.getRoom(roomId)!!
|
val room = aliceSession.getRoom(roomId)!!
|
||||||
|
|
||||||
@ -380,7 +381,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
|
|||||||
val session = testHelper.createAccount("User_$index", defaultSessionParams)
|
val session = testHelper.createAccount("User_$index", defaultSessionParams)
|
||||||
testHelper.runBlockingTest(timeout = 600_000) { room.invite(session.myUserId, null) }
|
testHelper.runBlockingTest(timeout = 600_000) { room.invite(session.myUserId, null) }
|
||||||
println("TEST -> " + session.myUserId + " invited")
|
println("TEST -> " + session.myUserId + " invited")
|
||||||
testHelper.runBlockingTest { session.joinRoom(room.roomId, null, emptyList()) }
|
testHelper.runBlockingTest { session.roomService().joinRoom(room.roomId, null, emptyList()) }
|
||||||
println("TEST -> " + session.myUserId + " joined")
|
println("TEST -> " + session.myUserId + " joined")
|
||||||
sessions.add(session)
|
sessions.add(session)
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ import org.matrix.android.sdk.api.session.crypto.model.OlmDecryptionResult
|
|||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
|
import org.matrix.android.sdk.api.session.getRoomSummary
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.failure.JoinRoomFailure
|
import org.matrix.android.sdk.api.session.room.failure.JoinRoomFailure
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
@ -551,7 +553,7 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
testHelper.waitWithLatch { latch ->
|
testHelper.waitWithLatch { latch ->
|
||||||
testHelper.retryPeriodicallyWithLatch(latch) {
|
testHelper.retryPeriodicallyWithLatch(latch) {
|
||||||
otherAccounts.map {
|
otherAccounts.map {
|
||||||
aliceSession.getRoomMember(it.myUserId, e2eRoomID)?.membership
|
aliceSession.roomService().getRoomMember(it.myUserId, e2eRoomID)?.membership
|
||||||
}.all {
|
}.all {
|
||||||
it == Membership.JOIN
|
it == Membership.JOIN
|
||||||
}
|
}
|
||||||
@ -574,7 +576,7 @@ class E2eeSanityTests : InstrumentedTest {
|
|||||||
testHelper.runBlockingTest(60_000) {
|
testHelper.runBlockingTest(60_000) {
|
||||||
Log.v("#E2E TEST", "${otherSession.myUserId} tries to join room $e2eRoomID")
|
Log.v("#E2E TEST", "${otherSession.myUserId} tries to join room $e2eRoomID")
|
||||||
try {
|
try {
|
||||||
otherSession.joinRoom(e2eRoomID)
|
otherSession.roomService().joinRoom(e2eRoomID)
|
||||||
} catch (ex: JoinRoomFailure.JoinedWithTimeout) {
|
} catch (ex: JoinRoomFailure.JoinedWithTimeout) {
|
||||||
// it's ok we will wait after
|
// it's ok we will wait after
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import org.matrix.android.sdk.api.session.events.model.EventType
|
|||||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.content.RoomKeyContent
|
import org.matrix.android.sdk.api.session.events.model.content.RoomKeyContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
|||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
||||||
|
@ -28,6 +28,7 @@ import org.matrix.android.sdk.api.crypto.MXCRYPTO_ALGORITHM_MEGOLM
|
|||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
||||||
|
@ -50,6 +50,7 @@ import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransa
|
|||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
|
||||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
|
import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
@ -73,7 +74,7 @@ class KeyShareTests : InstrumentedTest {
|
|||||||
|
|
||||||
// Create an encrypted room and add a message
|
// Create an encrypted room and add a message
|
||||||
val roomId = commonTestHelper.runBlockingTest {
|
val roomId = commonTestHelper.runBlockingTest {
|
||||||
aliceSession.createRoom(
|
aliceSession.roomService().createRoom(
|
||||||
CreateRoomParams().apply {
|
CreateRoomParams().apply {
|
||||||
visibility = RoomDirectoryVisibility.PRIVATE
|
visibility = RoomDirectoryVisibility.PRIVATE
|
||||||
enableEncryption()
|
enableEncryption()
|
||||||
@ -340,7 +341,7 @@ class KeyShareTests : InstrumentedTest {
|
|||||||
|
|
||||||
// Create an encrypted room and send a couple of messages
|
// Create an encrypted room and send a couple of messages
|
||||||
val roomId = commonTestHelper.runBlockingTest {
|
val roomId = commonTestHelper.runBlockingTest {
|
||||||
aliceSession.createRoom(
|
aliceSession.roomService().createRoom(
|
||||||
CreateRoomParams().apply {
|
CreateRoomParams().apply {
|
||||||
visibility = RoomDirectoryVisibility.PRIVATE
|
visibility = RoomDirectoryVisibility.PRIVATE
|
||||||
enableEncryption()
|
enableEncryption()
|
||||||
@ -378,7 +379,7 @@ class KeyShareTests : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
commonTestHelper.runBlockingTest {
|
commonTestHelper.runBlockingTest {
|
||||||
bobSession.joinRoom(roomAlicePov.roomId, null, emptyList())
|
bobSession.roomService().joinRoom(roomAlicePov.roomId, null, emptyList())
|
||||||
}
|
}
|
||||||
|
|
||||||
// we want to discard alice outbound session
|
// we want to discard alice outbound session
|
||||||
|
@ -33,6 +33,7 @@ import org.matrix.android.sdk.api.session.events.model.EventType
|
|||||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.content.WithHeldCode
|
import org.matrix.android.sdk.api.session.events.model.content.WithHeldCode
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.MockOkHttpInterceptor
|
import org.matrix.android.sdk.common.MockOkHttpInterceptor
|
||||||
|
@ -41,6 +41,7 @@ import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysVersion
|
|||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupCreationInfo
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupCreationInfo
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.toKeysVersionResult
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.toKeysVersionResult
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.ImportRoomKeysResult
|
import org.matrix.android.sdk.api.session.crypto.model.ImportRoomKeysResult
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
|
@ -60,7 +60,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
|
|
||||||
val aliceSession = testHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(true))
|
val aliceSession = testHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(true))
|
||||||
|
|
||||||
val quadS = aliceSession.sharedSecretStorageService
|
val quadS = aliceSession.sharedSecretStorageService()
|
||||||
|
|
||||||
val TEST_KEY_ID = "my.test.Key"
|
val TEST_KEY_ID = "my.test.Key"
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
// Store a secret
|
// Store a secret
|
||||||
val clearSecret = "42".toByteArray().toBase64NoPadding()
|
val clearSecret = "42".toByteArray().toBase64NoPadding()
|
||||||
testHelper.runBlockingTest {
|
testHelper.runBlockingTest {
|
||||||
aliceSession.sharedSecretStorageService.storeSecret(
|
aliceSession.sharedSecretStorageService().storeSecret(
|
||||||
"secret.of.life",
|
"secret.of.life",
|
||||||
clearSecret,
|
clearSecret,
|
||||||
listOf(SharedSecretStorageService.KeyRef(null, keySpec)) // default key
|
listOf(SharedSecretStorageService.KeyRef(null, keySpec)) // default key
|
||||||
@ -141,7 +141,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
// Try to decrypt??
|
// Try to decrypt??
|
||||||
|
|
||||||
val decryptedSecret = testHelper.runBlockingTest {
|
val decryptedSecret = testHelper.runBlockingTest {
|
||||||
aliceSession.sharedSecretStorageService.getSecret(
|
aliceSession.sharedSecretStorageService().getSecret(
|
||||||
"secret.of.life",
|
"secret.of.life",
|
||||||
null, // default key
|
null, // default key
|
||||||
keySpec!!
|
keySpec!!
|
||||||
@ -158,7 +158,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
|
|
||||||
val aliceSession = testHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(true))
|
val aliceSession = testHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(true))
|
||||||
|
|
||||||
val quadS = aliceSession.sharedSecretStorageService
|
val quadS = aliceSession.sharedSecretStorageService()
|
||||||
|
|
||||||
val TEST_KEY_ID = "my.test.Key"
|
val TEST_KEY_ID = "my.test.Key"
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
val mySecretText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
|
val mySecretText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
|
||||||
|
|
||||||
testHelper.runBlockingTest {
|
testHelper.runBlockingTest {
|
||||||
aliceSession.sharedSecretStorageService.storeSecret(
|
aliceSession.sharedSecretStorageService().storeSecret(
|
||||||
"my.secret",
|
"my.secret",
|
||||||
mySecretText.toByteArray().toBase64NoPadding(),
|
mySecretText.toByteArray().toBase64NoPadding(),
|
||||||
listOf(
|
listOf(
|
||||||
@ -207,14 +207,14 @@ class QuadSTests : InstrumentedTest {
|
|||||||
|
|
||||||
// Assert that can decrypt with both keys
|
// Assert that can decrypt with both keys
|
||||||
testHelper.runBlockingTest {
|
testHelper.runBlockingTest {
|
||||||
aliceSession.sharedSecretStorageService.getSecret("my.secret",
|
aliceSession.sharedSecretStorageService().getSecret("my.secret",
|
||||||
keyId1,
|
keyId1,
|
||||||
RawBytesKeySpec.fromRecoveryKey(key1Info.recoveryKey)!!
|
RawBytesKeySpec.fromRecoveryKey(key1Info.recoveryKey)!!
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
testHelper.runBlockingTest {
|
testHelper.runBlockingTest {
|
||||||
aliceSession.sharedSecretStorageService.getSecret("my.secret",
|
aliceSession.sharedSecretStorageService().getSecret("my.secret",
|
||||||
keyId2,
|
keyId2,
|
||||||
RawBytesKeySpec.fromRecoveryKey(key2Info.recoveryKey)!!
|
RawBytesKeySpec.fromRecoveryKey(key2Info.recoveryKey)!!
|
||||||
)
|
)
|
||||||
@ -236,7 +236,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
val mySecretText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
|
val mySecretText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
|
||||||
|
|
||||||
testHelper.runBlockingTest {
|
testHelper.runBlockingTest {
|
||||||
aliceSession.sharedSecretStorageService.storeSecret(
|
aliceSession.sharedSecretStorageService().storeSecret(
|
||||||
"my.secret",
|
"my.secret",
|
||||||
mySecretText.toByteArray().toBase64NoPadding(),
|
mySecretText.toByteArray().toBase64NoPadding(),
|
||||||
listOf(SharedSecretStorageService.KeyRef(keyId1, RawBytesKeySpec.fromRecoveryKey(key1Info.recoveryKey)))
|
listOf(SharedSecretStorageService.KeyRef(keyId1, RawBytesKeySpec.fromRecoveryKey(key1Info.recoveryKey)))
|
||||||
@ -245,7 +245,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
|
|
||||||
testHelper.runBlockingTest {
|
testHelper.runBlockingTest {
|
||||||
try {
|
try {
|
||||||
aliceSession.sharedSecretStorageService.getSecret("my.secret",
|
aliceSession.sharedSecretStorageService().getSecret("my.secret",
|
||||||
keyId1,
|
keyId1,
|
||||||
RawBytesKeySpec.fromPassphrase(
|
RawBytesKeySpec.fromPassphrase(
|
||||||
"A bad passphrase",
|
"A bad passphrase",
|
||||||
@ -260,7 +260,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
|
|
||||||
// Now try with correct key
|
// Now try with correct key
|
||||||
testHelper.runBlockingTest {
|
testHelper.runBlockingTest {
|
||||||
aliceSession.sharedSecretStorageService.getSecret("my.secret",
|
aliceSession.sharedSecretStorageService().getSecret("my.secret",
|
||||||
keyId1,
|
keyId1,
|
||||||
RawBytesKeySpec.fromPassphrase(
|
RawBytesKeySpec.fromPassphrase(
|
||||||
passphrase,
|
passphrase,
|
||||||
@ -292,7 +292,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun generatedSecret(session: Session, keyId: String, asDefault: Boolean = true): SsssKeyCreationInfo {
|
private fun generatedSecret(session: Session, keyId: String, asDefault: Boolean = true): SsssKeyCreationInfo {
|
||||||
val quadS = session.sharedSecretStorageService
|
val quadS = session.sharedSecretStorageService()
|
||||||
val testHelper = CommonTestHelper(context())
|
val testHelper = CommonTestHelper(context())
|
||||||
|
|
||||||
val creationInfo = testHelper.runBlockingTest {
|
val creationInfo = testHelper.runBlockingTest {
|
||||||
@ -312,7 +312,7 @@ class QuadSTests : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun generatedSecretFromPassphrase(session: Session, passphrase: String, keyId: String, asDefault: Boolean = true): SsssKeyCreationInfo {
|
private fun generatedSecretFromPassphrase(session: Session, passphrase: String, keyId: String, asDefault: Boolean = true): SsssKeyCreationInfo {
|
||||||
val quadS = session.sharedSecretStorageService
|
val quadS = session.sharedSecretStorageService()
|
||||||
val testHelper = CommonTestHelper(context())
|
val testHelper = CommonTestHelper(context())
|
||||||
|
|
||||||
val creationInfo = testHelper.runBlockingTest {
|
val creationInfo = testHelper.runBlockingTest {
|
||||||
|
@ -31,6 +31,7 @@ import org.matrix.android.sdk.InstrumentedTest
|
|||||||
import org.matrix.android.sdk.api.session.events.model.getRootThreadEventId
|
import org.matrix.android.sdk.api.session.events.model.getRootThreadEventId
|
||||||
import org.matrix.android.sdk.api.session.events.model.isTextMessage
|
import org.matrix.android.sdk.api.session.events.model.isTextMessage
|
||||||
import org.matrix.android.sdk.api.session.events.model.isThread
|
import org.matrix.android.sdk.api.session.events.model.isThread
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
|
@ -30,6 +30,7 @@ import org.junit.runners.MethodSorters
|
|||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.PollResponseAggregatedSummary
|
import org.matrix.android.sdk.api.session.room.model.PollResponseAggregatedSummary
|
||||||
import org.matrix.android.sdk.api.session.room.model.PollSummaryContent
|
import org.matrix.android.sdk.api.session.room.model.PollSummaryContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent
|
||||||
|
@ -30,6 +30,7 @@ import org.matrix.android.sdk.InstrumentedTest
|
|||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
||||||
|
@ -28,6 +28,7 @@ import org.matrix.android.sdk.InstrumentedTest
|
|||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
||||||
|
@ -28,6 +28,7 @@ import org.matrix.android.sdk.InstrumentedTest
|
|||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.events.model.isTextMessage
|
import org.matrix.android.sdk.api.session.events.model.isTextMessage
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageTextContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageTextContent
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
||||||
|
@ -27,6 +27,7 @@ import org.junit.runners.MethodSorters
|
|||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
|
@ -24,6 +24,7 @@ import org.junit.runners.JUnit4
|
|||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.search.SearchResult
|
import org.matrix.android.sdk.api.session.search.SearchResult
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestData
|
import org.matrix.android.sdk.common.CryptoTestData
|
||||||
@ -59,9 +60,10 @@ class SearchMessagesTest : InstrumentedTest {
|
|||||||
fun sendTextMessageAndSearchPartOfItUsingRoom() {
|
fun sendTextMessageAndSearchPartOfItUsingRoom() {
|
||||||
doTest { cryptoTestData ->
|
doTest { cryptoTestData ->
|
||||||
cryptoTestData.firstSession
|
cryptoTestData.firstSession
|
||||||
.getRoom(cryptoTestData.roomId)!!
|
.searchService()
|
||||||
.search(
|
.search(
|
||||||
searchTerm = "lore",
|
searchTerm = "lore",
|
||||||
|
roomId = cryptoTestData.roomId,
|
||||||
limit = 10,
|
limit = 10,
|
||||||
includeProfile = true,
|
includeProfile = true,
|
||||||
afterLimit = 0,
|
afterLimit = 0,
|
||||||
|
@ -147,7 +147,7 @@ class SpaceCreationTest : InstrumentedTest {
|
|||||||
// create a room
|
// create a room
|
||||||
var firstChild: String? = null
|
var firstChild: String? = null
|
||||||
commonTestHelper.waitWithLatch {
|
commonTestHelper.waitWithLatch {
|
||||||
firstChild = aliceSession.createRoom(CreateRoomParams().apply {
|
firstChild = aliceSession.roomService().createRoom(CreateRoomParams().apply {
|
||||||
this.name = "FirstRoom"
|
this.name = "FirstRoom"
|
||||||
this.topic = "Description of first room"
|
this.topic = "Description of first room"
|
||||||
this.preset = CreateRoomPreset.PRESET_PUBLIC_CHAT
|
this.preset = CreateRoomPreset.PRESET_PUBLIC_CHAT
|
||||||
@ -162,7 +162,7 @@ class SpaceCreationTest : InstrumentedTest {
|
|||||||
|
|
||||||
var secondChild: String? = null
|
var secondChild: String? = null
|
||||||
commonTestHelper.waitWithLatch {
|
commonTestHelper.waitWithLatch {
|
||||||
secondChild = aliceSession.createRoom(CreateRoomParams().apply {
|
secondChild = aliceSession.roomService().createRoom(CreateRoomParams().apply {
|
||||||
this.name = "SecondRoom"
|
this.name = "SecondRoom"
|
||||||
this.topic = "Description of second room"
|
this.topic = "Description of second room"
|
||||||
this.preset = CreateRoomPreset.PRESET_PUBLIC_CHAT
|
this.preset = CreateRoomPreset.PRESET_PUBLIC_CHAT
|
||||||
|
@ -35,6 +35,8 @@ import org.matrix.android.sdk.api.session.Session
|
|||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
|
import org.matrix.android.sdk.api.session.getRoomSummary
|
||||||
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
|
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesAllowEntry
|
import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesAllowEntry
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
@ -68,7 +70,7 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
|
|
||||||
var roomId = ""
|
var roomId = ""
|
||||||
commonTestHelper.waitWithLatch {
|
commonTestHelper.waitWithLatch {
|
||||||
roomId = session.createRoom(CreateRoomParams().apply { name = "General" })
|
roomId = session.roomService().createRoom(CreateRoomParams().apply { name = "General" })
|
||||||
it.countDown()
|
it.countDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,27 +205,27 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
|
|
||||||
var orphan1 = ""
|
var orphan1 = ""
|
||||||
commonTestHelper.waitWithLatch {
|
commonTestHelper.waitWithLatch {
|
||||||
orphan1 = session.createRoom(CreateRoomParams().apply { name = "O1" })
|
orphan1 = session.roomService().createRoom(CreateRoomParams().apply { name = "O1" })
|
||||||
it.countDown()
|
it.countDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
var orphan2 = ""
|
var orphan2 = ""
|
||||||
commonTestHelper.waitWithLatch {
|
commonTestHelper.waitWithLatch {
|
||||||
orphan2 = session.createRoom(CreateRoomParams().apply { name = "O2" })
|
orphan2 = session.roomService().createRoom(CreateRoomParams().apply { name = "O2" })
|
||||||
it.countDown()
|
it.countDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
val allRooms = session.getRoomSummaries(roomSummaryQueryParams { excludeType = listOf(RoomType.SPACE) })
|
val allRooms = session.roomService().getRoomSummaries(roomSummaryQueryParams { excludeType = listOf(RoomType.SPACE) })
|
||||||
|
|
||||||
assertEquals("Unexpected number of rooms", 9, allRooms.size)
|
assertEquals("Unexpected number of rooms", 9, allRooms.size)
|
||||||
|
|
||||||
val orphans = session.getFlattenRoomSummaryChildrenOf(null)
|
val orphans = session.roomService().getFlattenRoomSummaryChildrenOf(null)
|
||||||
|
|
||||||
assertEquals("Unexpected number of orphan rooms", 2, orphans.size)
|
assertEquals("Unexpected number of orphan rooms", 2, orphans.size)
|
||||||
assertTrue("O1 should be an orphan", orphans.any { it.roomId == orphan1 })
|
assertTrue("O1 should be an orphan", orphans.any { it.roomId == orphan1 })
|
||||||
assertTrue("O2 should be an orphan ${orphans.map { it.name }}", orphans.any { it.roomId == orphan2 })
|
assertTrue("O2 should be an orphan ${orphans.map { it.name }}", orphans.any { it.roomId == orphan2 })
|
||||||
|
|
||||||
val aChildren = session.getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId)
|
val aChildren = session.roomService().getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId)
|
||||||
|
|
||||||
assertEquals("Unexpected number of flatten child rooms", 4, aChildren.size)
|
assertEquals("Unexpected number of flatten child rooms", 4, aChildren.size)
|
||||||
assertTrue("A1 should be a child of A", aChildren.any { it.name == "A1" })
|
assertTrue("A1 should be a child of A", aChildren.any { it.name == "A1" })
|
||||||
@ -233,13 +235,13 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
|
|
||||||
// Add a non canonical child and check that it does not appear as orphan
|
// Add a non canonical child and check that it does not appear as orphan
|
||||||
commonTestHelper.waitWithLatch {
|
commonTestHelper.waitWithLatch {
|
||||||
val a3 = session.createRoom(CreateRoomParams().apply { name = "A3" })
|
val a3 = session.roomService().createRoom(CreateRoomParams().apply { name = "A3" })
|
||||||
spaceA!!.addChildren(a3, viaServers, null, false)
|
spaceA!!.addChildren(a3, viaServers, null, false)
|
||||||
it.countDown()
|
it.countDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.sleep(6_000)
|
Thread.sleep(6_000)
|
||||||
val orphansUpdate = session.getRoomSummaries(roomSummaryQueryParams {
|
val orphansUpdate = session.roomService().getRoomSummaries(roomSummaryQueryParams {
|
||||||
activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null)
|
activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null)
|
||||||
})
|
})
|
||||||
assertEquals("Unexpected number of orphan rooms ${orphansUpdate.map { it.name }}", 2, orphansUpdate.size)
|
assertEquals("Unexpected number of orphan rooms ${orphansUpdate.map { it.name }}", 2, orphansUpdate.size)
|
||||||
@ -279,7 +281,7 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
|
|
||||||
// A -> C -> A
|
// A -> C -> A
|
||||||
|
|
||||||
val aChildren = session.getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId)
|
val aChildren = session.roomService().getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId)
|
||||||
|
|
||||||
assertEquals("Unexpected number of flatten child rooms ${aChildren.map { it.name }}", 4, aChildren.size)
|
assertEquals("Unexpected number of flatten child rooms ${aChildren.map { it.name }}", 4, aChildren.size)
|
||||||
assertTrue("A1 should be a child of A", aChildren.any { it.name == "A1" })
|
assertTrue("A1 should be a child of A", aChildren.any { it.name == "A1" })
|
||||||
@ -319,7 +321,7 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
|
|
||||||
commonTestHelper.waitWithLatch { latch ->
|
commonTestHelper.waitWithLatch { latch ->
|
||||||
|
|
||||||
val flatAChildren = session.getFlattenRoomSummaryChildrenOfLive(spaceAInfo.spaceId)
|
val flatAChildren = session.roomService().getFlattenRoomSummaryChildrenOfLive(spaceAInfo.spaceId)
|
||||||
val childObserver = object : Observer<List<RoomSummary>> {
|
val childObserver = object : Observer<List<RoomSummary>> {
|
||||||
override fun onChanged(children: List<RoomSummary>?) {
|
override fun onChanged(children: List<RoomSummary>?) {
|
||||||
// Log.d("## TEST", "Space A flat children update : ${children?.map { it.name }}")
|
// Log.d("## TEST", "Space A flat children update : ${children?.map { it.name }}")
|
||||||
@ -346,7 +348,7 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
val bRoomId = spaceBInfo.roomIds.first()
|
val bRoomId = spaceBInfo.roomIds.first()
|
||||||
|
|
||||||
commonTestHelper.waitWithLatch { latch ->
|
commonTestHelper.waitWithLatch { latch ->
|
||||||
val flatAChildren = session.getFlattenRoomSummaryChildrenOfLive(spaceAInfo.spaceId)
|
val flatAChildren = session.roomService().getFlattenRoomSummaryChildrenOfLive(spaceAInfo.spaceId)
|
||||||
val childObserver = object : Observer<List<RoomSummary>> {
|
val childObserver = object : Observer<List<RoomSummary>> {
|
||||||
override fun onChanged(children: List<RoomSummary>?) {
|
override fun onChanged(children: List<RoomSummary>?) {
|
||||||
System.out.println("## TEST | Space A flat children update : ${children?.map { it.name }}")
|
System.out.println("## TEST | Space A flat children update : ${children?.map { it.name }}")
|
||||||
@ -359,7 +361,7 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// part from b room
|
// part from b room
|
||||||
session.leaveRoom(bRoomId)
|
session.roomService().leaveRoom(bRoomId)
|
||||||
// The room should have disapear from flat children
|
// The room should have disapear from flat children
|
||||||
flatAChildren.observeForever(childObserver)
|
flatAChildren.observeForever(childObserver)
|
||||||
}
|
}
|
||||||
@ -385,7 +387,7 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
val viaServers = listOf(session.sessionParams.homeServerHost ?: "")
|
val viaServers = listOf(session.sessionParams.homeServerHost ?: "")
|
||||||
|
|
||||||
roomIds = childInfo.map { entry ->
|
roomIds = childInfo.map { entry ->
|
||||||
session.createRoom(CreateRoomParams().apply { name = entry.first })
|
session.roomService().createRoom(CreateRoomParams().apply { name = entry.first })
|
||||||
}
|
}
|
||||||
roomIds.forEachIndexed { index, roomId ->
|
roomIds.forEachIndexed { index, roomId ->
|
||||||
syncedSpace!!.addChildren(roomId, viaServers, null, childInfo[index].second)
|
syncedSpace!!.addChildren(roomId, viaServers, null, childInfo[index].second)
|
||||||
@ -414,8 +416,9 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
roomIds =
|
roomIds =
|
||||||
childInfo.map { entry ->
|
childInfo.map { entry ->
|
||||||
val homeServerCapabilities = session
|
val homeServerCapabilities = session
|
||||||
|
.homeServerCapabilitiesService()
|
||||||
.getHomeServerCapabilities()
|
.getHomeServerCapabilities()
|
||||||
session.createRoom(CreateRoomParams().apply {
|
session.roomService().createRoom(CreateRoomParams().apply {
|
||||||
name = entry.first
|
name = entry.first
|
||||||
this.featurePreset = RestrictedRoomPreset(
|
this.featurePreset = RestrictedRoomPreset(
|
||||||
homeServerCapabilities,
|
homeServerCapabilities,
|
||||||
@ -475,7 +478,9 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
// + C
|
// + C
|
||||||
// + c1, c2
|
// + c1, c2
|
||||||
|
|
||||||
val rootSpaces = session.spaceService().getRootSpaceSummaries()
|
val rootSpaces = commonTestHelper.runBlockingTest {
|
||||||
|
session.spaceService().getRootSpaceSummaries()
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals("Unexpected number of root spaces ${rootSpaces.map { it.name }}", 2, rootSpaces.size)
|
assertEquals("Unexpected number of root spaces ${rootSpaces.map { it.name }}", 2, rootSpaces.size)
|
||||||
|
|
||||||
@ -498,18 +503,18 @@ class SpaceHierarchyTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
commonTestHelper.runBlockingTest {
|
commonTestHelper.runBlockingTest {
|
||||||
bobSession.joinRoom(spaceAInfo.spaceId, null, emptyList())
|
bobSession.roomService().joinRoom(spaceAInfo.spaceId, null, emptyList())
|
||||||
}
|
}
|
||||||
|
|
||||||
var bobRoomId = ""
|
var bobRoomId = ""
|
||||||
commonTestHelper.waitWithLatch {
|
commonTestHelper.waitWithLatch {
|
||||||
bobRoomId = bobSession.createRoom(CreateRoomParams().apply { name = "A Bob Room" })
|
bobRoomId = bobSession.roomService().createRoom(CreateRoomParams().apply { name = "A Bob Room" })
|
||||||
bobSession.getRoom(bobRoomId)!!.invite(aliceSession.myUserId)
|
bobSession.getRoom(bobRoomId)!!.invite(aliceSession.myUserId)
|
||||||
it.countDown()
|
it.countDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
commonTestHelper.runBlockingTest {
|
commonTestHelper.runBlockingTest {
|
||||||
aliceSession.joinRoom(bobRoomId)
|
aliceSession.roomService().joinRoom(bobRoomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
commonTestHelper.waitWithLatch { latch ->
|
commonTestHelper.waitWithLatch { latch ->
|
||||||
|
@ -43,7 +43,8 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the matrix sdk.
|
* This is the main entry point to the matrix sdk.
|
||||||
* To get the singleton instance, use getInstance static method.
|
* <br/>
|
||||||
|
* See [Companion.createInstance] to create an instance. The app should create and manage the instance itself.
|
||||||
*/
|
*/
|
||||||
class Matrix private constructor(context: Context, matrixConfiguration: MatrixConfiguration) {
|
class Matrix private constructor(context: Context, matrixConfiguration: MatrixConfiguration) {
|
||||||
|
|
||||||
@ -74,9 +75,7 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
|
|||||||
|
|
||||||
fun getUserAgent() = userAgentHolder.userAgent
|
fun getUserAgent() = userAgentHolder.userAgent
|
||||||
|
|
||||||
fun authenticationService(): AuthenticationService {
|
fun authenticationService() = authenticationService
|
||||||
return authenticationService
|
|
||||||
}
|
|
||||||
|
|
||||||
fun rawService() = rawService
|
fun rawService() = rawService
|
||||||
|
|
||||||
@ -84,9 +83,7 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
|
|||||||
|
|
||||||
fun homeServerHistoryService() = homeServerHistoryService
|
fun homeServerHistoryService() = homeServerHistoryService
|
||||||
|
|
||||||
fun legacySessionImporter(): LegacySessionImporter {
|
fun legacySessionImporter() = legacySessionImporter
|
||||||
return legacySessionImporter
|
|
||||||
}
|
|
||||||
|
|
||||||
fun workerFactory(): WorkerFactory = matrixWorkerFactory
|
fun workerFactory(): WorkerFactory = matrixWorkerFactory
|
||||||
|
|
||||||
@ -143,6 +140,9 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
|
|||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a String with details about the Matrix SDK version
|
||||||
|
*/
|
||||||
fun getSdkVersion(): String {
|
fun getSdkVersion(): String {
|
||||||
return BuildConfig.SDK_VERSION + " (" + BuildConfig.GIT_SDK_REVISION + ")"
|
return BuildConfig.SDK_VERSION + " (" + BuildConfig.GIT_SDK_REVISION + ")"
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import org.matrix.android.sdk.api.failure.GlobalError
|
|||||||
import org.matrix.android.sdk.api.federation.FederationService
|
import org.matrix.android.sdk.api.federation.FederationService
|
||||||
import org.matrix.android.sdk.api.session.account.AccountService
|
import org.matrix.android.sdk.api.session.account.AccountService
|
||||||
import org.matrix.android.sdk.api.session.accountdata.SessionAccountDataService
|
import org.matrix.android.sdk.api.session.accountdata.SessionAccountDataService
|
||||||
import org.matrix.android.sdk.api.session.cache.CacheService
|
|
||||||
import org.matrix.android.sdk.api.session.call.CallSignalingService
|
import org.matrix.android.sdk.api.session.call.CallSignalingService
|
||||||
import org.matrix.android.sdk.api.session.content.ContentUploadStateTracker
|
import org.matrix.android.sdk.api.session.content.ContentUploadStateTracker
|
||||||
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
|
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
|
||||||
@ -68,26 +67,7 @@ import org.matrix.android.sdk.api.session.widgets.WidgetService
|
|||||||
* This interface defines interactions with a session.
|
* This interface defines interactions with a session.
|
||||||
* An instance of a session will be provided by the SDK.
|
* An instance of a session will be provided by the SDK.
|
||||||
*/
|
*/
|
||||||
interface Session :
|
interface Session {
|
||||||
RoomService,
|
|
||||||
RoomDirectoryService,
|
|
||||||
GroupService,
|
|
||||||
UserService,
|
|
||||||
CacheService,
|
|
||||||
SignOutService,
|
|
||||||
FilterService,
|
|
||||||
TermsService,
|
|
||||||
EventService,
|
|
||||||
ProfileService,
|
|
||||||
PresenceService,
|
|
||||||
PushRuleService,
|
|
||||||
PushersService,
|
|
||||||
SyncStatusService,
|
|
||||||
HomeServerCapabilitiesService,
|
|
||||||
SecureStorageService,
|
|
||||||
AccountService,
|
|
||||||
ToDeviceService,
|
|
||||||
EventStreamService {
|
|
||||||
|
|
||||||
val coroutineDispatchers: MatrixCoroutineDispatchers
|
val coroutineDispatchers: MatrixCoroutineDispatchers
|
||||||
|
|
||||||
@ -144,6 +124,11 @@ interface Session :
|
|||||||
*/
|
*/
|
||||||
fun stopSync()
|
fun stopSync()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear cache of the session
|
||||||
|
*/
|
||||||
|
suspend fun clearCache()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method allows to listen the sync state.
|
* This method allows to listen the sync state.
|
||||||
* @return a [LiveData] of [SyncState].
|
* @return a [LiveData] of [SyncState].
|
||||||
@ -206,6 +191,96 @@ interface Session :
|
|||||||
*/
|
*/
|
||||||
fun identityService(): IdentityService
|
fun identityService(): IdentityService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the HomeServerCapabilities service associated with the session
|
||||||
|
*/
|
||||||
|
fun homeServerCapabilitiesService(): HomeServerCapabilitiesService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the RoomService associated with the session
|
||||||
|
*/
|
||||||
|
fun roomService(): RoomService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the RoomDirectoryService associated with the session
|
||||||
|
*/
|
||||||
|
fun roomDirectoryService(): RoomDirectoryService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the GroupService associated with the session
|
||||||
|
*/
|
||||||
|
fun groupService(): GroupService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the UserService associated with the session
|
||||||
|
*/
|
||||||
|
fun userService(): UserService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the SignOutService associated with the session
|
||||||
|
*/
|
||||||
|
fun signOutService(): SignOutService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the FilterService associated with the session
|
||||||
|
*/
|
||||||
|
fun filterService(): FilterService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the PushRuleService associated with the session
|
||||||
|
*/
|
||||||
|
fun pushRuleService(): PushRuleService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the PushersService associated with the session
|
||||||
|
*/
|
||||||
|
fun pushersService(): PushersService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the EventService associated with the session
|
||||||
|
*/
|
||||||
|
fun eventService(): EventService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the TermsService associated with the session
|
||||||
|
*/
|
||||||
|
fun termsService(): TermsService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the SyncStatusService associated with the session
|
||||||
|
*/
|
||||||
|
fun syncStatusService(): SyncStatusService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the SecureStorageService associated with the session
|
||||||
|
*/
|
||||||
|
fun secureStorageService(): SecureStorageService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ProfileService associated with the session
|
||||||
|
*/
|
||||||
|
fun profileService(): ProfileService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the PresenceService associated with the session
|
||||||
|
*/
|
||||||
|
fun presenceService(): PresenceService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AccountService associated with the session
|
||||||
|
*/
|
||||||
|
fun accountService(): AccountService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ToDeviceService associated with the session
|
||||||
|
*/
|
||||||
|
fun toDeviceService(): ToDeviceService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the EventStreamService associated with the session
|
||||||
|
*/
|
||||||
|
fun eventStreamService(): EventStreamService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the widget service associated with the session
|
* Returns the widget service associated with the session
|
||||||
*/
|
*/
|
||||||
@ -266,6 +341,11 @@ interface Session :
|
|||||||
*/
|
*/
|
||||||
fun accountDataService(): SessionAccountDataService
|
fun accountDataService(): SessionAccountDataService
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the SharedSecretStorageService associated with the session
|
||||||
|
*/
|
||||||
|
fun sharedSecretStorageService(): SharedSecretStorageService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a listener to the session.
|
* Add a listener to the session.
|
||||||
* @param listener the listener to add.
|
* @param listener the listener to add.
|
||||||
@ -303,8 +383,6 @@ interface Session :
|
|||||||
fun onGlobalError(session: Session, globalError: GlobalError) = Unit
|
fun onGlobalError(session: Session, globalError: GlobalError) = Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
val sharedSecretStorageService: SharedSecretStorageService
|
|
||||||
|
|
||||||
fun getUiaSsoFallbackUrl(authenticationSessionId: String): String
|
fun getUiaSsoFallbackUrl(authenticationSessionId: String): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022 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
|
||||||
|
|
||||||
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
|
import org.matrix.android.sdk.api.session.user.model.User
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a room using the RoomService of a Session
|
||||||
|
*/
|
||||||
|
fun Session.getRoom(roomId: String): Room? = roomService().getRoom(roomId)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a room summary using the RoomService of a Session
|
||||||
|
*/
|
||||||
|
fun Session.getRoomSummary(roomIdOrAlias: String): RoomSummary? = roomService().getRoomSummary(roomIdOrAlias)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a user using the UserService of a Session
|
||||||
|
*/
|
||||||
|
fun Session.getUser(userId: String): User? = userService().getUser(userId)
|
@ -38,7 +38,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineService
|
|||||||
import org.matrix.android.sdk.api.session.room.typing.TypingService
|
import org.matrix.android.sdk.api.session.room.typing.TypingService
|
||||||
import org.matrix.android.sdk.api.session.room.uploads.UploadsService
|
import org.matrix.android.sdk.api.session.room.uploads.UploadsService
|
||||||
import org.matrix.android.sdk.api.session.room.version.RoomVersionService
|
import org.matrix.android.sdk.api.session.room.version.RoomVersionService
|
||||||
import org.matrix.android.sdk.api.session.search.SearchResult
|
|
||||||
import org.matrix.android.sdk.api.session.space.Space
|
import org.matrix.android.sdk.api.session.space.Space
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
|
|
||||||
@ -84,26 +83,6 @@ interface Room :
|
|||||||
*/
|
*/
|
||||||
fun roomSummary(): RoomSummary?
|
fun roomSummary(): RoomSummary?
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic function to search a term in a room.
|
|
||||||
* Ref: https://matrix.org/docs/spec/client_server/latest#module-search
|
|
||||||
* @param searchTerm the term to search
|
|
||||||
* @param nextBatch the token that retrieved from the previous response. Should be provided to get the next batch of results
|
|
||||||
* @param orderByRecent if true, the most recent message events will return in the first places of the list
|
|
||||||
* @param limit the maximum number of events to return.
|
|
||||||
* @param beforeLimit how many events before the result are returned.
|
|
||||||
* @param afterLimit how many events after the result are returned.
|
|
||||||
* @param includeProfile requests that the server returns the historic profile information for the users that sent the events that were returned.
|
|
||||||
* @return The search result
|
|
||||||
*/
|
|
||||||
suspend fun search(searchTerm: String,
|
|
||||||
nextBatch: String?,
|
|
||||||
orderByRecent: Boolean,
|
|
||||||
limit: Int,
|
|
||||||
beforeLimit: Int,
|
|
||||||
afterLimit: Int,
|
|
||||||
includeProfile: Boolean): SearchResult
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this room as a Space, if the type is correct.
|
* Use this room as a Space, if the type is correct.
|
||||||
*/
|
*/
|
||||||
|
@ -106,5 +106,8 @@ interface SpaceService {
|
|||||||
|
|
||||||
suspend fun removeSpaceParent(childRoomId: String, parentSpaceId: String)
|
suspend fun removeSpaceParent(childRoomId: String, parentSpaceId: String)
|
||||||
|
|
||||||
fun getRootSpaceSummaries(): List<RoomSummary>
|
/**
|
||||||
|
* Get the root spaces, i.e. all the spaces which do not have a parent space.
|
||||||
|
*/
|
||||||
|
suspend fun getRootSpaceSummaries(): List<RoomSummary>
|
||||||
}
|
}
|
||||||
|
@ -124,12 +124,12 @@ internal class DefaultSession @Inject constructor(
|
|||||||
private val syncStatusService: Lazy<SyncStatusService>,
|
private val syncStatusService: Lazy<SyncStatusService>,
|
||||||
private val homeServerCapabilitiesService: Lazy<HomeServerCapabilitiesService>,
|
private val homeServerCapabilitiesService: Lazy<HomeServerCapabilitiesService>,
|
||||||
private val accountDataService: Lazy<SessionAccountDataService>,
|
private val accountDataService: Lazy<SessionAccountDataService>,
|
||||||
private val _sharedSecretStorageService: Lazy<SharedSecretStorageService>,
|
private val sharedSecretStorageService: Lazy<SharedSecretStorageService>,
|
||||||
private val accountService: Lazy<AccountService>,
|
private val accountService: Lazy<AccountService>,
|
||||||
private val eventService: Lazy<EventService>,
|
private val eventService: Lazy<EventService>,
|
||||||
private val contentScannerService: Lazy<ContentScannerService>,
|
private val contentScannerService: Lazy<ContentScannerService>,
|
||||||
private val identityService: IdentityService,
|
private val identityService: Lazy<IdentityService>,
|
||||||
private val integrationManagerService: IntegrationManagerService,
|
private val integrationManagerService: Lazy<IntegrationManagerService>,
|
||||||
private val thirdPartyService: Lazy<ThirdPartyService>,
|
private val thirdPartyService: Lazy<ThirdPartyService>,
|
||||||
private val callSignalingService: Lazy<CallSignalingService>,
|
private val callSignalingService: Lazy<CallSignalingService>,
|
||||||
private val spaceService: Lazy<SpaceService>,
|
private val spaceService: Lazy<SpaceService>,
|
||||||
@ -140,28 +140,7 @@ internal class DefaultSession @Inject constructor(
|
|||||||
@UnauthenticatedWithCertificate
|
@UnauthenticatedWithCertificate
|
||||||
private val unauthenticatedWithCertificateOkHttpClient: Lazy<OkHttpClient>
|
private val unauthenticatedWithCertificateOkHttpClient: Lazy<OkHttpClient>
|
||||||
) : Session,
|
) : Session,
|
||||||
GlobalErrorHandler.Listener,
|
GlobalErrorHandler.Listener {
|
||||||
RoomService by roomService.get(),
|
|
||||||
RoomDirectoryService by roomDirectoryService.get(),
|
|
||||||
GroupService by groupService.get(),
|
|
||||||
UserService by userService.get(),
|
|
||||||
SignOutService by signOutService.get(),
|
|
||||||
FilterService by filterService.get(),
|
|
||||||
PushRuleService by pushRuleService.get(),
|
|
||||||
PushersService by pushersService.get(),
|
|
||||||
EventService by eventService.get(),
|
|
||||||
TermsService by termsService.get(),
|
|
||||||
SyncStatusService by syncStatusService.get(),
|
|
||||||
SecureStorageService by secureStorageService.get(),
|
|
||||||
HomeServerCapabilitiesService by homeServerCapabilitiesService.get(),
|
|
||||||
ProfileService by profileService.get(),
|
|
||||||
PresenceService by presenceService.get(),
|
|
||||||
AccountService by accountService.get(),
|
|
||||||
ToDeviceService by toDeviceService.get(),
|
|
||||||
EventStreamService by eventStreamService.get() {
|
|
||||||
|
|
||||||
override val sharedSecretStorageService: SharedSecretStorageService
|
|
||||||
get() = _sharedSecretStorageService.get()
|
|
||||||
|
|
||||||
private var isOpen = false
|
private var isOpen = false
|
||||||
|
|
||||||
@ -274,42 +253,44 @@ internal class DefaultSession @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun contentUrlResolver() = contentUrlResolver
|
override fun contentUrlResolver() = contentUrlResolver
|
||||||
|
|
||||||
override fun contentUploadProgressTracker() = contentUploadProgressTracker
|
override fun contentUploadProgressTracker() = contentUploadProgressTracker
|
||||||
|
|
||||||
override fun typingUsersTracker() = typingUsersTracker
|
override fun typingUsersTracker() = typingUsersTracker
|
||||||
|
|
||||||
override fun contentDownloadProgressTracker(): ContentDownloadStateTracker = contentDownloadStateTracker
|
override fun contentDownloadProgressTracker(): ContentDownloadStateTracker = contentDownloadStateTracker
|
||||||
|
|
||||||
override fun cryptoService(): CryptoService = cryptoService.get()
|
override fun cryptoService(): CryptoService = cryptoService.get()
|
||||||
|
|
||||||
override fun contentScannerService(): ContentScannerService = contentScannerService.get()
|
override fun contentScannerService(): ContentScannerService = contentScannerService.get()
|
||||||
|
override fun identityService(): IdentityService = identityService.get()
|
||||||
override fun identityService() = identityService
|
override fun homeServerCapabilitiesService(): HomeServerCapabilitiesService = homeServerCapabilitiesService.get()
|
||||||
|
override fun roomService(): RoomService = roomService.get()
|
||||||
|
override fun roomDirectoryService(): RoomDirectoryService = roomDirectoryService.get()
|
||||||
|
override fun groupService(): GroupService = groupService.get()
|
||||||
|
override fun userService(): UserService = userService.get()
|
||||||
|
override fun signOutService(): SignOutService = signOutService.get()
|
||||||
|
override fun filterService(): FilterService = filterService.get()
|
||||||
|
override fun pushRuleService(): PushRuleService = pushRuleService.get()
|
||||||
|
override fun pushersService(): PushersService = pushersService.get()
|
||||||
|
override fun eventService(): EventService = eventService.get()
|
||||||
|
override fun termsService(): TermsService = termsService.get()
|
||||||
|
override fun syncStatusService(): SyncStatusService = syncStatusService.get()
|
||||||
|
override fun secureStorageService(): SecureStorageService = secureStorageService.get()
|
||||||
|
override fun profileService(): ProfileService = profileService.get()
|
||||||
|
override fun presenceService(): PresenceService = presenceService.get()
|
||||||
|
override fun accountService(): AccountService = accountService.get()
|
||||||
|
override fun toDeviceService(): ToDeviceService = toDeviceService.get()
|
||||||
|
override fun eventStreamService(): EventStreamService = eventStreamService.get()
|
||||||
override fun fileService(): FileService = defaultFileService.get()
|
override fun fileService(): FileService = defaultFileService.get()
|
||||||
|
|
||||||
override fun permalinkService(): PermalinkService = permalinkService.get()
|
override fun permalinkService(): PermalinkService = permalinkService.get()
|
||||||
|
|
||||||
override fun widgetService(): WidgetService = widgetService.get()
|
override fun widgetService(): WidgetService = widgetService.get()
|
||||||
|
|
||||||
override fun mediaService(): MediaService = mediaService.get()
|
override fun mediaService(): MediaService = mediaService.get()
|
||||||
|
override fun integrationManagerService(): IntegrationManagerService = integrationManagerService.get()
|
||||||
override fun integrationManagerService() = integrationManagerService
|
|
||||||
|
|
||||||
override fun callSignalingService(): CallSignalingService = callSignalingService.get()
|
override fun callSignalingService(): CallSignalingService = callSignalingService.get()
|
||||||
|
|
||||||
override fun searchService(): SearchService = searchService.get()
|
override fun searchService(): SearchService = searchService.get()
|
||||||
|
|
||||||
override fun federationService(): FederationService = federationService.get()
|
override fun federationService(): FederationService = federationService.get()
|
||||||
|
|
||||||
override fun thirdPartyService(): ThirdPartyService = thirdPartyService.get()
|
override fun thirdPartyService(): ThirdPartyService = thirdPartyService.get()
|
||||||
|
|
||||||
override fun spaceService(): SpaceService = spaceService.get()
|
override fun spaceService(): SpaceService = spaceService.get()
|
||||||
|
|
||||||
override fun openIdService(): OpenIdService = openIdService.get()
|
override fun openIdService(): OpenIdService = openIdService.get()
|
||||||
|
|
||||||
override fun accountDataService(): SessionAccountDataService = accountDataService.get()
|
override fun accountDataService(): SessionAccountDataService = accountDataService.get()
|
||||||
|
override fun sharedSecretStorageService(): SharedSecretStorageService = sharedSecretStorageService.get()
|
||||||
|
|
||||||
override fun getOkHttpClient(): OkHttpClient {
|
override fun getOkHttpClient(): OkHttpClient {
|
||||||
return unauthenticatedWithCertificateOkHttpClient.get()
|
return unauthenticatedWithCertificateOkHttpClient.get()
|
||||||
|
@ -42,14 +42,12 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineService
|
|||||||
import org.matrix.android.sdk.api.session.room.typing.TypingService
|
import org.matrix.android.sdk.api.session.room.typing.TypingService
|
||||||
import org.matrix.android.sdk.api.session.room.uploads.UploadsService
|
import org.matrix.android.sdk.api.session.room.uploads.UploadsService
|
||||||
import org.matrix.android.sdk.api.session.room.version.RoomVersionService
|
import org.matrix.android.sdk.api.session.room.version.RoomVersionService
|
||||||
import org.matrix.android.sdk.api.session.search.SearchResult
|
|
||||||
import org.matrix.android.sdk.api.session.space.Space
|
import org.matrix.android.sdk.api.session.space.Space
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
import org.matrix.android.sdk.api.util.awaitCallback
|
import org.matrix.android.sdk.api.util.awaitCallback
|
||||||
import org.matrix.android.sdk.internal.session.permalinks.ViaParameterFinder
|
import org.matrix.android.sdk.internal.session.permalinks.ViaParameterFinder
|
||||||
import org.matrix.android.sdk.internal.session.room.state.SendStateTask
|
import org.matrix.android.sdk.internal.session.room.state.SendStateTask
|
||||||
import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryDataSource
|
import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryDataSource
|
||||||
import org.matrix.android.sdk.internal.session.search.SearchTask
|
|
||||||
import org.matrix.android.sdk.internal.session.space.DefaultSpace
|
import org.matrix.android.sdk.internal.session.space.DefaultSpace
|
||||||
import java.security.InvalidParameterException
|
import java.security.InvalidParameterException
|
||||||
|
|
||||||
@ -76,7 +74,6 @@ internal class DefaultRoom(override val roomId: String,
|
|||||||
private val roomVersionService: RoomVersionService,
|
private val roomVersionService: RoomVersionService,
|
||||||
private val sendStateTask: SendStateTask,
|
private val sendStateTask: SendStateTask,
|
||||||
private val viaParameterFinder: ViaParameterFinder,
|
private val viaParameterFinder: ViaParameterFinder,
|
||||||
private val searchTask: SearchTask,
|
|
||||||
override val coroutineDispatchers: MatrixCoroutineDispatchers
|
override val coroutineDispatchers: MatrixCoroutineDispatchers
|
||||||
) :
|
) :
|
||||||
Room,
|
Room,
|
||||||
@ -140,34 +137,14 @@ internal class DefaultRoom(override val roomId: String,
|
|||||||
eventType = EventType.STATE_ROOM_ENCRYPTION,
|
eventType = EventType.STATE_ROOM_ENCRYPTION,
|
||||||
body = mapOf(
|
body = mapOf(
|
||||||
"algorithm" to algorithm
|
"algorithm" to algorithm
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
sendStateTask.execute(params)
|
sendStateTask.execute(params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun search(searchTerm: String,
|
|
||||||
nextBatch: String?,
|
|
||||||
orderByRecent: Boolean,
|
|
||||||
limit: Int,
|
|
||||||
beforeLimit: Int,
|
|
||||||
afterLimit: Int,
|
|
||||||
includeProfile: Boolean): SearchResult {
|
|
||||||
return searchTask.execute(
|
|
||||||
SearchTask.Params(
|
|
||||||
searchTerm = searchTerm,
|
|
||||||
roomId = roomId,
|
|
||||||
nextBatch = nextBatch,
|
|
||||||
orderByRecent = orderByRecent,
|
|
||||||
limit = limit,
|
|
||||||
beforeLimit = beforeLimit,
|
|
||||||
afterLimit = afterLimit,
|
|
||||||
includeProfile = includeProfile
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun asSpace(): Space? {
|
override fun asSpace(): Space? {
|
||||||
if (roomSummary()?.roomType != RoomType.SPACE) return null
|
if (roomSummary()?.roomType != RoomType.SPACE) return null
|
||||||
return DefaultSpace(this, roomSummaryDataSource, viaParameterFinder)
|
return DefaultSpace(this, roomSummaryDataSource, viaParameterFinder)
|
||||||
|
@ -542,7 +542,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
|
|||||||
|
|
||||||
private fun getPollEvent(roomId: String, eventId: String): TimelineEvent? {
|
private fun getPollEvent(roomId: String, eventId: String): TimelineEvent? {
|
||||||
val session = sessionManager.getSessionComponent(sessionId)?.session()
|
val session = sessionManager.getSessionComponent(sessionId)?.session()
|
||||||
return session?.getRoom(roomId)?.getTimelineEvent(eventId) ?: return null.also {
|
return session?.roomService()?.getRoom(roomId)?.getTimelineEvent(eventId) ?: return null.also {
|
||||||
Timber.v("## POLL target poll event $eventId not found in room $roomId")
|
Timber.v("## POLL target poll event $eventId not found in room $roomId")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ import org.matrix.android.sdk.internal.session.room.timeline.DefaultTimelineServ
|
|||||||
import org.matrix.android.sdk.internal.session.room.typing.DefaultTypingService
|
import org.matrix.android.sdk.internal.session.room.typing.DefaultTypingService
|
||||||
import org.matrix.android.sdk.internal.session.room.uploads.DefaultUploadsService
|
import org.matrix.android.sdk.internal.session.room.uploads.DefaultUploadsService
|
||||||
import org.matrix.android.sdk.internal.session.room.version.DefaultRoomVersionService
|
import org.matrix.android.sdk.internal.session.room.version.DefaultRoomVersionService
|
||||||
import org.matrix.android.sdk.internal.session.search.SearchTask
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface RoomFactory {
|
internal interface RoomFactory {
|
||||||
@ -71,7 +70,6 @@ internal class DefaultRoomFactory @Inject constructor(private val cryptoService:
|
|||||||
private val roomAccountDataServiceFactory: DefaultRoomAccountDataService.Factory,
|
private val roomAccountDataServiceFactory: DefaultRoomAccountDataService.Factory,
|
||||||
private val sendStateTask: SendStateTask,
|
private val sendStateTask: SendStateTask,
|
||||||
private val viaParameterFinder: ViaParameterFinder,
|
private val viaParameterFinder: ViaParameterFinder,
|
||||||
private val searchTask: SearchTask,
|
|
||||||
private val coroutineDispatchers: MatrixCoroutineDispatchers) :
|
private val coroutineDispatchers: MatrixCoroutineDispatchers) :
|
||||||
RoomFactory {
|
RoomFactory {
|
||||||
|
|
||||||
@ -99,7 +97,6 @@ internal class DefaultRoomFactory @Inject constructor(private val cryptoService:
|
|||||||
roomAccountDataService = roomAccountDataServiceFactory.create(roomId),
|
roomAccountDataService = roomAccountDataServiceFactory.create(roomId),
|
||||||
roomVersionService = roomVersionServiceFactory.create(roomId),
|
roomVersionService = roomVersionServiceFactory.create(roomId),
|
||||||
sendStateTask = sendStateTask,
|
sendStateTask = sendStateTask,
|
||||||
searchTask = searchTask,
|
|
||||||
viaParameterFinder = viaParameterFinder,
|
viaParameterFinder = viaParameterFinder,
|
||||||
coroutineDispatchers = coroutineDispatchers
|
coroutineDispatchers = coroutineDispatchers
|
||||||
)
|
)
|
||||||
|
@ -18,6 +18,8 @@ package org.matrix.android.sdk.internal.session.space
|
|||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
|
||||||
import org.matrix.android.sdk.api.query.QueryStringValue
|
import org.matrix.android.sdk.api.query.QueryStringValue
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
@ -64,7 +66,8 @@ internal class DefaultSpaceService @Inject constructor(
|
|||||||
private val stateEventDataSource: StateEventDataSource,
|
private val stateEventDataSource: StateEventDataSource,
|
||||||
private val peekSpaceTask: PeekSpaceTask,
|
private val peekSpaceTask: PeekSpaceTask,
|
||||||
private val resolveSpaceInfoTask: ResolveSpaceInfoTask,
|
private val resolveSpaceInfoTask: ResolveSpaceInfoTask,
|
||||||
private val leaveRoomTask: LeaveRoomTask
|
private val leaveRoomTask: LeaveRoomTask,
|
||||||
|
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||||
) : SpaceService {
|
) : SpaceService {
|
||||||
|
|
||||||
override suspend fun createSpace(params: CreateSpaceParams): String {
|
override suspend fun createSpace(params: CreateSpaceParams): String {
|
||||||
@ -105,8 +108,10 @@ internal class DefaultSpaceService @Inject constructor(
|
|||||||
return roomSummaryDataSource.getSpaceSummaries(spaceSummaryQueryParams, sortOrder)
|
return roomSummaryDataSource.getSpaceSummaries(spaceSummaryQueryParams, sortOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRootSpaceSummaries(): List<RoomSummary> {
|
override suspend fun getRootSpaceSummaries(): List<RoomSummary> {
|
||||||
return roomSummaryDataSource.getRootSpaceSummaries()
|
return withContext(coroutineDispatchers.io) {
|
||||||
|
roomSummaryDataSource.getRootSpaceSummaries()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun peekSpace(spaceId: String): SpacePeekResult {
|
override suspend fun peekSpace(spaceId: String): SpacePeekResult {
|
||||||
|
@ -107,7 +107,7 @@ internal class DefaultSyncTask @Inject constructor(
|
|||||||
val isInitialSync = token == null
|
val isInitialSync = token == null
|
||||||
if (isInitialSync) {
|
if (isInitialSync) {
|
||||||
// We might want to get the user information in parallel too
|
// We might want to get the user information in parallel too
|
||||||
val user = tryOrNull { session.getProfileAsUser(userId) }
|
val user = tryOrNull { session.profileService().getProfileAsUser(userId) }
|
||||||
userStore.createOrUpdate(
|
userStore.createOrUpdate(
|
||||||
userId = userId,
|
userId = userId,
|
||||||
displayName = user?.displayName,
|
displayName = user?.displayName,
|
||||||
|
@ -166,7 +166,7 @@ class SecurityBootstrapTest : VerificationTestBase() {
|
|||||||
assert(uiSession.cryptoService().crossSigningService().allPrivateKeysKnown())
|
assert(uiSession.cryptoService().crossSigningService().allPrivateKeysKnown())
|
||||||
assert(uiSession.cryptoService().keysBackupService().isEnabled)
|
assert(uiSession.cryptoService().keysBackupService().isEnabled)
|
||||||
assert(uiSession.cryptoService().keysBackupService().currentBackupVersion != null)
|
assert(uiSession.cryptoService().keysBackupService().currentBackupVersion != null)
|
||||||
assert(uiSession.sharedSecretStorageService.isRecoverySetup())
|
assert(uiSession.sharedSecretStorageService().isRecoverySetup())
|
||||||
assert(uiSession.sharedSecretStorageService.isMegolmKeyInBackup())
|
assert(uiSession.sharedSecretStorageService().isMegolmKeyInBackup())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class TestTokenRegistration @Inject constructor(private val context: FragmentAct
|
|||||||
status = TestStatus.FAILED
|
status = TestStatus.FAILED
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val pushers = session.getPushers().filter {
|
val pushers = session.pushersService().getPushers().filter {
|
||||||
it.pushKey == fcmToken && it.state == PusherState.REGISTERED
|
it.pushKey == fcmToken && it.state == PusherState.REGISTERED
|
||||||
}
|
}
|
||||||
if (pushers.isEmpty()) {
|
if (pushers.isEmpty()) {
|
||||||
|
@ -46,6 +46,7 @@ import kotlinx.coroutines.runBlocking
|
|||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.logger.LoggerTag
|
import org.matrix.android.sdk.api.logger.LoggerTag
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -194,7 +195,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
|
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
Timber.tag(loggerTag.value).d("Fast lane: start request")
|
Timber.tag(loggerTag.value).d("Fast lane: start request")
|
||||||
val event = tryOrNull { session.getEvent(roomId, eventId) } ?: return@launch
|
val event = tryOrNull { session.eventService().getEvent(roomId, eventId) } ?: return@launch
|
||||||
|
|
||||||
val resolvedEvent = notifiableEventResolver.resolveInMemoryEvent(session, event, canBeReplaced = true)
|
val resolvedEvent = notifiableEventResolver.resolveInMemoryEvent(session, event, canBeReplaced = true)
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ import kotlinx.coroutines.flow.onEach
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
|
import org.matrix.android.sdk.api.session.getRoomSummary
|
||||||
import org.matrix.android.sdk.api.session.group.model.GroupSummary
|
import org.matrix.android.sdk.api.session.group.model.GroupSummary
|
||||||
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
|
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
@ -78,7 +80,7 @@ class AppStateHandler @Inject constructor(
|
|||||||
return selectedSpaceDataSource.currentValue?.orNull()?.let {
|
return selectedSpaceDataSource.currentValue?.orNull()?.let {
|
||||||
if (it is RoomGroupingMethod.BySpace) {
|
if (it is RoomGroupingMethod.BySpace) {
|
||||||
// try to refresh sum?
|
// try to refresh sum?
|
||||||
it.spaceSummary?.roomId?.let { activeSessionHolder.getSafeActiveSession()?.getRoomSummary(it) }?.let {
|
it.spaceSummary?.roomId?.let { activeSessionHolder.getSafeActiveSession()?.roomService()?.getRoomSummary(it) }?.let {
|
||||||
RoomGroupingMethod.BySpace(it)
|
RoomGroupingMethod.BySpace(it)
|
||||||
} ?: it
|
} ?: it
|
||||||
} else it
|
} else it
|
||||||
@ -110,12 +112,12 @@ class AppStateHandler @Inject constructor(
|
|||||||
val uSession = session ?: activeSessionHolder.getSafeActiveSession() ?: return
|
val uSession = session ?: activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
if (selectedSpaceDataSource.currentValue?.orNull() is RoomGroupingMethod.ByLegacyGroup &&
|
if (selectedSpaceDataSource.currentValue?.orNull() is RoomGroupingMethod.ByLegacyGroup &&
|
||||||
groupId == selectedSpaceDataSource.currentValue?.orNull()?.group()?.groupId) return
|
groupId == selectedSpaceDataSource.currentValue?.orNull()?.group()?.groupId) return
|
||||||
val activeGroup = groupId?.let { uSession.getGroupSummary(groupId) }
|
val activeGroup = groupId?.let { uSession.groupService().getGroupSummary(groupId) }
|
||||||
selectedSpaceDataSource.post(Option.just(RoomGroupingMethod.ByLegacyGroup(activeGroup)))
|
selectedSpaceDataSource.post(Option.just(RoomGroupingMethod.ByLegacyGroup(activeGroup)))
|
||||||
if (groupId != null) {
|
if (groupId != null) {
|
||||||
uSession.coroutineScope.launch {
|
uSession.coroutineScope.launch {
|
||||||
tryOrNull {
|
tryOrNull {
|
||||||
uSession.getGroup(groupId)?.fetchGroupData()
|
uSession.groupService().getGroup(groupId)?.fetchGroupData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,7 +141,7 @@ class AppStateHandler @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun observeSyncStatus(session: Session) {
|
private fun observeSyncStatus(session: Session) {
|
||||||
session.getSyncStatusLive()
|
session.syncStatusService().getSyncStatusLive()
|
||||||
.asFlow()
|
.asFlow()
|
||||||
.filterIsInstance<SyncStatusService.Status.IncrementalSyncDone>()
|
.filterIsInstance<SyncStatusService.Status.IncrementalSyncDone>()
|
||||||
.map { session.spaceService().getRootSpaceSummaries().size }
|
.map { session.spaceService().getRootSpaceSummaries().size }
|
||||||
|
@ -169,7 +169,7 @@ class AutoRageShaker @Inject constructor(
|
|||||||
|
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
try {
|
try {
|
||||||
activeSessionHolder.getSafeActiveSession()?.sendToDevice(
|
activeSessionHolder.getSafeActiveSession()?.toDeviceService()?.sendToDevice(
|
||||||
eventType = AUTO_RS_REQUEST,
|
eventType = AUTO_RS_REQUEST,
|
||||||
userId = target.senderUserId,
|
userId = target.senderUserId,
|
||||||
deviceId = target.senderDeviceId,
|
deviceId = target.senderDeviceId,
|
||||||
@ -261,7 +261,7 @@ class AutoRageShaker @Inject constructor(
|
|||||||
this.currentActiveSessionId = sessionId
|
this.currentActiveSessionId = sessionId
|
||||||
|
|
||||||
hasSynced = session.hasAlreadySynced()
|
hasSynced = session.hasAlreadySynced()
|
||||||
session.getSyncStatusLive()
|
session.syncStatusService().getSyncStatusLive()
|
||||||
.asFlow()
|
.asFlow()
|
||||||
.onEach {
|
.onEach {
|
||||||
hasSynced = it !is SyncStatusService.Status.InitialSyncProgressing
|
hasSynced = it !is SyncStatusService.Status.InitialSyncProgressing
|
||||||
@ -269,11 +269,11 @@ class AutoRageShaker @Inject constructor(
|
|||||||
.launchIn(session.coroutineScope)
|
.launchIn(session.coroutineScope)
|
||||||
activeSessionIds.add(sessionId)
|
activeSessionIds.add(sessionId)
|
||||||
session.addListener(this)
|
session.addListener(this)
|
||||||
session.addEventStreamListener(detector)
|
session.eventStreamService().addEventStreamListener(detector)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSessionStopped(session: Session) {
|
override fun onSessionStopped(session: Session) {
|
||||||
session.removeEventStreamListener(detector)
|
session.eventStreamService().removeEventStreamListener(detector)
|
||||||
activeSessionIds.remove(session.sessionId)
|
activeSessionIds.remove(session.sessionId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,11 @@ import timber.log.Timber
|
|||||||
fun Session.configureAndStart(context: Context, startSyncing: Boolean = true) {
|
fun Session.configureAndStart(context: Context, startSyncing: Boolean = true) {
|
||||||
Timber.i("Configure and start session for $myUserId")
|
Timber.i("Configure and start session for $myUserId")
|
||||||
open()
|
open()
|
||||||
setFilter(FilterService.FilterPreset.ElementFilter)
|
filterService().setFilter(FilterService.FilterPreset.ElementFilter)
|
||||||
if (startSyncing) {
|
if (startSyncing) {
|
||||||
startSyncing(context)
|
startSyncing(context)
|
||||||
}
|
}
|
||||||
refreshPushers()
|
pushersService().refreshPushers()
|
||||||
context.singletonEntryPoint().webRtcCallManager().checkForProtocolsSupportIfNeeded()
|
context.singletonEntryPoint().webRtcCallManager().checkForProtocolsSupportIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ fun Session.cannotLogoutSafely(): Boolean {
|
|||||||
// has local cross signing keys
|
// has local cross signing keys
|
||||||
(cryptoService().crossSigningService().allPrivateKeysKnown() &&
|
(cryptoService().crossSigningService().allPrivateKeysKnown() &&
|
||||||
// That are not backed up
|
// That are not backed up
|
||||||
!sharedSecretStorageService.isRecoverySetup())
|
!sharedSecretStorageService().isRecoverySetup())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Session.vectorStore(context: Context) = VectorSessionStore(context, myUserId)
|
fun Session.vectorStore(context: Context) = VectorSessionStore(context, myUserId)
|
||||||
|
@ -37,7 +37,7 @@ class PushersManager @Inject constructor(
|
|||||||
suspend fun testPush(pushKey: String) {
|
suspend fun testPush(pushKey: String) {
|
||||||
val currentSession = activeSessionHolder.getActiveSession()
|
val currentSession = activeSessionHolder.getActiveSession()
|
||||||
|
|
||||||
currentSession.testPush(
|
currentSession.pushersService().testPush(
|
||||||
stringProvider.getString(R.string.pusher_http_url),
|
stringProvider.getString(R.string.pusher_http_url),
|
||||||
stringProvider.getString(R.string.pusher_app_id),
|
stringProvider.getString(R.string.pusher_app_id),
|
||||||
pushKey,
|
pushKey,
|
||||||
@ -47,12 +47,12 @@ class PushersManager @Inject constructor(
|
|||||||
|
|
||||||
fun enqueueRegisterPusherWithFcmKey(pushKey: String): UUID {
|
fun enqueueRegisterPusherWithFcmKey(pushKey: String): UUID {
|
||||||
val currentSession = activeSessionHolder.getActiveSession()
|
val currentSession = activeSessionHolder.getActiveSession()
|
||||||
return currentSession.enqueueAddHttpPusher(createHttpPusher(pushKey))
|
return currentSession.pushersService().enqueueAddHttpPusher(createHttpPusher(pushKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun registerPusherWithFcmKey(pushKey: String) {
|
suspend fun registerPusherWithFcmKey(pushKey: String) {
|
||||||
val currentSession = activeSessionHolder.getActiveSession()
|
val currentSession = activeSessionHolder.getActiveSession()
|
||||||
currentSession.addHttpPusher(createHttpPusher(pushKey))
|
currentSession.pushersService().addHttpPusher(createHttpPusher(pushKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createHttpPusher(pushKey: String) = PushersService.HttpPusher(
|
private fun createHttpPusher(pushKey: String) = PushersService.HttpPusher(
|
||||||
@ -70,7 +70,7 @@ class PushersManager @Inject constructor(
|
|||||||
suspend fun registerEmailForPush(email: String) {
|
suspend fun registerEmailForPush(email: String) {
|
||||||
val currentSession = activeSessionHolder.getActiveSession()
|
val currentSession = activeSessionHolder.getActiveSession()
|
||||||
val appName = appNameProvider.getAppName()
|
val appName = appNameProvider.getAppName()
|
||||||
currentSession.addEmailPusher(
|
currentSession.pushersService().addEmailPusher(
|
||||||
email = email,
|
email = email,
|
||||||
lang = localeProvider.current().language,
|
lang = localeProvider.current().language,
|
||||||
emailBranding = appName,
|
emailBranding = appName,
|
||||||
@ -81,12 +81,12 @@ class PushersManager @Inject constructor(
|
|||||||
|
|
||||||
suspend fun unregisterEmailPusher(email: String) {
|
suspend fun unregisterEmailPusher(email: String) {
|
||||||
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
currentSession.removeEmailPusher(email)
|
currentSession.pushersService().removeEmailPusher(email)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun unregisterPusher(pushKey: String) {
|
suspend fun unregisterPusher(pushKey: String) {
|
||||||
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
currentSession.removeHttpPusher(pushKey, stringProvider.getString(R.string.pusher_app_id))
|
currentSession.pushersService().removeHttpPusher(pushKey, stringProvider.getString(R.string.pusher_app_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -160,7 +160,7 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
|
|||||||
args.clearCredentials -> {
|
args.clearCredentials -> {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
try {
|
try {
|
||||||
session.signOut(!args.isUserLoggedOut)
|
session.signOutService().signOut(!args.isUserLoggedOut)
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
displayError(failure)
|
displayError(failure)
|
||||||
return@launch
|
return@launch
|
||||||
|
@ -66,7 +66,7 @@ class AnalyticsAccountDataViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
private fun observeInitSync() {
|
private fun observeInitSync() {
|
||||||
combine(
|
combine(
|
||||||
session.getSyncStatusLive().asFlow(),
|
session.syncStatusService().getSyncStatusLive().asFlow(),
|
||||||
analytics.getUserConsent(),
|
analytics.getUserConsent(),
|
||||||
analytics.getAnalyticsId()
|
analytics.getAnalyticsId()
|
||||||
) { status, userConsent, analyticsId ->
|
) { status, userConsent, analyticsId ->
|
||||||
|
@ -58,7 +58,7 @@ class ReAuthViewModel @AssistedInject constructor(
|
|||||||
is ReAuthActions.ReAuthWithPass -> {
|
is ReAuthActions.ReAuthWithPass -> {
|
||||||
val safeForIntentCypher = ByteArrayOutputStream().also {
|
val safeForIntentCypher = ByteArrayOutputStream().also {
|
||||||
it.use {
|
it.use {
|
||||||
session.securelyStoreObject(action.password, initialState.resultKeyStoreAlias, it)
|
session.secureStorageService().securelyStoreObject(action.password, initialState.resultKeyStoreAlias, it)
|
||||||
}
|
}
|
||||||
}.toByteArray().toBase64NoPadding()
|
}.toByteArray().toBase64NoPadding()
|
||||||
_viewEvents.post(ReAuthEvents.PasswordFinishSuccess(safeForIntentCypher))
|
_viewEvents.post(ReAuthEvents.PasswordFinishSuccess(safeForIntentCypher))
|
||||||
|
@ -55,7 +55,7 @@ class AutocompleteGroupPresenter @Inject constructor(context: Context,
|
|||||||
QueryStringValue.Contains(query.toString(), QueryStringValue.Case.INSENSITIVE)
|
QueryStringValue.Contains(query.toString(), QueryStringValue.Case.INSENSITIVE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val groups = session.getGroupSummaries(queryParams)
|
val groups = session.groupService().getGroupSummaries(queryParams)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.sortedBy { it.displayName }
|
.sortedBy { it.displayName }
|
||||||
controller.setData(groups.toList())
|
controller.setData(groups.toList())
|
||||||
|
@ -27,6 +27,7 @@ import im.vector.app.features.autocomplete.RecyclerViewPresenter
|
|||||||
import org.matrix.android.sdk.api.query.QueryStringValue
|
import org.matrix.android.sdk.api.query.QueryStringValue
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.pushrules.SenderNotificationPermissionCondition
|
import org.matrix.android.sdk.api.session.pushrules.SenderNotificationPermissionCondition
|
||||||
import org.matrix.android.sdk.api.session.room.members.RoomMemberQueryParams
|
import org.matrix.android.sdk.api.session.room.members.RoomMemberQueryParams
|
||||||
import org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams
|
import org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams
|
||||||
@ -147,7 +148,7 @@ class AutocompleteMemberPresenter @AssistedInject constructor(context: Context,
|
|||||||
AutocompleteMemberItem.Everyone(it)
|
AutocompleteMemberItem.Everyone(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun canNotifyEveryone() = session.resolveSenderNotificationPermissionCondition(
|
private fun canNotifyEveryone() = session.pushRuleService().resolveSenderNotificationPermissionCondition(
|
||||||
Event(
|
Event(
|
||||||
senderId = session.myUserId,
|
senderId = session.myUserId,
|
||||||
roomId = roomId
|
roomId = roomId
|
||||||
|
@ -51,7 +51,7 @@ class AutocompleteRoomPresenter @Inject constructor(context: Context,
|
|||||||
QueryStringValue.Contains(query.toString(), QueryStringValue.Case.INSENSITIVE)
|
QueryStringValue.Contains(query.toString(), QueryStringValue.Case.INSENSITIVE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val rooms = session.getRoomSummaries(queryParams)
|
val rooms = session.roomService().getRoomSummaries(queryParams)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.sortedBy { it.displayName }
|
.sortedBy { it.displayName }
|
||||||
controller.setData(rooms.toList())
|
controller.setData(rooms.toList())
|
||||||
|
@ -42,6 +42,7 @@ import org.matrix.android.sdk.api.session.Session
|
|||||||
import org.matrix.android.sdk.api.session.call.CallState
|
import org.matrix.android.sdk.api.session.call.CallState
|
||||||
import org.matrix.android.sdk.api.session.call.MxCall
|
import org.matrix.android.sdk.api.session.call.MxCall
|
||||||
import org.matrix.android.sdk.api.session.call.MxPeerConnectionState
|
import org.matrix.android.sdk.api.session.call.MxPeerConnectionState
|
||||||
|
import org.matrix.android.sdk.api.session.getRoomSummary
|
||||||
import org.matrix.android.sdk.api.session.room.model.call.supportCallTransfer
|
import org.matrix.android.sdk.api.session.room.model.call.supportCallTransfer
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ import org.jitsi.meet.sdk.JitsiMeetUserInfo
|
|||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.raw.RawService
|
import org.matrix.android.sdk.api.raw.RawService
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getRoomSummary
|
||||||
import org.matrix.android.sdk.api.session.widgets.model.Widget
|
import org.matrix.android.sdk.api.session.widgets.model.Widget
|
||||||
import org.matrix.android.sdk.api.session.widgets.model.WidgetType
|
import org.matrix.android.sdk.api.session.widgets.model.WidgetType
|
||||||
import org.matrix.android.sdk.api.util.MatrixJsonParser
|
import org.matrix.android.sdk.api.util.MatrixJsonParser
|
||||||
@ -99,7 +100,7 @@ class JitsiService @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun joinConference(roomId: String, jitsiWidget: Widget, enableVideo: Boolean): JitsiCallViewEvents.JoinConference {
|
suspend fun joinConference(roomId: String, jitsiWidget: Widget, enableVideo: Boolean): JitsiCallViewEvents.JoinConference {
|
||||||
val me = session.getRoomMember(session.myUserId, roomId)?.toMatrixItem()
|
val me = session.roomService().getRoomMember(session.myUserId, roomId)?.toMatrixItem()
|
||||||
val userDisplayName = me?.getBestName()
|
val userDisplayName = me?.getBestName()
|
||||||
val userAvatar = me?.avatarUrl?.let { session.contentUrlResolver().resolveFullSize(it) }
|
val userAvatar = me?.avatarUrl?.let { session.contentUrlResolver().resolveFullSize(it) }
|
||||||
val userInfo = JitsiMeetUserInfo().apply {
|
val userInfo = JitsiMeetUserInfo().apply {
|
||||||
|
@ -47,7 +47,7 @@ class DialPadLookup @Inject constructor(
|
|||||||
if (nativeUserId == session.myUserId) {
|
if (nativeUserId == session.myUserId) {
|
||||||
throw Failure.NumberIsYours
|
throw Failure.NumberIsYours
|
||||||
}
|
}
|
||||||
session.getExistingDirectRoomWithUser(nativeUserId)
|
session.roomService().getExistingDirectRoomWithUser(nativeUserId)
|
||||||
// if there is not, just create a DM with the sip user
|
// if there is not, just create a DM with the sip user
|
||||||
?: directRoomHelper.ensureDMExists(sipUserId)
|
?: directRoomHelper.ensureDMExists(sipUserId)
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,6 +20,7 @@ import org.matrix.android.sdk.api.extensions.tryOrNull
|
|||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataTypes
|
import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataTypes
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
||||||
@ -61,7 +62,7 @@ class CallUserMapper(private val session: Session, private val protocolsChecker:
|
|||||||
val nativeLookup = session.sipNativeLookup(inviterId).firstOrNull() ?: return
|
val nativeLookup = session.sipNativeLookup(inviterId).firstOrNull() ?: return
|
||||||
if (nativeLookup.fields.containsKey("is_virtual")) {
|
if (nativeLookup.fields.containsKey("is_virtual")) {
|
||||||
val nativeUser = nativeLookup.userId
|
val nativeUser = nativeLookup.userId
|
||||||
val nativeRoomId = session.getExistingDirectRoomWithUser(nativeUser)
|
val nativeRoomId = session.roomService().getExistingDirectRoomWithUser(nativeUser)
|
||||||
if (nativeRoomId != null) {
|
if (nativeRoomId != null) {
|
||||||
// It's a virtual room with a matching native room, so set the room account data. This
|
// It's a virtual room with a matching native room, so set the room account data. This
|
||||||
// will make sure we know where how to map calls and also allow us know not to display
|
// will make sure we know where how to map calls and also allow us know not to display
|
||||||
@ -82,7 +83,7 @@ class CallUserMapper(private val session: Session, private val protocolsChecker:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun ensureVirtualRoomExists(userId: String, nativeRoomId: String): String {
|
private suspend fun ensureVirtualRoomExists(userId: String, nativeRoomId: String): String {
|
||||||
val existingDMRoom = tryOrNull { session.getExistingDirectRoomWithUser(userId) }
|
val existingDMRoom = tryOrNull { session.roomService().getExistingDirectRoomWithUser(userId) }
|
||||||
val roomId: String
|
val roomId: String
|
||||||
if (existingDMRoom != null) {
|
if (existingDMRoom != null) {
|
||||||
roomId = existingDMRoom
|
roomId = existingDMRoom
|
||||||
@ -92,7 +93,7 @@ class CallUserMapper(private val session: Session, private val protocolsChecker:
|
|||||||
setDirectMessage()
|
setDirectMessage()
|
||||||
creationContent[RoomAccountDataTypes.EVENT_TYPE_VIRTUAL_ROOM] = nativeRoomId
|
creationContent[RoomAccountDataTypes.EVENT_TYPE_VIRTUAL_ROOM] = nativeRoomId
|
||||||
}
|
}
|
||||||
roomId = session.createRoom(roomParams)
|
roomId = session.roomService().createRoom(roomParams)
|
||||||
}
|
}
|
||||||
return roomId
|
return roomId
|
||||||
}
|
}
|
||||||
|
@ -989,7 +989,7 @@ class WebRtcCall(
|
|||||||
val nativeUserId = session.sipNativeLookup(newAssertedIdentity.id!!).firstOrNull()?.userId
|
val nativeUserId = session.sipNativeLookup(newAssertedIdentity.id!!).firstOrNull()?.userId
|
||||||
if (nativeUserId != null) {
|
if (nativeUserId != null) {
|
||||||
val resolvedUser = tryOrNull {
|
val resolvedUser = tryOrNull {
|
||||||
session.resolveUser(nativeUserId)
|
session.userService().resolveUser(nativeUserId)
|
||||||
}
|
}
|
||||||
if (resolvedUser != null) {
|
if (resolvedUser != null) {
|
||||||
remoteAssertedIdentity = newAssertedIdentity.copy(
|
remoteAssertedIdentity = newAssertedIdentity.copy(
|
||||||
|
@ -18,6 +18,7 @@ package im.vector.app.features.call.webrtc
|
|||||||
|
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import kotlinx.coroutines.launch
|
|||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.raw.RawService
|
import org.matrix.android.sdk.api.raw.RawService
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getUser
|
||||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkData
|
import org.matrix.android.sdk.api.session.permalinks.PermalinkData
|
||||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkParser
|
import org.matrix.android.sdk.api.session.permalinks.PermalinkParser
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
||||||
@ -74,7 +75,11 @@ class CreateDirectRoomViewModel @AssistedInject constructor(
|
|||||||
_viewEvents.post(CreateDirectRoomViewEvents.DmSelf)
|
_viewEvents.post(CreateDirectRoomViewEvents.DmSelf)
|
||||||
} else {
|
} else {
|
||||||
// Try to get user from known users and fall back to creating a User object from MXID
|
// Try to get user from known users and fall back to creating a User object from MXID
|
||||||
val qrInvitee = if (session.getUser(mxid) != null) session.getUser(mxid)!! else User(mxid, null, null)
|
val qrInvitee = if (session.getUser(mxid) != null) {
|
||||||
|
session.getUser(mxid)!!
|
||||||
|
} else {
|
||||||
|
User(mxid, null, null)
|
||||||
|
}
|
||||||
onSubmitInvitees(setOf(PendingSelection.UserPendingSelection(qrInvitee)))
|
onSubmitInvitees(setOf(PendingSelection.UserPendingSelection(qrInvitee)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +90,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor(
|
|||||||
*/
|
*/
|
||||||
private fun onSubmitInvitees(selections: Set<PendingSelection>) {
|
private fun onSubmitInvitees(selections: Set<PendingSelection>) {
|
||||||
val existingRoomId = selections.singleOrNull()?.getMxId()?.let { userId ->
|
val existingRoomId = selections.singleOrNull()?.getMxId()?.let { userId ->
|
||||||
session.getExistingDirectRoomWithUser(userId)
|
session.roomService().getExistingDirectRoomWithUser(userId)
|
||||||
}
|
}
|
||||||
if (existingRoomId != null) {
|
if (existingRoomId != null) {
|
||||||
// Do not create a new DM, just tell that the creation is successful by passing the existing roomId
|
// Do not create a new DM, just tell that the creation is successful by passing the existing roomId
|
||||||
@ -119,7 +124,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val result = runCatchingToAsync {
|
val result = runCatchingToAsync {
|
||||||
session.createRoom(roomParams)
|
session.roomService().createRoom(roomParams)
|
||||||
}
|
}
|
||||||
analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse()))
|
analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse()))
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class DirectRoomHelper @Inject constructor(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun ensureDMExists(userId: String): String {
|
suspend fun ensureDMExists(userId: String): String {
|
||||||
val existingRoomId = tryOrNull { session.getExistingDirectRoomWithUser(userId) }
|
val existingRoomId = tryOrNull { session.roomService().getExistingDirectRoomWithUser(userId) }
|
||||||
val roomId: String
|
val roomId: String
|
||||||
if (existingRoomId != null) {
|
if (existingRoomId != null) {
|
||||||
roomId = existingRoomId
|
roomId = existingRoomId
|
||||||
@ -48,7 +48,7 @@ class DirectRoomHelper @Inject constructor(
|
|||||||
setDirectMessage()
|
setDirectMessage()
|
||||||
enableEncryptionIfInvitedUsersSupportIt = adminE2EByDefault
|
enableEncryptionIfInvitedUsersSupportIt = adminE2EByDefault
|
||||||
}
|
}
|
||||||
roomId = session.createRoom(roomParams)
|
roomId = session.roomService().createRoom(roomParams)
|
||||||
analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse()))
|
analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse()))
|
||||||
}
|
}
|
||||||
return roomId
|
return roomId
|
||||||
|
@ -170,7 +170,7 @@ class KeysBackupRestoreSharedViewModel @Inject constructor(
|
|||||||
fun handleGotSecretFromSSSS(cipherData: String, alias: String) {
|
fun handleGotSecretFromSSSS(cipherData: String, alias: String) {
|
||||||
try {
|
try {
|
||||||
cipherData.fromBase64().inputStream().use { ins ->
|
cipherData.fromBase64().inputStream().use { ins ->
|
||||||
val res = session.loadSecureSecret<Map<String, String>>(ins, alias)
|
val res = session.secureStorageService().loadSecureSecret<Map<String, String>>(ins, alias)
|
||||||
val secret = res?.get(KEYBACKUP_SECRET_SSSS_NAME)
|
val secret = res?.get(KEYBACKUP_SECRET_SSSS_NAME)
|
||||||
if (secret == null) {
|
if (secret == null) {
|
||||||
_navigateEvent.postValue(
|
_navigateEvent.postValue(
|
||||||
@ -252,7 +252,7 @@ class KeysBackupRestoreSharedViewModel @Inject constructor(
|
|||||||
?: return false
|
?: return false
|
||||||
|
|
||||||
// Some sanity ?
|
// Some sanity ?
|
||||||
val defaultKeyResult = session.sharedSecretStorageService.getDefaultKey()
|
val defaultKeyResult = session.sharedSecretStorageService().getDefaultKey()
|
||||||
val keyInfo = (defaultKeyResult as? KeyInfoResult.Success)?.keyInfo
|
val keyInfo = (defaultKeyResult as? KeyInfoResult.Success)?.keyInfo
|
||||||
?: return false
|
?: return false
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor(
|
|||||||
setState {
|
setState {
|
||||||
copy(userId = session.myUserId)
|
copy(userId = session.myUserId)
|
||||||
}
|
}
|
||||||
val integrityResult = session.sharedSecretStorageService.checkShouldBeAbleToAccessSecrets(initialState.requestedSecrets, initialState.keyId)
|
val integrityResult = session.sharedSecretStorageService().checkShouldBeAbleToAccessSecrets(initialState.requestedSecrets, initialState.keyId)
|
||||||
if (integrityResult !is IntegrityResult.Success) {
|
if (integrityResult !is IntegrityResult.Success) {
|
||||||
_viewEvents.post(
|
_viewEvents.post(
|
||||||
SharedSecureStorageViewEvent.Error(
|
SharedSecureStorageViewEvent.Error(
|
||||||
@ -96,8 +96,8 @@ class SharedSecureStorageViewModel @AssistedInject constructor(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val keyResult = initialState.keyId?.let { session.sharedSecretStorageService.getKey(it) }
|
val keyResult = initialState.keyId?.let { session.sharedSecretStorageService().getKey(it) }
|
||||||
?: session.sharedSecretStorageService.getDefaultKey()
|
?: session.sharedSecretStorageService().getDefaultKey()
|
||||||
|
|
||||||
if (!keyResult.isSuccess()) {
|
if (!keyResult.isSuccess()) {
|
||||||
_viewEvents.post(SharedSecureStorageViewEvent.Dismiss)
|
_viewEvents.post(SharedSecureStorageViewEvent.Dismiss)
|
||||||
@ -205,7 +205,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor(
|
|||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
runCatching {
|
runCatching {
|
||||||
val recoveryKey = action.recoveryKey
|
val recoveryKey = action.recoveryKey
|
||||||
val keyInfoResult = session.sharedSecretStorageService.getDefaultKey()
|
val keyInfoResult = session.sharedSecretStorageService().getDefaultKey()
|
||||||
if (!keyInfoResult.isSuccess()) {
|
if (!keyInfoResult.isSuccess()) {
|
||||||
_viewEvents.post(SharedSecureStorageViewEvent.HideModalLoading)
|
_viewEvents.post(SharedSecureStorageViewEvent.HideModalLoading)
|
||||||
_viewEvents.post(SharedSecureStorageViewEvent.Error(stringProvider.getString(R.string.failed_to_access_secure_storage)))
|
_viewEvents.post(SharedSecureStorageViewEvent.Error(stringProvider.getString(R.string.failed_to_access_secure_storage)))
|
||||||
@ -228,7 +228,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor(
|
|||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
initialState.requestedSecrets.forEach {
|
initialState.requestedSecrets.forEach {
|
||||||
if (session.accountDataService().getUserAccountDataEvent(it) != null) {
|
if (session.accountDataService().getUserAccountDataEvent(it) != null) {
|
||||||
val res = session.sharedSecretStorageService.getSecret(
|
val res = session.sharedSecretStorageService().getSecret(
|
||||||
name = it,
|
name = it,
|
||||||
keyId = keyInfo.id,
|
keyId = keyInfo.id,
|
||||||
secretKey = keySpec)
|
secretKey = keySpec)
|
||||||
@ -243,7 +243,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor(
|
|||||||
_viewEvents.post(SharedSecureStorageViewEvent.HideModalLoading)
|
_viewEvents.post(SharedSecureStorageViewEvent.HideModalLoading)
|
||||||
val safeForIntentCypher = ByteArrayOutputStream().also {
|
val safeForIntentCypher = ByteArrayOutputStream().also {
|
||||||
it.use {
|
it.use {
|
||||||
session.securelyStoreObject(decryptedSecretMap as Map<String, String>, initialState.resultKeyStoreAlias, it)
|
session.secureStorageService().securelyStoreObject(decryptedSecretMap as Map<String, String>, initialState.resultKeyStoreAlias, it)
|
||||||
}
|
}
|
||||||
}.toByteArray().toBase64NoPadding()
|
}.toByteArray().toBase64NoPadding()
|
||||||
_viewEvents.post(SharedSecureStorageViewEvent.FinishSuccess(safeForIntentCypher))
|
_viewEvents.post(SharedSecureStorageViewEvent.FinishSuccess(safeForIntentCypher))
|
||||||
@ -262,7 +262,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor(
|
|||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
runCatching {
|
runCatching {
|
||||||
val passphrase = action.passphrase
|
val passphrase = action.passphrase
|
||||||
val keyInfoResult = session.sharedSecretStorageService.getDefaultKey()
|
val keyInfoResult = session.sharedSecretStorageService().getDefaultKey()
|
||||||
if (!keyInfoResult.isSuccess()) {
|
if (!keyInfoResult.isSuccess()) {
|
||||||
_viewEvents.post(SharedSecureStorageViewEvent.HideModalLoading)
|
_viewEvents.post(SharedSecureStorageViewEvent.HideModalLoading)
|
||||||
_viewEvents.post(SharedSecureStorageViewEvent.Error("Cannot find ssss key"))
|
_viewEvents.post(SharedSecureStorageViewEvent.Error("Cannot find ssss key"))
|
||||||
@ -297,7 +297,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor(
|
|||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
initialState.requestedSecrets.forEach {
|
initialState.requestedSecrets.forEach {
|
||||||
if (session.accountDataService().getUserAccountDataEvent(it) != null) {
|
if (session.accountDataService().getUserAccountDataEvent(it) != null) {
|
||||||
val res = session.sharedSecretStorageService.getSecret(
|
val res = session.sharedSecretStorageService().getSecret(
|
||||||
name = it,
|
name = it,
|
||||||
keyId = keyInfo.id,
|
keyId = keyInfo.id,
|
||||||
secretKey = keySpec)
|
secretKey = keySpec)
|
||||||
@ -312,7 +312,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor(
|
|||||||
_viewEvents.post(SharedSecureStorageViewEvent.HideModalLoading)
|
_viewEvents.post(SharedSecureStorageViewEvent.HideModalLoading)
|
||||||
val safeForIntentCypher = ByteArrayOutputStream().also {
|
val safeForIntentCypher = ByteArrayOutputStream().also {
|
||||||
it.use {
|
it.use {
|
||||||
session.securelyStoreObject(decryptedSecretMap as Map<String, String>, initialState.resultKeyStoreAlias, it)
|
session.secureStorageService().securelyStoreObject(decryptedSecretMap as Map<String, String>, initialState.resultKeyStoreAlias, it)
|
||||||
}
|
}
|
||||||
}.toByteArray().toBase64NoPadding()
|
}.toByteArray().toBase64NoPadding()
|
||||||
_viewEvents.post(SharedSecureStorageViewEvent.FinishSuccess(safeForIntentCypher))
|
_viewEvents.post(SharedSecureStorageViewEvent.FinishSuccess(safeForIntentCypher))
|
||||||
|
@ -61,7 +61,7 @@ class BackupToQuadSMigrationTask @Inject constructor(
|
|||||||
// We need to use the current secret for keybackup and use it as the new master key for SSSS
|
// We need to use the current secret for keybackup and use it as the new master key for SSSS
|
||||||
// Then we need to put back the backup key in sss
|
// Then we need to put back the backup key in sss
|
||||||
val keysBackupService = session.cryptoService().keysBackupService()
|
val keysBackupService = session.cryptoService().keysBackupService()
|
||||||
val quadS = session.sharedSecretStorageService
|
val quadS = session.sharedSecretStorageService()
|
||||||
|
|
||||||
val version = keysBackupService.keysBackupVersion ?: return Result.NoKeyBackupVersion
|
val version = keysBackupService.keysBackupVersion ?: return Result.NoKeyBackupVersion
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ class BootstrapCrossSigningTask @Inject constructor(
|
|||||||
|
|
||||||
val keyInfo: SsssKeyCreationInfo
|
val keyInfo: SsssKeyCreationInfo
|
||||||
|
|
||||||
val ssssService = session.sharedSecretStorageService
|
val ssssService = session.sharedSecretStorageService()
|
||||||
|
|
||||||
params.progressListener?.onProgress(
|
params.progressListener?.onProgress(
|
||||||
WaitingViewData(
|
WaitingViewData(
|
||||||
|
@ -246,7 +246,8 @@ class BootstrapSharedViewModel @AssistedInject constructor(
|
|||||||
uiaContinuation?.resume(DefaultBaseAuth(session = pendingAuth?.session ?: ""))
|
uiaContinuation?.resume(DefaultBaseAuth(session = pendingAuth?.session ?: ""))
|
||||||
}
|
}
|
||||||
is BootstrapActions.PasswordAuthDone -> {
|
is BootstrapActions.PasswordAuthDone -> {
|
||||||
val decryptedPass = session.loadSecureSecret<String>(action.password.fromBase64().inputStream(), ReAuthActivity.DEFAULT_RESULT_KEYSTORE_ALIAS)
|
val decryptedPass = session.secureStorageService()
|
||||||
|
.loadSecureSecret<String>(action.password.fromBase64().inputStream(), ReAuthActivity.DEFAULT_RESULT_KEYSTORE_ALIAS)
|
||||||
uiaContinuation?.resume(
|
uiaContinuation?.resume(
|
||||||
UserPasswordAuth(
|
UserPasswordAuth(
|
||||||
session = pendingAuth?.session,
|
session = pendingAuth?.session,
|
||||||
|
@ -63,7 +63,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
|
|||||||
when (tx.state) {
|
when (tx.state) {
|
||||||
is VerificationTxState.OnStarted -> {
|
is VerificationTxState.OnStarted -> {
|
||||||
// Add a notification for every incoming request
|
// Add a notification for every incoming request
|
||||||
val user = session?.getUser(tx.otherUserId)
|
val user = session?.userService()?.getUser(tx.otherUserId)
|
||||||
val name = user?.toMatrixItem()?.getBestName() ?: tx.otherUserId
|
val name = user?.toMatrixItem()?.getBestName() ?: tx.otherUserId
|
||||||
val alert = VerificationVectorAlert(
|
val alert = VerificationVectorAlert(
|
||||||
uid,
|
uid,
|
||||||
@ -127,7 +127,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
|
|||||||
// XXX this is a bit hard coded :/
|
// XXX this is a bit hard coded :/
|
||||||
popupAlertManager.cancelAlert("review_login")
|
popupAlertManager.cancelAlert("review_login")
|
||||||
}
|
}
|
||||||
val user = session?.getUser(pr.otherUserId)?.toMatrixItem()
|
val user = session?.userService()?.getUser(pr.otherUserId)?.toMatrixItem()
|
||||||
val name = user?.getBestName() ?: pr.otherUserId
|
val name = user?.getBestName() ?: pr.otherUserId
|
||||||
val description = if (name == pr.otherUserId) {
|
val description = if (name == pr.otherUserId) {
|
||||||
name
|
name
|
||||||
|
@ -53,6 +53,7 @@ import org.matrix.android.sdk.api.session.crypto.verification.VerificationServic
|
|||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
|
||||||
import org.matrix.android.sdk.api.session.events.model.LocalEcho
|
import org.matrix.android.sdk.api.session.events.model.LocalEcho
|
||||||
|
import org.matrix.android.sdk.api.session.getUser
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import org.matrix.android.sdk.api.util.awaitCallback
|
import org.matrix.android.sdk.api.util.awaitCallback
|
||||||
import org.matrix.android.sdk.api.util.fromBase64
|
import org.matrix.android.sdk.api.util.fromBase64
|
||||||
@ -149,7 +150,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
|
|||||||
pendingRequest = if (pr != null) Success(pr) else Uninitialized,
|
pendingRequest = if (pr != null) Success(pr) else Uninitialized,
|
||||||
isMe = initialState.otherUserId == session.myUserId,
|
isMe = initialState.otherUserId == session.myUserId,
|
||||||
currentDeviceCanCrossSign = session.cryptoService().crossSigningService().canCrossSign(),
|
currentDeviceCanCrossSign = session.cryptoService().crossSigningService().canCrossSign(),
|
||||||
quadSContainsSecrets = session.sharedSecretStorageService.isRecoverySetup(),
|
quadSContainsSecrets = session.sharedSecretStorageService().isRecoverySetup(),
|
||||||
hasAnyOtherSession = hasAnyOtherSession
|
hasAnyOtherSession = hasAnyOtherSession
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -231,7 +232,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
|
|||||||
override fun handle(action: VerificationAction) = withState { state ->
|
override fun handle(action: VerificationAction) = withState { state ->
|
||||||
val otherUserId = state.otherUserMxItem?.id ?: return@withState
|
val otherUserId = state.otherUserMxItem?.id ?: return@withState
|
||||||
val roomId = state.roomId
|
val roomId = state.roomId
|
||||||
?: session.getExistingDirectRoomWithUser(otherUserId)
|
?: session.roomService().getExistingDirectRoomWithUser(otherUserId)
|
||||||
|
|
||||||
when (action) {
|
when (action) {
|
||||||
is VerificationAction.RequestVerificationByDM -> {
|
is VerificationAction.RequestVerificationByDM -> {
|
||||||
@ -244,7 +245,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val result = runCatching { session.createDirectRoom(otherUserId) }
|
val result = runCatching { session.roomService().createDirectRoom(otherUserId) }
|
||||||
result.fold(
|
result.fold(
|
||||||
{ data ->
|
{ data ->
|
||||||
setState {
|
setState {
|
||||||
@ -372,7 +373,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
|
|||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
action.cypherData.fromBase64().inputStream().use { ins ->
|
action.cypherData.fromBase64().inputStream().use { ins ->
|
||||||
val res = session.loadSecureSecret<Map<String, String>>(ins, action.alias)
|
val res = session.secureStorageService().loadSecureSecret<Map<String, String>>(ins, action.alias)
|
||||||
val trustResult = session.cryptoService().crossSigningService().checkTrustFromPrivateKeys(
|
val trustResult = session.cryptoService().crossSigningService().checkTrustFromPrivateKeys(
|
||||||
res?.get(MASTER_KEY_SSSS_NAME),
|
res?.get(MASTER_KEY_SSSS_NAME),
|
||||||
res?.get(USER_SIGNING_KEY_SSSS_NAME),
|
res?.get(USER_SIGNING_KEY_SSSS_NAME),
|
||||||
|
@ -40,6 +40,7 @@ import org.matrix.android.sdk.api.session.crypto.verification.SasVerificationTra
|
|||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
|
||||||
|
import org.matrix.android.sdk.api.session.getUser
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import org.matrix.android.sdk.api.session.Session
|
|||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
import org.matrix.android.sdk.api.util.MatrixJsonParser
|
import org.matrix.android.sdk.api.util.MatrixJsonParser
|
||||||
|
@ -290,7 +290,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun retrieveBinding() {
|
private fun retrieveBinding() {
|
||||||
retrieveBinding(session.getThreePids())
|
retrieveBinding(session.profileService().getThreePids())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun retrieveBinding(threePids: List<ThreePid>) = withState { state ->
|
private fun retrieveBinding(threePids: List<ThreePid>) = withState { state ->
|
||||||
|
@ -24,7 +24,7 @@ import org.matrix.android.sdk.api.session.terms.TermsService
|
|||||||
suspend fun Session.fetchIdentityServerWithTerms(userLanguage: String): ServerAndPolicies? {
|
suspend fun Session.fetchIdentityServerWithTerms(userLanguage: String): ServerAndPolicies? {
|
||||||
return identityService().getCurrentIdentityServerUrl()
|
return identityService().getCurrentIdentityServerUrl()
|
||||||
?.let { identityServerUrl ->
|
?.let { identityServerUrl ->
|
||||||
val termsResponse = getTerms(TermsService.ServiceType.IdentityService, identityServerUrl.ensureProtocol())
|
val termsResponse = termsService().getTerms(TermsService.ServiceType.IdentityService, identityServerUrl.ensureProtocol())
|
||||||
.serverResponse
|
.serverResponse
|
||||||
buildServerAndPolicies(identityServerUrl, termsResponse, userLanguage)
|
buildServerAndPolicies(identityServerUrl, termsResponse, userLanguage)
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ suspend fun Session.fetchIdentityServerWithTerms(userLanguage: String): ServerAn
|
|||||||
|
|
||||||
suspend fun Session.fetchHomeserverWithTerms(userLanguage: String): ServerAndPolicies {
|
suspend fun Session.fetchHomeserverWithTerms(userLanguage: String): ServerAndPolicies {
|
||||||
val homeserverUrl = sessionParams.homeServerUrl
|
val homeserverUrl = sessionParams.homeServerUrl
|
||||||
val terms = getHomeserverTerms(homeserverUrl.ensureProtocol())
|
val terms = termsService().getHomeserverTerms(homeserverUrl.ensureProtocol())
|
||||||
return buildServerAndPolicies(homeserverUrl, terms, userLanguage)
|
return buildServerAndPolicies(homeserverUrl, terms, userLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class SetIdentityServerViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
private suspend fun checkTerms(baseUrl: String) {
|
private suspend fun checkTerms(baseUrl: String) {
|
||||||
try {
|
try {
|
||||||
val data = mxSession.getTerms(TermsService.ServiceType.IdentityService, baseUrl)
|
val data = mxSession.termsService().getTerms(TermsService.ServiceType.IdentityService, baseUrl)
|
||||||
|
|
||||||
// has all been accepted?
|
// has all been accepted?
|
||||||
val resp = data.serverResponse
|
val resp = data.serverResponse
|
||||||
|
@ -44,6 +44,7 @@ import org.matrix.android.sdk.api.auth.registration.nextUncompletedStage
|
|||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
||||||
|
import org.matrix.android.sdk.api.session.getUser
|
||||||
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
|
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
|
||||||
import org.matrix.android.sdk.api.session.pushrules.RuleIds
|
import org.matrix.android.sdk.api.session.pushrules.RuleIds
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
@ -175,7 +176,7 @@ class HomeActivityViewModel @AssistedInject constructor(
|
|||||||
private fun observeInitialSync() {
|
private fun observeInitialSync() {
|
||||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
|
|
||||||
session.getSyncStatusLive()
|
session.syncStatusService().getSyncStatusLive()
|
||||||
.asFlow()
|
.asFlow()
|
||||||
.onEach { status ->
|
.onEach { status ->
|
||||||
when (status) {
|
when (status) {
|
||||||
@ -215,13 +216,16 @@ class HomeActivityViewModel @AssistedInject constructor(
|
|||||||
if (!vectorPreferences.areNotificationEnabledForDevice()) {
|
if (!vectorPreferences.areNotificationEnabledForDevice()) {
|
||||||
// Check if set at account level
|
// Check if set at account level
|
||||||
val mRuleMaster = activeSessionHolder.getSafeActiveSession()
|
val mRuleMaster = activeSessionHolder.getSafeActiveSession()
|
||||||
|
?.pushRuleService()
|
||||||
?.getPushRules()
|
?.getPushRules()
|
||||||
?.getAllRules()
|
?.getAllRules()
|
||||||
?.find { it.ruleId == RuleIds.RULE_ID_DISABLE_ALL }
|
?.find { it.ruleId == RuleIds.RULE_ID_DISABLE_ALL }
|
||||||
if (mRuleMaster?.enabled == false) {
|
if (mRuleMaster?.enabled == false) {
|
||||||
// So push are enabled at account level but not for this session
|
// So push are enabled at account level but not for this session
|
||||||
// Let's check that there are some rooms?
|
// Let's check that there are some rooms?
|
||||||
val knownRooms = activeSessionHolder.getSafeActiveSession()?.getRoomSummaries(roomSummaryQueryParams {
|
val knownRooms = activeSessionHolder.getSafeActiveSession()
|
||||||
|
?.roomService()
|
||||||
|
?.getRoomSummaries(roomSummaryQueryParams {
|
||||||
memberships = Membership.activeMemberships()
|
memberships = Membership.activeMemberships()
|
||||||
})?.size ?: 0
|
})?.size ?: 0
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
private val refreshRoomSummariesOnCryptoSessionChange = object : NewSessionListener {
|
private val refreshRoomSummariesOnCryptoSessionChange = object : NewSessionListener {
|
||||||
override fun onNewSession(roomId: String?, senderKey: String, sessionId: String) {
|
override fun onNewSession(roomId: String?, senderKey: String, sessionId: String) {
|
||||||
session.refreshJoinedRoomSummaryPreviews(roomId)
|
session.roomService().refreshJoinedRoomSummaryPreviews(roomId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
|||||||
private fun handleMarkAllRoomsRead() = withState { _ ->
|
private fun handleMarkAllRoomsRead() = withState { _ ->
|
||||||
// questionable to use viewmodelscope
|
// questionable to use viewmodelscope
|
||||||
viewModelScope.launch(Dispatchers.Default) {
|
viewModelScope.launch(Dispatchers.Default) {
|
||||||
val roomIds = session.getRoomSummaries(
|
val roomIds = session.roomService().getRoomSummaries(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
memberships = listOf(Membership.JOIN)
|
memberships = listOf(Membership.JOIN)
|
||||||
roomCategoryFilter = RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS
|
roomCategoryFilter = RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS
|
||||||
@ -184,7 +184,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
|||||||
)
|
)
|
||||||
.map { it.roomId }
|
.map { it.roomId }
|
||||||
try {
|
try {
|
||||||
session.markAllAsRead(roomIds)
|
session.roomService().markAllAsRead(roomIds)
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
Timber.d(failure, "Failed to mark all as read")
|
Timber.d(failure, "Failed to mark all as read")
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
|||||||
copy(syncState = syncState)
|
copy(syncState = syncState)
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getSyncStatusLive()
|
session.syncStatusService().getSyncStatusLive()
|
||||||
.asFlow()
|
.asFlow()
|
||||||
.filterIsInstance<SyncStatusService.Status.IncrementalSyncStatus>()
|
.filterIsInstance<SyncStatusService.Status.IncrementalSyncStatus>()
|
||||||
.setOnEach {
|
.setOnEach {
|
||||||
@ -219,7 +219,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
|||||||
appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().flatMapLatest {
|
appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().flatMapLatest {
|
||||||
// we use it as a trigger to all changes in room, but do not really load
|
// we use it as a trigger to all changes in room, but do not really load
|
||||||
// the actual models
|
// the actual models
|
||||||
session.getPagedRoomSummariesLive(
|
session.roomService().getPagedRoomSummariesLive(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
memberships = Membership.activeMemberships()
|
memberships = Membership.activeMemberships()
|
||||||
},
|
},
|
||||||
@ -237,7 +237,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
|||||||
var dmInvites = 0
|
var dmInvites = 0
|
||||||
var roomsInvite = 0
|
var roomsInvite = 0
|
||||||
if (autoAcceptInvites.showInvites()) {
|
if (autoAcceptInvites.showInvites()) {
|
||||||
dmInvites = session.getRoomSummaries(
|
dmInvites = session.roomService().getRoomSummaries(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
memberships = listOf(Membership.INVITE)
|
memberships = listOf(Membership.INVITE)
|
||||||
roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
@ -245,7 +245,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
).size
|
).size
|
||||||
|
|
||||||
roomsInvite = session.getRoomSummaries(
|
roomsInvite = session.roomService().getRoomSummaries(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
memberships = listOf(Membership.INVITE)
|
memberships = listOf(Membership.INVITE)
|
||||||
roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
|
roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
|
||||||
@ -254,7 +254,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
|||||||
).size
|
).size
|
||||||
}
|
}
|
||||||
|
|
||||||
val dmRooms = session.getNotificationCountForRooms(
|
val dmRooms = session.roomService().getNotificationCountForRooms(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
memberships = listOf(Membership.JOIN)
|
memberships = listOf(Membership.JOIN)
|
||||||
roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
@ -262,7 +262,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val otherRooms = session.getNotificationCountForRooms(
|
val otherRooms = session.roomService().getNotificationCountForRooms(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
memberships = listOf(Membership.JOIN)
|
memberships = listOf(Membership.JOIN)
|
||||||
roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
|
roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
|
||||||
|
@ -60,7 +60,7 @@ class HomeDrawerFragment @Inject constructor(
|
|||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
replaceChildFragment(R.id.homeDrawerGroupListContainer, SpaceListFragment::class.java)
|
replaceChildFragment(R.id.homeDrawerGroupListContainer, SpaceListFragment::class.java)
|
||||||
}
|
}
|
||||||
session.getUserLive(session.myUserId).observeK(viewLifecycleOwner) { optionalUser ->
|
session.userService().getUserLive(session.myUserId).observeK(viewLifecycleOwner) { optionalUser ->
|
||||||
val user = optionalUser?.getOrNull()
|
val user = optionalUser?.getOrNull()
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
avatarRenderer.render(user.toMatrixItem(), views.homeDrawerHeaderAvatarView)
|
avatarRenderer.render(user.toMatrixItem(), views.homeDrawerHeaderAvatarView)
|
||||||
|
@ -39,6 +39,7 @@ import org.matrix.android.sdk.api.NoOpMatrixCallback
|
|||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||||
|
import org.matrix.android.sdk.api.session.getUser
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||||
import org.matrix.android.sdk.flow.flow
|
import org.matrix.android.sdk.flow.flow
|
||||||
|
@ -71,9 +71,11 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
|||||||
|
|
||||||
override fun handle(action: EmptyAction) {}
|
override fun handle(action: EmptyAction) {}
|
||||||
|
|
||||||
|
private val roomService = session.roomService()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
session.getPagedRoomSummariesLive(
|
roomService.getPagedRoomSummariesLive(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
this.memberships = listOf(Membership.JOIN)
|
this.memberships = listOf(Membership.JOIN)
|
||||||
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null)
|
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null)
|
||||||
@ -81,7 +83,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
|||||||
).asFlow()
|
).asFlow()
|
||||||
.throttleFirst(300)
|
.throttleFirst(300)
|
||||||
.execute {
|
.execute {
|
||||||
val counts = session.getNotificationCountForRooms(
|
val counts = roomService.getNotificationCountForRooms(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
this.memberships = listOf(Membership.JOIN)
|
this.memberships = listOf(Membership.JOIN)
|
||||||
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null)
|
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null)
|
||||||
@ -90,7 +92,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
|||||||
val invites = if (autoAcceptInvites.hideInvites) {
|
val invites = if (autoAcceptInvites.hideInvites) {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
session.getRoomSummaries(
|
roomService.getRoomSummaries(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
this.memberships = listOf(Membership.INVITE)
|
this.memberships = listOf(Membership.INVITE)
|
||||||
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null)
|
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null)
|
||||||
@ -109,7 +111,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
|||||||
combine(
|
combine(
|
||||||
appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged(),
|
appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged(),
|
||||||
appStateHandler.selectedRoomGroupingFlow.flatMapLatest {
|
appStateHandler.selectedRoomGroupingFlow.flatMapLatest {
|
||||||
session.getPagedRoomSummariesLive(
|
roomService.getPagedRoomSummariesLive(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
this.memberships = Membership.activeMemberships()
|
this.memberships = Membership.activeMemberships()
|
||||||
}, sortOrder = RoomSortOrder.NONE
|
}, sortOrder = RoomSortOrder.NONE
|
||||||
@ -131,7 +133,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
|||||||
val inviteCount = if (autoAcceptInvites.hideInvites) {
|
val inviteCount = if (autoAcceptInvites.hideInvites) {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
session.getRoomSummaries(
|
roomService.getRoomSummaries(
|
||||||
roomSummaryQueryParams { this.memberships = listOf(Membership.INVITE) }
|
roomSummaryQueryParams { this.memberships = listOf(Membership.INVITE) }
|
||||||
).size
|
).size
|
||||||
}
|
}
|
||||||
@ -139,14 +141,14 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
|||||||
val spaceInviteCount = if (autoAcceptInvites.hideInvites) {
|
val spaceInviteCount = if (autoAcceptInvites.hideInvites) {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
session.getRoomSummaries(
|
roomService.getRoomSummaries(
|
||||||
spaceSummaryQueryParams {
|
spaceSummaryQueryParams {
|
||||||
this.memberships = listOf(Membership.INVITE)
|
this.memberships = listOf(Membership.INVITE)
|
||||||
}
|
}
|
||||||
).size
|
).size
|
||||||
}
|
}
|
||||||
|
|
||||||
val totalCount = session.getNotificationCountForRooms(
|
val totalCount = roomService.getNotificationCountForRooms(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
this.memberships = listOf(Membership.JOIN)
|
this.memberships = listOf(Membership.JOIN)
|
||||||
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf {
|
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf {
|
||||||
|
@ -86,6 +86,7 @@ import org.matrix.android.sdk.api.session.events.model.isTextMessage
|
|||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.api.session.file.FileService
|
import org.matrix.android.sdk.api.session.file.FileService
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
|
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
|
||||||
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
||||||
import org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams
|
import org.matrix.android.sdk.api.session.room.members.roomMemberQueryParams
|
||||||
@ -185,7 +186,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
// Inform the SDK that the room is displayed
|
// Inform the SDK that the room is displayed
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
tryOrNull { session.onRoomDisplayed(initialState.roomId) }
|
tryOrNull { session.roomService().onRoomDisplayed(initialState.roomId) }
|
||||||
}
|
}
|
||||||
callManager.addProtocolsCheckerListener(this)
|
callManager.addProtocolsCheckerListener(this)
|
||||||
callManager.checkForProtocolsSupportIfNeeded()
|
callManager.checkForProtocolsSupportIfNeeded()
|
||||||
@ -682,7 +683,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val result = runCatchingToAsync {
|
val result = runCatchingToAsync {
|
||||||
session.joinRoom(roomId, viaServers = viaServers)
|
session.roomService().joinRoom(roomId, viaServers = viaServers)
|
||||||
roomId
|
roomId
|
||||||
}
|
}
|
||||||
setState {
|
setState {
|
||||||
@ -808,7 +809,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||||||
notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(initialState.roomId) }
|
notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(initialState.roomId) }
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
session.leaveRoom(room.roomId)
|
session.roomService().leaveRoom(room.roomId)
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
_viewEvents.post(RoomDetailViewEvents.Failure(throwable, showInDialog = true))
|
_viewEvents.post(RoomDetailViewEvents.Failure(throwable, showInDialog = true))
|
||||||
}
|
}
|
||||||
@ -819,7 +820,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||||||
notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(initialState.roomId) }
|
notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(initialState.roomId) }
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
session.joinRoom(room.roomId)
|
session.roomService().joinRoom(room.roomId)
|
||||||
analyticsTracker.capture(room.roomSummary().toAnalyticsJoinedRoom())
|
analyticsTracker.capture(room.roomSummary().toAnalyticsJoinedRoom())
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
_viewEvents.post(RoomDetailViewEvents.Failure(throwable, showInDialog = true))
|
_viewEvents.post(RoomDetailViewEvents.Failure(throwable, showInDialog = true))
|
||||||
@ -996,7 +997,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val event = try {
|
val event = try {
|
||||||
session.ignoreUserIds(listOf(action.userId))
|
session.userService().ignoreUserIds(listOf(action.userId))
|
||||||
RoomDetailViewEvents.ActionSuccess(action)
|
RoomDetailViewEvents.ActionSuccess(action)
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
RoomDetailViewEvents.ActionFailure(action, failure)
|
RoomDetailViewEvents.ActionFailure(action, failure)
|
||||||
@ -1086,7 +1087,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||||||
copy(syncState = syncState)
|
copy(syncState = syncState)
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getSyncStatusLive()
|
session.syncStatusService().getSyncStatusLive()
|
||||||
.asFlow()
|
.asFlow()
|
||||||
.filterIsInstance<SyncStatusService.Status.IncrementalSyncStatus>()
|
.filterIsInstance<SyncStatusService.Status.IncrementalSyncStatus>()
|
||||||
.setOnEach {
|
.setOnEach {
|
||||||
@ -1190,7 +1191,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
if (summary.membership == Membership.INVITE) {
|
if (summary.membership == Membership.INVITE) {
|
||||||
summary.inviterId?.let { inviterId ->
|
summary.inviterId?.let { inviterId ->
|
||||||
session.getRoomMember(inviterId, summary.roomId)
|
session.roomService().getRoomMember(inviterId, summary.roomId)
|
||||||
}?.also {
|
}?.also {
|
||||||
setState { copy(asyncInviter = Success(it)) }
|
setState { copy(asyncInviter = Success(it)) }
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,8 @@ import org.matrix.android.sdk.api.session.events.model.getRootThreadEventId
|
|||||||
import org.matrix.android.sdk.api.session.events.model.isThread
|
import org.matrix.android.sdk.api.session.events.model.isThread
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
|
import org.matrix.android.sdk.api.session.getRoomSummary
|
||||||
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
|
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomAvatarContent
|
import org.matrix.android.sdk.api.session.room.model.RoomAvatarContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomEncryptionAlgorithm
|
import org.matrix.android.sdk.api.session.room.model.RoomEncryptionAlgorithm
|
||||||
@ -445,7 +447,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||||||
is ParsedCommand.LeaveRoom -> {
|
is ParsedCommand.LeaveRoom -> {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
session.leaveRoom(parsedCommand.roomId)
|
session.roomService().leaveRoom(parsedCommand.roomId)
|
||||||
popDraft()
|
popDraft()
|
||||||
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand))
|
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand))
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
@ -609,7 +611,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||||||
private fun handleJoinToAnotherRoomSlashCommand(command: ParsedCommand.JoinRoom) {
|
private fun handleJoinToAnotherRoomSlashCommand(command: ParsedCommand.JoinRoom) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
session.joinRoom(command.roomAlias, command.reason, emptyList())
|
session.roomService().joinRoom(command.roomAlias, command.reason, emptyList())
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultError(failure))
|
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultError(failure))
|
||||||
return@launch
|
return@launch
|
||||||
@ -676,7 +678,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
private fun handleChangeDisplayNameSlashCommand(changeDisplayName: ParsedCommand.ChangeDisplayName) {
|
private fun handleChangeDisplayNameSlashCommand(changeDisplayName: ParsedCommand.ChangeDisplayName) {
|
||||||
launchSlashCommandFlowSuspendable(changeDisplayName) {
|
launchSlashCommandFlowSuspendable(changeDisplayName) {
|
||||||
session.setDisplayName(session.myUserId, changeDisplayName.displayName)
|
session.profileService().setDisplayName(session.myUserId, changeDisplayName.displayName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +693,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||||||
?.let { session.getRoom(it) }
|
?.let { session.getRoom(it) }
|
||||||
}
|
}
|
||||||
?.let {
|
?.let {
|
||||||
session.leaveRoom(it.roomId)
|
session.roomService().leaveRoom(it.roomId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -756,7 +758,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
private fun handleIgnoreSlashCommand(ignore: ParsedCommand.IgnoreUser) {
|
private fun handleIgnoreSlashCommand(ignore: ParsedCommand.IgnoreUser) {
|
||||||
launchSlashCommandFlowSuspendable(ignore) {
|
launchSlashCommandFlowSuspendable(ignore) {
|
||||||
session.ignoreUserIds(listOf(ignore.userId))
|
session.userService().ignoreUserIds(listOf(ignore.userId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,7 +775,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
private fun handleUnignoreSlashCommandConfirmed(unignore: ParsedCommand.UnignoreUser) {
|
private fun handleUnignoreSlashCommandConfirmed(unignore: ParsedCommand.UnignoreUser) {
|
||||||
launchSlashCommandFlowSuspendable(unignore) {
|
launchSlashCommandFlowSuspendable(unignore) {
|
||||||
session.unIgnoreUserIds(listOf(unignore.userId))
|
session.userService().unIgnoreUserIds(listOf(unignore.userId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class SearchResultController @Inject constructor(
|
|||||||
.formattedDate(dateFormatter.format(event.originServerTs, DateFormatKind.MESSAGE_SIMPLE))
|
.formattedDate(dateFormatter.format(event.originServerTs, DateFormatKind.MESSAGE_SIMPLE))
|
||||||
.spannable(spannable.toEpoxyCharSequence())
|
.spannable(spannable.toEpoxyCharSequence())
|
||||||
.sender(eventAndSender.sender
|
.sender(eventAndSender.sender
|
||||||
?: eventAndSender.event.senderId?.let { session.getRoomMember(it, data.roomId) }?.toMatrixItem())
|
?: eventAndSender.event.senderId?.let { session.roomService().getRoomMember(it, data.roomId) }?.toMatrixItem())
|
||||||
.threadDetails(event.threadDetails)
|
.threadDetails(event.threadDetails)
|
||||||
.threadSummaryFormatted(displayableEventFormatter.formatThreadSummary(event.threadDetails?.threadSummaryLatestEvent).toString())
|
.threadSummaryFormatted(displayableEventFormatter.formatThreadSummary(event.threadDetails?.threadSummaryLatestEvent).toString())
|
||||||
.areThreadMessagesEnabled(userPreferencesProvider.areThreadMessagesEnabled())
|
.areThreadMessagesEnabled(userPreferencesProvider.areThreadMessagesEnabled())
|
||||||
|
@ -30,11 +30,12 @@ import kotlinx.coroutines.CancellationException
|
|||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.search.SearchResult
|
import org.matrix.android.sdk.api.session.search.SearchResult
|
||||||
|
|
||||||
class SearchViewModel @AssistedInject constructor(
|
class SearchViewModel @AssistedInject constructor(
|
||||||
@Assisted private val initialState: SearchViewState,
|
@Assisted private val initialState: SearchViewState,
|
||||||
session: Session
|
private val session: Session
|
||||||
) : VectorViewModel<SearchViewState, SearchAction, SearchViewEvents>(initialState) {
|
) : VectorViewModel<SearchViewState, SearchAction, SearchViewEvents>(initialState) {
|
||||||
|
|
||||||
private val room = session.getRoom(initialState.roomId)
|
private val room = session.getRoom(initialState.roomId)
|
||||||
@ -100,8 +101,9 @@ class SearchViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
currentTask = viewModelScope.launch {
|
currentTask = viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
val result = room.search(
|
val result = session.searchService().search(
|
||||||
searchTerm = state.searchTerm,
|
searchTerm = state.searchTerm,
|
||||||
|
roomId = initialState.roomId,
|
||||||
nextBatch = nextBatch,
|
nextBatch = nextBatch,
|
||||||
orderByRecent = true,
|
orderByRecent = true,
|
||||||
beforeLimit = 0,
|
beforeLimit = 0,
|
||||||
|
@ -48,6 +48,7 @@ import org.matrix.android.sdk.api.session.events.model.isAttachmentMessage
|
|||||||
import org.matrix.android.sdk.api.session.events.model.isTextMessage
|
import org.matrix.android.sdk.api.session.events.model.isTextMessage
|
||||||
import org.matrix.android.sdk.api.session.events.model.isThread
|
import org.matrix.android.sdk.api.session.events.model.isThread
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageFormat
|
import org.matrix.android.sdk.api.session.room.model.message.MessageFormat
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent
|
||||||
@ -454,7 +455,7 @@ class MessageActionsViewModel @AssistedInject constructor(
|
|||||||
// if (!vectorPreferences.areThreadMessagesEnabled()) return false
|
// if (!vectorPreferences.areThreadMessagesEnabled()) return false
|
||||||
// Disable beta prompt if the homeserver do not support threads
|
// Disable beta prompt if the homeserver do not support threads
|
||||||
if (!vectorPreferences.areThreadMessagesEnabled() &&
|
if (!vectorPreferences.areThreadMessagesEnabled() &&
|
||||||
!session.getHomeServerCapabilities().canUseThreading) return false
|
!session.homeServerCapabilitiesService().getHomeServerCapabilities().canUseThreading) return false
|
||||||
|
|
||||||
if (initialState.isFromThreadTimeline) return false
|
if (initialState.isFromThreadTimeline) return false
|
||||||
if (event.root.isThread()) return false
|
if (event.root.isThread()) return false
|
||||||
|
@ -32,6 +32,7 @@ import org.matrix.android.sdk.api.session.Session
|
|||||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.OlmDecryptionResult
|
import org.matrix.android.sdk.api.session.crypto.model.OlmDecryptionResult
|
||||||
import org.matrix.android.sdk.api.session.events.model.isReply
|
import org.matrix.android.sdk.api.session.events.model.isReply
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import org.matrix.android.sdk.api.extensions.orFalse
|
|||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoomSummary
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class EncryptionItemFactory @Inject constructor(
|
class EncryptionItemFactory @Inject constructor(
|
||||||
|
@ -38,6 +38,7 @@ import org.matrix.android.sdk.api.query.QueryStringValue
|
|||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
|
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.RoomCreateContent
|
import org.matrix.android.sdk.api.session.room.model.create.RoomCreateContent
|
||||||
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
||||||
|
@ -436,7 +436,7 @@ class MessageItemFactory @Inject constructor(
|
|||||||
|
|
||||||
val otherUserId = if (informationData.sentByMe) messageContent.toUserId else informationData.senderId
|
val otherUserId = if (informationData.sentByMe) messageContent.toUserId else informationData.senderId
|
||||||
val otherUserName = if (informationData.sentByMe) {
|
val otherUserName = if (informationData.sentByMe) {
|
||||||
session.getRoomMember(messageContent.toUserId, roomId)?.displayName
|
session.roomService().getRoomMember(messageContent.toUserId, roomId)?.displayName
|
||||||
} else {
|
} else {
|
||||||
informationData.memberName
|
informationData.memberName
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import im.vector.app.features.home.room.detail.timeline.merged.MergedTimelines
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -32,6 +32,7 @@ import org.matrix.android.sdk.api.session.crypto.verification.safeValueOf
|
|||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.RelationType
|
import org.matrix.android.sdk.api.session.events.model.RelationType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageRelationContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageRelationContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationCancelContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationCancelContent
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -29,6 +29,7 @@ import im.vector.app.core.di.ActiveSessionHolder
|
|||||||
import im.vector.app.core.glide.GlideApp
|
import im.vector.app.core.glide.GlideApp
|
||||||
import im.vector.app.core.utils.DimensionConverter
|
import im.vector.app.core.utils.DimensionConverter
|
||||||
import im.vector.app.features.home.AvatarRenderer
|
import im.vector.app.features.home.AvatarRenderer
|
||||||
|
import org.matrix.android.sdk.api.session.getUser
|
||||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -33,6 +33,7 @@ import im.vector.app.core.platform.VectorViewModel
|
|||||||
import im.vector.app.features.home.room.detail.timeline.action.TimelineEventFragmentArgs
|
import im.vector.app.features.home.room.detail.timeline.action.TimelineEventFragmentArgs
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.flow.flow
|
import org.matrix.android.sdk.flow.flow
|
||||||
import org.matrix.android.sdk.flow.unwrap
|
import org.matrix.android.sdk.flow.unwrap
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class EventTextRenderer @AssistedInject constructor(@Assisted private val roomId
|
|||||||
* ========================================================================================== */
|
* ========================================================================================== */
|
||||||
|
|
||||||
private fun addNotifyEveryoneSpans(text: Spannable, roomId: String) {
|
private fun addNotifyEveryoneSpans(text: Spannable, roomId: String) {
|
||||||
val room: RoomSummary? = sessionHolder.getSafeActiveSession()?.getRoomSummary(roomId)
|
val room: RoomSummary? = sessionHolder.getSafeActiveSession()?.roomService()?.getRoomSummary(roomId)
|
||||||
val matrixItem = MatrixItem.EveryoneInRoomItem(
|
val matrixItem = MatrixItem.EveryoneInRoomItem(
|
||||||
id = roomId,
|
id = roomId,
|
||||||
avatarUrl = room?.avatarUrl,
|
avatarUrl = room?.avatarUrl,
|
||||||
|
@ -29,6 +29,8 @@ import im.vector.app.core.platform.VectorViewModel
|
|||||||
import im.vector.app.features.session.coroutineScope
|
import im.vector.app.features.session.coroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
|
import org.matrix.android.sdk.api.session.getRoomSummary
|
||||||
|
|
||||||
class MigrateRoomViewModel @AssistedInject constructor(
|
class MigrateRoomViewModel @AssistedInject constructor(
|
||||||
@Assisted initialState: MigrateRoomViewState,
|
@Assisted initialState: MigrateRoomViewState,
|
||||||
|
@ -20,6 +20,7 @@ import im.vector.app.core.platform.ViewModelTask
|
|||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -70,11 +70,11 @@ class RoomListSectionBuilderGroup(
|
|||||||
},
|
},
|
||||||
{ qpm ->
|
{ qpm ->
|
||||||
val name = stringProvider.getString(R.string.bottom_action_rooms)
|
val name = stringProvider.getString(R.string.bottom_action_rooms)
|
||||||
val updatableFilterLivePageResult = session.getFilteredPagedRoomSummariesLive(qpm)
|
val updatableFilterLivePageResult = session.roomService().getFilteredPagedRoomSummariesLive(qpm)
|
||||||
onUpdatable(updatableFilterLivePageResult)
|
onUpdatable(updatableFilterLivePageResult)
|
||||||
|
|
||||||
val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow()
|
val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow()
|
||||||
.flatMapLatest { session.getRoomCountLive(updatableFilterLivePageResult.queryParams).asFlow() }
|
.flatMapLatest { session.roomService().getRoomCountLive(updatableFilterLivePageResult.queryParams).asFlow() }
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
|
|
||||||
sections.add(
|
sections.add(
|
||||||
@ -252,7 +252,7 @@ class RoomListSectionBuilderGroup(
|
|||||||
query: (RoomSummaryQueryParams.Builder) -> Unit) {
|
query: (RoomSummaryQueryParams.Builder) -> Unit) {
|
||||||
withQueryParams(query) { roomQueryParams ->
|
withQueryParams(query) { roomQueryParams ->
|
||||||
val name = stringProvider.getString(nameRes)
|
val name = stringProvider.getString(nameRes)
|
||||||
session.getFilteredPagedRoomSummariesLive(roomQueryParams)
|
session.roomService().getFilteredPagedRoomSummariesLive(roomQueryParams)
|
||||||
.also {
|
.also {
|
||||||
activeSpaceUpdaters.add(it)
|
activeSpaceUpdaters.add(it)
|
||||||
}.livePagedList
|
}.livePagedList
|
||||||
@ -262,7 +262,7 @@ class RoomListSectionBuilderGroup(
|
|||||||
.onEach {
|
.onEach {
|
||||||
sections.find { it.sectionName == name }
|
sections.find { it.sectionName == name }
|
||||||
?.notificationCount
|
?.notificationCount
|
||||||
?.postValue(session.getNotificationCountForRooms(roomQueryParams))
|
?.postValue(session.roomService().getNotificationCountForRooms(roomQueryParams))
|
||||||
}
|
}
|
||||||
.flowOn(Dispatchers.Default)
|
.flowOn(Dispatchers.Default)
|
||||||
.launchIn(coroutineScope)
|
.launchIn(coroutineScope)
|
||||||
@ -272,7 +272,7 @@ class RoomListSectionBuilderGroup(
|
|||||||
sectionName = name,
|
sectionName = name,
|
||||||
livePages = livePagedList,
|
livePages = livePagedList,
|
||||||
notifyOfLocalEcho = notifyOfLocalEcho,
|
notifyOfLocalEcho = notifyOfLocalEcho,
|
||||||
itemCount = session.getRoomCountLive(roomQueryParams).asFlow()
|
itemCount = session.roomService().getRoomCountLive(roomQueryParams).asFlow()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import org.matrix.android.sdk.api.query.ActiveSpaceFilter
|
|||||||
import org.matrix.android.sdk.api.query.RoomCategoryFilter
|
import org.matrix.android.sdk.api.query.RoomCategoryFilter
|
||||||
import org.matrix.android.sdk.api.query.RoomTagQueryFilter
|
import org.matrix.android.sdk.api.query.RoomTagQueryFilter
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.getRoomSummary
|
||||||
import org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams
|
import org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams
|
||||||
import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult
|
import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
@ -324,11 +325,11 @@ class RoomListSectionBuilderSpace(
|
|||||||
},
|
},
|
||||||
{ qpm ->
|
{ qpm ->
|
||||||
val name = stringProvider.getString(R.string.bottom_action_rooms)
|
val name = stringProvider.getString(R.string.bottom_action_rooms)
|
||||||
val updatableFilterLivePageResult = session.getFilteredPagedRoomSummariesLive(qpm)
|
val updatableFilterLivePageResult = session.roomService().getFilteredPagedRoomSummariesLive(qpm)
|
||||||
onUpdatable(updatableFilterLivePageResult)
|
onUpdatable(updatableFilterLivePageResult)
|
||||||
|
|
||||||
val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow()
|
val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow()
|
||||||
.flatMapLatest { session.getRoomCountLive(updatableFilterLivePageResult.queryParams).asFlow() }
|
.flatMapLatest { session.roomService().getRoomCountLive(updatableFilterLivePageResult.queryParams).asFlow() }
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
|
|
||||||
sections.add(
|
sections.add(
|
||||||
@ -354,13 +355,13 @@ class RoomListSectionBuilderSpace(
|
|||||||
val liveQueryParams = MutableStateFlow(updatedQueryParams)
|
val liveQueryParams = MutableStateFlow(updatedQueryParams)
|
||||||
val itemCountFlow = liveQueryParams
|
val itemCountFlow = liveQueryParams
|
||||||
.flatMapLatest {
|
.flatMapLatest {
|
||||||
session.getRoomCountLive(it).asFlow()
|
session.roomService().getRoomCountLive(it).asFlow()
|
||||||
}
|
}
|
||||||
.flowOn(Dispatchers.Main)
|
.flowOn(Dispatchers.Main)
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
|
|
||||||
val name = stringProvider.getString(nameRes)
|
val name = stringProvider.getString(nameRes)
|
||||||
val filteredPagedRoomSummariesLive = session.getFilteredPagedRoomSummariesLive(
|
val filteredPagedRoomSummariesLive = session.roomService().getFilteredPagedRoomSummariesLive(
|
||||||
roomQueryParams.process(spaceFilterStrategy, appStateHandler.safeActiveSpaceId()),
|
roomQueryParams.process(spaceFilterStrategy, appStateHandler.safeActiveSpaceId()),
|
||||||
pagedListConfig
|
pagedListConfig
|
||||||
)
|
)
|
||||||
@ -407,7 +408,7 @@ class RoomListSectionBuilderSpace(
|
|||||||
if (countRoomAsNotif) {
|
if (countRoomAsNotif) {
|
||||||
RoomAggregateNotificationCount(it.size, it.size)
|
RoomAggregateNotificationCount(it.size, it.size)
|
||||||
} else {
|
} else {
|
||||||
session.getNotificationCountForRooms(
|
session.roomService().getNotificationCountForRooms(
|
||||||
roomQueryParams.process(spaceFilterStrategy, appStateHandler.safeActiveSpaceId())
|
roomQueryParams.process(spaceFilterStrategy, appStateHandler.safeActiveSpaceId())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user