mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-22 18:54:58 -05:00
Use a single query in ProfileHandler.get_profile
(#13209)
This commit is contained in:
parent
4aaeb87dad
commit
2b5ab8e367
1
changelog.d/13209.misc
Normal file
1
changelog.d/13209.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
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)
|
target_user = UserID.from_string(user_id)
|
||||||
|
|
||||||
if self.hs.is_mine(target_user):
|
if self.hs.is_mine(target_user):
|
||||||
try:
|
profileinfo = await self.store.get_profileinfo(target_user.localpart)
|
||||||
displayname = await self.store.get_profile_displayname(
|
if profileinfo.display_name is None:
|
||||||
target_user.localpart
|
raise SynapseError(404, "Profile was not found", Codes.NOT_FOUND)
|
||||||
)
|
|
||||||
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
|
|
||||||
|
|
||||||
return {"displayname": displayname, "avatar_url": avatar_url}
|
return {
|
||||||
|
"displayname": profileinfo.display_name,
|
||||||
|
"avatar_url": profileinfo.avatar_url,
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
result = await self.federation.make_query(
|
result = await self.federation.make_query(
|
||||||
|
Loading…
Reference in New Issue
Block a user