Skip to content
Snippets Groups Projects
Unverified Commit 2b5ab8e3 authored by Nick Mills-Barrett's avatar Nick Mills-Barrett Committed by GitHub
Browse files

Use a single query in `ProfileHandler.get_profile` (#13209)

parent 4aaeb87d
No related branches found
No related tags found
No related merge requests found
Reduce number of queries used to get profile information. Contributed by Nick @ Beeper (@fizzadar).
......@@ -67,19 +67,14 @@ class ProfileHandler:
target_user = UserID.from_string(user_id)
if self.hs.is_mine(target_user):
try:
displayname = await self.store.get_profile_displayname(
target_user.localpart
)
avatar_url = await self.store.get_profile_avatar_url(
target_user.localpart
)
except StoreError as e:
if e.code == 404:
raise SynapseError(404, "Profile was not found", Codes.NOT_FOUND)
raise
profileinfo = await self.store.get_profileinfo(target_user.localpart)
if profileinfo.display_name is None:
raise SynapseError(404, "Profile was not found", Codes.NOT_FOUND)
return {"displayname": displayname, "avatar_url": avatar_url}
return {
"displayname": profileinfo.display_name,
"avatar_url": profileinfo.avatar_url,
}
else:
try:
result = await self.federation.make_query(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment