summary refs log tree commit diff
path: root/synapse/storage/data_stores
diff options
context:
space:
mode:
authorDirk Klimpel <5740567+dklimpel@users.noreply.github.com>2020-02-28 10:58:05 +0100
committerGitHub <noreply@github.com>2020-02-28 09:58:05 +0000
commit9b06d8f8a62dc5c423aa9a694e0759eaf1c3c77e (patch)
tree0b3ada818ba583d277b3b7c5b48d046b4fe84329 /synapse/storage/data_stores
parentMerge remote-tracking branch 'origin/release-v1.11.1' into develop (diff)
downloadsynapse-9b06d8f8a62dc5c423aa9a694e0759eaf1c3c77e.tar.xz
Fixed set a user as an admin with the new API (#6928)
Fix #6910 
Diffstat (limited to 'synapse/storage/data_stores')
-rw-r--r--synapse/storage/data_stores/main/registration.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/synapse/storage/data_stores/main/registration.py b/synapse/storage/data_stores/main/registration.py
index 49306642ed..3e53c8568a 100644
--- a/synapse/storage/data_stores/main/registration.py
+++ b/synapse/storage/data_stores/main/registration.py
@@ -301,12 +301,16 @@ class RegistrationWorkerStore(SQLBaseStore):
             admin (bool): true iff the user is to be a server admin,
                 false otherwise.
         """
-        return self.db.simple_update_one(
-            table="users",
-            keyvalues={"name": user.to_string()},
-            updatevalues={"admin": 1 if admin else 0},
-            desc="set_server_admin",
-        )
+
+        def set_server_admin_txn(txn):
+            self.db.simple_update_one_txn(
+                txn, "users", {"name": user.to_string()}, {"admin": 1 if admin else 0}
+            )
+            self._invalidate_cache_and_stream(
+                txn, self.get_user_by_id, (user.to_string(),)
+            )
+
+        return self.db.runInteraction("set_server_admin", set_server_admin_txn)
 
     def _query_for_auth(self, txn, token):
         sql = (