summary refs log tree commit diff
path: root/synapse/storage/presence.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2016-08-15 15:39:05 +0100
committerGitHub <noreply@github.com>2016-08-15 15:39:05 +0100
commit75299af4fcaecfacb7449ebe0982d2ed0bd6edbd (patch)
tree65f878a58ae489aa0708f5ba66882f5c85f73003 /synapse/storage/presence.py
parentMerge pull request #1007 from sargon/develop (diff)
parentDoc get_next() context manager usage (diff)
downloadsynapse-75299af4fcaecfacb7449ebe0982d2ed0bd6edbd.tar.xz
Merge pull request #1009 from matrix-org/erikj/event_split
Split out /events to synchrotron
Diffstat (limited to 'synapse/storage/presence.py')
-rw-r--r--synapse/storage/presence.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/synapse/storage/presence.py b/synapse/storage/presence.py
index d03f7c541e..21d0696640 100644
--- a/synapse/storage/presence.py
+++ b/synapse/storage/presence.py
@@ -189,18 +189,30 @@ class PresenceStore(SQLBaseStore):
             desc="add_presence_list_pending",
         )
 
-    @defer.inlineCallbacks
     def set_presence_list_accepted(self, observer_localpart, observed_userid):
-        result = yield self._simple_update_one(
-            table="presence_list",
-            keyvalues={"user_id": observer_localpart,
-                       "observed_user_id": observed_userid},
-            updatevalues={"accepted": True},
-            desc="set_presence_list_accepted",
+        def update_presence_list_txn(txn):
+            result = self._simple_update_one_txn(
+                txn,
+                table="presence_list",
+                keyvalues={
+                    "user_id": observer_localpart,
+                    "observed_user_id": observed_userid
+                },
+                updatevalues={"accepted": True},
+            )
+
+            self._invalidate_cache_and_stream(
+                txn, self.get_presence_list_accepted, (observer_localpart,)
+            )
+            self._invalidate_cache_and_stream(
+                txn, self.get_presence_list_observers_accepted, (observed_userid,)
+            )
+
+            return result
+
+        return self.runInteraction(
+            "set_presence_list_accepted", update_presence_list_txn,
         )
-        self.get_presence_list_accepted.invalidate((observer_localpart,))
-        self.get_presence_list_observers_accepted.invalidate((observed_userid,))
-        defer.returnValue(result)
 
     def get_presence_list(self, observer_localpart, accepted=None):
         if accepted: