Ensure a group ID is valid before trying to get rooms for it. (#8129)

code_spécifique_watcha
Patrick Cloke 4 years ago committed by GitHub
parent 76c43f086a
commit 731dfff347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      changelog.d/8129.bugfix
  2. 4
      synapse/rest/client/v2_alpha/groups.py

@ -0,0 +1 @@
Return a proper error code when the rooms of an invalid group are requested.

@ -16,6 +16,7 @@
import logging
from synapse.api.errors import SynapseError
from synapse.http.servlet import RestServlet, parse_json_object_from_request
from synapse.types import GroupID
@ -325,6 +326,9 @@ class GroupRoomServlet(RestServlet):
requester = await self.auth.get_user_by_req(request, allow_guest=True)
requester_user_id = requester.user.to_string()
if not GroupID.is_valid(group_id):
raise SynapseError(400, "%s was not legal group ID" % (group_id,))
result = await self.groups_handler.get_rooms_in_group(
group_id, requester_user_id
)

Loading…
Cancel
Save