@@ -104,15 +104,15 @@ def __init__(self, hs: "HomeServer"):
104104
105105 async def get_room_data (
106106 self ,
107- user_id : str ,
107+ requester : Requester ,
108108 room_id : str ,
109109 event_type : str ,
110110 state_key : str ,
111111 ) -> Optional [EventBase ]:
112112 """Get data from a room.
113113
114114 Args:
115- user_id
115+ requester: The user who did the request.
116116 room_id
117117 event_type
118118 state_key
@@ -125,7 +125,7 @@ async def get_room_data(
125125 membership ,
126126 membership_event_id ,
127127 ) = await self .auth .check_user_in_room_or_world_readable (
128- room_id , user_id , allow_departed_users = True
128+ room_id , requester , allow_departed_users = True
129129 )
130130
131131 if membership == Membership .JOIN :
@@ -161,11 +161,10 @@ async def get_room_data(
161161
162162 async def get_state_events (
163163 self ,
164- user_id : str ,
164+ requester : Requester ,
165165 room_id : str ,
166166 state_filter : Optional [StateFilter ] = None ,
167167 at_token : Optional [StreamToken ] = None ,
168- is_guest : bool = False ,
169168 ) -> List [dict ]:
170169 """Retrieve all state events for a given room. If the user is
171170 joined to the room then return the current state. If the user has
@@ -174,14 +173,13 @@ async def get_state_events(
174173 visible.
175174
176175 Args:
177- user_id : The user requesting state events.
176+ requester : The user requesting state events.
178177 room_id: The room ID to get all state events from.
179178 state_filter: The state filter used to fetch state from the database.
180179 at_token: the stream token of the at which we are requesting
181180 the stats. If the user is not allowed to view the state as of that
182181 stream token, we raise a 403 SynapseError. If None, returns the current
183182 state based on the current_state_events table.
184- is_guest: whether this user is a guest
185183 Returns:
186184 A list of dicts representing state events. [{}, {}, {}]
187185 Raises:
@@ -191,6 +189,7 @@ async def get_state_events(
191189 members of this room.
192190 """
193191 state_filter = state_filter or StateFilter .all ()
192+ user_id = requester .user .to_string ()
194193
195194 if at_token :
196195 last_event_id = (
@@ -223,7 +222,7 @@ async def get_state_events(
223222 membership ,
224223 membership_event_id ,
225224 ) = await self .auth .check_user_in_room_or_world_readable (
226- room_id , user_id , allow_departed_users = True
225+ room_id , requester , allow_departed_users = True
227226 )
228227
229228 if membership == Membership .JOIN :
@@ -317,12 +316,11 @@ async def get_joined_members(self, requester: Requester, room_id: str) -> dict:
317316 Returns:
318317 A dict of user_id to profile info
319318 """
320- user_id = requester .user .to_string ()
321319 if not requester .app_service :
322320 # We check AS auth after fetching the room membership, as it
323321 # requires us to pull out all joined members anyway.
324322 membership , _ = await self .auth .check_user_in_room_or_world_readable (
325- room_id , user_id , allow_departed_users = True
323+ room_id , requester , allow_departed_users = True
326324 )
327325 if membership != Membership .JOIN :
328326 raise SynapseError (
@@ -340,7 +338,10 @@ async def get_joined_members(self, requester: Requester, room_id: str) -> dict:
340338 # If this is an AS, double check that they are allowed to see the members.
341339 # This can either be because the AS user is in the room or because there
342340 # is a user in the room that the AS is "interested in"
343- if requester .app_service and user_id not in users_with_profile :
341+ if (
342+ requester .app_service
343+ and requester .user .to_string () not in users_with_profile
344+ ):
344345 for uid in users_with_profile :
345346 if requester .app_service .is_interested_in_user (uid ):
346347 break
0 commit comments