mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Rename to respect naming convention #3
This commit is contained in:
parent
5d0e917f04
commit
fb858bc112
9 changed files with 42 additions and 42 deletions
|
@ -27,7 +27,7 @@ import java.util.UUID
|
|||
data class PendingVerificationRequest(
|
||||
val ageLocalTs: Long,
|
||||
val isIncoming: Boolean = false,
|
||||
val localID: String = UUID.randomUUID().toString(),
|
||||
val localId: String = UUID.randomUUID().toString(),
|
||||
val otherUserId: String,
|
||||
val roomId: String?,
|
||||
val transactionId: String? = null,
|
||||
|
|
|
@ -41,22 +41,22 @@ internal class DefaultSendVerificationMessageTask @Inject constructor(
|
|||
|
||||
override suspend fun execute(params: SendVerificationMessageTask.Params): String {
|
||||
val event = handleEncryption(params)
|
||||
val localID = event.eventId!!
|
||||
val localId = event.eventId!!
|
||||
|
||||
try {
|
||||
localEchoUpdater.updateSendState(localID, SendState.SENDING)
|
||||
localEchoUpdater.updateSendState(localId, SendState.SENDING)
|
||||
val executeRequest = executeRequest<SendResponse>(eventBus) {
|
||||
apiCall = roomAPI.send(
|
||||
localID,
|
||||
localId,
|
||||
roomId = event.roomId ?: "",
|
||||
content = event.content,
|
||||
eventType = event.type
|
||||
)
|
||||
}
|
||||
localEchoUpdater.updateSendState(localID, SendState.SENT)
|
||||
localEchoUpdater.updateSendState(localId, SendState.SENT)
|
||||
return executeRequest.eventId
|
||||
} catch (e: Throwable) {
|
||||
localEchoUpdater.updateSendState(localID, SendState.UNDELIVERED)
|
||||
localEchoUpdater.updateSendState(localId, SendState.UNDELIVERED)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
otherUserId = senderId, // requestInfo.toUserId,
|
||||
roomId = null,
|
||||
transactionId = validRequestInfo.transactionId,
|
||||
localID = validRequestInfo.transactionId,
|
||||
localId = validRequestInfo.transactionId,
|
||||
requestInfo = validRequestInfo
|
||||
)
|
||||
requestsForUser.add(pendingVerificationRequest)
|
||||
|
@ -343,7 +343,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
otherUserId = senderId, // requestInfo.toUserId,
|
||||
roomId = event.roomId,
|
||||
transactionId = event.eventId,
|
||||
localID = event.eventId!!,
|
||||
localId = event.eventId!!,
|
||||
requestInfo = validRequestInfo
|
||||
)
|
||||
requestsForUser.add(pendingVerificationRequest)
|
||||
|
@ -1005,13 +1005,13 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
val localID = localId ?: LocalEcho.createLocalEchoId()
|
||||
val validLocalId = localId ?: LocalEcho.createLocalEchoId()
|
||||
|
||||
val verificationRequest = PendingVerificationRequest(
|
||||
ageLocalTs = System.currentTimeMillis(),
|
||||
isIncoming = false,
|
||||
roomId = roomId,
|
||||
localID = localID,
|
||||
localId = validLocalId,
|
||||
otherUserId = otherUserId
|
||||
)
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
}
|
||||
.distinct()
|
||||
|
||||
transport.sendVerificationRequest(methodValues, localID, otherUserId, roomId, null) { syncedId, info ->
|
||||
transport.sendVerificationRequest(methodValues, validLocalId, otherUserId, roomId, null) { syncedId, info ->
|
||||
// We need to update with the syncedID
|
||||
updatePendingRequest(verificationRequest.copy(
|
||||
transactionId = syncedId,
|
||||
|
@ -1071,14 +1071,14 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
val localID = LocalEcho.createLocalEchoId()
|
||||
val localId = LocalEcho.createLocalEchoId()
|
||||
|
||||
val verificationRequest = PendingVerificationRequest(
|
||||
transactionId = localID,
|
||||
transactionId = localId,
|
||||
ageLocalTs = System.currentTimeMillis(),
|
||||
isIncoming = false,
|
||||
roomId = null,
|
||||
localID = localID,
|
||||
localId = localId,
|
||||
otherUserId = otherUserId,
|
||||
targetDevices = targetDevices
|
||||
)
|
||||
|
@ -1099,7 +1099,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
}
|
||||
.distinct()
|
||||
|
||||
transport.sendVerificationRequest(methodValues, localID, otherUserId, null, targetDevices) { _, info ->
|
||||
transport.sendVerificationRequest(methodValues, localId, otherUserId, null, targetDevices) { _, info ->
|
||||
// Nothing special to do in to device mode
|
||||
updatePendingRequest(verificationRequest.copy(
|
||||
// localId stays different
|
||||
|
@ -1131,7 +1131,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
}
|
||||
val index = requestsForUser.indexOfFirst {
|
||||
it.transactionId == updated.transactionId
|
||||
|| it.transactionId == null && it.localID == updated.localID
|
||||
|| it.transactionId == null && it.localId == updated.localId
|
||||
}
|
||||
if (index != -1) {
|
||||
requestsForUser.removeAt(index)
|
||||
|
|
|
@ -35,7 +35,7 @@ internal interface VerificationTransport {
|
|||
onDone: (() -> Unit)?)
|
||||
|
||||
fun sendVerificationRequest(supportedMethods: List<String>,
|
||||
localID: String,
|
||||
localId: String,
|
||||
otherUserId: String,
|
||||
roomId: String?,
|
||||
toDevices: List<String>?,
|
||||
|
|
|
@ -137,7 +137,7 @@ internal class VerificationTransportRoomMessage(
|
|||
}
|
||||
|
||||
override fun sendVerificationRequest(supportedMethods: List<String>,
|
||||
localID: String,
|
||||
localId: String,
|
||||
otherUserId: String,
|
||||
roomId: String?,
|
||||
toDevices: List<String>?,
|
||||
|
@ -163,7 +163,7 @@ internal class VerificationTransportRoomMessage(
|
|||
val content = info.toContent()
|
||||
|
||||
val event = createEventAndLocalEcho(
|
||||
localID,
|
||||
localId,
|
||||
EventType.MESSAGE,
|
||||
roomId,
|
||||
content
|
||||
|
@ -198,8 +198,8 @@ internal class VerificationTransportRoomMessage(
|
|||
?.let { wInfo ->
|
||||
if (wInfo.outputData.getBoolean("failed", false)) {
|
||||
callback(null, null)
|
||||
} else if (wInfo.outputData.getString(localID) != null) {
|
||||
callback(wInfo.outputData.getString(localID), validInfo)
|
||||
} else if (wInfo.outputData.getString(localId) != null) {
|
||||
callback(wInfo.outputData.getString(localId), validInfo)
|
||||
} else {
|
||||
callback(null, null)
|
||||
}
|
||||
|
@ -327,15 +327,15 @@ internal class VerificationTransportRoomMessage(
|
|||
)
|
||||
}
|
||||
|
||||
private fun createEventAndLocalEcho(localID: String = LocalEcho.createLocalEchoId(), type: String, roomId: String, content: Content): Event {
|
||||
private fun createEventAndLocalEcho(localId: String = LocalEcho.createLocalEchoId(), type: String, roomId: String, content: Content): Event {
|
||||
return Event(
|
||||
roomId = roomId,
|
||||
originServerTs = System.currentTimeMillis(),
|
||||
senderId = userId,
|
||||
eventId = localID,
|
||||
eventId = localId,
|
||||
type = type,
|
||||
content = content,
|
||||
unsignedData = UnsignedData(age = null, transactionId = localID)
|
||||
unsignedData = UnsignedData(age = null, transactionId = localId)
|
||||
).also {
|
||||
localEchoEventFactory.createLocalEcho(it)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ internal class VerificationTransportToDevice(
|
|||
) : VerificationTransport {
|
||||
|
||||
override fun sendVerificationRequest(supportedMethods: List<String>,
|
||||
localID: String,
|
||||
localId: String,
|
||||
otherUserId: String,
|
||||
roomId: String?,
|
||||
toDevices: List<String>?,
|
||||
|
@ -55,7 +55,7 @@ internal class VerificationTransportToDevice(
|
|||
Timber.d("## SAS sending verification request with supported methods: $supportedMethods")
|
||||
val contentMap = MXUsersDevicesMap<Any>()
|
||||
val validKeyReq = ValidVerificationInfoRequest(
|
||||
transactionId = localID,
|
||||
transactionId = localId,
|
||||
fromDevice = myDeviceId ?: "",
|
||||
methods = supportedMethods,
|
||||
timestamp = System.currentTimeMillis()
|
||||
|
@ -70,11 +70,11 @@ internal class VerificationTransportToDevice(
|
|||
contentMap.setObject(otherUserId, it, keyReq)
|
||||
}
|
||||
sendToDeviceTask
|
||||
.configureWith(SendToDeviceTask.Params(MessageType.MSGTYPE_VERIFICATION_REQUEST, contentMap, localID)) {
|
||||
.configureWith(SendToDeviceTask.Params(MessageType.MSGTYPE_VERIFICATION_REQUEST, contentMap, localId)) {
|
||||
this.callback = object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(data: Unit) {
|
||||
Timber.v("## verification [$tx.transactionId] send toDevice request success")
|
||||
callback.invoke(localID, validKeyReq)
|
||||
callback.invoke(localId, validKeyReq)
|
||||
}
|
||||
|
||||
override fun onFailure(failure: Throwable) {
|
||||
|
|
|
@ -335,25 +335,25 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
}
|
||||
|
||||
private fun createEvent(roomId: String, content: Any? = null): Event {
|
||||
val localID = LocalEcho.createLocalEchoId()
|
||||
val localId = LocalEcho.createLocalEchoId()
|
||||
return Event(
|
||||
roomId = roomId,
|
||||
originServerTs = dummyOriginServerTs(),
|
||||
senderId = userId,
|
||||
eventId = localID,
|
||||
eventId = localId,
|
||||
type = EventType.MESSAGE,
|
||||
content = content.toContent(),
|
||||
unsignedData = UnsignedData(age = null, transactionId = localID)
|
||||
unsignedData = UnsignedData(age = null, transactionId = localId)
|
||||
)
|
||||
}
|
||||
|
||||
fun createVerificationRequest(roomId: String, fromDevice: String, toUserId: String, methods: List<String>): Event {
|
||||
val localID = LocalEcho.createLocalEchoId()
|
||||
val localId = LocalEcho.createLocalEchoId()
|
||||
return Event(
|
||||
roomId = roomId,
|
||||
originServerTs = dummyOriginServerTs(),
|
||||
senderId = userId,
|
||||
eventId = localID,
|
||||
eventId = localId,
|
||||
type = EventType.MESSAGE,
|
||||
content = MessageVerificationRequestContent(
|
||||
body = stringProvider.getString(R.string.key_verification_request_fallback_message, userId),
|
||||
|
@ -362,7 +362,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
timestamp = System.currentTimeMillis(),
|
||||
methods = methods
|
||||
).toContent(),
|
||||
unsignedData = UnsignedData(age = null, transactionId = localID)
|
||||
unsignedData = UnsignedData(age = null, transactionId = localId)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -469,16 +469,16 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
}
|
||||
*/
|
||||
fun createRedactEvent(roomId: String, eventId: String, reason: String?): Event {
|
||||
val localID = LocalEcho.createLocalEchoId()
|
||||
val localId = LocalEcho.createLocalEchoId()
|
||||
return Event(
|
||||
roomId = roomId,
|
||||
originServerTs = dummyOriginServerTs(),
|
||||
senderId = userId,
|
||||
eventId = localID,
|
||||
eventId = localId,
|
||||
type = EventType.REDACTION,
|
||||
redacts = eventId,
|
||||
content = reason?.let { mapOf("reason" to it).toContent() },
|
||||
unsignedData = UnsignedData(age = null, transactionId = localID)
|
||||
unsignedData = UnsignedData(age = null, transactionId = localId)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() {
|
|||
putParcelable(MvRx.KEY_ARG, VerificationArgs(
|
||||
state.otherUserMxItem?.id ?: "",
|
||||
// If it was outgoing it.transaction id would be null, but the pending request
|
||||
// would be updated (from localID to txId)
|
||||
// would be updated (from localId to txId)
|
||||
state.pendingRequest.invoke()?.transactionId ?: state.transactionId))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -155,10 +155,10 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
|
|||
when (action) {
|
||||
is VerificationAction.RequestVerificationByDM -> {
|
||||
if (roomId == null) {
|
||||
val localID = LocalEcho.createLocalEchoId()
|
||||
val localId = LocalEcho.createLocalEchoId()
|
||||
setState {
|
||||
copy(
|
||||
pendingLocalId = localID,
|
||||
pendingLocalId = localId,
|
||||
pendingRequest = Loading()
|
||||
)
|
||||
}
|
||||
|
@ -387,8 +387,8 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
if (pr.localID == state.pendingLocalId
|
||||
|| pr.localID == state.pendingRequest.invoke()?.localID
|
||||
if (pr.localId == state.pendingLocalId
|
||||
|| pr.localId == state.pendingRequest.invoke()?.localId
|
||||
|| state.pendingRequest.invoke()?.transactionId == pr.transactionId) {
|
||||
setState {
|
||||
copy(pendingRequest = Success(pr))
|
||||
|
|
Loading…
Reference in a new issue