diff options
author | Erik Johnston <erik@matrix.org> | 2015-07-16 18:18:36 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-07-16 18:18:36 +0100 |
commit | b6d4a4c6d883a4c3084938e11fc5bb654b5779e4 (patch) | |
tree | dbcdb1eb3459c5a53c7bdb8117d2aaee26332366 /synapse/notifier.py | |
parent | Merge pull request #203 from matrix-org/erikj/room_creation_presets (diff) | |
parent | Docs (diff) | |
download | synapse-b6d4a4c6d883a4c3084938e11fc5bb654b5779e4.tar.xz |
Merge pull request #199 from matrix-org/erikj/receipts
Implement read receipts.
Diffstat (limited to 'synapse/notifier.py')
-rw-r--r-- | synapse/notifier.py | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py index bdd03dcbe8..85ae343135 100644 --- a/synapse/notifier.py +++ b/synapse/notifier.py @@ -221,16 +221,7 @@ class Notifier(object): event ) - room_id = event.room_id - - room_user_streams = self.room_to_user_streams.get(room_id, set()) - - user_streams = room_user_streams.copy() - - for user in extra_users: - user_stream = self.user_to_user_stream.get(str(user)) - if user_stream is not None: - user_streams.add(user_stream) + app_streams = set() for appservice in self.appservice_to_user_streams: # TODO (kegan): Redundant appservice listener checks? @@ -242,24 +233,20 @@ class Notifier(object): app_user_streams = self.appservice_to_user_streams.get( appservice, set() ) - user_streams |= app_user_streams - - logger.debug("on_new_room_event listeners %s", user_streams) + app_streams |= app_user_streams - time_now_ms = self.clock.time_msec() - for user_stream in user_streams: - try: - user_stream.notify( - "room_key", "s%d" % (room_stream_id,), time_now_ms - ) - except: - logger.exception("Failed to notify listener") + self.on_new_event( + "room_key", room_stream_id, + users=extra_users, + rooms=[event.room_id], + extra_streams=app_streams, + ) @defer.inlineCallbacks @log_function - def on_new_user_event(self, stream_key, new_token, users=[], rooms=[]): - """ Used to inform listeners that something has happend - presence/user event wise. + def on_new_event(self, stream_key, new_token, users=[], rooms=[], + extra_streams=set()): + """ Used to inform listeners that something has happend event wise. Will wake up all listeners for the given users and rooms. """ @@ -283,7 +270,7 @@ class Notifier(object): @defer.inlineCallbacks def wait_for_events(self, user, rooms, timeout, callback, - from_token=StreamToken("s0", "0", "0")): + from_token=StreamToken("s0", "0", "0", "0")): """Wait until the callback returns a non empty response or the timeout fires. """ |