summary refs log tree commit diff
path: root/synapse/handlers/_base.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-03-01 17:27:22 +0000
committerRichard van der Hoff <richard@matrix.org>2016-03-01 17:27:22 +0000
commit8a1d3b86af5a6b23bd45ed137a4eb2b53c274297 (patch)
treec9f8115b5b750ada36e655ba47a2eab837638c54 /synapse/handlers/_base.py
parentMerge pull request #607 from matrix-org/dbkr/send_inviter_member_event (diff)
downloadsynapse-8a1d3b86af5a6b23bd45ed137a4eb2b53c274297.tar.xz
Handle rejections of invites from local users locally
Slightly hacky fix to SYN-642, which avoids the federation codepath when trying
to reject invites from local users.
Diffstat (limited to 'synapse/handlers/_base.py')
-rw-r--r--synapse/handlers/_base.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py
index bdade98bf7..51bd1ee4de 100644
--- a/synapse/handlers/_base.py
+++ b/synapse/handlers/_base.py
@@ -199,8 +199,7 @@ class BaseHandler(object):
         # events in the room, because we don't know enough about the graph
         # fragment we received to treat it like a graph, so the above returned
         # no relevant events. It may have returned some events (if we have
-        # joined and left the room), but not useful ones, like the invite. So we
-        # forcibly set our context to the invite we received over federation.
+        # joined and left the room), but not useful ones, like the invite.
         if (
             not self.is_host_in_room(context.current_state) and
             builder.type == EventTypes.Member
@@ -208,7 +207,18 @@ class BaseHandler(object):
             prev_member_event = yield self.store.get_room_member(
                 builder.sender, builder.room_id
             )
-            if prev_member_event:
+
+            # if we have the prev_member_event in context, we didn't receive
+            # the invite over federation. (More likely is that the inviting
+            # user, and all other local users, have left, making
+            # is_host_in_room return false).
+            #
+            context_events = (e.event_id for e in context.current_state.values())
+
+            if prev_member_event and not prev_member_event.event_id in context_events:
+                # The prev_member_event is missing from context, so it must
+                # have arrived over federation and is an outlier. We forcibly
+                # set our context to the invite we received over federation
                 builder.prev_events = (
                     prev_member_event.event_id,
                     prev_member_event.prev_events