cleaning
This commit is contained in:
parent
dd991e759e
commit
b3d8b1527c
@ -112,7 +112,6 @@ android {
|
|||||||
// Disabled for now, there are too many errors. Could be handled in another dedicated PR
|
// Disabled for now, there are too many errors. Could be handled in another dedicated PR
|
||||||
// '-Xexplicit-api=strict', // or warning
|
// '-Xexplicit-api=strict', // or warning
|
||||||
"-opt-in=kotlin.RequiresOptIn",
|
"-opt-in=kotlin.RequiresOptIn",
|
||||||
"-opt-in=kotlin.OptIn",
|
|
||||||
// Opt in for kotlinx.coroutines.FlowPreview
|
// Opt in for kotlinx.coroutines.FlowPreview
|
||||||
"-opt-in=kotlinx.coroutines.FlowPreview",
|
"-opt-in=kotlinx.coroutines.FlowPreview",
|
||||||
]
|
]
|
||||||
|
@ -201,7 +201,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLiveEvent(roomId: String, event: Event, isInitialSync: Boolean) {
|
override fun onLiveEvent(roomId: String, event: Event, initialSync: Boolean) {
|
||||||
// handle state events
|
// handle state events
|
||||||
if (event.isStateEvent()) {
|
if (event.isStateEvent()) {
|
||||||
when (event.type) {
|
when (event.type) {
|
||||||
@ -212,7 +212,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle verification
|
// handle verification
|
||||||
if (!isInitialSync) {
|
if (!initialSync) {
|
||||||
if (event.type != null && verificationMessageProcessor.shouldProcess(event.type)) {
|
if (event.type != null && verificationMessageProcessor.shouldProcess(event.type)) {
|
||||||
cryptoCoroutineScope.launch(coroutineDispatchers.dmVerif) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.dmVerif) {
|
||||||
verificationMessageProcessor.process(roomId, event)
|
verificationMessageProcessor.process(roomId, event)
|
||||||
|
@ -92,25 +92,20 @@ internal class EnsureOlmSessionsForDevicesAction @Inject constructor(
|
|||||||
|
|
||||||
// Let's now claim one time keys
|
// Let's now claim one time keys
|
||||||
val claimParams = ClaimOneTimeKeysForUsersDeviceTask.Params(usersDevicesToClaim.map)
|
val claimParams = ClaimOneTimeKeysForUsersDeviceTask.Params(usersDevicesToClaim.map)
|
||||||
val oneTimeKeys = withContext(coroutineDispatchers.io) {
|
val oneTimeKeysForUsers = withContext(coroutineDispatchers.io) {
|
||||||
oneTimeKeysForUsersDeviceTask.executeRetry(claimParams, ONE_TIME_KEYS_RETRY_COUNT)
|
oneTimeKeysForUsersDeviceTask.executeRetry(claimParams, ONE_TIME_KEYS_RETRY_COUNT)
|
||||||
}.oneTimeKeys.let { oneTimeKeys ->
|
}
|
||||||
val map = MXUsersDevicesMap<MXKey>()
|
val oneTimeKeys = MXUsersDevicesMap<MXKey>()
|
||||||
oneTimeKeys?.let { oneTimeKeys ->
|
for ((userId, mapByUserId) in oneTimeKeysForUsers.oneTimeKeys.orEmpty()) {
|
||||||
for ((userId, mapByUserId) in oneTimeKeys) {
|
|
||||||
for ((deviceId, deviceKey) in mapByUserId) {
|
for ((deviceId, deviceKey) in mapByUserId) {
|
||||||
val mxKey = MXKey.from(deviceKey)
|
val mxKey = MXKey.from(deviceKey)
|
||||||
|
|
||||||
if (mxKey != null) {
|
if (mxKey != null) {
|
||||||
map.setObject(userId, deviceId, mxKey)
|
oneTimeKeys.setObject(userId, deviceId, mxKey)
|
||||||
} else {
|
} else {
|
||||||
Timber.e("## claimOneTimeKeysForUsersDevices : fail to create a MXKey")
|
Timber.e("## claimOneTimeKeysForUsersDevices : fail to create a MXKey")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
map
|
|
||||||
}
|
|
||||||
|
|
||||||
// let now start olm session using the new otks
|
// let now start olm session using the new otks
|
||||||
devicesToCreateSessionWith.forEach { deviceInfo ->
|
devicesToCreateSessionWith.forEach { deviceInfo ->
|
||||||
|
@ -77,8 +77,7 @@ internal class VerificationTransportLayer @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun sendInRoom(localId: String = LocalEcho.createLocalEchoId(),
|
suspend fun sendInRoom(type: String,
|
||||||
type: String,
|
|
||||||
roomId: String,
|
roomId: String,
|
||||||
content: Content): String {
|
content: Content): String {
|
||||||
val event = createEventAndLocalEcho(
|
val event = createEventAndLocalEcho(
|
||||||
|
@ -522,9 +522,7 @@ internal class RealmCryptoStore @Inject constructor(
|
|||||||
val key = it.keyBackupRecoveryKey
|
val key = it.keyBackupRecoveryKey
|
||||||
val version = it.keyBackupRecoveryKeyVersion
|
val version = it.keyBackupRecoveryKeyVersion
|
||||||
if (!key.isNullOrBlank() && !version.isNullOrBlank()) {
|
if (!key.isNullOrBlank() && !version.isNullOrBlank()) {
|
||||||
BackupUtils.recoveryKeyFromBase58(key)?.let { key ->
|
SavedKeyBackupKeyInfo(recoveryKey = BackupUtils.recoveryKeyFromBase58(key), version = version)
|
||||||
SavedKeyBackupKeyInfo(recoveryKey = key, version = version)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
@ -95,12 +95,13 @@ internal class DefaultSendEventTask @Inject constructor(
|
|||||||
@Throws
|
@Throws
|
||||||
private suspend fun handleEncryption(params: SendEventTask.Params): Event {
|
private suspend fun handleEncryption(params: SendEventTask.Params): Event {
|
||||||
if (params.encrypt && !params.event.isEncrypted()) {
|
if (params.encrypt && !params.event.isEncrypted()) {
|
||||||
val params = EncryptEventTask.Params(
|
return encryptEventTask.execute(
|
||||||
|
EncryptEventTask.Params(
|
||||||
params.event.roomId ?: "",
|
params.event.roomId ?: "",
|
||||||
params.event,
|
params.event,
|
||||||
listOf("m.relates_to")
|
listOf("m.relates_to")
|
||||||
)
|
)
|
||||||
return encryptEventTask.execute(params)
|
)
|
||||||
}
|
}
|
||||||
return params.event
|
return params.event
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ internal class SyncResponseHandler @Inject constructor(
|
|||||||
|
|
||||||
// Handle the to device events before the room ones
|
// Handle the to device events before the room ones
|
||||||
// to ensure to decrypt them properly
|
// to ensure to decrypt them properly
|
||||||
handleToDevice(syncResponse, reporter)
|
handleToDevice(syncResponse)
|
||||||
|
|
||||||
val aggregator = SyncResponsePostTreatmentAggregator()
|
val aggregator = SyncResponsePostTreatmentAggregator()
|
||||||
|
|
||||||
@ -112,11 +112,10 @@ internal class SyncResponseHandler @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun handleToDevice(syncResponse: SyncResponse, reporter: ProgressReporter?) {
|
private suspend fun handleToDevice(syncResponse: SyncResponse) {
|
||||||
relevantPlugins.measureSpan("task", "handle_to_device") {
|
relevantPlugins.measureSpan("task", "handle_to_device") {
|
||||||
measureTimeMillis {
|
measureTimeMillis {
|
||||||
Timber.v("Handle toDevice")
|
Timber.v("Handle toDevice")
|
||||||
|
|
||||||
cryptoService.receiveSyncChanges(
|
cryptoService.receiveSyncChanges(
|
||||||
syncResponse.toDevice,
|
syncResponse.toDevice,
|
||||||
syncResponse.deviceLists,
|
syncResponse.deviceLists,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -17,6 +17,7 @@
|
|||||||
package org.matrix.android.sdk.internal.coroutines.builder
|
package org.matrix.android.sdk.internal.coroutines.builder
|
||||||
|
|
||||||
import kotlinx.coroutines.CompletableDeferred
|
import kotlinx.coroutines.CompletableDeferred
|
||||||
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.channels.ProducerScope
|
import kotlinx.coroutines.channels.ProducerScope
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +35,7 @@ import kotlinx.coroutines.channels.ProducerScope
|
|||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
internal fun <T> ProducerScope<T>.safeInvokeOnClose(handler: (cause: Throwable?) -> Unit): CompletableDeferred<Unit> {
|
internal fun <T> ProducerScope<T>.safeInvokeOnClose(handler: (cause: Throwable?) -> Unit): CompletableDeferred<Unit> {
|
||||||
val onClose = CompletableDeferred<Unit>()
|
val onClose = CompletableDeferred<Unit>()
|
||||||
invokeOnClose {
|
invokeOnClose {
|
@ -772,7 +772,7 @@ internal class OlmMachine @Inject constructor(
|
|||||||
UserTrustResult.Success
|
UserTrustResult.Success
|
||||||
} catch (failure: Exception) {
|
} catch (failure: Exception) {
|
||||||
// KeyImportError?
|
// KeyImportError?
|
||||||
UserTrustResult.Failure(failure.localizedMessage)
|
UserTrustResult.Failure(failure.localizedMessage ?: "Unknown Error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
withContext(coroutineDispatchers.main) {
|
withContext(coroutineDispatchers.main) {
|
||||||
|
@ -74,7 +74,7 @@ class PushersManager @Inject constructor(
|
|||||||
deviceDisplayName = getDeviceInfoUseCase.execute().displayName().orEmpty(),
|
deviceDisplayName = getDeviceInfoUseCase.execute().displayName().orEmpty(),
|
||||||
url = gateway,
|
url = gateway,
|
||||||
enabled = true,
|
enabled = true,
|
||||||
deviceId = activeSessionHolder.getActiveSession().sessionParams.deviceId ?: "MOBILE",
|
deviceId = activeSessionHolder.getActiveSession().sessionParams.deviceId,
|
||||||
append = false,
|
append = false,
|
||||||
withEventIdOnly = true,
|
withEventIdOnly = true,
|
||||||
)
|
)
|
||||||
@ -87,7 +87,7 @@ class PushersManager @Inject constructor(
|
|||||||
lang = localeProvider.current().language,
|
lang = localeProvider.current().language,
|
||||||
emailBranding = appName,
|
emailBranding = appName,
|
||||||
appDisplayName = appName,
|
appDisplayName = appName,
|
||||||
deviceDisplayName = currentSession.sessionParams.deviceId ?: "MOBILE"
|
deviceDisplayName = currentSession.sessionParams.deviceId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +302,7 @@ class SelfVerificationController @Inject constructor(
|
|||||||
private fun renderTransaction(state: SelfVerificationViewState, transaction: VerificationTransactionData) {
|
private fun renderTransaction(state: SelfVerificationViewState, transaction: VerificationTransactionData) {
|
||||||
when (transaction) {
|
when (transaction) {
|
||||||
is VerificationTransactionData.QrTransactionData -> {
|
is VerificationTransactionData.QrTransactionData -> {
|
||||||
|
TODO("Render QR transaction $state")
|
||||||
// TODO
|
// TODO
|
||||||
// renderQrTransaction(transaction, state.otherUserMxItem)
|
// renderQrTransaction(transaction, state.otherUserMxItem)
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ class UserVerificationController @Inject constructor(
|
|||||||
|
|
||||||
private fun renderQrTransaction(transaction: VerificationTransactionData.QrTransactionData, otherUserItem: MatrixItem) {
|
private fun renderQrTransaction(transaction: VerificationTransactionData.QrTransactionData, otherUserItem: MatrixItem) {
|
||||||
val host = this
|
val host = this
|
||||||
when (val txState = transaction.state) {
|
when (transaction.state) {
|
||||||
QRCodeVerificationState.Reciprocated -> {
|
QRCodeVerificationState.Reciprocated -> {
|
||||||
// we are waiting for confirmation from the other side
|
// we are waiting for confirmation from the other side
|
||||||
bottomSheetVerificationNoticeItem {
|
bottomSheetVerificationNoticeItem {
|
||||||
|
@ -254,7 +254,8 @@ class DefaultNavigator @Inject constructor(
|
|||||||
override fun requestSessionVerification(context: Context, otherSessionId: String) {
|
override fun requestSessionVerification(context: Context, otherSessionId: String) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
val session = sessionHolder.getSafeActiveSession() ?: return@launch
|
val session = sessionHolder.getSafeActiveSession() ?: return@launch
|
||||||
val pr = session.cryptoService().verificationService().requestSelfKeyVerification(
|
// val pr =
|
||||||
|
session.cryptoService().verificationService().requestSelfKeyVerification(
|
||||||
supportedVerificationMethodsProvider.provide()
|
supportedVerificationMethodsProvider.provide()
|
||||||
)
|
)
|
||||||
if (context is AppCompatActivity) {
|
if (context is AppCompatActivity) {
|
||||||
@ -269,7 +270,8 @@ class DefaultNavigator @Inject constructor(
|
|||||||
|
|
||||||
override fun requestSelfSessionVerification(context: Context) {
|
override fun requestSelfSessionVerification(context: Context) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
val session = sessionHolder.getSafeActiveSession() ?: return@launch
|
// TODO
|
||||||
|
// val session = sessionHolder.getSafeActiveSession() ?: return@launch
|
||||||
// val otherSessions = session.cryptoService()
|
// val otherSessions = session.cryptoService()
|
||||||
// .getCryptoDeviceInfoList(session.myUserId)
|
// .getCryptoDeviceInfoList(session.myUserId)
|
||||||
// .filter { it.deviceId != session.sessionParams.deviceId }
|
// .filter { it.deviceId != session.sessionParams.deviceId }
|
||||||
|
@ -261,7 +261,7 @@ class BugReporter @Inject constructor(
|
|||||||
|
|
||||||
activeSessionHolder.getSafeActiveSession()?.let { session ->
|
activeSessionHolder.getSafeActiveSession()?.let { session ->
|
||||||
userId = session.myUserId
|
userId = session.myUserId
|
||||||
deviceId = session.sessionParams.deviceId ?: "undefined"
|
deviceId = session.sessionParams.deviceId
|
||||||
olmVersion = session.cryptoService().getCryptoVersion(context, true)
|
olmVersion = session.cryptoService().getCryptoVersion(context, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ class DevicesViewModel @AssistedInject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val hasAccountCrossSigning = session.cryptoService().crossSigningService().isCrossSigningInitialized()
|
val hasAccountCrossSigning = session.cryptoService().crossSigningService().isCrossSigningInitialized()
|
||||||
val accountCrossSigningIsTrusted = session.cryptoService().crossSigningService().isCrossSigningVerified()
|
val accountCrossSigningIsTrusted = session.cryptoService().crossSigningService().isCrossSigningVerified()
|
||||||
val myDeviceId = session.sessionParams.deviceId ?: ""
|
val myDeviceId = session.sessionParams.deviceId
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
hasAccountCrossSigning = hasAccountCrossSigning,
|
hasAccountCrossSigning = hasAccountCrossSigning,
|
||||||
@ -279,8 +279,8 @@ class DevicesViewModel @AssistedInject constructor(
|
|||||||
supportedVerificationMethodsProvider.provide(),
|
supportedVerificationMethodsProvider.provide(),
|
||||||
session.myUserId,
|
session.myUserId,
|
||||||
action.deviceId
|
action.deviceId
|
||||||
)?.transactionId
|
).transactionId
|
||||||
?.let {
|
.let {
|
||||||
_viewEvents.post(
|
_viewEvents.post(
|
||||||
DevicesViewEvents.ShowVerifyDevice(
|
DevicesViewEvents.ShowVerifyDevice(
|
||||||
session.myUserId,
|
session.myUserId,
|
||||||
|
@ -33,7 +33,7 @@ class DisableNotificationsForCurrentSessionUseCase @Inject constructor(
|
|||||||
|
|
||||||
suspend fun execute() {
|
suspend fun execute() {
|
||||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
val deviceId = session.sessionParams.deviceId ?: return
|
val deviceId = session.sessionParams.deviceId
|
||||||
if (checkIfCanTogglePushNotificationsViaPusherUseCase.execute(session)) {
|
if (checkIfCanTogglePushNotificationsViaPusherUseCase.execute(session)) {
|
||||||
togglePushNotificationUseCase.execute(deviceId, enabled = false)
|
togglePushNotificationUseCase.execute(deviceId, enabled = false)
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,7 +45,7 @@ class EnableNotificationsForCurrentSessionUseCase @Inject constructor(
|
|||||||
|
|
||||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
if (checkIfCanTogglePushNotificationsViaPusherUseCase.execute(session)) {
|
if (checkIfCanTogglePushNotificationsViaPusherUseCase.execute(session)) {
|
||||||
val deviceId = session.sessionParams.deviceId ?: return
|
val deviceId = session.sessionParams.deviceId
|
||||||
togglePushNotificationUseCase.execute(deviceId, enabled = true)
|
togglePushNotificationUseCase.execute(deviceId, enabled = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user