Add deletion action on voice broadcast event
This commit is contained in:
parent
daf4fc0f6d
commit
e4a52e1d5e
|
@ -17,6 +17,7 @@
|
||||||
package im.vector.app.features.home.room.detail.timeline.action
|
package im.vector.app.features.home.room.detail.timeline.action
|
||||||
|
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
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.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -27,8 +28,13 @@ class CheckIfCanRedactEventUseCase @Inject constructor(
|
||||||
|
|
||||||
fun execute(event: TimelineEvent, actionPermissions: ActionPermissions): Boolean {
|
fun execute(event: TimelineEvent, actionPermissions: ActionPermissions): Boolean {
|
||||||
// Only some event types are supported for the moment
|
// Only some event types are supported for the moment
|
||||||
val canRedactEventTypes = listOf(EventType.MESSAGE, EventType.STICKER) +
|
val canRedactEventTypes: List<String> = listOf(
|
||||||
EventType.POLL_START + EventType.STATE_ROOM_BEACON_INFO
|
EventType.MESSAGE,
|
||||||
|
EventType.STICKER,
|
||||||
|
STATE_ROOM_VOICE_BROADCAST_INFO,
|
||||||
|
) +
|
||||||
|
EventType.POLL_START +
|
||||||
|
EventType.STATE_ROOM_BEACON_INFO
|
||||||
|
|
||||||
return event.root.getClearType() in canRedactEventTypes &&
|
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
|
// Message sent by the current user can always be redacted, else check permission for messages sent by other users
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package im.vector.app.features.home.room.detail.timeline.action
|
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 im.vector.app.test.fakes.FakeActiveSessionHolder
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import org.amshove.kluent.shouldBe
|
import org.amshove.kluent.shouldBe
|
||||||
|
@ -34,7 +35,7 @@ class CheckIfCanRedactEventUseCaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given an event which can be redacted and owned by user when use case executes then the result is true`() {
|
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
|
EventType.POLL_START + EventType.STATE_ROOM_BEACON_INFO
|
||||||
|
|
||||||
canRedactEventTypes.forEach { eventType ->
|
canRedactEventTypes.forEach { eventType ->
|
||||||
|
|
Loading…
Reference in New Issue