File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
main/java/im/vector/app/features/notifications
test/java/im/vector/app/features/notifications Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package im.vector.app.features.notifications
1919import im.vector.app.features.invite.AutoAcceptInvites
2020import im.vector.app.features.notifications.ProcessedEvent.Type.KEEP
2121import im.vector.app.features.notifications.ProcessedEvent.Type.REMOVE
22+ import org.matrix.android.sdk.api.session.events.model.EventType
2223import javax.inject.Inject
2324
2425private 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 }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import im.vector.app.test.fakes.FakeAutoAcceptInvites
2121import im.vector.app.test.fakes.FakeOutdatedEventDetector
2222import org.amshove.kluent.shouldBeEqualTo
2323import org.junit.Test
24+ import org.matrix.android.sdk.api.session.events.model.EventType
2425
2526private 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 ,
You can’t perform that action at this time.
0 commit comments