summary refs log tree commit diff
path: root/synapse/handlers/presence.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-28 17:20:32 +0100
committerErik Johnston <erik@matrix.org>2015-04-28 17:20:32 +0100
commitd98edb548af8833a7c44eded610a528e3d0515c6 (patch)
treeaf22607504ea692f1771e3205b1d0c8e0fdb026e /synapse/handlers/presence.py
parentMerge pull request #123 from matrix-org/postgres (diff)
downloadsynapse-d98edb548af8833a7c44eded610a528e3d0515c6.tar.xz
Ensure the serial returned by presence is always an integer
Diffstat (limited to 'synapse/handlers/presence.py')
-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",