summary refs log tree commit diff
path: root/synapse/api/errors.py
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/api/errors.py
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/api/errors.py')
-rw-r--r--synapse/api/errors.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/synapse/api/errors.py b/synapse/api/errors.py
index e92db29f6d..cb3b7323d5 100644
--- a/synapse/api/errors.py
+++ b/synapse/api/errors.py
@@ -79,6 +79,8 @@ class Codes:
     UNABLE_AUTHORISE_JOIN = "M_UNABLE_TO_AUTHORISE_JOIN"
     UNABLE_TO_GRANT_JOIN = "M_UNABLE_TO_GRANT_JOIN"
 
+    UNREDACTED_CONTENT_DELETED = "FI.MAU.MSC2815_UNREDACTED_CONTENT_DELETED"
+
 
 class CodeMessageException(RuntimeError):
     """An exception with integer code and message string attributes.
@@ -483,6 +485,22 @@ class RequestSendFailed(RuntimeError):
         self.can_retry = can_retry
 
 
+class UnredactedContentDeletedError(SynapseError):
+    def __init__(self, content_keep_ms: Optional[int] = None):
+        super().__init__(
+            404,
+            "The content for that event has already been erased from the database",
+            errcode=Codes.UNREDACTED_CONTENT_DELETED,
+        )
+        self.content_keep_ms = content_keep_ms
+
+    def error_dict(self) -> "JsonDict":
+        extra = {}
+        if self.content_keep_ms is not None:
+            extra = {"fi.mau.msc2815.content_keep_ms": self.content_keep_ms}
+        return cs_error(self.msg, self.errcode, **extra)
+
+
 def cs_error(msg: str, code: str = Codes.UNKNOWN, **kwargs: Any) -> "JsonDict":
     """Utility method for constructing an error response for client-server
     interactions.