summary refs log tree commit diff
path: root/synapse/rest/admin/rooms.py
diff options
context:
space:
mode:
authorJason Robinson <jasonr@matrix.org>2021-01-07 23:03:54 +0200
committerJason Robinson <jasonr@matrix.org>2021-01-07 23:03:54 +0200
commitc91045f56c8acf78a11fd722525e98c7cee77ac3 (patch)
treea7b0c06f7ffd7203f729cad8c268b8e41ba43bfe /synapse/rest/admin/rooms.py
parentAdd forward extremities endpoint to rooms admin API (diff)
downloadsynapse-c91045f56c8acf78a11fd722525e98c7cee77ac3.tar.xz
Move unknown room ID error into resolve_room_id
Signed-off-by: Jason Robinson <jasonr@matrix.org>
Diffstat (limited to 'synapse/rest/admin/rooms.py')
-rw-r--r--synapse/rest/admin/rooms.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/synapse/rest/admin/rooms.py b/synapse/rest/admin/rooms.py
index 37703610c5..1f7b7daea9 100644
--- a/synapse/rest/admin/rooms.py
+++ b/synapse/rest/admin/rooms.py
@@ -524,14 +524,18 @@ class ForwardExtremitiesRestServlet(RestServlet):
     async def resolve_room_id(self, room_identifier: str) -> str:
         """Resolve to a room ID, if necessary."""
         if RoomID.is_valid(room_identifier):
-            return room_identifier
+            room_id = room_identifier
         elif RoomAlias.is_valid(room_identifier):
             room_alias = RoomAlias.from_string(room_identifier)
             room_id, _ = await self.room_member_handler.lookup_room_alias(room_alias)
-            return room_id.to_string()
-        raise SynapseError(
-            400, "%s was not legal room ID or room alias" % (room_identifier,)
-        )
+            room_id = room_id.to_string()
+        else:
+            raise SynapseError(
+                400, "%s was not legal room ID or room alias" % (room_identifier,)
+            )
+        if not room_id:
+            raise SynapseError(400, "Unknown room ID or room alias %s" % room_identifier)
+        return room_id
 
     async def on_DELETE(self, request, room_identifier):
         requester = await self.auth.get_user_by_req(request)
@@ -544,8 +548,6 @@ class ForwardExtremitiesRestServlet(RestServlet):
         await assert_user_is_admin(self.auth, requester.user)
 
         room_id = await self.resolve_room_id(room_identifier)
-        if not room_id:
-            raise SynapseError(400, "Unknown room ID or room alias %s" % room_identifier)
 
         extremities = await self.store.get_forward_extremities_for_room(room_id)
         return 200, {