Cleanup API

This commit is contained in:
Benoit Marty 2020-02-11 18:08:12 +01:00
parent 6ff974b3ea
commit 377d944228
11 changed files with 18 additions and 23 deletions

View File

@ -68,11 +68,11 @@ interface VerificationService {
otherDevices: List<String>?): PendingVerificationRequest otherDevices: List<String>?): PendingVerificationRequest
fun declineVerificationRequestInDMs(otherUserId: String, fun declineVerificationRequestInDMs(otherUserId: String,
otherDeviceId: String,
transactionId: String, transactionId: String,
roomId: String) roomId: String)
// Only SAS method is supported for the moment // Only SAS method is supported for the moment
// TODO Parameter otherDeviceId should be removed in this case
fun beginKeyVerificationInDMs(method: VerificationMethod, fun beginKeyVerificationInDMs(method: VerificationMethod,
transactionId: String, transactionId: String,
roomId: String, roomId: String,

View File

@ -1151,9 +1151,9 @@ internal class DefaultVerificationService @Inject constructor(
return verificationRequest return verificationRequest
} }
override fun declineVerificationRequestInDMs(otherUserId: String, otherDeviceId: String, transactionId: String, roomId: String) { override fun declineVerificationRequestInDMs(otherUserId: String, transactionId: String, roomId: String) {
verificationTransportRoomMessageFactory.createTransport(roomId, null) verificationTransportRoomMessageFactory.createTransport(roomId, null)
.cancelTransaction(transactionId, otherUserId, otherDeviceId, CancelCode.User) .cancelTransaction(transactionId, otherUserId, null, CancelCode.User)
getExistingVerificationRequest(otherUserId, transactionId)?.let { getExistingVerificationRequest(otherUserId, transactionId)?.let {
updatePendingRequest(it.copy( updatePendingRequest(it.copy(

View File

@ -42,7 +42,7 @@ internal interface VerificationTransport {
fun cancelTransaction(transactionId: String, fun cancelTransaction(transactionId: String,
otherUserId: String, otherUserId: String,
otherUserDeviceId: String, otherUserDeviceId: String?,
code: CancelCode) code: CancelCode)
fun done(transactionId: String) fun done(transactionId: String)
@ -79,11 +79,13 @@ internal interface VerificationTransport {
fun createMac(tid: String, mac: Map<String, String>, keys: String): VerificationInfoMac fun createMac(tid: String, mac: Map<String, String>, keys: String): VerificationInfoMac
fun createReady(tid: String, fromDevice: String, methods: List<String>): VerificationInfoReady fun createReady(tid: String,
fromDevice: String,
methods: List<String>): VerificationInfoReady
// TODO Refactor // TODO Refactor
fun sendVerificationReady(keyReq: VerificationInfoReady, fun sendVerificationReady(keyReq: VerificationInfoReady,
otherUserId: String, otherUserId: String,
otherDeviceId: String, otherDeviceId: String?,
callback: (() -> Unit)?) callback: (() -> Unit)?)
} }

View File

@ -208,7 +208,7 @@ internal class VerificationTransportRoomMessage(
} }
} }
override fun cancelTransaction(transactionId: String, otherUserId: String, otherUserDeviceId: String, code: CancelCode) { override fun cancelTransaction(transactionId: String, otherUserId: String, otherUserDeviceId: String?, code: CancelCode) {
Timber.d("## SAS canceling transaction $transactionId for reason $code") Timber.d("## SAS canceling transaction $transactionId for reason $code")
val event = createEventAndLocalEcho( val event = createEventAndLocalEcho(
type = EventType.KEY_VERIFICATION_CANCEL, type = EventType.KEY_VERIFICATION_CANCEL,
@ -337,7 +337,7 @@ internal class VerificationTransportRoomMessage(
override fun sendVerificationReady(keyReq: VerificationInfoReady, override fun sendVerificationReady(keyReq: VerificationInfoReady,
otherUserId: String, otherUserId: String,
otherDeviceId: String, otherDeviceId: String?,
callback: (() -> Unit)?) { callback: (() -> Unit)?) {
// Not applicable (send event is called directly) // Not applicable (send event is called directly)
Timber.w("## SAS ignored verification ready with methods: ${keyReq.methods}") Timber.w("## SAS ignored verification ready with methods: ${keyReq.methods}")

View File

@ -80,7 +80,7 @@ internal class VerificationTransportToDevice(
override fun sendVerificationReady(keyReq: VerificationInfoReady, override fun sendVerificationReady(keyReq: VerificationInfoReady,
otherUserId: String, otherUserId: String,
otherDeviceId: String, otherDeviceId: String?,
callback: (() -> Unit)?) { callback: (() -> Unit)?) {
Timber.d("## SAS sending verification ready with methods: ${keyReq.methods}") Timber.d("## SAS sending verification ready with methods: ${keyReq.methods}")
val contentMap = MXUsersDevicesMap<Any>() val contentMap = MXUsersDevicesMap<Any>()
@ -159,7 +159,7 @@ internal class VerificationTransportToDevice(
.executeBy(taskExecutor) .executeBy(taskExecutor)
} }
override fun cancelTransaction(transactionId: String, otherUserId: String, otherUserDeviceId: String, code: CancelCode) { override fun cancelTransaction(transactionId: String, otherUserId: String, otherUserDeviceId: String?, code: CancelCode) {
Timber.d("## SAS canceling transaction $transactionId for reason $code") Timber.d("## SAS canceling transaction $transactionId for reason $code")
val cancelMessage = KeyVerificationCancel.create(transactionId, code) val cancelMessage = KeyVerificationCancel.create(transactionId, code)
val contentMap = MXUsersDevicesMap<Any>() val contentMap = MXUsersDevicesMap<Any>()

View File

@ -145,7 +145,6 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context
} }
dismissedAction = Runnable { dismissedAction = Runnable {
session?.getVerificationService()?.declineVerificationRequestInDMs(pr.otherUserId, session?.getVerificationService()?.declineVerificationRequestInDMs(pr.otherUserId,
pr.requestInfo?.fromDevice ?: "",
pr.transactionId ?: "", pr.transactionId ?: "",
pr.roomId ?: "" pr.roomId ?: ""
) )

View File

@ -65,8 +65,8 @@ sealed class RoomDetailAction : VectorViewModelAction {
object ClearSendQueue : RoomDetailAction() object ClearSendQueue : RoomDetailAction()
object ResendAll : RoomDetailAction() object ResendAll : RoomDetailAction()
data class AcceptVerificationRequest(val transactionId: String, val otherUserId: String, val otherdDeviceId: String) : RoomDetailAction() data class AcceptVerificationRequest(val transactionId: String, val otherUserId: String) : RoomDetailAction()
data class DeclineVerificationRequest(val transactionId: String, val otherUserId: String, val otherdDeviceId: String) : RoomDetailAction() data class DeclineVerificationRequest(val transactionId: String, val otherUserId: String) : RoomDetailAction()
data class RequestVerification(val userId: String) : RoomDetailAction() data class RequestVerification(val userId: String) : RoomDetailAction()
data class ResumeVerification(val transactionId: String, val otherUserId: String? = null, val otherdDeviceId: String? = null) : RoomDetailAction() data class ResumeVerification(val transactionId: String, val otherUserId: String?) : RoomDetailAction()
} }

View File

@ -1028,7 +1028,7 @@ class RoomDetailFragment @Inject constructor(
override fun onEventCellClicked(informationData: MessageInformationData, messageContent: MessageContent?, view: View) { override fun onEventCellClicked(informationData: MessageInformationData, messageContent: MessageContent?, view: View) {
if (messageContent is MessageVerificationRequestContent) { if (messageContent is MessageVerificationRequestContent) {
roomDetailViewModel.handle(RoomDetailAction.ResumeVerification(informationData.eventId)) roomDetailViewModel.handle(RoomDetailAction.ResumeVerification(informationData.eventId, null))
} }
} }

View File

@ -833,7 +833,6 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
private fun handleDeclineVerification(action: RoomDetailAction.DeclineVerificationRequest) { private fun handleDeclineVerification(action: RoomDetailAction.DeclineVerificationRequest) {
session.getVerificationService().declineVerificationRequestInDMs( session.getVerificationService().declineVerificationRequestInDMs(
action.otherUserId, action.otherUserId,
action.otherdDeviceId,
action.transactionId, action.transactionId,
room.roomId) room.roomId)
} }

View File

@ -181,7 +181,6 @@ class MessageItemFactory @Inject constructor(
VerificationRequestItem.Attributes( VerificationRequestItem.Attributes(
otherUserId = otherUserId, otherUserId = otherUserId,
otherUserName = otherUserName.toString(), otherUserName = otherUserName.toString(),
fromDevide = messageContent.fromDevice ?: "",
referenceId = informationData.eventId, referenceId = informationData.eventId,
informationData = informationData, informationData = informationData,
avatarRenderer = attributes.avatarRenderer, avatarRenderer = attributes.avatarRenderer,

View File

@ -134,12 +134,9 @@ abstract class VerificationRequestItem : AbsBaseMessageItem<VerificationRequestI
private val _clickListener = DebouncedClickListener(View.OnClickListener { private val _clickListener = DebouncedClickListener(View.OnClickListener {
val att = attributes ?: return@OnClickListener val att = attributes ?: return@OnClickListener
if (it == acceptButton) { if (it == acceptButton) {
callback?.onTimelineItemAction(RoomDetailAction.AcceptVerificationRequest( callback?.onTimelineItemAction(RoomDetailAction.AcceptVerificationRequest(att.referenceId, att.otherUserId))
att.referenceId,
att.otherUserId,
att.fromDevide))
} else if (it == declineButton) { } else if (it == declineButton) {
callback?.onTimelineItemAction(RoomDetailAction.DeclineVerificationRequest(att.referenceId, att.otherUserId, att.fromDevide)) callback?.onTimelineItemAction(RoomDetailAction.DeclineVerificationRequest(att.referenceId, att.otherUserId))
} }
}) })
@ -169,7 +166,6 @@ abstract class VerificationRequestItem : AbsBaseMessageItem<VerificationRequestI
data class Attributes( data class Attributes(
val otherUserId: String, val otherUserId: String,
val otherUserName: String, val otherUserName: String,
val fromDevide: String,
val referenceId: String, val referenceId: String,
// val avatarSize: Int, // val avatarSize: Int,
override val informationData: MessageInformationData, override val informationData: MessageInformationData,