summary refs log tree commit diff
path: root/synapse/storage/group_server.py
diff options
context:
space:
mode:
authorLuke Barnard <lukeb@openmarket.com>2017-10-31 17:04:28 +0000
committerLuke Barnard <lukeb@openmarket.com>2017-10-31 17:04:28 +0000
commit20fe347906355e6eec2b890f5d9dc8e2c4534ce3 (patch)
tree628df3eb06d9fa513d0a6c3ce1ccdecb4115b9c9 /synapse/storage/group_server.py
parentMerge pull request #2609 from matrix-org/rav/refactor_login (diff)
downloadsynapse-20fe347906355e6eec2b890f5d9dc8e2c4534ce3.tar.xz
Modify group room association API to allow modification of is_public
also includes renamings to make things more consistent.
Diffstat (limited to 'synapse/storage/group_server.py')
-rw-r--r--synapse/storage/group_server.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/synapse/storage/group_server.py b/synapse/storage/group_server.py
index 8c4ad0a9a9..a7a43de279 100644
--- a/synapse/storage/group_server.py
+++ b/synapse/storage/group_server.py
@@ -846,19 +846,25 @@ class GroupServerStore(SQLBaseStore):
             )
         return self.runInteraction("remove_user_from_group", _remove_user_from_group_txn)
 
-    def add_room_to_group(self, group_id, room_id, is_public):
-        return self._simple_insert(
+    def update_room_group_association(self, group_id, room_id, is_public=True):
+        return self._simple_upsert(
             table="group_rooms",
-            values={
+            keyvalues={
                 "group_id": group_id,
                 "room_id": room_id,
+            },
+            values={
                 "is_public": is_public,
             },
-            desc="add_room_to_group",
+            insertion_values={
+                "group_id": group_id,
+                "room_id": room_id,
+            },
+            desc="update_room_group_association",
         )
 
-    def remove_room_from_group(self, group_id, room_id):
-        def _remove_room_from_group_txn(txn):
+    def delete_room_group_association(self, group_id, room_id):
+        def _delete_room_group_association_txn(txn):
             self._simple_delete_txn(
                 txn,
                 table="group_rooms",
@@ -877,7 +883,7 @@ class GroupServerStore(SQLBaseStore):
                 },
             )
         return self.runInteraction(
-            "remove_room_from_group", _remove_room_from_group_txn,
+            "delete_room_group_association", _delete_room_group_association_txn,
         )
 
     def get_publicised_groups_for_user(self, user_id):