mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Factor out loops into '_discard_if_notified'
This commit is contained in:
parent
830d07db82
commit
638be5a6b9
@ -169,9 +169,7 @@ class Notifier(object):
|
|||||||
room_listeners = self.room_to_listeners.get(room_id, set())
|
room_listeners = self.room_to_listeners.get(room_id, set())
|
||||||
|
|
||||||
# Remove any 'stale' listeners.
|
# Remove any 'stale' listeners.
|
||||||
for l in room_listeners.copy():
|
_discard_if_notified(room_listeners)
|
||||||
if l.notified():
|
|
||||||
room_listeners.discard(l)
|
|
||||||
|
|
||||||
listeners = room_listeners.copy()
|
listeners = room_listeners.copy()
|
||||||
|
|
||||||
@ -179,9 +177,7 @@ class Notifier(object):
|
|||||||
user_listeners = self.user_to_listeners.get(user, set())
|
user_listeners = self.user_to_listeners.get(user, set())
|
||||||
|
|
||||||
# Remove any 'stale' listeners.
|
# Remove any 'stale' listeners.
|
||||||
for l in user_listeners.copy():
|
_discard_if_notified(user_listeners)
|
||||||
if l.notified():
|
|
||||||
user_listeners.discard(l)
|
|
||||||
|
|
||||||
listeners |= user_listeners
|
listeners |= user_listeners
|
||||||
|
|
||||||
@ -197,9 +193,7 @@ class Notifier(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Remove any 'stale' listeners.
|
# Remove any 'stale' listeners.
|
||||||
for l in app_listeners.copy():
|
_discard_if_notified(app_listeners)
|
||||||
if l.notified():
|
|
||||||
app_listeners.discard(l)
|
|
||||||
|
|
||||||
listeners |= app_listeners
|
listeners |= app_listeners
|
||||||
|
|
||||||
@ -255,9 +249,7 @@ class Notifier(object):
|
|||||||
user_listeners = self.user_to_listeners.get(user, set())
|
user_listeners = self.user_to_listeners.get(user, set())
|
||||||
|
|
||||||
# Remove any 'stale' listeners.
|
# Remove any 'stale' listeners.
|
||||||
for l in user_listeners.copy():
|
_discard_if_notified(user_listeners)
|
||||||
if l.notified():
|
|
||||||
user_listeners.discard(l)
|
|
||||||
|
|
||||||
listeners |= user_listeners
|
listeners |= user_listeners
|
||||||
|
|
||||||
@ -265,9 +257,7 @@ class Notifier(object):
|
|||||||
room_listeners = self.room_to_listeners.get(room, set())
|
room_listeners = self.room_to_listeners.get(room, set())
|
||||||
|
|
||||||
# Remove any 'stale' listeners.
|
# Remove any 'stale' listeners.
|
||||||
for l in room_listeners.copy():
|
_discard_if_notified(room_listeners)
|
||||||
if l.notified():
|
|
||||||
room_listeners.discard(l)
|
|
||||||
|
|
||||||
listeners |= room_listeners
|
listeners |= room_listeners
|
||||||
|
|
||||||
@ -470,3 +460,12 @@ class Notifier(object):
|
|||||||
|
|
||||||
for l in new_listeners:
|
for l in new_listeners:
|
||||||
l.rooms.add(room_id)
|
l.rooms.add(room_id)
|
||||||
|
|
||||||
|
|
||||||
|
def _discard_if_notified(listener_set):
|
||||||
|
to_discard = set()
|
||||||
|
for l in listener_set:
|
||||||
|
if l.notified():
|
||||||
|
to_discard.add(l)
|
||||||
|
|
||||||
|
listener_set -= to_discard
|
||||||
|
Loading…
Reference in New Issue
Block a user