summary refs log tree commit diff
path: root/synapse/storage/presence.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-03-01 09:43:27 +0000
committerErik Johnston <erik@matrix.org>2016-03-01 09:43:27 +0000
commit903fb34b39cd750050b4c89d9c0f5492652b8fcd (patch)
tree7e74b35c054227b2897ed46bccfb2b4de40f47f6 /synapse/storage/presence.py
parentReport size of ExpiringCache (diff)
parentMerge pull request #607 from matrix-org/dbkr/send_inviter_member_event (diff)
downloadsynapse-903fb34b39cd750050b4c89d9c0f5492652b8fcd.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/expiring_cache_size
Diffstat (limited to 'synapse/storage/presence.py')
-rw-r--r--synapse/storage/presence.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/synapse/storage/presence.py b/synapse/storage/presence.py
index 70ece56548..3ef91d34db 100644
--- a/synapse/storage/presence.py
+++ b/synapse/storage/presence.py
@@ -58,17 +58,20 @@ class UserPresenceState(namedtuple("UserPresenceState",
 class PresenceStore(SQLBaseStore):
     @defer.inlineCallbacks
     def update_presence(self, presence_states):
-        stream_id_manager = yield self._presence_id_gen.get_next(self)
-        with stream_id_manager as stream_id:
+        stream_ordering_manager = yield self._presence_id_gen.get_next_mult(
+            self, len(presence_states)
+        )
+
+        with stream_ordering_manager as stream_orderings:
             yield self.runInteraction(
                 "update_presence",
-                self._update_presence_txn, stream_id, presence_states,
+                self._update_presence_txn, stream_orderings, presence_states,
             )
 
-        defer.returnValue((stream_id, self._presence_id_gen.get_max_token()))
+        defer.returnValue((stream_orderings[-1], self._presence_id_gen.get_max_token()))
 
-    def _update_presence_txn(self, txn, stream_id, presence_states):
-        for state in presence_states:
+    def _update_presence_txn(self, txn, stream_orderings, presence_states):
+        for stream_id, state in zip(stream_orderings, presence_states):
             txn.call_after(
                 self.presence_stream_cache.entity_has_changed,
                 state.user_id, stream_id,