mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
removing redacted events from the room notification message list
This commit is contained in:
parent
b146501f29
commit
a5fe6f7212
2 changed files with 15 additions and 1 deletions
|
@ -33,7 +33,7 @@ class NotificationFactory @Inject constructor(
|
|||
when {
|
||||
events.hasNoEventsToDisplay() -> RoomNotification.Removed(roomId)
|
||||
else -> {
|
||||
val messageEvents = events.onlyKeptEvents()
|
||||
val messageEvents = events.onlyKeptEvents().filterNot { it.isRedacted }
|
||||
roomGroupMessageCreator.createRoomMessage(messageEvents, roomId, myUserDisplayName, myUserAvatarUrl)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,6 +135,20 @@ class NotificationFactoryTest {
|
|||
roomId = A_ROOM_ID
|
||||
))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given a room with redacted and non redacted message events when mapping to notification then redacted events are removed`() = testWith(notificationFactory) {
|
||||
val roomWithRedactedMessage = mapOf(A_ROOM_ID to listOf(
|
||||
ProcessedEvent(Type.KEEP, A_MESSAGE_EVENT.copy(isRedacted = true)),
|
||||
ProcessedEvent(Type.KEEP, A_MESSAGE_EVENT.copy(eventId = "not-redacted"))
|
||||
))
|
||||
val withRedactedRemoved = listOf(A_MESSAGE_EVENT.copy(eventId = "not-redacted"))
|
||||
val expectedNotification = roomGroupMessageCreator.givenCreatesRoomMessageFor(withRedactedRemoved, A_ROOM_ID, MY_USER_ID, MY_AVATAR_URL)
|
||||
|
||||
val result = roomWithRedactedMessage.toNotifications(MY_USER_ID, MY_AVATAR_URL)
|
||||
|
||||
result shouldBeEqualTo listOf(expectedNotification)
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> testWith(receiver: T, block: T.() -> Unit) {
|
||||
|
|
Loading…
Reference in a new issue