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

Fix 404 on /profile when the display name is empty but not the avatar #16012

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion synapse/handlers/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def get_profile(self, user_id: str, ignore_backoff: bool = True) -> JsonDi

if self.hs.is_mine(target_user):
profileinfo = await self.store.get_profileinfo(target_user)
if profileinfo.display_name is None:
if profileinfo.display_name is None and profileinfo.avatar_url is None:
raise SynapseError(404, "Profile was not found", Codes.NOT_FOUND)

return {
Expand Down
10 changes: 10 additions & 0 deletions tests/handlers/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ def test_get_my_avatar(self) -> None:

self.assertEqual("http://my.server/me.png", avatar_url)

def test_get_profile_empty_displayname(self) -> None:
self.get_success(self.store.set_profile_displayname(self.frank, None))
self.get_success(
self.store.set_profile_avatar_url(self.frank, "http://my.server/me.png")
)

profile = self.get_success(self.handler.get_profile(self.frank.to_string()))

self.assertEqual("http://my.server/me.png", profile["avatar_url"])

def test_set_my_avatar(self) -> None:
self.get_success(
self.handler.set_avatar_url(
Expand Down
Loading