summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2022-04-20 14:57:39 +0300
committerGitHub <noreply@github.com>2022-04-20 12:57:39 +0100
commit4bc8cb4669ddeb719a3a6de39b093fc3be8db6fe (patch)
tree4a1c11e3f5f5bf463a5c5e9cfebf2da4c4ad55ab /synapse/storage
parentAdd CI job to act as a canary for testing against latest dependencies (#12472) (diff)
downloadsynapse-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/storage')
-rw-r--r--synapse/storage/databases/main/events_worker.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/events_worker.py b/synapse/storage/databases/main/events_worker.py
index 5288cdba03..60876204bd 100644
--- a/synapse/storage/databases/main/events_worker.py
+++ b/synapse/storage/databases/main/events_worker.py
@@ -303,6 +303,24 @@ class EventsWorkerStore(SQLBaseStore):
             desc="get_received_ts",
         )
 
+    async def have_censored_event(self, event_id: str) -> bool:
+        """Check if an event has been censored, i.e. if the content of the event has been erased
+        from the database due to a redaction.
+
+        Args:
+            event_id: The event ID that was redacted.
+
+        Returns:
+            True if the event has been censored, False otherwise.
+        """
+        censored_redactions_list = await self.db_pool.simple_select_onecol(
+            table="redactions",
+            keyvalues={"redacts": event_id},
+            retcol="have_censored",
+            desc="get_have_censored",
+        )
+        return any(censored_redactions_list)
+
     # Inform mypy that if allow_none is False (the default) then get_event
     # always returns an EventBase.
     @overload