From 1bc88cc48febe71dfce82f1cd1207db781bcb230 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 29 Jan 2024 22:26:37 +0100 Subject: [PATCH] fix: await stream read, don't pass bare mxids --- src/aioappsrv/app.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/aioappsrv/app.py b/src/aioappsrv/app.py index facc20f..bc584e5 100644 --- a/src/aioappsrv/app.py +++ b/src/aioappsrv/app.py @@ -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},