mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
wip crypto
This commit is contained in:
parent
94b4351e19
commit
7096094224
4 changed files with 8 additions and 9 deletions
|
@ -35,7 +35,7 @@ data class TimelineEvent(
|
|||
val isUniqueDisplayName: Boolean,
|
||||
val senderAvatar: String?,
|
||||
val sendState: SendState,
|
||||
// val hasClearEventFlag: Boolean = false,
|
||||
val hasClearEventFlag: Boolean = false, //used to refresh
|
||||
val annotations: EventAnnotationsSummary? = null
|
||||
) {
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ internal object TimelineEventMapper {
|
|||
senderName = timelineEventEntity.senderName,
|
||||
isUniqueDisplayName = timelineEventEntity.isUniqueDisplayName,
|
||||
senderAvatar = timelineEventEntity.senderAvatar,
|
||||
sendState = timelineEventEntity.root?.sendState ?: SendState.UNKNOWN
|
||||
sendState = timelineEventEntity.root?.sendState ?: SendState.UNKNOWN,
|
||||
hasClearEventFlag = timelineEventEntity.root?.decryptionResultJson != null
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -81,5 +81,7 @@ internal open class EventEntity(@PrimaryKey var localId: String = UUID.randomUUI
|
|||
)
|
||||
val adapter = MoshiProvider.providesMoshi().adapter<OlmDecryptionResult>(OlmDecryptionResult::class.java)
|
||||
decryptionResultJson = adapter.toJson(decryptionResult)
|
||||
decryptionErrorCode = null
|
||||
timelineEventEntity?.firstOrNull()?.root = this
|
||||
}
|
||||
}
|
|
@ -99,14 +99,10 @@ internal class TimelineEventDecryptor(
|
|||
val event = eventEntity.asDomain()
|
||||
try {
|
||||
val result = cryptoService.decryptEvent(event, timelineId)
|
||||
if (result == null) {
|
||||
Timber.e("Null decryption result for event ${eventId}")
|
||||
} else {
|
||||
Timber.v("Successfully decrypted event ${eventId}")
|
||||
eventEntity.setDecryptionResult(result)
|
||||
}
|
||||
|
||||
Timber.v("Successfully decrypted event ${eventId}")
|
||||
eventEntity.setDecryptionResult(result)
|
||||
} catch (e: MXCryptoError) {
|
||||
Timber.v("Failed to decrypte event ${eventId} ${e}")
|
||||
if (e is MXCryptoError.Base && e.errorType == MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID) {
|
||||
//Keep track of unknown sessions to automatically try to decrypt on new session
|
||||
eventEntity.decryptionErrorCode = e.errorType.name
|
||||
|
|
Loading…
Reference in a new issue