mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:06:07 -04:00
Remove unused parameter from, and add safeguard in, get_room_data (#8174)
Small cleanup PR. * Removed the unused `is_guest` argument * Added a safeguard to a (currently) impossible code path, fixing static checking at the same time.
This commit is contained in:
parent
ed18f32e1b
commit
e0d6244beb
4 changed files with 14 additions and 10 deletions
|
@ -95,12 +95,7 @@ class MessageHandler(object):
|
|||
)
|
||||
|
||||
async def get_room_data(
|
||||
self,
|
||||
user_id: str,
|
||||
room_id: str,
|
||||
event_type: str,
|
||||
state_key: str,
|
||||
is_guest: bool,
|
||||
self, user_id: str, room_id: str, event_type: str, state_key: str,
|
||||
) -> dict:
|
||||
""" Get data from a room.
|
||||
|
||||
|
@ -109,11 +104,10 @@ class MessageHandler(object):
|
|||
room_id
|
||||
event_type
|
||||
state_key
|
||||
is_guest
|
||||
Returns:
|
||||
The path data content.
|
||||
Raises:
|
||||
SynapseError if something went wrong.
|
||||
SynapseError or AuthError if the user is not in the room
|
||||
"""
|
||||
(
|
||||
membership,
|
||||
|
@ -130,6 +124,16 @@ class MessageHandler(object):
|
|||
[membership_event_id], StateFilter.from_types([key])
|
||||
)
|
||||
data = room_state[membership_event_id].get(key)
|
||||
else:
|
||||
# check_user_in_room_or_world_readable, if it doesn't raise an AuthError, should
|
||||
# only ever return a Membership.JOIN/LEAVE object
|
||||
#
|
||||
# Safeguard in case it returned something else
|
||||
logger.error(
|
||||
"Attempted to retrieve data from a room for a user that has never been in it. "
|
||||
"This should not have happened."
|
||||
)
|
||||
raise SynapseError(403, "User not in room", errcode=Codes.FORBIDDEN)
|
||||
|
||||
return data
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue