mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Cleanup API
This commit is contained in:
parent
6ff974b3ea
commit
377d944228
11 changed files with 18 additions and 23 deletions
|
@ -68,11 +68,11 @@ interface VerificationService {
|
|||
otherDevices: List<String>?): PendingVerificationRequest
|
||||
|
||||
fun declineVerificationRequestInDMs(otherUserId: String,
|
||||
otherDeviceId: String,
|
||||
transactionId: String,
|
||||
roomId: String)
|
||||
|
||||
// Only SAS method is supported for the moment
|
||||
// TODO Parameter otherDeviceId should be removed in this case
|
||||
fun beginKeyVerificationInDMs(method: VerificationMethod,
|
||||
transactionId: String,
|
||||
roomId: String,
|
||||
|
|
|
@ -1151,9 +1151,9 @@ internal class DefaultVerificationService @Inject constructor(
|
|||
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)
|
||||
.cancelTransaction(transactionId, otherUserId, otherDeviceId, CancelCode.User)
|
||||
.cancelTransaction(transactionId, otherUserId, null, CancelCode.User)
|
||||
|
||||
getExistingVerificationRequest(otherUserId, transactionId)?.let {
|
||||
updatePendingRequest(it.copy(
|
||||
|
|
|
@ -42,7 +42,7 @@ internal interface VerificationTransport {
|
|||
|
||||
fun cancelTransaction(transactionId: String,
|
||||
otherUserId: String,
|
||||
otherUserDeviceId: String,
|
||||
otherUserDeviceId: String?,
|
||||
code: CancelCode)
|
||||
|
||||
fun done(transactionId: String)
|
||||
|
@ -79,11 +79,13 @@ internal interface VerificationTransport {
|
|||
|
||||
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
|
||||
fun sendVerificationReady(keyReq: VerificationInfoReady,
|
||||
otherUserId: String,
|
||||
otherDeviceId: String,
|
||||
otherDeviceId: String?,
|
||||
callback: (() -> Unit)?)
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
val event = createEventAndLocalEcho(
|
||||
type = EventType.KEY_VERIFICATION_CANCEL,
|
||||
|
@ -337,7 +337,7 @@ internal class VerificationTransportRoomMessage(
|
|||
|
||||
override fun sendVerificationReady(keyReq: VerificationInfoReady,
|
||||
otherUserId: String,
|
||||
otherDeviceId: String,
|
||||
otherDeviceId: String?,
|
||||
callback: (() -> Unit)?) {
|
||||
// Not applicable (send event is called directly)
|
||||
Timber.w("## SAS ignored verification ready with methods: ${keyReq.methods}")
|
||||
|
|
|
@ -80,7 +80,7 @@ internal class VerificationTransportToDevice(
|
|||
|
||||
override fun sendVerificationReady(keyReq: VerificationInfoReady,
|
||||
otherUserId: String,
|
||||
otherDeviceId: String,
|
||||
otherDeviceId: String?,
|
||||
callback: (() -> Unit)?) {
|
||||
Timber.d("## SAS sending verification ready with methods: ${keyReq.methods}")
|
||||
val contentMap = MXUsersDevicesMap<Any>()
|
||||
|
@ -159,7 +159,7 @@ internal class VerificationTransportToDevice(
|
|||
.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")
|
||||
val cancelMessage = KeyVerificationCancel.create(transactionId, code)
|
||||
val contentMap = MXUsersDevicesMap<Any>()
|
||||
|
|
|
@ -145,7 +145,6 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context
|
|||
}
|
||||
dismissedAction = Runnable {
|
||||
session?.getVerificationService()?.declineVerificationRequestInDMs(pr.otherUserId,
|
||||
pr.requestInfo?.fromDevice ?: "",
|
||||
pr.transactionId ?: "",
|
||||
pr.roomId ?: ""
|
||||
)
|
||||
|
|
|
@ -65,8 +65,8 @@ sealed class RoomDetailAction : VectorViewModelAction {
|
|||
object ClearSendQueue : RoomDetailAction()
|
||||
object ResendAll : RoomDetailAction()
|
||||
|
||||
data class AcceptVerificationRequest(val transactionId: String, val otherUserId: String, val otherdDeviceId: String) : RoomDetailAction()
|
||||
data class DeclineVerificationRequest(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) : 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()
|
||||
}
|
||||
|
|
|
@ -1028,7 +1028,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
|
||||
override fun onEventCellClicked(informationData: MessageInformationData, messageContent: MessageContent?, view: View) {
|
||||
if (messageContent is MessageVerificationRequestContent) {
|
||||
roomDetailViewModel.handle(RoomDetailAction.ResumeVerification(informationData.eventId))
|
||||
roomDetailViewModel.handle(RoomDetailAction.ResumeVerification(informationData.eventId, null))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -833,7 +833,6 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
private fun handleDeclineVerification(action: RoomDetailAction.DeclineVerificationRequest) {
|
||||
session.getVerificationService().declineVerificationRequestInDMs(
|
||||
action.otherUserId,
|
||||
action.otherdDeviceId,
|
||||
action.transactionId,
|
||||
room.roomId)
|
||||
}
|
||||
|
|
|
@ -181,7 +181,6 @@ class MessageItemFactory @Inject constructor(
|
|||
VerificationRequestItem.Attributes(
|
||||
otherUserId = otherUserId,
|
||||
otherUserName = otherUserName.toString(),
|
||||
fromDevide = messageContent.fromDevice ?: "",
|
||||
referenceId = informationData.eventId,
|
||||
informationData = informationData,
|
||||
avatarRenderer = attributes.avatarRenderer,
|
||||
|
|
|
@ -134,12 +134,9 @@ abstract class VerificationRequestItem : AbsBaseMessageItem<VerificationRequestI
|
|||
private val _clickListener = DebouncedClickListener(View.OnClickListener {
|
||||
val att = attributes ?: return@OnClickListener
|
||||
if (it == acceptButton) {
|
||||
callback?.onTimelineItemAction(RoomDetailAction.AcceptVerificationRequest(
|
||||
att.referenceId,
|
||||
att.otherUserId,
|
||||
att.fromDevide))
|
||||
callback?.onTimelineItemAction(RoomDetailAction.AcceptVerificationRequest(att.referenceId, att.otherUserId))
|
||||
} 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(
|
||||
val otherUserId: String,
|
||||
val otherUserName: String,
|
||||
val fromDevide: String,
|
||||
val referenceId: String,
|
||||
// val avatarSize: Int,
|
||||
override val informationData: MessageInformationData,
|
||||
|
|
Loading…
Reference in a new issue