From bde682c7e094a600431e6cca4aa0fa6d633aaf62 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 29 May 2020 15:32:49 +0100 Subject: [PATCH 1/2] Fix 'FederationGroupsRoomsServlet' API when group has room server is not in --- synapse/handlers/room_list.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/synapse/handlers/room_list.py b/synapse/handlers/room_list.py index e75dabcd7710..4cbc02b0d0b2 100644 --- a/synapse/handlers/room_list.py +++ b/synapse/handlers/room_list.py @@ -253,10 +253,21 @@ def generate_room_entry( """ result = {"room_id": room_id, "num_joined_members": num_joined_users} + if with_alias: + aliases = yield self.store.get_aliases_for_room( + room_id, on_invalidate=cache_context.invalidate + ) + if aliases: + result["aliases"] = aliases + current_state_ids = yield self.store.get_current_state_ids( room_id, on_invalidate=cache_context.invalidate ) + if not current_state_ids: + # We're not in the room, so may as well bail out here. + return result + event_map = yield self.store.get_events( [ event_id @@ -289,14 +300,7 @@ def generate_room_entry( create_event = current_state.get((EventTypes.Create, "")) result["m.federate"] = create_event.content.get("m.federate", True) - if with_alias: - aliases = yield self.store.get_aliases_for_room( - room_id, on_invalidate=cache_context.invalidate - ) - if aliases: - result["aliases"] = aliases - - name_event = yield current_state.get((EventTypes.Name, "")) + name_event = current_state.get((EventTypes.Name, "")) if name_event: name = name_event.content.get("name", None) if name: From 51feefdcf18e0c18c9f60b5fde905ff297b8e209 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 29 May 2020 15:35:27 +0100 Subject: [PATCH 2/2] Newsfile --- changelog.d/7599.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7599.bugfix diff --git a/changelog.d/7599.bugfix b/changelog.d/7599.bugfix new file mode 100644 index 000000000000..deefe5680f3f --- /dev/null +++ b/changelog.d/7599.bugfix @@ -0,0 +1 @@ +Fix bug where returning rooms for a group would fail if it included a room that the server was not in.