diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-05-21 15:14:26 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-05-21 16:41:39 +0100 |
commit | 53447e9cd380262c16677cfddeda1d75aeebe38c (patch) | |
tree | cf563422554aa7308b9df7ee9f0b13fd3a88b33d /synapse/push | |
parent | Add a cache for get_current_state with state_key (diff) | |
download | synapse-53447e9cd380262c16677cfddeda1d75aeebe38c.tar.xz |
Add caches for things requested by the pushers
Diffstat (limited to 'synapse/push')
-rw-r--r-- | synapse/push/__init__.py | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/synapse/push/__init__.py b/synapse/push/__init__.py index 8125987845..d4b376913c 100644 --- a/synapse/push/__init__.py +++ b/synapse/push/__init__.py @@ -84,25 +84,20 @@ class Pusher(object): rules = baserules.list_with_base_rules(rawrules, user) + room_id = ev['room_id'] + # get *our* member event for display name matching - member_events_for_room = yield self.store.get_current_state( - room_id=ev['room_id'], + my_display_name = None + our_member_event = yield self.store.get_current_state( + room_id=room_id, event_type='m.room.member', - state_key=None + state_key=self.user_name, ) - my_display_name = None - room_member_count = 0 - for mev in member_events_for_room: - if mev.content['membership'] != 'join': - continue - - # This loop does two things: - # 1) Find our current display name - if mev.state_key == self.user_name and 'displayname' in mev.content: - my_display_name = mev.content['displayname'] + if our_member_event: + my_display_name = our_member_event[0].content.get("displayname") - # and 2) Get the number of people in that room - room_member_count += 1 + room_members = yield self.store.get_users_in_room(room_id) + room_member_count = len(room_members) for r in rules: if r['rule_id'] in enabled_map: |