Send verification request when the device is not new
This commit is contained in:
commit
d49d0295a2
@ -10,7 +10,8 @@ Improvements 🙌:
|
|||||||
- Handling (almost) properly the groups fetching (#1634)
|
- Handling (almost) properly the groups fetching (#1634)
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
-
|
- Regression | Share action menu do not work (#1647)
|
||||||
|
- verification issues on transition (#1555)
|
||||||
|
|
||||||
Translations 🗣:
|
Translations 🗣:
|
||||||
-
|
-
|
||||||
|
@ -1234,7 +1234,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// We can SCAN or SHOW QR codes only if cross-signing is enabled
|
// We can SCAN or SHOW QR codes only if cross-signing is enabled
|
||||||
val methodValues = if (crossSigningService.isCrossSigningVerified()) {
|
val methodValues = if (crossSigningService.getMyCrossSigningKeys() != null) {
|
||||||
// Add reciprocate method if application declares it can scan or show QR codes
|
// Add reciprocate method if application declares it can scan or show QR codes
|
||||||
// Not sure if it ok to do that (?)
|
// Not sure if it ok to do that (?)
|
||||||
val reciprocateMethod = methods
|
val reciprocateMethod = methods
|
||||||
|
@ -250,7 +250,10 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() {
|
|||||||
is VerificationTxState.Started,
|
is VerificationTxState.Started,
|
||||||
is VerificationTxState.WaitingOtherReciprocateConfirm -> {
|
is VerificationTxState.WaitingOtherReciprocateConfirm -> {
|
||||||
showFragment(VerificationQRWaitingFragment::class, Bundle().apply {
|
showFragment(VerificationQRWaitingFragment::class, Bundle().apply {
|
||||||
putParcelable(MvRx.KEY_ARG, VerificationQRWaitingFragment.Args(state.isMe, state.otherUserMxItem?.getBestName() ?: ""))
|
putParcelable(MvRx.KEY_ARG, VerificationQRWaitingFragment.Args(
|
||||||
|
isMe = state.isMe,
|
||||||
|
otherUserName = state.otherUserMxItem?.getBestName() ?: ""
|
||||||
|
))
|
||||||
})
|
})
|
||||||
return@withState
|
return@withState
|
||||||
}
|
}
|
||||||
@ -353,6 +356,17 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun forSelfVerification(session: Session, outgoingRequest: String): VerificationBottomSheet {
|
||||||
|
return VerificationBottomSheet().apply {
|
||||||
|
arguments = Bundle().apply {
|
||||||
|
putParcelable(MvRx.KEY_ARG, VerificationArgs(
|
||||||
|
otherUserId = session.myUserId,
|
||||||
|
selfVerificationMode = true,
|
||||||
|
verificationId = outgoingRequest
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const val WAITING_SELF_VERIF_TAG: String = "WAITING_SELF_VERIF_TAG"
|
const val WAITING_SELF_VERIF_TAG: String = "WAITING_SELF_VERIF_TAG"
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,11 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
|
|||||||
R.string.crosssigning_verify_this_session,
|
R.string.crosssigning_verify_this_session,
|
||||||
R.string.confirm_your_identity
|
R.string.confirm_your_identity
|
||||||
) {
|
) {
|
||||||
it.navigator.waitSessionVerification(it)
|
if (event.waitForIncomingRequest) {
|
||||||
|
it.navigator.waitSessionVerification(it)
|
||||||
|
} else {
|
||||||
|
it.navigator.requestSelfSessionVerification(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,5 +21,5 @@ import im.vector.riotx.core.platform.VectorViewEvents
|
|||||||
|
|
||||||
sealed class HomeActivityViewEvents : VectorViewEvents {
|
sealed class HomeActivityViewEvents : VectorViewEvents {
|
||||||
data class AskPasswordToInitCrossSigning(val userItem: MatrixItem.UserItem?) : HomeActivityViewEvents()
|
data class AskPasswordToInitCrossSigning(val userItem: MatrixItem.UserItem?) : HomeActivityViewEvents()
|
||||||
data class OnNewSession(val userItem: MatrixItem.UserItem?) : HomeActivityViewEvents()
|
data class OnNewSession(val userItem: MatrixItem.UserItem?, val waitForIncomingRequest: Boolean = true) : HomeActivityViewEvents()
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,14 @@ class HomeActivityViewModel @AssistedInject constructor(
|
|||||||
// Cross-signing is already set up for this user, is it trusted?
|
// Cross-signing is already set up for this user, is it trusted?
|
||||||
if (!mxCrossSigningInfo.isTrusted()) {
|
if (!mxCrossSigningInfo.isTrusted()) {
|
||||||
// New session
|
// New session
|
||||||
_viewEvents.post(HomeActivityViewEvents.OnNewSession(session.getUser(session.myUserId)?.toMatrixItem()))
|
_viewEvents.post(
|
||||||
|
HomeActivityViewEvents.OnNewSession(
|
||||||
|
session.getUser(session.myUserId)?.toMatrixItem(),
|
||||||
|
// If it's an old unverified, we should send requests
|
||||||
|
// instead of waiting for an incoming one
|
||||||
|
reAuthHelper.data != null
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Initialize cross-signing
|
// Initialize cross-signing
|
||||||
|
@ -1337,13 +1337,13 @@ class RoomDetailFragment @Inject constructor(
|
|||||||
|
|
||||||
private fun onShareActionClicked(action: EventSharedAction.Share) {
|
private fun onShareActionClicked(action: EventSharedAction.Share) {
|
||||||
session.fileService().downloadFile(
|
session.fileService().downloadFile(
|
||||||
FileService.DownloadMode.FOR_EXTERNAL_SHARE,
|
downloadMode = FileService.DownloadMode.FOR_EXTERNAL_SHARE,
|
||||||
action.eventId,
|
id = action.eventId,
|
||||||
action.messageContent.body,
|
fileName = action.messageContent.body,
|
||||||
action.messageContent.getFileUrl(),
|
mimeType = action.messageContent.mimeType,
|
||||||
action.messageContent.mimeType,
|
url = action.messageContent.getFileUrl(),
|
||||||
action.messageContent.encryptedFileInfo?.toElementToDecrypt(),
|
elementToDecrypt = action.messageContent.encryptedFileInfo?.toElementToDecrypt(),
|
||||||
object : MatrixCallback<File> {
|
callback = object : MatrixCallback<File> {
|
||||||
override fun onSuccess(data: File) {
|
override fun onSuccess(data: File) {
|
||||||
if (isAdded) {
|
if (isAdded) {
|
||||||
shareMedia(requireContext(), data, getMimeTypeFromUri(requireContext(), data.toUri()))
|
shareMedia(requireContext(), data, getMimeTypeFromUri(requireContext(), data.toUri()))
|
||||||
|
@ -873,13 +873,13 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
session.fileService().downloadFile(
|
session.fileService().downloadFile(
|
||||||
FileService.DownloadMode.FOR_INTERNAL_USE,
|
downloadMode = FileService.DownloadMode.FOR_INTERNAL_USE,
|
||||||
action.eventId,
|
id = action.eventId,
|
||||||
action.messageFileContent.getFileName(),
|
fileName = action.messageFileContent.getFileName(),
|
||||||
action.messageFileContent.mimeType,
|
mimeType = action.messageFileContent.mimeType,
|
||||||
mxcUrl,
|
url = mxcUrl,
|
||||||
action.messageFileContent.encryptedFileInfo?.toElementToDecrypt(),
|
elementToDecrypt = action.messageFileContent.encryptedFileInfo?.toElementToDecrypt(),
|
||||||
object : MatrixCallback<File> {
|
callback = object : MatrixCallback<File> {
|
||||||
override fun onSuccess(data: File) {
|
override fun onSuccess(data: File) {
|
||||||
_viewEvents.post(RoomDetailViewEvents.DownloadFileState(
|
_viewEvents.post(RoomDetailViewEvents.DownloadFileState(
|
||||||
action.messageFileContent.mimeType,
|
action.messageFileContent.mimeType,
|
||||||
|
@ -134,13 +134,13 @@ class ImageMediaViewerActivity : VectorBaseActivity() {
|
|||||||
|
|
||||||
private fun onShareActionClicked() {
|
private fun onShareActionClicked() {
|
||||||
session.fileService().downloadFile(
|
session.fileService().downloadFile(
|
||||||
FileService.DownloadMode.FOR_EXTERNAL_SHARE,
|
downloadMode = FileService.DownloadMode.FOR_EXTERNAL_SHARE,
|
||||||
mediaData.eventId,
|
id = mediaData.eventId,
|
||||||
mediaData.filename,
|
fileName = mediaData.filename,
|
||||||
mediaData.mimeType,
|
mimeType = mediaData.mimeType,
|
||||||
mediaData.url,
|
url = mediaData.url,
|
||||||
mediaData.elementToDecrypt,
|
elementToDecrypt = mediaData.elementToDecrypt,
|
||||||
object : MatrixCallback<File> {
|
callback = object : MatrixCallback<File> {
|
||||||
override fun onSuccess(data: File) {
|
override fun onSuccess(data: File) {
|
||||||
shareMedia(this@ImageMediaViewerActivity, data, getMimeTypeFromUri(this@ImageMediaViewerActivity, data.toUri()))
|
shareMedia(this@ImageMediaViewerActivity, data, getMimeTypeFromUri(this@ImageMediaViewerActivity, data.toUri()))
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class VideoContentRenderer @Inject constructor(private val activeSessionHolder:
|
|||||||
downloadMode = FileService.DownloadMode.FOR_INTERNAL_USE,
|
downloadMode = FileService.DownloadMode.FOR_INTERNAL_USE,
|
||||||
id = data.eventId,
|
id = data.eventId,
|
||||||
fileName = data.filename,
|
fileName = data.filename,
|
||||||
mimeType = null,
|
mimeType = data.mimeType,
|
||||||
url = data.url,
|
url = data.url,
|
||||||
elementToDecrypt = data.elementToDecrypt,
|
elementToDecrypt = data.elementToDecrypt,
|
||||||
callback = object : MatrixCallback<File> {
|
callback = object : MatrixCallback<File> {
|
||||||
|
@ -79,13 +79,13 @@ class VideoMediaViewerActivity : VectorBaseActivity() {
|
|||||||
|
|
||||||
private fun onShareActionClicked() {
|
private fun onShareActionClicked() {
|
||||||
session.fileService().downloadFile(
|
session.fileService().downloadFile(
|
||||||
FileService.DownloadMode.FOR_EXTERNAL_SHARE,
|
downloadMode = FileService.DownloadMode.FOR_EXTERNAL_SHARE,
|
||||||
mediaData.eventId,
|
id = mediaData.eventId,
|
||||||
mediaData.filename,
|
fileName = mediaData.filename,
|
||||||
mediaData.mimeType,
|
mimeType = mediaData.mimeType,
|
||||||
mediaData.url,
|
url = mediaData.url,
|
||||||
mediaData.elementToDecrypt,
|
elementToDecrypt = mediaData.elementToDecrypt,
|
||||||
object : MatrixCallback<File> {
|
callback = object : MatrixCallback<File> {
|
||||||
override fun onSuccess(data: File) {
|
override fun onSuccess(data: File) {
|
||||||
shareMedia(this@VideoMediaViewerActivity, data, getMimeTypeFromUri(this@VideoMediaViewerActivity, data.toUri()))
|
shareMedia(this@VideoMediaViewerActivity, data, getMimeTypeFromUri(this@VideoMediaViewerActivity, data.toUri()))
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,26 @@ class DefaultNavigator @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun requestSelfSessionVerification(context: Context) {
|
||||||
|
val session = sessionHolder.getSafeActiveSession() ?: return
|
||||||
|
val otherSessions = session.cryptoService().getCryptoDeviceInfo(session.myUserId).filter {
|
||||||
|
it.deviceId != session.sessionParams.deviceId
|
||||||
|
}.map { it.deviceId }
|
||||||
|
if (context is VectorBaseActivity) {
|
||||||
|
if (otherSessions.isNotEmpty()) {
|
||||||
|
val pr = session.cryptoService().verificationService().requestKeyVerification(
|
||||||
|
supportedVerificationMethodsProvider.provide(),
|
||||||
|
session.myUserId,
|
||||||
|
otherSessions)
|
||||||
|
VerificationBottomSheet.forSelfVerification(session, pr.transactionId ?: pr.localId)
|
||||||
|
.show(context.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
||||||
|
} else {
|
||||||
|
VerificationBottomSheet.forSelfVerification(session)
|
||||||
|
.show(context.supportFragmentManager, VerificationBottomSheet.WAITING_SELF_VERIF_TAG)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun waitSessionVerification(context: Context) {
|
override fun waitSessionVerification(context: Context) {
|
||||||
val session = sessionHolder.getSafeActiveSession() ?: return
|
val session = sessionHolder.getSafeActiveSession() ?: return
|
||||||
if (context is VectorBaseActivity) {
|
if (context is VectorBaseActivity) {
|
||||||
|
@ -40,6 +40,8 @@ interface Navigator {
|
|||||||
|
|
||||||
fun requestSessionVerification(context: Context, otherSessionId: String)
|
fun requestSessionVerification(context: Context, otherSessionId: String)
|
||||||
|
|
||||||
|
fun requestSelfSessionVerification(context: Context)
|
||||||
|
|
||||||
fun waitSessionVerification(context: Context)
|
fun waitSessionVerification(context: Context)
|
||||||
|
|
||||||
fun upgradeSessionSecurity(context: Context, initCrossSigningOnly: Boolean)
|
fun upgradeSessionSecurity(context: Context, initCrossSigningOnly: Boolean)
|
||||||
|
@ -158,13 +158,13 @@ class RoomUploadsViewModel @AssistedInject constructor(
|
|||||||
try {
|
try {
|
||||||
val file = awaitCallback<File> {
|
val file = awaitCallback<File> {
|
||||||
session.fileService().downloadFile(
|
session.fileService().downloadFile(
|
||||||
FileService.DownloadMode.FOR_EXTERNAL_SHARE,
|
downloadMode = FileService.DownloadMode.FOR_EXTERNAL_SHARE,
|
||||||
action.uploadEvent.eventId,
|
id = action.uploadEvent.eventId,
|
||||||
action.uploadEvent.contentWithAttachmentContent.body,
|
fileName = action.uploadEvent.contentWithAttachmentContent.body,
|
||||||
action.uploadEvent.contentWithAttachmentContent.getFileUrl(),
|
mimeType = action.uploadEvent.contentWithAttachmentContent.mimeType,
|
||||||
action.uploadEvent.contentWithAttachmentContent.mimeType,
|
url = action.uploadEvent.contentWithAttachmentContent.getFileUrl(),
|
||||||
action.uploadEvent.contentWithAttachmentContent.encryptedFileInfo?.toElementToDecrypt(),
|
elementToDecrypt = action.uploadEvent.contentWithAttachmentContent.encryptedFileInfo?.toElementToDecrypt(),
|
||||||
it)
|
callback = it)
|
||||||
}
|
}
|
||||||
_viewEvents.post(RoomUploadsViewEvents.FileReadyForSaving(file, action.uploadEvent.contentWithAttachmentContent.body))
|
_viewEvents.post(RoomUploadsViewEvents.FileReadyForSaving(file, action.uploadEvent.contentWithAttachmentContent.body))
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
|
@ -51,7 +51,7 @@ class CrossSigningSettingsFragment @Inject constructor(
|
|||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
CrossSigningSettingsViewEvents.VerifySession -> {
|
CrossSigningSettingsViewEvents.VerifySession -> {
|
||||||
navigator.waitSessionVerification(requireActivity())
|
navigator.requestSelfSessionVerification(requireActivity())
|
||||||
}
|
}
|
||||||
CrossSigningSettingsViewEvents.SetUpRecovery -> {
|
CrossSigningSettingsViewEvents.SetUpRecovery -> {
|
||||||
navigator.upgradeSessionSecurity(requireActivity(), false)
|
navigator.upgradeSessionSecurity(requireActivity(), false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user