Skip to content

Commit 6d9877d

Browse files
committed
filtering out redacted simple message events, we handle them by updating the notifications
1 parent a5fe6f7 commit 6d9877d

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

vector/src/main/java/im/vector/app/features/notifications/NotifiableEventProcessor.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package im.vector.app.features.notifications
1919
import im.vector.app.features.invite.AutoAcceptInvites
2020
import im.vector.app.features.notifications.ProcessedEvent.Type.KEEP
2121
import im.vector.app.features.notifications.ProcessedEvent.Type.REMOVE
22+
import org.matrix.android.sdk.api.session.events.model.EventType
2223
import javax.inject.Inject
2324

2425
private typealias ProcessedEvents = List<ProcessedEvent<NotifiableEvent>>
@@ -35,7 +36,10 @@ class NotifiableEventProcessor @Inject constructor(
3536
is NotifiableMessageEvent -> if (shouldIgnoreMessageEventInRoom(currentRoomId, it.roomId) || outdatedDetector.isMessageOutdated(it)) {
3637
REMOVE
3738
} else KEEP
38-
is SimpleNotifiableEvent -> KEEP
39+
is SimpleNotifiableEvent -> when (it.type) {
40+
EventType.REDACTION -> REMOVE
41+
else -> KEEP
42+
}
3943
}
4044
ProcessedEvent(type, it)
4145
}

vector/src/test/java/im/vector/app/features/notifications/NotifiableEventProcessorTest.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import im.vector.app.test.fakes.FakeAutoAcceptInvites
2121
import im.vector.app.test.fakes.FakeOutdatedEventDetector
2222
import org.amshove.kluent.shouldBeEqualTo
2323
import org.junit.Test
24+
import org.matrix.android.sdk.api.session.events.model.EventType
2425

2526
private val NOT_VIEWING_A_ROOM: String? = null
2627

@@ -46,6 +47,17 @@ class NotifiableEventProcessorTest {
4647
)
4748
}
4849

50+
@Test
51+
fun `given redacted simple event when processing then remove redaction event`() {
52+
val events = listOf(aSimpleNotifiableEvent(eventId = "event-1", type = EventType.REDACTION))
53+
54+
val result = eventProcessor.process(events, currentRoomId = NOT_VIEWING_A_ROOM, renderedEvents = emptyList())
55+
56+
result shouldBeEqualTo listOfProcessedEvents(
57+
Type.REMOVE to events[0]
58+
)
59+
}
60+
4961
@Test
5062
fun `given invites are auto accepted when processing then remove invitations`() {
5163
autoAcceptInvites._isEnabled = true
@@ -134,14 +146,14 @@ class NotifiableEventProcessorTest {
134146
}
135147
}
136148

137-
fun aSimpleNotifiableEvent(eventId: String) = SimpleNotifiableEvent(
149+
fun aSimpleNotifiableEvent(eventId: String, type: String? = null) = SimpleNotifiableEvent(
138150
matrixID = null,
139151
eventId = eventId,
140152
editedEventId = null,
141153
noisy = false,
142154
title = "title",
143155
description = "description",
144-
type = null,
156+
type = type,
145157
timestamp = 0,
146158
soundName = null,
147159
canBeReplaced = false,

0 commit comments

Comments
 (0)