summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--synapse/handlers/presence.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index 571eacd343..774df46aba 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -859,7 +859,7 @@ class PresenceEventSource(object):
         presence = self.hs.get_handlers().presence_handler
         cachemap = presence._user_cachemap
         clock = self.clock
-        latest_serial = None
+        latest_serial = 0
 
         updates = []
         # TODO(paul): use a DeferredList ? How to limit concurrency.
@@ -872,8 +872,7 @@ class PresenceEventSource(object):
             if not (yield self.is_visible(observer_user, observed_user)):
                 continue
 
-            if latest_serial is None or cached.serial > latest_serial:
-                latest_serial = cached.serial
+            latest_serial = max(cached.serial, latest_serial)
             updates.append(cached.make_event(user=observed_user, clock=clock))
 
         # TODO(paul): limit
@@ -882,6 +881,7 @@ class PresenceEventSource(object):
             if serial < from_key:
                 break
 
+            latest_serial = max(cached.serial, serial)
             for u in user_ids:
                 updates.append({
                     "type": "m.presence",