diff options
author | Erik Johnston <erikj@jki.re> | 2016-08-26 13:41:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-26 13:41:57 +0100 |
commit | c943d8d2e8a08d3ec2cc17a466f8426058fb6246 (patch) | |
tree | ff4b826a956b0890727734063b2895c8e61cefbc /synapse/handlers/_base.py | |
parent | Merge pull request #1043 from matrix-org/erikj/backfill_fix (diff) | |
parent | Add is_host_joined to slave storage (diff) | |
download | synapse-c943d8d2e8a08d3ec2cc17a466f8426058fb6246.tar.xz |
Merge pull request #1047 from matrix-org/erikj/state_ids
Avoid pulling the full state of a room out so often.
Diffstat (limited to 'synapse/handlers/_base.py')
-rw-r--r-- | synapse/handlers/_base.py | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py index 11081a0cd5..e58735294e 100644 --- a/synapse/handlers/_base.py +++ b/synapse/handlers/_base.py @@ -65,33 +65,21 @@ class BaseHandler(object): retry_after_ms=int(1000 * (time_allowed - time_now)), ) - def is_host_in_room(self, current_state): - room_members = [ - (state_key, event.membership) - for ((event_type, state_key), event) in current_state.items() - if event_type == EventTypes.Member - ] - if len(room_members) == 0: - # Have we just created the room, and is this about to be the very - # first member event? - create_event = current_state.get(("m.room.create", "")) - if create_event: - return True - for (state_key, membership) in room_members: - if ( - self.hs.is_mine_id(state_key) - and membership == Membership.JOIN - ): - return True - return False - @defer.inlineCallbacks - def maybe_kick_guest_users(self, event, current_state): + def maybe_kick_guest_users(self, event, context=None): # Technically this function invalidates current_state by changing it. # Hopefully this isn't that important to the caller. if event.type == EventTypes.GuestAccess: guest_access = event.content.get("guest_access", "forbidden") if guest_access != "can_join": + if context: + current_state = yield self.store.get_events( + context.current_state_ids.values() + ) + current_state = current_state.values() + else: + current_state = yield self.store.get_current_state(event.room_id) + logger.info("maybe_kick_guest_users %r", current_state) yield self.kick_guest_users(current_state) @defer.inlineCallbacks |