mirror of
https://github.com/vector-im/riotX-android
synced 2025-10-06 00:02:48 +02:00
Compare commits
1 Commits
v1.6.44
...
yostyle/li
Author | SHA1 | Date | |
---|---|---|---|
|
f343f84490 |
@@ -31,5 +31,11 @@ data class MXCryptoConfig constructor(
|
||||
* If set to false, the request will be forwarded to the application layer; in this
|
||||
* case the application can decide to prompt the user.
|
||||
*/
|
||||
val discardRoomKeyRequestsFromUntrustedDevices: Boolean = true
|
||||
val discardRoomKeyRequestsFromUntrustedDevices: Boolean = true,
|
||||
|
||||
/**
|
||||
* If set to true, the SDK will send room key request to my devices only.
|
||||
* If set to false, the SDK will send room key request to my devices and the sender device.
|
||||
*/
|
||||
val onlyRequestRoomKeysToMyDevices: Boolean = false
|
||||
)
|
||||
|
@@ -19,6 +19,8 @@ package org.matrix.android.sdk.internal.crypto.algorithms.megolm
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
|
||||
import org.matrix.android.sdk.api.crypto.MXCryptoConfig
|
||||
import org.matrix.android.sdk.api.extensions.orTrue
|
||||
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.EventType
|
||||
@@ -53,6 +55,7 @@ internal class MXMegolmDecryption(private val userId: String,
|
||||
private val cryptoStore: IMXCryptoStore,
|
||||
private val sendToDeviceTask: SendToDeviceTask,
|
||||
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||
private val cryptoConfig: MXCryptoConfig,
|
||||
private val cryptoCoroutineScope: CoroutineScope
|
||||
) : IMXDecrypting, IMXWithHeldExtension {
|
||||
|
||||
@@ -68,7 +71,7 @@ internal class MXMegolmDecryption(private val userId: String,
|
||||
override fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult {
|
||||
// If cross signing is enabled, we don't send request until the keys are trusted
|
||||
// There could be a race effect here when xsigning is enabled, we should ensure that keys was downloaded once
|
||||
val requestOnFail = cryptoStore.getMyCrossSigningInfo()?.isTrusted() == true
|
||||
val requestOnFail = cryptoStore.getMyCrossSigningInfo()?.isTrusted().orTrue()
|
||||
return decryptEvent(event, timeline, requestOnFail)
|
||||
}
|
||||
|
||||
@@ -180,7 +183,7 @@ internal class MXMegolmDecryption(private val userId: String,
|
||||
val encryptedEventContent = event.content.toModel<EncryptedEventContent>()
|
||||
val senderDevice = encryptedEventContent?.deviceId ?: return
|
||||
|
||||
val recipients = if (event.senderId == userId || withHeld) {
|
||||
val recipients = if (event.senderId == userId || withHeld|| cryptoConfig.onlyRequestRoomKeysToMyDevices) {
|
||||
mapOf(
|
||||
userId to listOf("*")
|
||||
)
|
||||
|
Reference in New Issue
Block a user