diff options
-rw-r--r-- | synapse/handlers/message.py | 13 | ||||
-rw-r--r-- | synapse/rest/admin/rooms.py | 16 |
2 files changed, 15 insertions, 14 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 457491b75d..d3f8dc550d 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -137,7 +137,6 @@ class MessageHandler: state_filter: StateFilter = StateFilter.all(), at_token: Optional[StreamToken] = None, is_guest: bool = False, - is_admin: bool = False, ) -> List[dict]: """Retrieve all state events for a given room. If the user is joined to the room then return the current state. If the user has @@ -154,7 +153,6 @@ class MessageHandler: stream token, we raise a 403 SynapseError. If None, returns the current state based on the current_state_events table. is_guest: whether this user is a guest - is_admin: whether this user is making the request as a server admin. Returns: A list of dicts representing state events. [{}, {}, {}] Raises: @@ -175,12 +173,9 @@ class MessageHandler: if not last_events: raise NotFoundError("Can't find event for token %s" % (at_token,)) - if is_admin: - visible_events = last_events - else: - visible_events = await filter_events_for_client( - self.storage, user_id, last_events, filter_send_to_client=False, - ) + visible_events = await filter_events_for_client( + self.storage, user_id, last_events, filter_send_to_client=False, + ) event = last_events[0] if visible_events: @@ -202,7 +197,7 @@ class MessageHandler: room_id, user_id, allow_departed_users=True ) - if membership == Membership.JOIN or is_admin: + if membership == Membership.JOIN: state_ids = await self.store.get_filtered_current_state_ids( room_id, state_filter=state_filter ) diff --git a/synapse/rest/admin/rooms.py b/synapse/rest/admin/rooms.py index 1d5f6c1807..d903129dd2 100644 --- a/synapse/rest/admin/rooms.py +++ b/synapse/rest/admin/rooms.py @@ -303,7 +303,8 @@ class RoomStateRestServlet(RestServlet): self.hs = hs self.auth = hs.get_auth() self.store = hs.get_datastore() - self.message_handler = hs.get_message_handler() + self.clock = hs.get_clock() + self._event_serializer = hs.get_event_client_serializer() async def on_GET( self, request: SynapseRequest, room_id: str @@ -315,10 +316,15 @@ class RoomStateRestServlet(RestServlet): if not ret: raise NotFoundError("Room not found") - room_state = await self.message_handler.get_state_events( - user_id=requester.user.to_string(), - room_id=room_id, - is_admin=True, # already verified above + event_ids = await self.store.get_current_state_ids(room_id) + events = await self.store.get_events(event_ids.values()) + now = self.clock.time_msec() + room_state = await self._event_serializer.serialize_events( + events.values(), + now, + # We don't bother bundling aggregations in when asked for state + # events, as clients won't use them. + bundle_aggregations=False, ) ret = {"state": room_state} |