mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-16 12:00:03 +03:00
Moar cleanup after rebase and before merge
This commit is contained in:
parent
91872fe673
commit
5c9750fb07
5 changed files with 35 additions and 41 deletions
|
@ -10,6 +10,7 @@ Improvements 🙌:
|
||||||
- Improve initial sync performance (#983)
|
- Improve initial sync performance (#983)
|
||||||
- PIP support for Jitsi call (#2418)
|
- PIP support for Jitsi call (#2418)
|
||||||
- Add tooltip for room quick actions
|
- Add tooltip for room quick actions
|
||||||
|
- Pre-share session keys when opening a room or start typing (#2771)
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Try to fix crash about UrlPreview (#2640)
|
- Try to fix crash about UrlPreview (#2640)
|
||||||
|
@ -41,7 +42,6 @@ Improvements 🙌:
|
||||||
- Improve room profile UX
|
- Improve room profile UX
|
||||||
- Upgrade Jitsi library from 2.9.3 to 3.1.0
|
- Upgrade Jitsi library from 2.9.3 to 3.1.0
|
||||||
- a11y improvements
|
- a11y improvements
|
||||||
- Pre-share session keys when opening a room or start typing (#2771)
|
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- VoIP : fix audio devices output
|
- VoIP : fix audio devices output
|
||||||
|
|
|
@ -33,7 +33,6 @@ interface RoomCryptoService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures all members of the room are loaded and outbound session keys are shared.
|
* Ensures all members of the room are loaded and outbound session keys are shared.
|
||||||
* Call this method according to [OutboundSessionKeySharingStrategy].
|
|
||||||
* If this method is not called, CryptoService will ensure it before sending events.
|
* If this method is not called, CryptoService will ensure it before sending events.
|
||||||
*/
|
*/
|
||||||
suspend fun prepareToEncrypt()
|
suspend fun prepareToEncrypt()
|
||||||
|
|
|
@ -18,8 +18,6 @@ package org.matrix.android.sdk.internal.crypto.algorithms.megolm
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.MatrixCallback
|
|
||||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
|
||||||
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.Content
|
import org.matrix.android.sdk.api.session.events.model.Content
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
|
@ -40,8 +38,6 @@ import org.matrix.android.sdk.internal.crypto.model.forEach
|
||||||
import org.matrix.android.sdk.internal.crypto.repository.WarnOnUnknownDeviceRepository
|
import org.matrix.android.sdk.internal.crypto.repository.WarnOnUnknownDeviceRepository
|
||||||
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.task.TaskExecutor
|
|
||||||
import org.matrix.android.sdk.internal.task.configureWith
|
|
||||||
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.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import org.matrix.android.sdk.internal.util.convertToUTF8
|
import org.matrix.android.sdk.internal.util.convertToUTF8
|
||||||
|
@ -55,11 +51,11 @@ internal class MXMegolmEncryption(
|
||||||
private val cryptoStore: IMXCryptoStore,
|
private val cryptoStore: IMXCryptoStore,
|
||||||
private val deviceListManager: DeviceListManager,
|
private val deviceListManager: DeviceListManager,
|
||||||
private val ensureOlmSessionsForDevicesAction: EnsureOlmSessionsForDevicesAction,
|
private val ensureOlmSessionsForDevicesAction: EnsureOlmSessionsForDevicesAction,
|
||||||
private val credentials: Credentials,
|
private val userId: String,
|
||||||
|
private val deviceId: String,
|
||||||
private val sendToDeviceTask: SendToDeviceTask,
|
private val sendToDeviceTask: SendToDeviceTask,
|
||||||
private val messageEncrypter: MessageEncrypter,
|
private val messageEncrypter: MessageEncrypter,
|
||||||
private val warnOnUnknownDevicesRepository: WarnOnUnknownDeviceRepository,
|
private val warnOnUnknownDevicesRepository: WarnOnUnknownDeviceRepository,
|
||||||
private val taskExecutor: TaskExecutor,
|
|
||||||
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||||
private val cryptoCoroutineScope: CoroutineScope
|
private val cryptoCoroutineScope: CoroutineScope
|
||||||
) : IMXEncrypting, IMXGroupEncryption {
|
) : IMXEncrypting, IMXGroupEncryption {
|
||||||
|
@ -282,7 +278,7 @@ internal class MXMegolmEncryption(
|
||||||
gossipingEventBuffer.add(
|
gossipingEventBuffer.add(
|
||||||
Event(
|
Event(
|
||||||
type = EventType.ROOM_KEY,
|
type = EventType.ROOM_KEY,
|
||||||
senderId = credentials.userId,
|
senderId = this.userId,
|
||||||
content = submap.apply {
|
content = submap.apply {
|
||||||
this["session_key"] = ""
|
this["session_key"] = ""
|
||||||
// we add a fake key for trail
|
// we add a fake key for trail
|
||||||
|
@ -310,8 +306,11 @@ internal class MXMegolmEncryption(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun notifyKeyWithHeld(targets: List<UserDevice>, sessionId: String, senderKey: String?, code: WithHeldCode) {
|
private suspend fun notifyKeyWithHeld(targets: List<UserDevice>,
|
||||||
Timber.i("## CRYPTO | notifyKeyWithHeld() :sending withheld key for $targets session:$sessionId and code $code ")
|
sessionId: String,
|
||||||
|
senderKey: String?,
|
||||||
|
code: WithHeldCode) {
|
||||||
|
Timber.i("## CRYPTO | notifyKeyWithHeld() :sending withheld key for $targets session:$sessionId and code $code")
|
||||||
val withHeldContent = RoomKeyWithHeldContent(
|
val withHeldContent = RoomKeyWithHeldContent(
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
senderKey = senderKey,
|
senderKey = senderKey,
|
||||||
|
@ -327,13 +326,11 @@ internal class MXMegolmEncryption(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
sendToDeviceTask.configureWith(params) {
|
try {
|
||||||
callback = object : MatrixCallback<Unit> {
|
sendToDeviceTask.execute(params)
|
||||||
override fun onFailure(failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
Timber.e("## CRYPTO | notifyKeyWithHeld() : Failed to notify withheld key for $targets session: $sessionId ")
|
Timber.e("## CRYPTO | notifyKeyWithHeld() : Failed to notify withheld key for $targets session: $sessionId ")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}.executeBy(taskExecutor)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -359,7 +356,7 @@ internal class MXMegolmEncryption(
|
||||||
|
|
||||||
// Include our device ID so that recipients can send us a
|
// Include our device ID so that recipients can send us a
|
||||||
// m.new_device message if they don't have our session key.
|
// m.new_device message if they don't have our session key.
|
||||||
map["device_id"] = credentials.deviceId!!
|
map["device_id"] = deviceId
|
||||||
session.useCount++
|
session.useCount++
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
|
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
|
||||||
import org.matrix.android.sdk.internal.crypto.DeviceListManager
|
import org.matrix.android.sdk.internal.crypto.DeviceListManager
|
||||||
import org.matrix.android.sdk.internal.crypto.MXOlmDevice
|
import org.matrix.android.sdk.internal.crypto.MXOlmDevice
|
||||||
import org.matrix.android.sdk.internal.crypto.actions.EnsureOlmSessionsForDevicesAction
|
import org.matrix.android.sdk.internal.crypto.actions.EnsureOlmSessionsForDevicesAction
|
||||||
|
@ -26,7 +25,8 @@ import org.matrix.android.sdk.internal.crypto.keysbackup.DefaultKeysBackupServic
|
||||||
import org.matrix.android.sdk.internal.crypto.repository.WarnOnUnknownDeviceRepository
|
import org.matrix.android.sdk.internal.crypto.repository.WarnOnUnknownDeviceRepository
|
||||||
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.task.TaskExecutor
|
import org.matrix.android.sdk.internal.di.DeviceId
|
||||||
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -36,29 +36,29 @@ internal class MXMegolmEncryptionFactory @Inject constructor(
|
||||||
private val cryptoStore: IMXCryptoStore,
|
private val cryptoStore: IMXCryptoStore,
|
||||||
private val deviceListManager: DeviceListManager,
|
private val deviceListManager: DeviceListManager,
|
||||||
private val ensureOlmSessionsForDevicesAction: EnsureOlmSessionsForDevicesAction,
|
private val ensureOlmSessionsForDevicesAction: EnsureOlmSessionsForDevicesAction,
|
||||||
private val credentials: Credentials,
|
@UserId private val userId: String,
|
||||||
|
@DeviceId private val deviceId: String?,
|
||||||
private val sendToDeviceTask: SendToDeviceTask,
|
private val sendToDeviceTask: SendToDeviceTask,
|
||||||
private val messageEncrypter: MessageEncrypter,
|
private val messageEncrypter: MessageEncrypter,
|
||||||
private val warnOnUnknownDevicesRepository: WarnOnUnknownDeviceRepository,
|
private val warnOnUnknownDevicesRepository: WarnOnUnknownDeviceRepository,
|
||||||
private val taskExecutor: TaskExecutor,
|
|
||||||
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||||
private val cryptoCoroutineScope: CoroutineScope) {
|
private val cryptoCoroutineScope: CoroutineScope) {
|
||||||
|
|
||||||
fun create(roomId: String): MXMegolmEncryption {
|
fun create(roomId: String): MXMegolmEncryption {
|
||||||
return MXMegolmEncryption(
|
return MXMegolmEncryption(
|
||||||
roomId,
|
roomId = roomId,
|
||||||
olmDevice,
|
olmDevice = olmDevice,
|
||||||
defaultKeysBackupService,
|
defaultKeysBackupService = defaultKeysBackupService,
|
||||||
cryptoStore,
|
cryptoStore = cryptoStore,
|
||||||
deviceListManager,
|
deviceListManager = deviceListManager,
|
||||||
ensureOlmSessionsForDevicesAction,
|
ensureOlmSessionsForDevicesAction = ensureOlmSessionsForDevicesAction,
|
||||||
credentials,
|
userId = userId,
|
||||||
sendToDeviceTask,
|
deviceId = deviceId!!,
|
||||||
messageEncrypter,
|
sendToDeviceTask = sendToDeviceTask,
|
||||||
warnOnUnknownDevicesRepository,
|
messageEncrypter = messageEncrypter,
|
||||||
taskExecutor,
|
warnOnUnknownDevicesRepository = warnOnUnknownDevicesRepository,
|
||||||
coroutineDispatchers,
|
coroutineDispatchers = coroutineDispatchers,
|
||||||
cryptoCoroutineScope
|
cryptoCoroutineScope = cryptoCoroutineScope
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,11 +195,11 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepareForEncryption() {
|
private fun prepareForEncryption() {
|
||||||
// check if there is not already a call made
|
// check if there is not already a call made, or if there has been an error
|
||||||
if (prepareToEncrypt !is Loading) {
|
if (prepareToEncrypt.shouldLoad) {
|
||||||
prepareToEncrypt = Loading()
|
prepareToEncrypt = Loading()
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
kotlin.runCatching {
|
runCatching {
|
||||||
room.prepareToEncrypt()
|
room.prepareToEncrypt()
|
||||||
}.fold({
|
}.fold({
|
||||||
prepareToEncrypt = Success(Unit)
|
prepareToEncrypt = Success(Unit)
|
||||||
|
@ -629,8 +629,6 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||||
if (action.focused) {
|
if (action.focused) {
|
||||||
// Should we add some rate limit here, or do it only once per model lifecycle?
|
// Should we add some rate limit here, or do it only once per model lifecycle?
|
||||||
prepareForEncryption()
|
prepareForEncryption()
|
||||||
} else {
|
|
||||||
// we could eventually cancel here :/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue