summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2018-06-25 20:14:18 +0100
committerGitHub <noreply@github.com>2018-06-25 20:14:18 +0100
commitd72fb9a44851fdaee74781c826ef4d6b35e3172e (patch)
tree2622e0e9fc6c4bd2ecf9ed5c7da3492a637b7445
parentMerge pull request #3443 from matrix-org/erikj/fast_filter_servers (diff)
parentallow non-consented users to still part rooms (to let us autopart them) (diff)
downloadsynapse-d72fb9a44851fdaee74781c826ef4d6b35e3172e.tar.xz
Merge pull request #3442 from matrix-org/matthew/allow-unconsented-parts
allow non-consented users to still part rooms (to let us autopart them)
-rw-r--r--synapse/handlers/message.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index a812117dea..8467284758 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -491,7 +491,7 @@ class EventCreationHandler(object):
                         target, e
                     )
 
-        is_exempt = yield self._is_exempt_from_privacy_policy(builder)
+        is_exempt = yield self._is_exempt_from_privacy_policy(builder, requester)
         if not is_exempt:
             yield self.assert_accepted_privacy_policy(requester)
 
@@ -509,12 +509,13 @@ class EventCreationHandler(object):
 
         defer.returnValue((event, context))
 
-    def _is_exempt_from_privacy_policy(self, builder):
+    def _is_exempt_from_privacy_policy(self, builder, requester):
         """"Determine if an event to be sent is exempt from having to consent
         to the privacy policy
 
         Args:
             builder (synapse.events.builder.EventBuilder): event being created
+            requester (Requster): user requesting this event
 
         Returns:
             Deferred[bool]: true if the event can be sent without the user
@@ -525,6 +526,9 @@ class EventCreationHandler(object):
             membership = builder.content.get("membership", None)
             if membership == Membership.JOIN:
                 return self._is_server_notices_room(builder.room_id)
+            elif membership == Membership.LEAVE:
+                # the user is always allowed to leave (but not kick people)
+                return builder.state_key == requester.user.to_string()
         return succeed(False)
 
     @defer.inlineCallbacks