summary refs log tree commit diff
path: root/synapse/storage/presence.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-03-03 11:39:25 +0000
committerRichard van der Hoff <richard@matrix.org>2016-03-03 11:39:25 +0000
commit79f34bdbc2720a832cdab36ba58e83201e549c41 (patch)
tree2bdadb2bd2d2dac1a6722c4d33ca81febb7d7ece /synapse/storage/presence.py
parentFix typo (diff)
parentjenkins.sh: set -x (diff)
downloadsynapse-79f34bdbc2720a832cdab36ba58e83201e549c41.tar.xz
Merge branch 'develop' into rav/SYN-642
Diffstat (limited to 'synapse/storage/presence.py')
-rw-r--r--synapse/storage/presence.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/synapse/storage/presence.py b/synapse/storage/presence.py
index 3ef91d34db..4cec31e316 100644
--- a/synapse/storage/presence.py
+++ b/synapse/storage/presence.py
@@ -58,8 +58,8 @@ class UserPresenceState(namedtuple("UserPresenceState",
 class PresenceStore(SQLBaseStore):
     @defer.inlineCallbacks
     def update_presence(self, presence_states):
-        stream_ordering_manager = yield self._presence_id_gen.get_next_mult(
-            self, len(presence_states)
+        stream_ordering_manager = self._presence_id_gen.get_next_mult(
+            len(presence_states)
         )
 
         with stream_ordering_manager as stream_orderings:
@@ -115,6 +115,22 @@ class PresenceStore(SQLBaseStore):
                 args
             )
 
+    def get_all_presence_updates(self, last_id, current_id):
+        def get_all_presence_updates_txn(txn):
+            sql = (
+                "SELECT stream_id, user_id, state, last_active_ts,"
+                " last_federation_update_ts, last_user_sync_ts, status_msg,"
+                " currently_active"
+                " FROM presence_stream"
+                " WHERE ? < stream_id AND stream_id <= ?"
+            )
+            txn.execute(sql, (last_id, current_id))
+            return txn.fetchall()
+
+        return self.runInteraction(
+            "get_all_presence_updates", get_all_presence_updates_txn
+        )
+
     @defer.inlineCallbacks
     def get_presence_for_users(self, user_ids):
         rows = yield self._simple_select_many_batch(