mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 18:53:53 +01:00
Modify group room association API to allow modification of is_public
also includes renamings to make things more consistent.
This commit is contained in:
parent
c31a7c3ff6
commit
20fe347906
6 changed files with 25 additions and 19 deletions
|
@ -531,7 +531,7 @@ class TransportLayerClient(object):
|
||||||
ignore_backoff=True,
|
ignore_backoff=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def add_room_to_group(self, destination, group_id, requester_user_id, room_id,
|
def update_room_group_association(self, destination, group_id, requester_user_id, room_id,
|
||||||
content):
|
content):
|
||||||
"""Add a room to a group
|
"""Add a room to a group
|
||||||
"""
|
"""
|
||||||
|
@ -545,7 +545,7 @@ class TransportLayerClient(object):
|
||||||
ignore_backoff=True,
|
ignore_backoff=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def remove_room_from_group(self, destination, group_id, requester_user_id, room_id):
|
def delete_room_group_association(self, destination, group_id, requester_user_id, room_id):
|
||||||
"""Remove a room from a group
|
"""Remove a room from a group
|
||||||
"""
|
"""
|
||||||
path = PREFIX + "/groups/%s/room/%s" % (group_id, room_id,)
|
path = PREFIX + "/groups/%s/room/%s" % (group_id, room_id,)
|
||||||
|
|
|
@ -684,7 +684,7 @@ class FederationGroupsAddRoomsServlet(BaseFederationServlet):
|
||||||
if get_domain_from_id(requester_user_id) != origin:
|
if get_domain_from_id(requester_user_id) != origin:
|
||||||
raise SynapseError(403, "requester_user_id doesn't match origin")
|
raise SynapseError(403, "requester_user_id doesn't match origin")
|
||||||
|
|
||||||
new_content = yield self.handler.add_room_to_group(
|
new_content = yield self.handler.update_room_group_association(
|
||||||
group_id, requester_user_id, room_id, content
|
group_id, requester_user_id, room_id, content
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -696,7 +696,7 @@ class FederationGroupsAddRoomsServlet(BaseFederationServlet):
|
||||||
if get_domain_from_id(requester_user_id) != origin:
|
if get_domain_from_id(requester_user_id) != origin:
|
||||||
raise SynapseError(403, "requester_user_id doesn't match origin")
|
raise SynapseError(403, "requester_user_id doesn't match origin")
|
||||||
|
|
||||||
new_content = yield self.handler.remove_room_from_group(
|
new_content = yield self.handler.delete_room_group_association(
|
||||||
group_id, requester_user_id, room_id,
|
group_id, requester_user_id, room_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -531,7 +531,7 @@ class GroupsServerHandler(object):
|
||||||
})
|
})
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def add_room_to_group(self, group_id, requester_user_id, room_id, content):
|
def update_room_group_association(self, group_id, requester_user_id, room_id, content):
|
||||||
"""Add room to group
|
"""Add room to group
|
||||||
"""
|
"""
|
||||||
RoomID.from_string(room_id) # Ensure valid room id
|
RoomID.from_string(room_id) # Ensure valid room id
|
||||||
|
@ -542,19 +542,19 @@ class GroupsServerHandler(object):
|
||||||
|
|
||||||
is_public = _parse_visibility_from_contents(content)
|
is_public = _parse_visibility_from_contents(content)
|
||||||
|
|
||||||
yield self.store.add_room_to_group(group_id, room_id, is_public=is_public)
|
yield self.store.update_room_group_association(group_id, room_id, is_public=is_public)
|
||||||
|
|
||||||
defer.returnValue({})
|
defer.returnValue({})
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def remove_room_from_group(self, group_id, requester_user_id, room_id):
|
def delete_room_group_association(self, group_id, requester_user_id, room_id):
|
||||||
"""Remove room from group
|
"""Remove room from group
|
||||||
"""
|
"""
|
||||||
yield self.check_group_is_ours(
|
yield self.check_group_is_ours(
|
||||||
group_id, requester_user_id, and_exists=True, and_is_admin=requester_user_id
|
group_id, requester_user_id, and_exists=True, and_is_admin=requester_user_id
|
||||||
)
|
)
|
||||||
|
|
||||||
yield self.store.remove_room_from_group(group_id, room_id)
|
yield self.store.delete_room_group_association(group_id, room_id)
|
||||||
|
|
||||||
defer.returnValue({})
|
defer.returnValue({})
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,8 @@ class GroupsLocalHandler(object):
|
||||||
|
|
||||||
get_invited_users_in_group = _create_rerouter("get_invited_users_in_group")
|
get_invited_users_in_group = _create_rerouter("get_invited_users_in_group")
|
||||||
|
|
||||||
add_room_to_group = _create_rerouter("add_room_to_group")
|
update_room_group_association = _create_rerouter("update_room_group_association")
|
||||||
remove_room_from_group = _create_rerouter("remove_room_from_group")
|
delete_room_group_association = _create_rerouter("delete_room_group_association")
|
||||||
|
|
||||||
update_group_summary_room = _create_rerouter("update_group_summary_room")
|
update_group_summary_room = _create_rerouter("update_group_summary_room")
|
||||||
delete_group_summary_room = _create_rerouter("delete_group_summary_room")
|
delete_group_summary_room = _create_rerouter("delete_group_summary_room")
|
||||||
|
|
|
@ -451,7 +451,7 @@ class GroupAdminRoomsServlet(RestServlet):
|
||||||
requester_user_id = requester.user.to_string()
|
requester_user_id = requester.user.to_string()
|
||||||
|
|
||||||
content = parse_json_object_from_request(request)
|
content = parse_json_object_from_request(request)
|
||||||
result = yield self.groups_handler.add_room_to_group(
|
result = yield self.groups_handler.update_room_group_association(
|
||||||
group_id, requester_user_id, room_id, content,
|
group_id, requester_user_id, room_id, content,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ class GroupAdminRoomsServlet(RestServlet):
|
||||||
requester = yield self.auth.get_user_by_req(request)
|
requester = yield self.auth.get_user_by_req(request)
|
||||||
requester_user_id = requester.user.to_string()
|
requester_user_id = requester.user.to_string()
|
||||||
|
|
||||||
result = yield self.groups_handler.remove_room_from_group(
|
result = yield self.groups_handler.delete_room_group_association(
|
||||||
group_id, requester_user_id, room_id,
|
group_id, requester_user_id, room_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -846,19 +846,25 @@ class GroupServerStore(SQLBaseStore):
|
||||||
)
|
)
|
||||||
return self.runInteraction("remove_user_from_group", _remove_user_from_group_txn)
|
return self.runInteraction("remove_user_from_group", _remove_user_from_group_txn)
|
||||||
|
|
||||||
def add_room_to_group(self, group_id, room_id, is_public):
|
def update_room_group_association(self, group_id, room_id, is_public=True):
|
||||||
return self._simple_insert(
|
return self._simple_upsert(
|
||||||
table="group_rooms",
|
table="group_rooms",
|
||||||
values={
|
keyvalues={
|
||||||
"group_id": group_id,
|
"group_id": group_id,
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
|
},
|
||||||
|
values={
|
||||||
"is_public": is_public,
|
"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 delete_room_group_association(self, group_id, room_id):
|
||||||
def _remove_room_from_group_txn(txn):
|
def _delete_room_group_association_txn(txn):
|
||||||
self._simple_delete_txn(
|
self._simple_delete_txn(
|
||||||
txn,
|
txn,
|
||||||
table="group_rooms",
|
table="group_rooms",
|
||||||
|
@ -877,7 +883,7 @@ class GroupServerStore(SQLBaseStore):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return self.runInteraction(
|
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):
|
def get_publicised_groups_for_user(self, user_id):
|
||||||
|
|
Loading…
Reference in a new issue