mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 14:38:45 +03:00
Add Re-Request keys for fail to decrypt
This commit is contained in:
parent
757e90986e
commit
9e63a3219c
6 changed files with 22 additions and 2 deletions
|
@ -71,4 +71,5 @@ sealed class RoomDetailAction : VectorViewModelAction {
|
|||
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?) : RoomDetailAction()
|
||||
data class ReRequestKeys(val eventId: String) : RoomDetailAction()
|
||||
}
|
||||
|
|
|
@ -1236,6 +1236,9 @@ class RoomDetailFragment @Inject constructor(
|
|||
is EventSharedAction.OnUrlLongClicked -> {
|
||||
onUrlLongClicked(action.url)
|
||||
}
|
||||
is EventSharedAction.ReRequestKey -> {
|
||||
roomDetailViewModel.handle(RoomDetailAction.ReRequestKeys(action.eventId))
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(context, "Action $action is not implemented yet", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
|
|
@ -209,6 +209,7 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||
is RoomDetailAction.DeclineVerificationRequest -> handleDeclineVerification(action)
|
||||
is RoomDetailAction.RequestVerification -> handleRequestVerification(action)
|
||||
is RoomDetailAction.ResumeVerification -> handleResumeRequestVerification(action)
|
||||
is RoomDetailAction.ReRequestKeys -> handleReRequestKeys(action)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -886,6 +887,14 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleReRequestKeys(action: RoomDetailAction.ReRequestKeys) {
|
||||
// Check if this request is still active and handled by me
|
||||
room.getTimeLineEvent(action.eventId)?.let {
|
||||
session.cryptoService().reRequestRoomKeyForEvent(it.root)
|
||||
_viewEvents.post(RoomDetailViewEvents.ShowMessage(stringProvider.getString(R.string.e2e_re_request_encryption_key_dialog_content)))
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleReplyToOptions(action: RoomDetailAction.ReplyToOptions) {
|
||||
room.sendOptionsReply(action.eventId, action.optionIndex, action.optionValue)
|
||||
}
|
||||
|
|
|
@ -102,4 +102,7 @@ sealed class EventSharedAction(@StringRes val titleRes: Int,
|
|||
// An url in the event preview has been long clicked
|
||||
data class OnUrlLongClicked(val url: String) :
|
||||
EventSharedAction(0, 0)
|
||||
|
||||
data class ReRequestKey(val eventId: String) :
|
||||
EventSharedAction(R.string.e2e_re_request_encryption_key, R.drawable.key_small)
|
||||
}
|
||||
|
|
|
@ -271,9 +271,13 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
|||
}
|
||||
}
|
||||
|
||||
if (timelineEvent.isEncrypted() && timelineEvent.root.mCryptoError != null) {
|
||||
add(EventSharedAction.ReRequestKey(timelineEvent.eventId))
|
||||
}
|
||||
|
||||
if (vectorPreferences.developerMode()) {
|
||||
add(EventSharedAction.ViewSource(timelineEvent.root.toContentStringWithIndent()))
|
||||
if (timelineEvent.isEncrypted()) {
|
||||
if (timelineEvent.isEncrypted() && timelineEvent.root.mxDecryptionResult != null) {
|
||||
val decryptedContent = timelineEvent.root.toClearContentStringWithIndent()
|
||||
?: stringProvider.getString(R.string.encryption_information_decryption_error)
|
||||
add(EventSharedAction.ViewDecryptedSource(decryptedContent))
|
||||
|
|
|
@ -301,7 +301,7 @@
|
|||
<string name="e2e_need_log_in_again">You need to log back in to generate end-to-end encryption keys for this session and submit the public key to your homeserver.\nThis is a once off.\nSorry for the inconvenience.</string>
|
||||
|
||||
<!-- request again e2e key -->
|
||||
<string name="e2e_re_request_encryption_key"><u>Re-request encryption keys</u> from your other sessions.</string>
|
||||
<string name="e2e_re_request_encryption_key">Re-request encryption keys from your other sessions.</string>
|
||||
|
||||
<string name="e2e_re_request_encryption_key_sent">Key request sent.</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue