summary refs log tree commit diff
path: root/synapse/handlers/_base.py
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2015-08-28 15:31:49 +0100
committerDaniel Wagner-Hall <daniel@matrix.org>2015-08-28 15:31:49 +0100
commit8256a8ece7e228bf69fcd352f1b4adfa2138719a (patch)
tree414bc3f5442b52dae1d0fd2aee8b0f7f14d2026b /synapse/handlers/_base.py
parentMerge pull request #254 from matrix-org/markjh/tox_setuptools (diff)
downloadsynapse-8256a8ece7e228bf69fcd352f1b4adfa2138719a.tar.xz
Allow users to redact their own events
Diffstat (limited to 'synapse/handlers/_base.py')
-rw-r--r--synapse/handlers/_base.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py
index e91f1129db..9d36e3b6d2 100644
--- a/synapse/handlers/_base.py
+++ b/synapse/handlers/_base.py
@@ -15,7 +15,7 @@
 
 from twisted.internet import defer
 
-from synapse.api.errors import LimitExceededError, SynapseError
+from synapse.api.errors import LimitExceededError, SynapseError, AuthError
 from synapse.crypto.event_signing import add_hashes_and_signatures
 from synapse.api.constants import Membership, EventTypes
 from synapse.types import UserID, RoomAlias
@@ -131,7 +131,7 @@ class BaseHandler(object):
                     )
 
         if event.type == EventTypes.CanonicalAlias:
-            # Check the alias is acually valid (at this time at least)
+            # Check the alias is actually valid (at this time at least)
             room_alias_str = event.content.get("alias", None)
             if room_alias_str:
                 room_alias = RoomAlias.from_string(room_alias_str)
@@ -146,6 +146,21 @@ class BaseHandler(object):
                         )
                     )
 
+        if event.type == EventTypes.Redaction:
+            if self.auth.check_redaction(event, auth_events=context.current_state):
+                original_event = yield self.store.get_event(
+                    event.redacts,
+                    check_redacted=False,
+                    get_prev_content=False,
+                    allow_rejected=False,
+                    allow_none=False
+                )
+                if event.user_id != original_event.user_id:
+                    raise AuthError(
+                        403,
+                        "You don't have permission to redact events"
+                    )
+
         destinations = set(extra_destinations)
         for k, s in context.current_state.items():
             try: