Skip to content
Snippets Groups Projects
Commit 4886102e authored by Benoit Marty's avatar Benoit Marty
Browse files

Merge branch 'release/1.3.4' into main

parents 5601d409 09d1f9ae
No related branches found
No related tags found
No related merge requests found
Showing
with 259 additions and 76 deletions
Please also refer to the Changelog of Element Android: https://github.com/vector-im/element-android/blob/main/CHANGES.md Please also refer to the Changelog of Element Android: https://github.com/vector-im/element-android/blob/main/CHANGES.md
Changes in Matrix-SDK 1.3.4 (2021-10-20)
===================================================
Imported from Element 1.3.4. (https://github.com/vector-im/element-android/releases/tag/v1.3.4)
SDK API changes ⚠️
------------------
Add Presence support:
- PresenceService has been added, with the ability to set the presence of the current user
- For DM, the presence of the other user is added to the RoomSummary
Changes in Matrix-SDK 1.3.2 (2021-10-08) Changes in Matrix-SDK 1.3.2 (2021-10-08)
=================================================== ===================================================
......
...@@ -7,7 +7,7 @@ ext.versions = [ ...@@ -7,7 +7,7 @@ ext.versions = [
'targetCompat' : JavaVersion.VERSION_11, 'targetCompat' : JavaVersion.VERSION_11,
] ]
def gradle = "7.0.2" def gradle = "7.0.3"
// Ref: https://kotlinlang.org/releases.html // Ref: https://kotlinlang.org/releases.html
def kotlin = "1.5.31" def kotlin = "1.5.31"
def kotlinCoroutines = "1.5.2" def kotlinCoroutines = "1.5.2"
...@@ -19,6 +19,7 @@ def moshi = "1.12.0" ...@@ -19,6 +19,7 @@ def moshi = "1.12.0"
def lifecycle = "2.2.0" def lifecycle = "2.2.0"
def rxBinding = "3.1.0" def rxBinding = "3.1.0"
def epoxy = "4.6.2" def epoxy = "4.6.2"
def mavericks = "2.4.0"
def glide = "4.12.0" def glide = "4.12.0"
def bigImageViewer = "1.8.1" def bigImageViewer = "1.8.1"
def jjwt = "0.11.2" def jjwt = "0.11.2"
...@@ -36,8 +37,6 @@ ext.libs = [ ...@@ -36,8 +37,6 @@ ext.libs = [
'kotlinPlugin' : "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin" 'kotlinPlugin' : "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin"
], ],
jetbrains : [ jetbrains : [
'kotlinStdlibJdk7' : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin",
'kotlinStdlib' : "org.jetbrains.kotlin:kotlin-stdlib:$kotlin",
'coroutinesCore' : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutines", 'coroutinesCore' : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutines",
'coroutinesAndroid' : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutines", 'coroutinesAndroid' : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutines",
'coroutinesRx2' : "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlinCoroutines" 'coroutinesRx2' : "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlinCoroutines"
...@@ -98,7 +97,9 @@ ext.libs = [ ...@@ -98,7 +97,9 @@ ext.libs = [
'epoxyGlide' : "com.airbnb.android:epoxy-glide-preloading:$epoxy", 'epoxyGlide' : "com.airbnb.android:epoxy-glide-preloading:$epoxy",
'epoxyProcessor' : "com.airbnb.android:epoxy-processor:$epoxy", 'epoxyProcessor' : "com.airbnb.android:epoxy-processor:$epoxy",
'epoxyPaging' : "com.airbnb.android:epoxy-paging:$epoxy", 'epoxyPaging' : "com.airbnb.android:epoxy-paging:$epoxy",
'mvrx' : "com.airbnb.android:mvrx:1.5.1" 'mavericks' : "com.airbnb.android:mavericks:$mavericks",
'mavericksRx' : "com.airbnb.android:mavericks-rxjava2:$mavericks",
'mavericksTesting' : "com.airbnb.android:mavericks-testing:$mavericks"
], ],
mockk : [ mockk : [
'mockk' : "io.mockk:mockk:$mockk", 'mockk' : "io.mockk:mockk:$mockk",
...@@ -123,10 +124,13 @@ ext.libs = [ ...@@ -123,10 +124,13 @@ ext.libs = [
'jjwtImpl' : "io.jsonwebtoken:jjwt-impl:$jjwt", 'jjwtImpl' : "io.jsonwebtoken:jjwt-impl:$jjwt",
'jjwtOrgjson' : "io.jsonwebtoken:jjwt-orgjson:$jjwt" 'jjwtOrgjson' : "io.jsonwebtoken:jjwt-orgjson:$jjwt"
], ],
vanniktech: [ vanniktech : [
'emojiMaterial' : "com.vanniktech:emoji-material:$vanniktechEmoji", 'emojiMaterial' : "com.vanniktech:emoji-material:$vanniktechEmoji",
'emojiGoogle' : "com.vanniktech:emoji-google:$vanniktechEmoji" 'emojiGoogle' : "com.vanniktech:emoji-google:$vanniktechEmoji"
], ],
apache : [
'commonsImaging' : "org.apache.sanselan:sanselan:0.97-incubator"
],
tests : [ tests : [
'kluent' : "org.amshove.kluent:kluent-android:1.68", 'kluent' : "org.amshove.kluent:kluent-android:1.68",
'timberJunitRule' : "net.lachlanmckee:timber-junit-rule:1.0.1", 'timberJunitRule' : "net.lachlanmckee:timber-junit-rule:1.0.1",
......
...@@ -26,7 +26,7 @@ vector.httpLogLevel=NONE ...@@ -26,7 +26,7 @@ vector.httpLogLevel=NONE
# Ref: https://github.com/vanniktech/gradle-maven-publish-plugin # Ref: https://github.com/vanniktech/gradle-maven-publish-plugin
GROUP=org.matrix.android GROUP=org.matrix.android
POM_ARTIFACT_ID=matrix-android-sdk2 POM_ARTIFACT_ID=matrix-android-sdk2
VERSION_NAME=1.3.2 VERSION_NAME=1.3.4
POM_PACKAGING=aar POM_PACKAGING=aar
......
...@@ -103,8 +103,6 @@ static def gitRevisionDate() { ...@@ -103,8 +103,6 @@ static def gitRevisionDate() {
} }
dependencies { dependencies {
implementation libs.jetbrains.kotlinStdlibJdk7
implementation libs.jetbrains.coroutinesCore implementation libs.jetbrains.coroutinesCore
implementation libs.jetbrains.coroutinesAndroid implementation libs.jetbrains.coroutinesAndroid
...@@ -133,6 +131,7 @@ dependencies { ...@@ -133,6 +131,7 @@ dependencies {
// Database // Database
implementation 'com.github.Zhuinden:realm-monarchy:0.7.1' implementation 'com.github.Zhuinden:realm-monarchy:0.7.1'
kapt 'dk.ilios:realmfieldnameshelper:2.0.0' kapt 'dk.ilios:realmfieldnameshelper:2.0.0'
// Work // Work
...@@ -156,8 +155,11 @@ dependencies { ...@@ -156,8 +155,11 @@ dependencies {
// Video compression // Video compression
implementation 'com.otaliastudios:transcoder:0.10.4' implementation 'com.otaliastudios:transcoder:0.10.4'
// Exif data handling
implementation libs.apache.commonsImaging
// Phone number https://github.com/google/libphonenumber // Phone number https://github.com/google/libphonenumber
implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.34' implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.35'
testImplementation libs.tests.junit testImplementation libs.tests.junit
testImplementation 'org.robolectric:robolectric:4.6.1' testImplementation 'org.robolectric:robolectric:4.6.1'
...@@ -168,6 +170,8 @@ dependencies { ...@@ -168,6 +170,8 @@ dependencies {
implementation libs.jetbrains.coroutinesAndroid implementation libs.jetbrains.coroutinesAndroid
// Plant Timber tree for test // Plant Timber tree for test
testImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1' testImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1'
// Transitively required for mocking realm as monarchy doesn't expose Rx
testImplementation libs.rx.rxKotlin
kaptAndroidTest libs.dagger.daggerCompiler kaptAndroidTest libs.dagger.daggerCompiler
androidTestImplementation libs.androidx.testCore androidTestImplementation libs.androidx.testCore
......
...@@ -18,7 +18,7 @@ package org.matrix.android.sdk ...@@ -18,7 +18,7 @@ package org.matrix.android.sdk
import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.asCoroutineDispatcher
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import java.util.concurrent.Executors import java.util.concurrent.Executors
internal val testCoroutineDispatchers = MatrixCoroutineDispatchers(Main, Main, Main, Main, internal val testCoroutineDispatchers = MatrixCoroutineDispatchers(Main, Main, Main, Main,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
package org.matrix.android.sdk.internal.util package org.matrix.android.sdk.api
import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineDispatcher
internal data class MatrixCoroutineDispatchers( data class MatrixCoroutineDispatchers(
val io: CoroutineDispatcher, val io: CoroutineDispatcher,
val computation: CoroutineDispatcher, val computation: CoroutineDispatcher,
val main: CoroutineDispatcher, val main: CoroutineDispatcher,
......
...@@ -20,6 +20,7 @@ import androidx.annotation.MainThread ...@@ -20,6 +20,7 @@ import androidx.annotation.MainThread
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.SharedFlow
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.auth.data.SessionParams import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.api.failure.GlobalError import org.matrix.android.sdk.api.failure.GlobalError
import org.matrix.android.sdk.api.federation.FederationService import org.matrix.android.sdk.api.federation.FederationService
...@@ -42,6 +43,7 @@ import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerS ...@@ -42,6 +43,7 @@ import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerS
import org.matrix.android.sdk.api.session.media.MediaService import org.matrix.android.sdk.api.session.media.MediaService
import org.matrix.android.sdk.api.session.openid.OpenIdService import org.matrix.android.sdk.api.session.openid.OpenIdService
import org.matrix.android.sdk.api.session.permalinks.PermalinkService import org.matrix.android.sdk.api.session.permalinks.PermalinkService
import org.matrix.android.sdk.api.session.presence.PresenceService
import org.matrix.android.sdk.api.session.profile.ProfileService import org.matrix.android.sdk.api.session.profile.ProfileService
import org.matrix.android.sdk.api.session.pushers.PushersService import org.matrix.android.sdk.api.session.pushers.PushersService
import org.matrix.android.sdk.api.session.room.RoomDirectoryService import org.matrix.android.sdk.api.session.room.RoomDirectoryService
...@@ -75,6 +77,7 @@ interface Session : ...@@ -75,6 +77,7 @@ interface Session :
TermsService, TermsService,
EventService, EventService,
ProfileService, ProfileService,
PresenceService,
PushRuleService, PushRuleService,
PushersService, PushersService,
SyncStatusService, SyncStatusService,
...@@ -82,6 +85,8 @@ interface Session : ...@@ -82,6 +85,8 @@ interface Session :
SecureStorageService, SecureStorageService,
AccountService { AccountService {
val coroutineDispatchers: MatrixCoroutineDispatchers
/** /**
* The params associated to the session * The params associated to the session
*/ */
......
...@@ -30,6 +30,7 @@ import org.matrix.android.sdk.api.util.JsonDict ...@@ -30,6 +30,7 @@ import org.matrix.android.sdk.api.util.JsonDict
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
import org.matrix.android.sdk.internal.di.MoshiProvider import org.matrix.android.sdk.internal.di.MoshiProvider
import org.matrix.android.sdk.internal.session.presence.model.PresenceContent
import timber.log.Timber import timber.log.Timber
typealias Content = JsonDict typealias Content = JsonDict
...@@ -305,3 +306,7 @@ fun Event.isReply(): Boolean { ...@@ -305,3 +306,7 @@ fun Event.isReply(): Boolean {
fun Event.isEdition(): Boolean { fun Event.isEdition(): Boolean {
return getRelationContent()?.takeIf { it.type == RelationType.REPLACE }?.eventId != null return getRelationContent()?.takeIf { it.type == RelationType.REPLACE }?.eventId != null
} }
fun Event.getPresenceContent(): PresenceContent? {
return content.toModel<PresenceContent>()
}
/*
* Copyright 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.matrix.android.sdk.api.session.presence
import org.matrix.android.sdk.api.session.presence.model.PresenceEnum
import org.matrix.android.sdk.api.session.presence.model.UserPresence
/**
* This interface defines methods for handling user presence information.
*/
interface PresenceService {
/**
* Update the presence status for the current user
* @param presence the new presence state
* @param statusMsg the status message to attach to this state
*/
suspend fun setMyPresence(presence: PresenceEnum, statusMsg: String? = null)
/**
* Fetch the given user's presence state.
* @param userId the userId whose presence state to get.
*/
suspend fun fetchPresence(userId: String): UserPresence
// TODO Add live data (of Flow) of the presence of a userId
}
/*
* Copyright 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.android.sdk.api.session.presence.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = false)
enum class PresenceEnum(val value: String) {
@Json(name = "online")
ONLINE("online"),
@Json(name = "offline")
OFFLINE("offline"),
@Json(name = "unavailable")
UNAVAILABLE("unavailable");
companion object {
fun from(s: String): PresenceEnum? = values().find { it.value == s }
}
}
/*
* Copyright 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.android.sdk.api.session.presence.model
data class UserPresence(
val lastActiveAgo: Long? = null,
val statusMessage: String? = null,
val isCurrentlyActive: Boolean? = null,
val presence: PresenceEnum = PresenceEnum.OFFLINE
)
...@@ -29,38 +29,19 @@ interface PushersService { ...@@ -29,38 +29,19 @@ interface PushersService {
* Add a new HTTP pusher. * Add a new HTTP pusher.
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set * Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set
* *
* @param pushkey This is a unique identifier for this pusher. The value you should use for * @throws [InvalidParameterException] if a parameter is not correct
* this is the routing or destination address information for the notification, */
* for example, the APNS token for APNS or the Registration ID for GCM. If your suspend fun addHttpPusher(httpPusher: HttpPusher)
* notification client has no such concept, use any unique identifier. Max length, 512 chars.
* @param appId the application id /**
* This is a reverse-DNS style identifier for the application. It is recommended * Enqueues a new HTTP pusher via the WorkManager API.
* that this end with the platform, such that different platform versions get * Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set
* different app identifiers. Max length, 64 chars.
* @param profileTag This string determines which set of device specific rules this pusher executes.
* @param lang The preferred language for receiving notifications (e.g. "en" or "en-US").
* @param appDisplayName A human readable string that will allow the user to identify what application owns this pusher.
* @param deviceDisplayName A human readable string that will allow the user to identify what device owns this pusher.
* @param url The URL to use to send notifications to. MUST be an HTTPS URL with a path of /_matrix/push/v1/notify.
* @param append If true, the homeserver should add another pusher with the given pushkey and App ID in addition
* to any others with different user IDs. Otherwise, the homeserver must remove any other pushers
* with the same App ID and pushkey for different users.
* @param withEventIdOnly true to limit the push content to only id and not message content
* Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour
* *
* @return A work request uuid. Can be used to listen to the status * @return A work request uuid. Can be used to listen to the status
* (LiveData<WorkInfo> status = workManager.getWorkInfoByIdLiveData(<UUID>)) * (LiveData<WorkInfo> status = workManager.getWorkInfoByIdLiveData(<UUID>))
* @throws [InvalidParameterException] if a parameter is not correct * @throws [InvalidParameterException] if a parameter is not correct
*/ */
fun addHttpPusher(pushkey: String, fun enqueueAddHttpPusher(httpPusher: HttpPusher): UUID
appId: String,
profileTag: String,
lang: String,
appDisplayName: String,
deviceDisplayName: String,
url: String,
append: Boolean,
withEventIdOnly: Boolean): UUID
/** /**
* Add a new Email pusher. * Add a new Email pusher.
...@@ -75,16 +56,14 @@ interface PushersService { ...@@ -75,16 +56,14 @@ interface PushersService {
* to any others with different user IDs. Otherwise, the homeserver must remove any other pushers * to any others with different user IDs. Otherwise, the homeserver must remove any other pushers
* with the same App ID and pushkey for different users. Typically We always want to append for * with the same App ID and pushkey for different users. Typically We always want to append for
* email pushers since we don't want to stop other accounts notifying to the same email address. * email pushers since we don't want to stop other accounts notifying to the same email address.
* @return A work request uuid. Can be used to listen to the status
* (LiveData<WorkInfo> status = workManager.getWorkInfoByIdLiveData(<UUID>))
* @throws [InvalidParameterException] if a parameter is not correct * @throws [InvalidParameterException] if a parameter is not correct
*/ */
fun addEmailPusher(email: String, suspend fun addEmailPusher(email: String,
lang: String, lang: String,
emailBranding: String, emailBranding: String,
appDisplayName: String, appDisplayName: String,
deviceDisplayName: String, deviceDisplayName: String,
append: Boolean = true): UUID append: Boolean = true)
/** /**
* Directly ask the push gateway to send a push to this device * Directly ask the push gateway to send a push to this device
...@@ -128,4 +107,61 @@ interface PushersService { ...@@ -128,4 +107,61 @@ interface PushersService {
* Get the current pushers * Get the current pushers
*/ */
fun getPushers(): List<Pusher> fun getPushers(): List<Pusher>
data class HttpPusher(
/**
* This is a unique identifier for this pusher. The value you should use for
* this is the routing or destination address information for the notification,
* for example, the APNS token for APNS or the Registration ID for GCM. If your
* notification client has no such concept, use any unique identifier. Max length, 512 chars.
*/
val pushkey: String,
/**
* The application id
* This is a reverse-DNS style identifier for the application. It is recommended
* that this end with the platform, such that different platform versions get
* different app identifiers. Max length, 64 chars.
*/
val appId: String,
/**
* This string determines which set of device specific rules this pusher executes.
*/
val profileTag: String,
/**
* The preferred language for receiving notifications (e.g. "en" or "en-US").
*/
val lang: String,
/**
* A human readable string that will allow the user to identify what application owns this pusher.
*/
val appDisplayName: String,
/**
* A human readable string that will allow the user to identify what device owns this pusher.
*/
val deviceDisplayName: String,
/**
* The URL to use to send notifications to. MUST be an HTTPS URL with a path of /_matrix/push/v1/notify.
*/
val url: String,
/**
* If true, the homeserver should add another pusher with the given pushkey and App ID in addition
* to any others with different user IDs. Otherwise, the homeserver must remove any other pushers
* with the same App ID and pushkey for different users.
*/
val append: Boolean,
/**
* true to limit the push content to only id and not message content
* Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour
*/
val withEventIdOnly: Boolean
)
} }
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.matrix.android.sdk.api.session.room package org.matrix.android.sdk.api.session.room
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataService import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataService
import org.matrix.android.sdk.api.session.room.alias.AliasService import org.matrix.android.sdk.api.session.room.alias.AliasService
import org.matrix.android.sdk.api.session.room.call.RoomCallService import org.matrix.android.sdk.api.session.room.call.RoomCallService
...@@ -61,6 +62,8 @@ interface Room : ...@@ -61,6 +62,8 @@ interface Room :
RoomAccountDataService, RoomAccountDataService,
RoomVersionService { RoomVersionService {
val coroutineDispatchers: MatrixCoroutineDispatchers
/** /**
* The roomId of this room * The roomId of this room
*/ */
......
...@@ -16,12 +16,15 @@ ...@@ -16,12 +16,15 @@
package org.matrix.android.sdk.api.session.room.model package org.matrix.android.sdk.api.session.room.model
import org.matrix.android.sdk.api.session.presence.model.UserPresence
/** /**
* Class representing a simplified version of EventType.STATE_ROOM_MEMBER state event content * Class representing a simplified version of EventType.STATE_ROOM_MEMBER state event content
*/ */
data class RoomMemberSummary constructor( data class RoomMemberSummary constructor(
val membership: Membership, val membership: Membership,
val userId: String, val userId: String,
val userPresence: UserPresence? = null,
val displayName: String? = null, val displayName: String? = null,
val avatarUrl: String? = null val avatarUrl: String? = null
) )
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.matrix.android.sdk.api.session.room.model package org.matrix.android.sdk.api.session.room.model
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
import org.matrix.android.sdk.api.session.presence.model.UserPresence
import org.matrix.android.sdk.api.session.room.model.tag.RoomTag import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
import org.matrix.android.sdk.api.session.room.send.UserDraft import org.matrix.android.sdk.api.session.room.send.UserDraft
import org.matrix.android.sdk.api.session.room.sender.SenderInfo import org.matrix.android.sdk.api.session.room.sender.SenderInfo
...@@ -38,6 +39,7 @@ data class RoomSummary( ...@@ -38,6 +39,7 @@ data class RoomSummary(
val joinRules: RoomJoinRules? = null, val joinRules: RoomJoinRules? = null,
val isDirect: Boolean = false, val isDirect: Boolean = false,
val directUserId: String? = null, val directUserId: String? = null,
val directUserPresence: UserPresence? = null,
val joinedMembersCount: Int? = 0, val joinedMembersCount: Int? = 0,
val invitedMembersCount: Int? = 0, val invitedMembersCount: Int? = 0,
val latestPreviewableEvent: TimelineEvent? = null, val latestPreviewableEvent: TimelineEvent? = null,
......
...@@ -29,6 +29,7 @@ import kotlinx.coroutines.launch ...@@ -29,6 +29,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.MatrixCallback import org.matrix.android.sdk.api.MatrixCallback
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.NoOpMatrixCallback import org.matrix.android.sdk.api.NoOpMatrixCallback
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
import org.matrix.android.sdk.api.crypto.MXCryptoConfig import org.matrix.android.sdk.api.crypto.MXCryptoConfig
...@@ -93,7 +94,6 @@ import org.matrix.android.sdk.internal.task.TaskThread ...@@ -93,7 +94,6 @@ import org.matrix.android.sdk.internal.task.TaskThread
import org.matrix.android.sdk.internal.task.configureWith import org.matrix.android.sdk.internal.task.configureWith
import org.matrix.android.sdk.internal.task.launchToCallback import org.matrix.android.sdk.internal.task.launchToCallback
import org.matrix.android.sdk.internal.util.JsonCanonicalizer import org.matrix.android.sdk.internal.util.JsonCanonicalizer
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import org.matrix.olm.OlmManager import org.matrix.olm.OlmManager
import timber.log.Timber import timber.log.Timber
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
......
...@@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.crypto ...@@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.crypto
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.MatrixPatterns import org.matrix.android.sdk.api.MatrixPatterns
import org.matrix.android.sdk.api.auth.data.Credentials import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
...@@ -29,7 +30,6 @@ import org.matrix.android.sdk.internal.crypto.tasks.DownloadKeysForUsersTask ...@@ -29,7 +30,6 @@ import org.matrix.android.sdk.internal.crypto.tasks.DownloadKeysForUsersTask
import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.session.sync.SyncTokenStore import org.matrix.android.sdk.internal.session.sync.SyncTokenStore
import org.matrix.android.sdk.internal.task.TaskExecutor import org.matrix.android.sdk.internal.task.TaskExecutor
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import org.matrix.android.sdk.internal.util.logLimit import org.matrix.android.sdk.internal.util.logLimit
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
......
...@@ -20,6 +20,7 @@ import kotlinx.coroutines.CoroutineScope ...@@ -20,6 +20,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.MatrixCallback import org.matrix.android.sdk.api.MatrixCallback
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
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.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
...@@ -27,16 +28,17 @@ import org.matrix.android.sdk.api.session.events.model.toModel ...@@ -27,16 +28,17 @@ import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.internal.crypto.actions.EnsureOlmSessionsForDevicesAction import org.matrix.android.sdk.internal.crypto.actions.EnsureOlmSessionsForDevicesAction
import org.matrix.android.sdk.internal.crypto.actions.MessageEncrypter import org.matrix.android.sdk.internal.crypto.actions.MessageEncrypter
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.internal.crypto.model.MXOlmSessionResult
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.internal.crypto.model.event.OlmEventContent import org.matrix.android.sdk.internal.crypto.model.event.OlmEventContent
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
import org.matrix.android.sdk.internal.extensions.foldToCallback import org.matrix.android.sdk.internal.extensions.foldToCallback
import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
import kotlin.jvm.Throws
private const val SEND_TO_DEVICE_RETRY_COUNT = 3
@SessionScope @SessionScope
internal class EventDecryptor @Inject constructor( internal class EventDecryptor @Inject constructor(
...@@ -146,29 +148,36 @@ internal class EventDecryptor @Inject constructor( ...@@ -146,29 +148,36 @@ internal class EventDecryptor @Inject constructor(
// offload this from crypto thread (?) // offload this from crypto thread (?)
cryptoCoroutineScope.launch(coroutineDispatchers.computation) { cryptoCoroutineScope.launch(coroutineDispatchers.computation) {
val ensured = ensureOlmSessionsForDevicesAction.handle(mapOf(senderId to listOf(deviceInfo)), force = true) runCatching { ensureOlmSessionsForDevicesAction.handle(mapOf(senderId to listOf(deviceInfo)), force = true) }.fold(
onSuccess = { sendDummyToDevice(ensured = it, deviceInfo, senderId) },
onFailure = {
Timber.e("## CRYPTO | markOlmSessionForUnwedging() : failed to ensure device info ${senderId}${deviceInfo.deviceId}")
}
)
}
}
Timber.i("## CRYPTO | markOlmSessionForUnwedging() : ensureOlmSessionsForDevicesAction isEmpty:${ensured.isEmpty}") private suspend fun sendDummyToDevice(ensured: MXUsersDevicesMap<MXOlmSessionResult>, deviceInfo: CryptoDeviceInfo, senderId: String) {
Timber.i("## CRYPTO | markOlmSessionForUnwedging() : ensureOlmSessionsForDevicesAction isEmpty:${ensured.isEmpty}")
// Now send a blank message on that session so the other side knows about it. // Now send a blank message on that session so the other side knows about it.
// (The keyshare request is sent in the clear so that won't do) // (The keyshare request is sent in the clear so that won't do)
// We send this first such that, as long as the toDevice messages arrive in the // We send this first such that, as long as the toDevice messages arrive in the
// same order we sent them, the other end will get this first, set up the new session, // same order we sent them, the other end will get this first, set up the new session,
// then get the keyshare request and send the key over this new session (because it // then get the keyshare request and send the key over this new session (because it
// is the session it has most recently received a message on). // is the session it has most recently received a message on).
val payloadJson = mapOf<String, Any>("type" to EventType.DUMMY) val payloadJson = mapOf<String, Any>("type" to EventType.DUMMY)
val encodedPayload = messageEncrypter.encryptMessage(payloadJson, listOf(deviceInfo)) val encodedPayload = messageEncrypter.encryptMessage(payloadJson, listOf(deviceInfo))
val sendToDeviceMap = MXUsersDevicesMap<Any>() val sendToDeviceMap = MXUsersDevicesMap<Any>()
sendToDeviceMap.setObject(senderId, deviceInfo.deviceId, encodedPayload) sendToDeviceMap.setObject(senderId, deviceInfo.deviceId, encodedPayload)
Timber.i("## CRYPTO | markOlmSessionForUnwedging() : sending dummy to $senderId:${deviceInfo.deviceId}") Timber.i("## CRYPTO | markOlmSessionForUnwedging() : sending dummy to $senderId:${deviceInfo.deviceId}")
withContext(coroutineDispatchers.io) { withContext(coroutineDispatchers.io) {
val sendToDeviceParams = SendToDeviceTask.Params(EventType.ENCRYPTED, sendToDeviceMap) val sendToDeviceParams = SendToDeviceTask.Params(EventType.ENCRYPTED, sendToDeviceMap)
try { try {
sendToDeviceTask.execute(sendToDeviceParams) sendToDeviceTask.executeRetry(sendToDeviceParams, remainingRetry = SEND_TO_DEVICE_RETRY_COUNT)
} catch (failure: Throwable) { } catch (failure: Throwable) {
Timber.e(failure, "## CRYPTO | markOlmSessionForUnwedging() : failed to send dummy to $senderId:${deviceInfo.deviceId}") Timber.e(failure, "## CRYPTO | markOlmSessionForUnwedging() : failed to send dummy to $senderId:${deviceInfo.deviceId}")
}
} }
} }
} }
......
...@@ -19,10 +19,10 @@ package org.matrix.android.sdk.internal.crypto ...@@ -19,10 +19,10 @@ package org.matrix.android.sdk.internal.crypto
import android.util.LruCache import android.util.LruCache
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.internal.crypto.model.OlmInboundGroupSessionWrapper2 import org.matrix.android.sdk.internal.crypto.model.OlmInboundGroupSessionWrapper2
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import timber.log.Timber import timber.log.Timber
import java.util.Timer import java.util.Timer
import java.util.TimerTask import java.util.TimerTask
......
...@@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.crypto ...@@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.crypto
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.auth.data.Credentials import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.crypto.MXCryptoConfig import org.matrix.android.sdk.api.crypto.MXCryptoConfig
import org.matrix.android.sdk.api.session.crypto.crosssigning.KEYBACKUP_SECRET_SSSS_NAME import org.matrix.android.sdk.api.session.crypto.crosssigning.KEYBACKUP_SECRET_SSSS_NAME
...@@ -38,7 +39,6 @@ import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore ...@@ -38,7 +39,6 @@ import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.android.sdk.internal.crypto.tasks.createUniqueTxnId import org.matrix.android.sdk.internal.crypto.tasks.createUniqueTxnId
import org.matrix.android.sdk.internal.di.SessionId import org.matrix.android.sdk.internal.di.SessionId
import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
import timber.log.Timber import timber.log.Timber
import java.util.concurrent.Executors import java.util.concurrent.Executors
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment