diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt index 5ae49f78..26587359 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt @@ -228,4 +228,8 @@ data class Event( } } + /** + * Tells if the event is redacted + */ + fun isRedacted() = unsignedData?.redactedEvent != null } \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventFactory.kt index e98e0d35..4fb237c3 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventFactory.kt @@ -107,7 +107,7 @@ internal class InMemoryTimelineEventFactory @Inject constructor(private val room senderRoomMember?.avatarUrl) } val event = eventEntity.asDomain() - if (event.getClearType() == EventType.ENCRYPTED) { + if (event.getClearType() == EventType.ENCRYPTED && !event.isRedacted()) { handleEncryptedEvent(event, eventEntity.localId) } @@ -141,6 +141,9 @@ internal class InMemoryTimelineEventFactory @Inject constructor(private val room Timber.e(failure, "Encrypted event: decryption failed") if (failure is MXDecryptionException) { event.setCryptoError(failure.cryptoError) + } else { + // Other error + Timber.e("Other error, should be handled") } } } diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 5cb7c943..f3d40bc6 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -71,7 +71,7 @@ class MessageItemFactory @Inject constructor( val informationData = messageInformationDataFactory.create(event, nextEvent) - if (event.root.unsignedData?.redactedEvent != null) { + if (event.root.isRedacted()) { //message is redacted return buildRedactedItem(informationData, highlight, callback) } diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/TimelineItemFactory.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/TimelineItemFactory.kt index 32edb0b8..84f4f287 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/TimelineItemFactory.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/TimelineItemFactory.kt @@ -55,7 +55,14 @@ class TimelineItemFactory @Inject constructor(private val messageItemFactory: Me // Crypto 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) EventType.STATE_ROOM_THIRD_PARTY_INVITE,