Skip to content

Commit a5fe6f7

Browse files
committed
removing redacted events from the room notification message list
1 parent b146501 commit a5fe6f7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class NotificationFactory @Inject constructor(
3333
when {
3434
events.hasNoEventsToDisplay() -> RoomNotification.Removed(roomId)
3535
else -> {
36-
val messageEvents = events.onlyKeptEvents()
36+
val messageEvents = events.onlyKeptEvents().filterNot { it.isRedacted }
3737
roomGroupMessageCreator.createRoomMessage(messageEvents, roomId, myUserDisplayName, myUserAvatarUrl)
3838
}
3939
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ class NotificationFactoryTest {
135135
roomId = A_ROOM_ID
136136
))
137137
}
138+
139+
@Test
140+
fun `given a room with redacted and non redacted message events when mapping to notification then redacted events are removed`() = testWith(notificationFactory) {
141+
val roomWithRedactedMessage = mapOf(A_ROOM_ID to listOf(
142+
ProcessedEvent(Type.KEEP, A_MESSAGE_EVENT.copy(isRedacted = true)),
143+
ProcessedEvent(Type.KEEP, A_MESSAGE_EVENT.copy(eventId = "not-redacted"))
144+
))
145+
val withRedactedRemoved = listOf(A_MESSAGE_EVENT.copy(eventId = "not-redacted"))
146+
val expectedNotification = roomGroupMessageCreator.givenCreatesRoomMessageFor(withRedactedRemoved, A_ROOM_ID, MY_USER_ID, MY_AVATAR_URL)
147+
148+
val result = roomWithRedactedMessage.toNotifications(MY_USER_ID, MY_AVATAR_URL)
149+
150+
result shouldBeEqualTo listOf(expectedNotification)
151+
}
138152
}
139153

140154
fun <T> testWith(receiver: T, block: T.() -> Unit) {

0 commit comments

Comments
 (0)