Create RequestIdHelper.createUniqueRequestId() for code clarity
This commit is contained in:
parent
0d408264e0
commit
a2180ec695
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.internal.crypto
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.events.model.LocalEcho
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
||||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||||
import org.matrix.android.sdk.internal.di.SessionId
|
import org.matrix.android.sdk.internal.di.SessionId
|
||||||
|
@ -27,6 +26,7 @@ import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.internal.crypto.tasks.createUniqueTxnId
|
import org.matrix.android.sdk.internal.crypto.tasks.createUniqueTxnId
|
||||||
|
import org.matrix.android.sdk.internal.crypto.util.RequestIdHelper
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ internal class OutgoingGossipingRequestManager @Inject constructor(
|
||||||
if (resend) {
|
if (resend) {
|
||||||
val reSendParams = SendGossipRequestWorker.Params(
|
val reSendParams = SendGossipRequestWorker.Params(
|
||||||
sessionId = sessionId,
|
sessionId = sessionId,
|
||||||
keyShareRequest = request.copy(requestId = LocalEcho.createLocalEchoId()),
|
keyShareRequest = request.copy(requestId = RequestIdHelper.createUniqueRequestId()),
|
||||||
txnId = createUniqueTxnId()
|
txnId = createUniqueTxnId()
|
||||||
)
|
)
|
||||||
val reSendWorkRequest = gossipingWorkManager.createWork<SendGossipRequestWorker>(WorkerParamsFactory.toData(reSendParams), true)
|
val reSendWorkRequest = gossipingWorkManager.createWork<SendGossipRequestWorker>(WorkerParamsFactory.toData(reSendParams), true)
|
||||||
|
|
|
@ -27,7 +27,6 @@ import io.realm.Sort
|
||||||
import io.realm.kotlin.where
|
import io.realm.kotlin.where
|
||||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
|
||||||
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.LocalEcho
|
|
||||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
import org.matrix.android.sdk.api.util.toOptional
|
import org.matrix.android.sdk.api.util.toOptional
|
||||||
|
@ -89,6 +88,7 @@ import org.matrix.android.sdk.internal.crypto.store.db.query.delete
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.query.get
|
import org.matrix.android.sdk.internal.crypto.store.db.query.get
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.query.getById
|
import org.matrix.android.sdk.internal.crypto.store.db.query.getById
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.query.getOrCreate
|
import org.matrix.android.sdk.internal.crypto.store.db.query.getOrCreate
|
||||||
|
import org.matrix.android.sdk.internal.crypto.util.RequestIdHelper
|
||||||
import org.matrix.android.sdk.internal.database.mapper.ContentMapper
|
import org.matrix.android.sdk.internal.database.mapper.ContentMapper
|
||||||
import org.matrix.android.sdk.internal.database.tools.RealmDebugTools
|
import org.matrix.android.sdk.internal.database.tools.RealmDebugTools
|
||||||
import org.matrix.android.sdk.internal.di.CryptoDatabase
|
import org.matrix.android.sdk.internal.di.CryptoDatabase
|
||||||
|
@ -1109,7 +1109,7 @@ internal class RealmCryptoStore @Inject constructor(
|
||||||
|
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
request = realm.createObject(OutgoingGossipingRequestEntity::class.java).apply {
|
request = realm.createObject(OutgoingGossipingRequestEntity::class.java).apply {
|
||||||
this.requestId = LocalEcho.createLocalEchoId()
|
this.requestId = RequestIdHelper.createUniqueRequestId()
|
||||||
this.setRecipients(recipients)
|
this.setRecipients(recipients)
|
||||||
this.requestState = OutgoingGossipingRequestState.UNSENT
|
this.requestState = OutgoingGossipingRequestState.UNSENT
|
||||||
this.type = GossipRequestType.KEY
|
this.type = GossipRequestType.KEY
|
||||||
|
@ -1139,7 +1139,7 @@ internal class RealmCryptoStore @Inject constructor(
|
||||||
this.type = GossipRequestType.SECRET
|
this.type = GossipRequestType.SECRET
|
||||||
setRecipients(recipients)
|
setRecipients(recipients)
|
||||||
this.requestState = OutgoingGossipingRequestState.UNSENT
|
this.requestState = OutgoingGossipingRequestState.UNSENT
|
||||||
this.requestId = LocalEcho.createLocalEchoId()
|
this.requestId = RequestIdHelper.createUniqueRequestId()
|
||||||
this.requestedInfoStr = secretName
|
this.requestedInfoStr = secretName
|
||||||
}.toOutgoingGossipingRequest() as? OutgoingSecretRequest
|
}.toOutgoingGossipingRequest() as? OutgoingSecretRequest
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 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.internal.crypto.util
|
||||||
|
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
internal object RequestIdHelper {
|
||||||
|
fun createUniqueRequestId() = "req_" + UUID.randomUUID().toString()
|
||||||
|
}
|
Loading…
Reference in New Issue