From e4a52e1d5e0848c0597b0ef5cade46596184953c Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Thu, 29 Sep 2022 13:41:43 +0200 Subject: [PATCH] Add deletion action on voice broadcast event --- .../timeline/action/CheckIfCanRedactEventUseCase.kt | 10 ++++++++-- .../action/CheckIfCanRedactEventUseCaseTest.kt | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/CheckIfCanRedactEventUseCase.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/CheckIfCanRedactEventUseCase.kt index 3bc3a5e351..eda1929133 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/CheckIfCanRedactEventUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/CheckIfCanRedactEventUseCase.kt @@ -17,6 +17,7 @@ package im.vector.app.features.home.room.detail.timeline.action import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.features.voicebroadcast.STATE_ROOM_VOICE_BROADCAST_INFO import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import javax.inject.Inject @@ -27,8 +28,13 @@ class CheckIfCanRedactEventUseCase @Inject constructor( fun execute(event: TimelineEvent, actionPermissions: ActionPermissions): Boolean { // Only some event types are supported for the moment - val canRedactEventTypes = listOf(EventType.MESSAGE, EventType.STICKER) + - EventType.POLL_START + EventType.STATE_ROOM_BEACON_INFO + val canRedactEventTypes: List = listOf( + EventType.MESSAGE, + EventType.STICKER, + STATE_ROOM_VOICE_BROADCAST_INFO, + ) + + EventType.POLL_START + + EventType.STATE_ROOM_BEACON_INFO return event.root.getClearType() in canRedactEventTypes && // Message sent by the current user can always be redacted, else check permission for messages sent by other users diff --git a/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/action/CheckIfCanRedactEventUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/action/CheckIfCanRedactEventUseCaseTest.kt index 08dd5dac5b..fcb052cb2b 100644 --- a/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/action/CheckIfCanRedactEventUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/action/CheckIfCanRedactEventUseCaseTest.kt @@ -16,6 +16,7 @@ package im.vector.app.features.home.room.detail.timeline.action +import im.vector.app.features.voicebroadcast.STATE_ROOM_VOICE_BROADCAST_INFO import im.vector.app.test.fakes.FakeActiveSessionHolder import io.mockk.mockk import org.amshove.kluent.shouldBe @@ -34,7 +35,7 @@ class CheckIfCanRedactEventUseCaseTest { @Test fun `given an event which can be redacted and owned by user when use case executes then the result is true`() { - val canRedactEventTypes = listOf(EventType.MESSAGE, EventType.STICKER) + + val canRedactEventTypes = listOf(EventType.MESSAGE, EventType.STICKER, STATE_ROOM_VOICE_BROADCAST_INFO) + EventType.POLL_START + EventType.STATE_ROOM_BEACON_INFO canRedactEventTypes.forEach { eventType ->