Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add a ModuleApi method to update a user's membership in a room #11147

Merged
merged 16 commits into from
Oct 28, 2021
Merged
22 changes: 14 additions & 8 deletions synapse/module_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,20 @@ async def update_room_membership(
target_user_id.to_string(),
)
except SynapseError as e:
if e.code == 404:
# If the profile couldn't be found, use default values.
profile = {
"displayname": target_user_id.localpart,
"avatar_url": None,
}
else:
raise
# If the profile couldn't be found, use default values.
profile = {
"displayname": target_user_id.localpart,
"avatar_url": None,
}

if e.code != 404:
# If the error isn't 404, it means we tried to fetch the profile over
# federation but the remote server responded with a non-standard
# status code.
logger.error(
"Got non-404 error status when fetching profile for %s"
% target_user_id.to_string(),
)
babolivier marked this conversation as resolved.
Show resolved Hide resolved

# Set the profile where it needs to be set.
if "avatar_url" not in content:
Expand Down