From 4a0a6e9f01d665505851fbb27221239c3223bc38 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 25 Mar 2021 14:42:15 +0100 Subject: [PATCH] FastLane: Ignore message edition --- .../org/matrix/android/sdk/api/session/events/model/Event.kt | 4 ++++ .../app/features/notifications/NotifiableEventResolver.kt | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt index 844e8dbbab..89b873febb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt @@ -289,3 +289,7 @@ fun Event.getRelationContent(): RelationDefaultContent? { fun Event.isReply(): Boolean { return getRelationContent()?.inReplyTo?.eventId != null } + +fun Event.isEdition(): Boolean { + return getRelationContent()?.takeIf { it.type == RelationType.REPLACE }?.eventId != null +} diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt index d5862f3a85..477534eda5 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt @@ -26,6 +26,7 @@ import org.matrix.android.sdk.api.session.content.ContentUrlResolver import org.matrix.android.sdk.api.session.crypto.MXCryptoError import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.EventType +import org.matrix.android.sdk.api.session.events.model.isEdition import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.RoomMemberContent @@ -89,7 +90,9 @@ class NotifiableEventResolver @Inject constructor( fun resolveInMemoryEvent(session: Session, event: Event): NotifiableEvent? { if (event.getClearType() != EventType.MESSAGE) return null - // TODO Ignore message edition + // Ignore message edition + if (event.isEdition()) return null + val user = session.getUser(event.senderId!!) ?: return null val timelineEvent = TimelineEvent(