Skip to content

Commit

Permalink
Rename to respect naming convention #2
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Mar 6, 2020
1 parent e420070 commit 5d0e917
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package im.vector.matrix.android.api.session.crypto.verification

data class ValidVerificationInfoReady(
val transactionID: String,
val transactionId: String,
val fromDevice: String,
val methods: List<String>
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package im.vector.matrix.android.api.session.crypto.verification

data class ValidVerificationInfoRequest(
val transactionID: String,
val transactionId: String,
val fromDevice: String,
val methods: List<String>,
val timestamp: Long?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ internal data class MessageVerificationDoneContent(
}

internal data class ValidVerificationDone(
val transactionID: String
val transactionId: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ internal class DefaultOutgoingSASDefaultVerificationTransaction(
// fromDevice = session.sessionParams.credentials.deviceId ?: "",
// methods = listOf(KeyVerificationStart.VERIF_METHOD_SAS),
// timestamp = System.currentTimeMillis().toInt(),
// transactionID = transactionId
// transactionId = transactionId
// )
//
// sendToOther(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ internal class DefaultVerificationService @Inject constructor(
isIncoming = true,
otherUserId = senderId, // requestInfo.toUserId,
roomId = null,
transactionId = validRequestInfo.transactionID,
localID = validRequestInfo.transactionID,
transactionId = validRequestInfo.transactionId,
localID = validRequestInfo.transactionId,
requestInfo = validRequestInfo
)
requestsForUser.add(pendingVerificationRequest)
Expand All @@ -313,7 +313,7 @@ internal class DefaultVerificationService @Inject constructor(
val requestInfo = event.getClearContent().toModel<MessageVerificationRequestContent>() ?: return
val validRequestInfo = requestInfo
// copy the EventId to the transactionId
.copy(transactionID = event.eventId)
.copy(transactionId = event.eventId)
.asValidObject() ?: return

val senderId = event.senderId ?: return
Expand Down Expand Up @@ -373,10 +373,10 @@ internal class DefaultVerificationService @Inject constructor(
val otherUserId = event.senderId
if (validStartReq == null) {
Timber.e("## received invalid verification request")
if (startReq?.transactionID != null) {
if (startReq?.transactionId != null) {
verificationTransportRoomMessageFactory.createTransport(event.roomId ?: "", null)
.cancelTransaction(
startReq.transactionID ?: "",
startReq.transactionId ?: "",
otherUserId!!,
startReq.fromDevice ?: event.getSenderKey()!!,
CancelCode.UnknownMethod
Expand All @@ -390,7 +390,7 @@ internal class DefaultVerificationService @Inject constructor(
}?.let {
verificationTransportRoomMessageFactory.createTransport(event.roomId ?: "", null)
.cancelTransaction(
validStartReq.transactionID,
validStartReq.transactionId,
otherUserId!!,
validStartReq.fromDevice,
it
Expand All @@ -407,9 +407,9 @@ internal class DefaultVerificationService @Inject constructor(
val otherUserId = event.senderId!!
if (validStartReq == null) {
Timber.e("## SAS received invalid verification request")
if (startReq?.transactionID != null) {
if (startReq?.transactionId != null) {
verificationTransportToDeviceFactory.createTransport(null).cancelTransaction(
startReq.transactionID,
startReq.transactionId,
otherUserId,
startReq.fromDevice ?: event.getSenderKey()!!,
CancelCode.UnknownMethod
Expand All @@ -422,7 +422,7 @@ internal class DefaultVerificationService @Inject constructor(
it.transport = verificationTransportToDeviceFactory.createTransport(it)
}?.let {
verificationTransportToDeviceFactory.createTransport(null).cancelTransaction(
validStartReq.transactionID,
validStartReq.transactionId,
otherUserId,
validStartReq.fromDevice,
it
Expand All @@ -436,17 +436,17 @@ internal class DefaultVerificationService @Inject constructor(
private suspend fun handleStart(otherUserId: String?,
startReq: ValidVerificationInfoStart,
txConfigure: (DefaultVerificationTransaction) -> Unit): CancelCode? {
Timber.d("## SAS onStartRequestReceived ${startReq.transactionID}")
Timber.d("## SAS onStartRequestReceived ${startReq.transactionId}")
if (checkKeysAreDownloaded(otherUserId!!, startReq.fromDevice) != null) {
val tid = startReq.transactionID
val tid = startReq.transactionId
val existing = getExistingTransaction(otherUserId, tid)

when (startReq) {
is ValidVerificationInfoStart.SasVerificationInfoStart -> {
when (existing) {
is SasVerificationTransaction -> {
// should cancel both!
Timber.v("## SAS onStartRequestReceived - Request exist with same id ${startReq.transactionID}")
Timber.v("## SAS onStartRequestReceived - Request exist with same id ${startReq.transactionId}")
existing.cancel(CancelCode.UnexpectedMessage)
// Already cancelled, so return null
return null
Expand All @@ -461,7 +461,7 @@ internal class DefaultVerificationService @Inject constructor(
?.also {
// Multiple keyshares between two devices:
// any two devices may only have at most one key verification in flight at a time.
Timber.v("## SAS onStartRequestReceived - Already a transaction with this user ${startReq.transactionID}")
Timber.v("## SAS onStartRequestReceived - Already a transaction with this user ${startReq.transactionId}")
}
?.forEach {
it.cancel(CancelCode.UnexpectedMessage)
Expand All @@ -473,12 +473,12 @@ internal class DefaultVerificationService @Inject constructor(
}

// Ok we can create a SAS transaction
Timber.v("## SAS onStartRequestReceived - request accepted ${startReq.transactionID}")
Timber.v("## SAS onStartRequestReceived - request accepted ${startReq.transactionId}")
// If there is a corresponding request, we can auto accept
// as we are the one requesting in first place (or we accepted the request)
// I need to check if the pending request was related to this device also
val autoAccept = getExistingVerificationRequest(otherUserId)?.any {
it.transactionId == startReq.transactionID
it.transactionId == startReq.transactionId
&& (it.requestInfo?.fromDevice == this.deviceId || it.readyInfo?.fromDevice == this.deviceId)
}
?: false
Expand All @@ -490,7 +490,7 @@ internal class DefaultVerificationService @Inject constructor(
cryptoStore,
crossSigningService,
myDeviceInfoHolder.get().myDevice.fingerprint()!!,
startReq.transactionID,
startReq.transactionId,
otherUserId,
autoAccept).also { txConfigure(it) }
addTransaction(tx)
Expand All @@ -503,7 +503,7 @@ internal class DefaultVerificationService @Inject constructor(
existing.onStartReceived(startReq)
return null
} else {
Timber.w("## SAS onStartRequestReceived - unexpected message ${startReq.transactionID}")
Timber.w("## SAS onStartRequestReceived - unexpected message ${startReq.transactionId}")
return CancelCode.UnexpectedMessage
}
}
Expand Down Expand Up @@ -545,7 +545,7 @@ internal class DefaultVerificationService @Inject constructor(
// TODO should we cancel?
return
}
getExistingVerificationRequest(event.senderId ?: "", validCancelReq.transactionID)?.let {
getExistingVerificationRequest(event.senderId ?: "", validCancelReq.transactionId)?.let {
updatePendingRequest(it.copy(cancelConclusion = safeValueOf(validCancelReq.code)))
// Should we remove it from the list?
}
Expand All @@ -569,8 +569,8 @@ internal class DefaultVerificationService @Inject constructor(
private fun handleOnCancel(otherUserId: String, cancelReq: ValidVerificationInfoCancel) {
Timber.v("## SAS onCancelReceived otherUser: $otherUserId reason: ${cancelReq.reason}")

val existingTransaction = getExistingTransaction(otherUserId, cancelReq.transactionID)
val existingRequest = getExistingVerificationRequest(otherUserId, cancelReq.transactionID)
val existingTransaction = getExistingTransaction(otherUserId, cancelReq.transactionId)
val existingRequest = getExistingVerificationRequest(otherUserId, cancelReq.transactionId)

if (existingRequest != null) {
// Mark this request as cancelled
Expand Down Expand Up @@ -606,7 +606,7 @@ internal class DefaultVerificationService @Inject constructor(

private fun handleAccept(acceptReq: ValidVerificationInfoAccept, senderId: String) {
val otherUserId = senderId
val existing = getExistingTransaction(otherUserId, acceptReq.transactionID)
val existing = getExistingTransaction(otherUserId, acceptReq.transactionId)
if (existing == null) {
Timber.e("## SAS Received invalid accept request")
return
Expand Down Expand Up @@ -649,7 +649,7 @@ internal class DefaultVerificationService @Inject constructor(
private fun handleKeyReceived(event: Event, keyReq: ValidVerificationInfoKey) {
Timber.d("## SAS Received Key from ${event.senderId} with info $keyReq")
val otherUserId = event.senderId!!
val existing = getExistingTransaction(otherUserId, keyReq.transactionID)
val existing = getExistingTransaction(otherUserId, keyReq.transactionId)
if (existing == null) {
Timber.e("## SAS Received invalid key request")
return
Expand Down Expand Up @@ -752,7 +752,7 @@ internal class DefaultVerificationService @Inject constructor(

private fun handleMacReceived(senderId: String, macReq: ValidVerificationInfoMac) {
Timber.v("## SAS Received $macReq")
val existing = getExistingTransaction(senderId, macReq.transactionID)
val existing = getExistingTransaction(senderId, macReq.transactionId)
if (existing == null) {
Timber.e("## SAS Received invalid Mac request")
return
Expand All @@ -767,9 +767,9 @@ internal class DefaultVerificationService @Inject constructor(
private fun handleReadyReceived(senderId: String,
readyReq: ValidVerificationInfoReady,
transportCreator: (DefaultVerificationTransaction) -> VerificationTransport) {
val existingRequest = getExistingVerificationRequest(senderId)?.find { it.transactionId == readyReq.transactionID }
val existingRequest = getExistingVerificationRequest(senderId)?.find { it.transactionId == readyReq.transactionId }
if (existingRequest == null) {
Timber.e("## SAS Received Ready for unknown request txId:${readyReq.transactionID} fromDevice ${readyReq.fromDevice}")
Timber.e("## SAS Received Ready for unknown request txId:${readyReq.transactionId} fromDevice ${readyReq.fromDevice}")
return
}

Expand All @@ -784,7 +784,7 @@ internal class DefaultVerificationService @Inject constructor(
// Create the pending transaction
val tx = DefaultQrCodeVerificationTransaction(
setDeviceVerificationAction,
readyReq.transactionID,
readyReq.transactionId,
senderId,
readyReq.fromDevice,
crossSigningService,
Expand Down Expand Up @@ -899,9 +899,9 @@ internal class DefaultVerificationService @Inject constructor(
}

private fun handleDoneReceived(senderId: String, doneInfo: ValidVerificationDone) {
val existingRequest = getExistingVerificationRequest(senderId)?.find { it.transactionId == doneInfo.transactionID }
val existingRequest = getExistingVerificationRequest(senderId)?.find { it.transactionId == doneInfo.transactionId }
if (existingRequest == null) {
Timber.e("## SAS Received Done for unknown request txId:${doneInfo.transactionID}")
Timber.e("## SAS Received Done for unknown request txId:${doneInfo.transactionId}")
return
}
updatePendingRequest(existingRequest.copy(isSuccessful = true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal interface VerificationInfoAcceptFactory {
}

internal data class ValidVerificationInfoAccept(
val transactionID: String,
val transactionId: String,
val keyAgreementProtocol: String,
val hash: String,
val messageAuthenticationCode: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal interface VerificationInfoCancel : VerificationInfo<ValidVerificationIn
}

internal data class ValidVerificationInfoCancel(
val transactionID: String,
val transactionId: String,
val code: String,
val reason: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ internal interface VerificationInfoKeyFactory {
}

internal data class ValidVerificationInfoKey(
val transactionID: String,
val transactionId: String,
val key: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal interface VerificationInfoMacFactory {
}

internal data class ValidVerificationInfoMac(
val transactionID: String,
val transactionId: String,
val mac: Map<String, String>,
val keys: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,21 @@ internal interface VerificationInfoStart : VerificationInfo<ValidVerificationInf
}

sealed class ValidVerificationInfoStart(
open val transactionID: String,
open val transactionId: String,
open val fromDevice: String) {
data class SasVerificationInfoStart(
override val transactionID: String,
override val transactionId: String,
override val fromDevice: String,
val keyAgreementProtocols: List<String>,
val hashes: List<String>,
val messageAuthenticationCodes: List<String>,
val shortAuthenticationStrings: List<String>,
val canonicalJson: String
) : ValidVerificationInfoStart(transactionID, fromDevice)
) : ValidVerificationInfoStart(transactionId, fromDevice)

data class ReciprocateVerificationInfoStart(
override val transactionID: String,
override val transactionId: String,
override val fromDevice: String,
val sharedSecret: String
) : ValidVerificationInfoStart(transactionID, fromDevice)
) : ValidVerificationInfoStart(transactionId, fromDevice)
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal interface VerificationTransport {
* Create start for SAS verification
*/
fun createStartForSas(fromDevice: String,
transactionID: String,
transactionId: String,
keyAgreementProtocols: List<String>,
hashes: List<String>,
messageAuthenticationCodes: List<String>,
Expand All @@ -75,7 +75,7 @@ internal interface VerificationTransport {
* Create start for QR code verification
*/
fun createStartForQrCode(fromDevice: String,
transactionID: String,
transactionId: String,
sharedSecret: String): VerificationInfoStart

fun createMac(tid: String, mac: Map<String, String>, keys: String): VerificationInfoMac
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ internal class VerificationTransportRoomMessage(
requireNotNull(roomId)

val validInfo = ValidVerificationInfoRequest(
transactionID = "",
transactionId = "",
fromDevice = userDeviceId ?: "",
methods = supportedMethods,
timestamp = System.currentTimeMillis()
Expand Down Expand Up @@ -278,7 +278,7 @@ internal class VerificationTransportRoomMessage(
override fun createMac(tid: String, mac: Map<String, String>, keys: String) = MessageVerificationMacContent.create(tid, mac, keys)

override fun createStartForSas(fromDevice: String,
transactionID: String,
transactionId: String,
keyAgreementProtocols: List<String>,
hashes: List<String>,
messageAuthenticationCodes: List<String>,
Expand All @@ -292,14 +292,14 @@ internal class VerificationTransportRoomMessage(
VERIFICATION_METHOD_SAS,
RelationDefaultContent(
type = RelationType.REFERENCE,
eventId = transactionID
eventId = transactionId
),
null
)
}

override fun createStartForQrCode(fromDevice: String,
transactionID: String,
transactionId: String,
sharedSecret: String): VerificationInfoStart {
return MessageVerificationStartContent(
fromDevice,
Expand All @@ -310,7 +310,7 @@ internal class VerificationTransportRoomMessage(
VERIFICATION_METHOD_RECIPROCATE,
RelationDefaultContent(
type = RelationType.REFERENCE,
eventId = transactionID
eventId = transactionId
),
sharedSecret
)
Expand Down
Loading

0 comments on commit 5d0e917

Please sign in to comment.