mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Handle redacted e2e event
This commit is contained in:
parent
3f74c4e933
commit
8e76700c8d
4 changed files with 17 additions and 3 deletions
|
@ -228,4 +228,8 @@ data class Event(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells if the event is redacted
|
||||||
|
*/
|
||||||
|
fun isRedacted() = unsignedData?.redactedEvent != null
|
||||||
}
|
}
|
|
@ -107,7 +107,7 @@ internal class InMemoryTimelineEventFactory @Inject constructor(private val room
|
||||||
senderRoomMember?.avatarUrl)
|
senderRoomMember?.avatarUrl)
|
||||||
}
|
}
|
||||||
val event = eventEntity.asDomain()
|
val event = eventEntity.asDomain()
|
||||||
if (event.getClearType() == EventType.ENCRYPTED) {
|
if (event.getClearType() == EventType.ENCRYPTED && !event.isRedacted()) {
|
||||||
handleEncryptedEvent(event, eventEntity.localId)
|
handleEncryptedEvent(event, eventEntity.localId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +141,9 @@ internal class InMemoryTimelineEventFactory @Inject constructor(private val room
|
||||||
Timber.e(failure, "Encrypted event: decryption failed")
|
Timber.e(failure, "Encrypted event: decryption failed")
|
||||||
if (failure is MXDecryptionException) {
|
if (failure is MXDecryptionException) {
|
||||||
event.setCryptoError(failure.cryptoError)
|
event.setCryptoError(failure.cryptoError)
|
||||||
|
} else {
|
||||||
|
// Other error
|
||||||
|
Timber.e("Other error, should be handled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class MessageItemFactory @Inject constructor(
|
||||||
|
|
||||||
val informationData = messageInformationDataFactory.create(event, nextEvent)
|
val informationData = messageInformationDataFactory.create(event, nextEvent)
|
||||||
|
|
||||||
if (event.root.unsignedData?.redactedEvent != null) {
|
if (event.root.isRedacted()) {
|
||||||
//message is redacted
|
//message is redacted
|
||||||
return buildRedactedItem(informationData, highlight, callback)
|
return buildRedactedItem(informationData, highlight, callback)
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,14 @@ class TimelineItemFactory @Inject constructor(private val messageItemFactory: Me
|
||||||
|
|
||||||
// Crypto
|
// Crypto
|
||||||
EventType.ENCRYPTION -> encryptionItemFactory.create(event, highlight, callback)
|
EventType.ENCRYPTION -> encryptionItemFactory.create(event, highlight, callback)
|
||||||
EventType.ENCRYPTED -> encryptedItemFactory.create(event, nextEvent, highlight, callback)
|
EventType.ENCRYPTED -> {
|
||||||
|
if (event.root.isRedacted()) {
|
||||||
|
// Redacted event, let the MessageItemFactory handle it
|
||||||
|
messageItemFactory.create(event, nextEvent, highlight, callback)
|
||||||
|
} else {
|
||||||
|
encryptedItemFactory.create(event, nextEvent, highlight, callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Unhandled event types (yet)
|
// Unhandled event types (yet)
|
||||||
EventType.STATE_ROOM_THIRD_PARTY_INVITE,
|
EventType.STATE_ROOM_THIRD_PARTY_INVITE,
|
||||||
|
|
Loading…
Reference in a new issue