mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Simplify logic of the use case to check if event can be redacted
This commit is contained in:
parent
667b30f145
commit
99fc4b4a21
@ -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 New Issue
Block a user