summary refs log tree commit diff
path: root/synapse/notifier.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2016-06-07 11:33:36 +0100
committerMark Haines <mark.haines@matrix.org>2016-06-07 11:33:36 +0100
commit88625db05f274ad855fb51b33c84c09c947a6bd0 (patch)
tree132b505f9ffe92354a3b91d2a630ac04c2072e4d /synapse/notifier.py
parentFix AS retries, but with correct ordering (diff)
downloadsynapse-88625db05f274ad855fb51b33c84c09c947a6bd0.tar.xz
Notify users for events in rooms they join.
Change how the notifier updates the map from room_id to user streams on
receiving a join event. Make it update the map when it notifies for the
join event, rather than using the "user_joined_room" distributor signal
Diffstat (limited to '')
-rw-r--r--synapse/notifier.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py
index cbec4d30ae..30883a0696 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 from twisted.internet import defer
-from synapse.api.constants import EventTypes
+from synapse.api.constants import EventTypes, Membership
 from synapse.api.errors import AuthError
 
 from synapse.util.logutils import log_function
@@ -152,10 +152,6 @@ class Notifier(object):
         self.appservice_handler = hs.get_application_service_handler()
         self.state_handler = hs.get_state_handler()
 
-        hs.get_distributor().observe(
-            "user_joined_room", self._user_joined_room
-        )
-
         self.clock.looping_call(
             self.remove_expired_streams, self.UNUSED_STREAM_EXPIRY_MS
         )
@@ -248,6 +244,9 @@ class Notifier(object):
                 )
                 app_streams |= app_user_streams
 
+        if event.type == EventTypes.Member and event.membership == Membership.JOIN:
+            self._user_joined_room(event.state_key, event.room_id)
+
         self.on_new_event(
             "room_key", room_stream_id,
             users=extra_users,
@@ -483,9 +482,8 @@ class Notifier(object):
                 user_stream.appservice, set()
             ).add(user_stream)
 
-    def _user_joined_room(self, user, room_id):
-        user = str(user)
-        new_user_stream = self.user_to_user_stream.get(user)
+    def _user_joined_room(self, user_id, room_id):
+        new_user_stream = self.user_to_user_stream.get(user_id)
         if new_user_stream is not None:
             room_streams = self.room_to_user_streams.setdefault(room_id, set())
             room_streams.add(new_user_stream)