diff --git a/pantalaimon/daemon.py b/pantalaimon/daemon.py index 2ed122d..5e2010a 100755 --- a/pantalaimon/daemon.py +++ b/pantalaimon/daemon.py @@ -1197,30 +1197,17 @@ class ProxyDaemon: if not client: return self._unknown_token - room_id = request.match_info["room_id"] - - # The room is not in the joined rooms list, just forward it. try: - room = client.rooms[room_id] - encrypt = room.encrypted - except KeyError: + content = await request.json() + except (JSONDecodeError, ContentTypeError): + return self._not_json + + try: + content = await self._map_media_upload("avatar_url", content, request, client) + return await self.forward_to_web(request, data=json.dumps(content), token=client.access_token) + except ValueError: return await self.forward_to_web(request, token=client.access_token) - # The room isn't encrypted just forward the message. - if not encrypt: - try: - content = await request.json() - except (JSONDecodeError, ContentTypeError): - return self._not_json - - try: - content = await self._map_media_upload("avatar_url", content, request, client) - return await self.forward_to_web(request, data=json.dumps(content), token=client.access_token) - except ValueError: - return await self.forward_to_web(request, token=client.access_token) - - return await self.forward_to_web(request, token=client.access_token) - async def download(self, request): server_name = request.match_info["server_name"] media_id = request.match_info["media_id"] diff --git a/pantalaimon/main.py b/pantalaimon/main.py index 1f0bb7b..adde3ea 100644 --- a/pantalaimon/main.py +++ b/pantalaimon/main.py @@ -97,7 +97,7 @@ async def init(data_dir, server_conf, send_queue, recv_queue): r"/_matrix/media/r0/upload", proxy.upload, ), - web.post( + web.put( r"/_matrix/client/r0/profile/{userId}/avatar_url", proxy.profile, ),