fix: await stream read, don't pass bare mxids
This commit is contained in:
parent
091906683a
commit
1bc88cc48f
1 changed files with 3 additions and 5 deletions
|
@ -115,7 +115,6 @@ class AppService:
|
|||
return doc["user_id"]
|
||||
|
||||
async def set_avatar(self, mxid: str, avatar_url: str) -> None:
|
||||
bare_mxid = fmt_mxid(mxid, full=False)
|
||||
async with self._client.get(avatar_url) as res:
|
||||
res.raise_for_status()
|
||||
async with self._client.request(
|
||||
|
@ -125,7 +124,7 @@ class AppService:
|
|||
"Authorization": f"Bearer {self.as_token}",
|
||||
"Content-Type": res.content_type,
|
||||
},
|
||||
chunked=res.content.read(),
|
||||
chunked=await res.content.read(),
|
||||
params={"filename":str(uuid.uuid4())},
|
||||
) as res:
|
||||
res.raise_for_status()
|
||||
|
@ -133,7 +132,7 @@ class AppService:
|
|||
avatar_uri = doc["content_uri"]
|
||||
async with self._client.request(
|
||||
method="PUT",
|
||||
url=f"{self.client_api}/profile/{bare_mxid}/avatar_url",
|
||||
url=f"{self.client_api}/profile/{mxid}/avatar_url",
|
||||
headers=self.api_headers,
|
||||
json={"avatar_url": avatar_uri},
|
||||
params={"user_id": mxid},
|
||||
|
@ -142,10 +141,9 @@ class AppService:
|
|||
self.logger.debug("updated avatar of %s to %s", mxid, avatar_url)
|
||||
|
||||
async def set_nick(self, mxid: str, nick: str) -> None:
|
||||
bare_mxid = fmt_mxid(mxid, full=False)
|
||||
async with self._client.request(
|
||||
method="PUT",
|
||||
url=f"{self.client_api}/profile/{bare_mxid}/displayname",
|
||||
url=f"{self.client_api}/profile/{mxid}/displayname",
|
||||
headers=self.api_headers,
|
||||
json={"displayname": nick},
|
||||
params={"user_id": mxid},
|
||||
|
|
Loading…
Reference in a new issue