diff options
author | Tulir Asokan <tulir@maunium.net> | 2022-04-20 14:57:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-20 12:57:39 +0100 |
commit | 4bc8cb4669ddeb719a3a6de39b093fc3be8db6fe (patch) | |
tree | 4a1c11e3f5f5bf463a5c5e9cfebf2da4c4ad55ab /synapse/handlers/events.py | |
parent | Add CI job to act as a canary for testing against latest dependencies (#12472) (diff) | |
download | synapse-4bc8cb4669ddeb719a3a6de39b093fc3be8db6fe.tar.xz |
Implement MSC2815: allow room moderators to view redacted event content (#12427)
Implements matrix-org/matrix-spec-proposals#2815 Signed-off-by: Tulir Asokan <tulir@maunium.net>
Diffstat (limited to 'synapse/handlers/events.py')
-rw-r--r-- | synapse/handlers/events.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/synapse/handlers/events.py b/synapse/handlers/events.py index e89c4df314..5b94b00bc3 100644 --- a/synapse/handlers/events.py +++ b/synapse/handlers/events.py @@ -21,6 +21,7 @@ from synapse.api.errors import AuthError, SynapseError from synapse.events import EventBase from synapse.events.utils import SerializeEventConfig from synapse.handlers.presence import format_user_presence_state +from synapse.storage.databases.main.events_worker import EventRedactBehaviour from synapse.streams.config import PaginationConfig from synapse.types import JsonDict, UserID from synapse.visibility import filter_events_for_client @@ -141,7 +142,11 @@ class EventHandler: self.storage = hs.get_storage() async def get_event( - self, user: UserID, room_id: Optional[str], event_id: str + self, + user: UserID, + room_id: Optional[str], + event_id: str, + show_redacted: bool = False, ) -> Optional[EventBase]: """Retrieve a single specified event. @@ -150,6 +155,7 @@ class EventHandler: room_id: The expected room id. We'll return None if the event's room does not match. event_id: The event ID to obtain. + show_redacted: Should the full content of redacted events be returned? Returns: An event, or None if there is no event matching this ID. Raises: @@ -157,7 +163,12 @@ class EventHandler: AuthError if the user does not have the rights to inspect this event. """ - event = await self.store.get_event(event_id, check_room_id=room_id) + redact_behaviour = ( + EventRedactBehaviour.AS_IS if show_redacted else EventRedactBehaviour.REDACT + ) + event = await self.store.get_event( + event_id, check_room_id=room_id, redact_behaviour=redact_behaviour + ) if not event: return None |