wip crypto

This commit is contained in:
Valere 2019-07-08 12:05:41 +02:00
parent 94b4351e19
commit 7096094224
4 changed files with 8 additions and 9 deletions

View File

@ -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
) {


View File

@ -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
)
}


View File

@ -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
}
}

View File

@ -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