diff options
author | Erik Johnston <erik@matrix.org> | 2015-04-17 11:22:31 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-04-17 11:22:31 +0100 |
commit | 6ba2e3df4e72aa7fea6cbba48aa669ed06f29453 (patch) | |
tree | 0cb4408ef42387011828b7843f58078afe512d68 /synapse/handlers | |
parent | Fix port script after storage changes. Add very simple (off by default) curse... (diff) | |
parent | Add kick users script (diff) | |
download | synapse-6ba2e3df4e72aa7fea6cbba48aa669ed06f29453.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into postgres
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/typing.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py index c2762f92c7..c0b2bd7db0 100644 --- a/synapse/handlers/typing.py +++ b/synapse/handlers/typing.py @@ -223,6 +223,7 @@ class TypingNotificationEventSource(object): def __init__(self, hs): self.hs = hs self._handler = None + self._room_member_handler = None def handler(self): # Avoid cyclic dependency in handler setup @@ -230,6 +231,11 @@ class TypingNotificationEventSource(object): self._handler = self.hs.get_handlers().typing_notification_handler return self._handler + def room_member_handler(self): + if not self._room_member_handler: + self._room_member_handler = self.hs.get_handlers().room_member_handler + return self._room_member_handler + def _make_event_for(self, room_id): typing = self.handler()._room_typing[room_id] return { @@ -240,19 +246,25 @@ class TypingNotificationEventSource(object): }, } + @defer.inlineCallbacks def get_new_events_for_user(self, user, from_key, limit): from_key = int(from_key) handler = self.handler() + joined_room_ids = ( + yield self.room_member_handler().get_joined_rooms_for_user(user) + ) + events = [] for room_id in handler._room_serials: + if room_id not in joined_room_ids: + continue if handler._room_serials[room_id] <= from_key: continue - # TODO: check if user is in room events.append(self._make_event_for(room_id)) - return (events, handler._latest_room_serial) + defer.returnValue((events, handler._latest_room_serial)) def get_current_key(self): return self.handler()._latest_room_serial |