mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Use the room type from stats in hierarchy response. (#14263)
This avoids pulling additional state information (and events) from the database for each item returned in the hierarchy response. The room type might be out of date until a background update finishes running, the worst impact of this would be spaces being treated as rooms in the hierarchy response. This should self-heal once the background update finishes.
This commit is contained in:
parent
62ed877433
commit
2920e540bf
1
changelog.d/14263.misc
Normal file
1
changelog.d/14263.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Improve performance of the `/hierarchy` endpoint.
|
@ -20,7 +20,6 @@ from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Sequence, Set,
|
|||||||
import attr
|
import attr
|
||||||
|
|
||||||
from synapse.api.constants import (
|
from synapse.api.constants import (
|
||||||
EventContentFields,
|
|
||||||
EventTypes,
|
EventTypes,
|
||||||
HistoryVisibility,
|
HistoryVisibility,
|
||||||
JoinRules,
|
JoinRules,
|
||||||
@ -701,13 +700,6 @@ class RoomSummaryHandler:
|
|||||||
# there should always be an entry
|
# there should always be an entry
|
||||||
assert stats is not None, "unable to retrieve stats for %s" % (room_id,)
|
assert stats is not None, "unable to retrieve stats for %s" % (room_id,)
|
||||||
|
|
||||||
current_state_ids = await self._storage_controllers.state.get_current_state_ids(
|
|
||||||
room_id
|
|
||||||
)
|
|
||||||
create_event = await self._store.get_event(
|
|
||||||
current_state_ids[(EventTypes.Create, "")]
|
|
||||||
)
|
|
||||||
|
|
||||||
entry = {
|
entry = {
|
||||||
"room_id": stats["room_id"],
|
"room_id": stats["room_id"],
|
||||||
"name": stats["name"],
|
"name": stats["name"],
|
||||||
@ -720,7 +712,7 @@ class RoomSummaryHandler:
|
|||||||
stats["history_visibility"] == HistoryVisibility.WORLD_READABLE
|
stats["history_visibility"] == HistoryVisibility.WORLD_READABLE
|
||||||
),
|
),
|
||||||
"guest_can_join": stats["guest_access"] == "can_join",
|
"guest_can_join": stats["guest_access"] == "can_join",
|
||||||
"room_type": create_event.content.get(EventContentFields.ROOM_TYPE),
|
"room_type": stats["room_type"],
|
||||||
}
|
}
|
||||||
|
|
||||||
if self._msc3266_enabled:
|
if self._msc3266_enabled:
|
||||||
@ -730,7 +722,11 @@ class RoomSummaryHandler:
|
|||||||
# Federation requests need to provide additional information so the
|
# Federation requests need to provide additional information so the
|
||||||
# requested server is able to filter the response appropriately.
|
# requested server is able to filter the response appropriately.
|
||||||
if for_federation:
|
if for_federation:
|
||||||
|
current_state_ids = (
|
||||||
|
await self._storage_controllers.state.get_current_state_ids(room_id)
|
||||||
|
)
|
||||||
room_version = await self._store.get_room_version(room_id)
|
room_version = await self._store.get_room_version(room_id)
|
||||||
|
|
||||||
if await self._event_auth_handler.has_restricted_join_rules(
|
if await self._event_auth_handler.has_restricted_join_rules(
|
||||||
current_state_ids, room_version
|
current_state_ids, room_version
|
||||||
):
|
):
|
||||||
|
Loading…
Reference in New Issue
Block a user