mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
filtering out redacted simple message events, we handle them by updating the notifications
This commit is contained in:
parent
a5fe6f7212
commit
6d9877d79c
2 changed files with 19 additions and 3 deletions
|
@ -19,6 +19,7 @@ package im.vector.app.features.notifications
|
|||
import im.vector.app.features.invite.AutoAcceptInvites
|
||||
import im.vector.app.features.notifications.ProcessedEvent.Type.KEEP
|
||||
import im.vector.app.features.notifications.ProcessedEvent.Type.REMOVE
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import javax.inject.Inject
|
||||
|
||||
private typealias ProcessedEvents = List<ProcessedEvent<NotifiableEvent>>
|
||||
|
@ -35,7 +36,10 @@ class NotifiableEventProcessor @Inject constructor(
|
|||
is NotifiableMessageEvent -> if (shouldIgnoreMessageEventInRoom(currentRoomId, it.roomId) || outdatedDetector.isMessageOutdated(it)) {
|
||||
REMOVE
|
||||
} else KEEP
|
||||
is SimpleNotifiableEvent -> KEEP
|
||||
is SimpleNotifiableEvent -> when (it.type) {
|
||||
EventType.REDACTION -> REMOVE
|
||||
else -> KEEP
|
||||
}
|
||||
}
|
||||
ProcessedEvent(type, it)
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import im.vector.app.test.fakes.FakeAutoAcceptInvites
|
|||
import im.vector.app.test.fakes.FakeOutdatedEventDetector
|
||||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.junit.Test
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
|
||||
private val NOT_VIEWING_A_ROOM: String? = null
|
||||
|
||||
|
@ -46,6 +47,17 @@ class NotifiableEventProcessorTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given redacted simple event when processing then remove redaction event`() {
|
||||
val events = listOf(aSimpleNotifiableEvent(eventId = "event-1", type = EventType.REDACTION))
|
||||
|
||||
val result = eventProcessor.process(events, currentRoomId = NOT_VIEWING_A_ROOM, renderedEvents = emptyList())
|
||||
|
||||
result shouldBeEqualTo listOfProcessedEvents(
|
||||
Type.REMOVE to events[0]
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given invites are auto accepted when processing then remove invitations`() {
|
||||
autoAcceptInvites._isEnabled = true
|
||||
|
@ -134,14 +146,14 @@ class NotifiableEventProcessorTest {
|
|||
}
|
||||
}
|
||||
|
||||
fun aSimpleNotifiableEvent(eventId: String) = SimpleNotifiableEvent(
|
||||
fun aSimpleNotifiableEvent(eventId: String, type: String? = null) = SimpleNotifiableEvent(
|
||||
matrixID = null,
|
||||
eventId = eventId,
|
||||
editedEventId = null,
|
||||
noisy = false,
|
||||
title = "title",
|
||||
description = "description",
|
||||
type = null,
|
||||
type = type,
|
||||
timestamp = 0,
|
||||
soundName = null,
|
||||
canBeReplaced = false,
|
||||
|
|
Loading…
Reference in a new issue