Merge pull request #2134 from vector-im/feature/fix_regression_verif_dm
Fix / Verification in DM not working
This commit is contained in:
commit
66b0e6c68f
@ -8,6 +8,7 @@ Improvements 🙌:
|
|||||||
- Add "show password" in import Megolm keys dialog
|
- Add "show password" in import Megolm keys dialog
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
|
- User Verification in DM not working
|
||||||
- Manual import of Megolm keys does back up the imported keys
|
- Manual import of Megolm keys does back up the imported keys
|
||||||
|
|
||||||
Translations 🗣:
|
Translations 🗣:
|
||||||
|
@ -25,6 +25,7 @@ import org.matrix.android.sdk.api.failure.shouldBeRetried
|
|||||||
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
||||||
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.internal.crypto.tasks.SendVerificationMessageTask
|
import org.matrix.android.sdk.internal.crypto.tasks.SendVerificationMessageTask
|
||||||
|
import org.matrix.android.sdk.internal.session.room.send.CancelSendTracker
|
||||||
import org.matrix.android.sdk.internal.worker.SessionWorkerParams
|
import org.matrix.android.sdk.internal.worker.SessionWorkerParams
|
||||||
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
|
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
|
||||||
import org.matrix.android.sdk.internal.worker.getSessionComponent
|
import org.matrix.android.sdk.internal.worker.getSessionComponent
|
||||||
@ -52,6 +53,8 @@ internal class SendVerificationMessageWorker(context: Context,
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var cryptoService: CryptoService
|
lateinit var cryptoService: CryptoService
|
||||||
|
|
||||||
|
@Inject lateinit var cancelSendTracker: CancelSendTracker
|
||||||
|
|
||||||
override suspend fun doWork(): Result {
|
override suspend fun doWork(): Result {
|
||||||
val errorOutputData = Data.Builder().putBoolean(OUTPUT_KEY_FAILED, true).build()
|
val errorOutputData = Data.Builder().putBoolean(OUTPUT_KEY_FAILED, true).build()
|
||||||
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
||||||
@ -63,7 +66,17 @@ internal class SendVerificationMessageWorker(context: Context,
|
|||||||
Timber.e("Unknown Session, cannot send message, sessionId: ${params.sessionId}")
|
Timber.e("Unknown Session, cannot send message, sessionId: ${params.sessionId}")
|
||||||
}
|
}
|
||||||
sessionComponent.inject(this)
|
sessionComponent.inject(this)
|
||||||
|
|
||||||
val localId = params.event.eventId ?: ""
|
val localId = params.event.eventId ?: ""
|
||||||
|
|
||||||
|
if (cancelSendTracker.isCancelRequestedFor(localId, params.event.roomId)) {
|
||||||
|
return Result.success()
|
||||||
|
.also {
|
||||||
|
cancelSendTracker.markCancelled(localId, params.event.roomId ?: "")
|
||||||
|
Timber.e("## SendEvent: Event sending has been cancelled $localId")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
val eventId = sendVerificationMessageTask.execute(
|
val eventId = sendVerificationMessageTask.execute(
|
||||||
SendVerificationMessageTask.Params(
|
SendVerificationMessageTask.Params(
|
||||||
|
@ -115,20 +115,31 @@ internal class VerificationTransportRoomMessage(
|
|||||||
val observer = object : Observer<List<WorkInfo>> {
|
val observer = object : Observer<List<WorkInfo>> {
|
||||||
override fun onChanged(workInfoList: List<WorkInfo>?) {
|
override fun onChanged(workInfoList: List<WorkInfo>?) {
|
||||||
workInfoList
|
workInfoList
|
||||||
?.filter { it.state == WorkInfo.State.SUCCEEDED }
|
|
||||||
?.firstOrNull { it.id == enqueueInfo.second }
|
?.firstOrNull { it.id == enqueueInfo.second }
|
||||||
?.let { wInfo ->
|
?.let { wInfo ->
|
||||||
if (SendVerificationMessageWorker.hasFailed(wInfo.outputData)) {
|
|
||||||
Timber.e("## SAS verification [${tx?.transactionId}] failed to send verification message in state : ${tx?.state}")
|
when (wInfo.state) {
|
||||||
tx?.cancel(onErrorReason)
|
WorkInfo.State.FAILED -> {
|
||||||
} else {
|
tx?.cancel(onErrorReason)
|
||||||
if (onDone != null) {
|
workLiveData.removeObserver(this)
|
||||||
onDone()
|
}
|
||||||
} else {
|
WorkInfo.State.SUCCEEDED -> {
|
||||||
tx?.state = nextState
|
if (SendVerificationMessageWorker.hasFailed(wInfo.outputData)) {
|
||||||
|
Timber.e("## SAS verification [${tx?.transactionId}] failed to send verification message in state : ${tx?.state}")
|
||||||
|
tx?.cancel(onErrorReason)
|
||||||
|
} else {
|
||||||
|
if (onDone != null) {
|
||||||
|
onDone()
|
||||||
|
} else {
|
||||||
|
tx?.state = nextState
|
||||||
|
}
|
||||||
|
}
|
||||||
|
workLiveData.removeObserver(this)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
// nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
workLiveData.removeObserver(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,7 +195,7 @@ internal class VerificationTransportRoomMessage(
|
|||||||
.build()
|
.build()
|
||||||
|
|
||||||
workManagerProvider.workManager
|
workManagerProvider.workManager
|
||||||
.beginUniqueWork("${roomId}_VerificationWork", ExistingWorkPolicy.APPEND, workRequest)
|
.beginUniqueWork("${roomId}_VerificationWork", ExistingWorkPolicy.APPEND_OR_REPLACE, workRequest)
|
||||||
.enqueue()
|
.enqueue()
|
||||||
|
|
||||||
// I cannot just listen to the given work request, because when used in a uniqueWork,
|
// I cannot just listen to the given work request, because when used in a uniqueWork,
|
||||||
@ -280,7 +291,7 @@ internal class VerificationTransportRoomMessage(
|
|||||||
.setBackoffCriteria(BackoffPolicy.LINEAR, 2_000L, TimeUnit.MILLISECONDS)
|
.setBackoffCriteria(BackoffPolicy.LINEAR, 2_000L, TimeUnit.MILLISECONDS)
|
||||||
.build()
|
.build()
|
||||||
return workManagerProvider.workManager
|
return workManagerProvider.workManager
|
||||||
.beginUniqueWork(uniqueQueueName(), ExistingWorkPolicy.APPEND, workRequest)
|
.beginUniqueWork(uniqueQueueName(), ExistingWorkPolicy.APPEND_OR_REPLACE, workRequest)
|
||||||
.enqueue() to workRequest.id
|
.enqueue() to workRequest.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ interface CheckNumberType {
|
|||||||
val numberAsString = reader.nextString()
|
val numberAsString = reader.nextString()
|
||||||
val decimal = BigDecimal(numberAsString)
|
val decimal = BigDecimal(numberAsString)
|
||||||
if (decimal.scale() <= 0) {
|
if (decimal.scale() <= 0) {
|
||||||
decimal.intValueExact()
|
decimal.longValueExact()
|
||||||
} else {
|
} else {
|
||||||
decimal.toDouble()
|
decimal.toDouble()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user