summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-08 13:40:20 +0100
committerErik Johnston <erik@matrix.org>2015-04-08 13:40:20 +0100
commit830d07db8278d773338fee94eb269eafd6b1b7fc (patch)
tree82044a322bb7cdca438a931025ed320958fc2712
parentAdd paranoia checks to make sure that we evict stale NotificationListeners wh... (diff)
downloadsynapse-830d07db8278d773338fee94eb269eafd6b1b7fc.tar.xz
Also perform paranoia checks in 'on_new_user_event'
-rw-r--r--synapse/notifier.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py
index ce9b0d2187..be78082021 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -252,10 +252,24 @@ class Notifier(object):
         listeners = set()
 
         for user in users:
-            listeners |= self.user_to_listeners.get(user, set()).copy()
+            user_listeners = self.user_to_listeners.get(user, set())
+
+            # Remove any 'stale' listeners.
+            for l in user_listeners.copy():
+                if l.notified():
+                    user_listeners.discard(l)
+
+            listeners |= user_listeners
 
         for room in rooms:
-            listeners |= self.room_to_listeners.get(room, set()).copy()
+            room_listeners = self.room_to_listeners.get(room, set())
+
+            # Remove any 'stale' listeners.
+            for l in room_listeners.copy():
+                if l.notified():
+                    room_listeners.discard(l)
+
+            listeners |= room_listeners
 
         @defer.inlineCallbacks
         def notify(listener):