mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Simplify logic of the use case to check if event can be redacted
This commit is contained in:
parent
667b30f145
commit
99fc4b4a21
1 changed files with 4 additions and 5 deletions
|
@ -29,10 +29,9 @@ class CheckIfCanRedactEventUseCase @Inject constructor(
|
|||
// Only some event types are supported for the moment
|
||||
val canRedactEventTypes = listOf(EventType.MESSAGE, EventType.STICKER) +
|
||||
EventType.POLL_START + EventType.STATE_ROOM_BEACON_INFO
|
||||
if (event.root.getClearType() !in canRedactEventTypes) return false
|
||||
// Message sent by the current user can always be redacted
|
||||
if (event.root.senderId == activeSessionHolder.getActiveSession().myUserId) return true
|
||||
// Check permission for messages sent by other users
|
||||
return actionPermissions.canRedact
|
||||
|
||||
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
|
||||
(event.root.senderId == activeSessionHolder.getActiveSession().myUserId || actionPermissions.canRedact)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue