mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Fix / Decline request was not implemented
This commit is contained in:
parent
52c25b803f
commit
bf28f14b8b
7 changed files with 38 additions and 14 deletions
|
@ -57,6 +57,8 @@ interface SasVerificationService {
|
||||||
|
|
||||||
fun requestKeyVerificationInDMs(userId: String, roomId: String): PendingVerificationRequest
|
fun requestKeyVerificationInDMs(userId: String, roomId: String): PendingVerificationRequest
|
||||||
|
|
||||||
|
fun declineVerificationRequestInDMs(otherUserId: String, otherDeviceId: String, transactionId: String, roomId: String)
|
||||||
|
|
||||||
fun beginKeyVerificationInDMs(method: String,
|
fun beginKeyVerificationInDMs(method: String,
|
||||||
transactionId: String,
|
transactionId: String,
|
||||||
roomId: String,
|
roomId: String,
|
||||||
|
|
|
@ -704,6 +704,16 @@ internal class DefaultSasVerificationService @Inject constructor(
|
||||||
val transport = sasTransportRoomMessageFactory.createTransport(context, credentials.userId, credentials.deviceId
|
val transport = sasTransportRoomMessageFactory.createTransport(context, credentials.userId, credentials.deviceId
|
||||||
?: "", roomId, null)
|
?: "", roomId, null)
|
||||||
|
|
||||||
|
// Cancel existing pending requests?
|
||||||
|
requestsForUser.forEach { existingRequest ->
|
||||||
|
existingRequest.transactionId?.let { tid ->
|
||||||
|
if (!existingRequest.isFinished) {
|
||||||
|
Timber.d("## SAS, cancelling pending requests to start a new one")
|
||||||
|
transport.cancelTransaction(tid, existingRequest.otherUserId, "", CancelCode.User)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val localID = LocalEcho.createLocalEchoId()
|
val localID = LocalEcho.createLocalEchoId()
|
||||||
|
|
||||||
val verificationRequest = PendingVerificationRequest(
|
val verificationRequest = PendingVerificationRequest(
|
||||||
|
@ -727,6 +737,17 @@ internal class DefaultSasVerificationService @Inject constructor(
|
||||||
return verificationRequest
|
return verificationRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun declineVerificationRequestInDMs(otherUserId: String, otherDeviceId: String, transactionId: String, roomId: String) {
|
||||||
|
sasTransportRoomMessageFactory.createTransport(context, credentials.userId, credentials.deviceId
|
||||||
|
?: "", roomId, null).cancelTransaction(transactionId, otherUserId, otherDeviceId, CancelCode.User)
|
||||||
|
|
||||||
|
getExistingVerificationRequest(otherUserId, transactionId)?.let {
|
||||||
|
updatePendingRequest(it.copy(
|
||||||
|
cancelConclusion = CancelCode.User
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updatePendingRequest(updated: PendingVerificationRequest) {
|
private fun updatePendingRequest(updated: PendingVerificationRequest) {
|
||||||
val requestsForUser = pendingRequests[updated.otherUserId]
|
val requestsForUser = pendingRequests[updated.otherUserId]
|
||||||
?: ArrayList<PendingVerificationRequest>().also {
|
?: ArrayList<PendingVerificationRequest>().also {
|
||||||
|
|
|
@ -37,4 +37,6 @@ data class PendingVerificationRequest(
|
||||||
|
|
||||||
val isReady: Boolean = readyInfo != null
|
val isReady: Boolean = readyInfo != null
|
||||||
val isSent: Boolean = transactionId != null
|
val isSent: Boolean = transactionId != null
|
||||||
|
|
||||||
|
val isFinished: Boolean = isSuccessful || cancelConclusion != null
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,11 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction has not yet started
|
// Transaction has not yet started
|
||||||
if (it.pendingRequest == null || !it.pendingRequest.isReady) {
|
if (it.pendingRequest?.cancelConclusion != null) {
|
||||||
|
// The request has been declined, we should dismiss
|
||||||
|
dismiss()
|
||||||
|
} else if (it.pendingRequest == null || !it.pendingRequest.isReady) {
|
||||||
|
// We are waiting for other party to reply with ready
|
||||||
showFragment(VerificationRequestFragment::class, Bundle().apply {
|
showFragment(VerificationRequestFragment::class, Bundle().apply {
|
||||||
putParcelable(MvRx.KEY_ARG, VerificationArgs(it.otherUserMxItem?.id ?: ""))
|
putParcelable(MvRx.KEY_ARG, VerificationArgs(it.otherUserMxItem?.id ?: ""))
|
||||||
})
|
})
|
||||||
|
|
|
@ -65,7 +65,7 @@ sealed class RoomDetailAction : VectorViewModelAction {
|
||||||
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, val otherdDeviceId: String) : RoomDetailAction()
|
||||||
data class DeclineVerificationRequest(val transactionId: String) : RoomDetailAction()
|
data class DeclineVerificationRequest(val transactionId: String, val otherUserId: String, val otherdDeviceId: String) : RoomDetailAction()
|
||||||
|
|
||||||
data class RequestVerification(val userId: String) : RoomDetailAction()
|
data class RequestVerification(val userId: String) : RoomDetailAction()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import com.squareup.inject.assisted.Assisted
|
||||||
import com.squareup.inject.assisted.AssistedInject
|
import com.squareup.inject.assisted.AssistedInject
|
||||||
import im.vector.matrix.android.api.MatrixCallback
|
import im.vector.matrix.android.api.MatrixCallback
|
||||||
import im.vector.matrix.android.api.MatrixPatterns
|
import im.vector.matrix.android.api.MatrixPatterns
|
||||||
import im.vector.matrix.android.api.failure.Failure
|
|
||||||
import im.vector.matrix.android.api.session.Session
|
import im.vector.matrix.android.api.session.Session
|
||||||
import im.vector.matrix.android.api.session.events.model.EventType
|
import im.vector.matrix.android.api.session.events.model.EventType
|
||||||
import im.vector.matrix.android.api.session.events.model.isImageMessage
|
import im.vector.matrix.android.api.session.events.model.isImageMessage
|
||||||
|
@ -185,7 +184,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||||
is RoomDetailAction.ExitTrackingUnreadMessagesState -> stopTrackingUnreadMessages()
|
is RoomDetailAction.ExitTrackingUnreadMessagesState -> stopTrackingUnreadMessages()
|
||||||
is RoomDetailAction.AcceptVerificationRequest -> handleAcceptVerification(action)
|
is RoomDetailAction.AcceptVerificationRequest -> handleAcceptVerification(action)
|
||||||
is RoomDetailAction.DeclineVerificationRequest -> handleDeclineVerification(action)
|
is RoomDetailAction.DeclineVerificationRequest -> handleDeclineVerification(action)
|
||||||
is RoomDetailAction.RequestVerification -> handleRequestVerification(action)
|
is RoomDetailAction.RequestVerification -> handleRequestVerification(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,18 +798,14 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||||
session.getSasVerificationService().readyPendingVerificationInDMs(action.otherUserId, room.roomId,
|
session.getSasVerificationService().readyPendingVerificationInDMs(action.otherUserId, room.roomId,
|
||||||
action.transactionId)
|
action.transactionId)
|
||||||
_requestLiveData.postValue(LiveEvent(Success(action)))
|
_requestLiveData.postValue(LiveEvent(Success(action)))
|
||||||
// session.getSasVerificationService().beginKeyVerificationInDMs(
|
|
||||||
// KeyVerificationStart.VERIF_METHOD_SAS,
|
|
||||||
// action.transactionId,
|
|
||||||
// room.roomId,
|
|
||||||
// action.otherUserMxItem,
|
|
||||||
// action.otherdDeviceId,
|
|
||||||
// null
|
|
||||||
// )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleDeclineVerification(action: RoomDetailAction.DeclineVerificationRequest) {
|
private fun handleDeclineVerification(action: RoomDetailAction.DeclineVerificationRequest) {
|
||||||
Timber.e("TODO implement $action")
|
session.getSasVerificationService().declineVerificationRequestInDMs(
|
||||||
|
action.otherUserId,
|
||||||
|
action.otherdDeviceId,
|
||||||
|
action.transactionId,
|
||||||
|
room.roomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleRequestVerification(action: RoomDetailAction.RequestVerification) {
|
private fun handleRequestVerification(action: RoomDetailAction.RequestVerification) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ abstract class VerificationRequestItem : AbsBaseMessageItem<VerificationRequestI
|
||||||
att.otherUserId,
|
att.otherUserId,
|
||||||
att.fromDevide))
|
att.fromDevide))
|
||||||
} else if (it == declineButton) {
|
} else if (it == declineButton) {
|
||||||
callback?.onTimelineItemAction(RoomDetailAction.DeclineVerificationRequest(att.referenceId))
|
callback?.onTimelineItemAction(RoomDetailAction.DeclineVerificationRequest(att.referenceId, att.otherUserId, att.fromDevide))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue