From 266b049cfcb26523a7978768134f6293b9c56ee0 Mon Sep 17 00:00:00 2001 From: Andrea Spacca Date: Thu, 7 Jan 2021 18:11:02 +0100 Subject: [PATCH] override existing content --- pantalaimon/daemon.py | 6 +----- pantalaimon/store.py | 16 +++------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/pantalaimon/daemon.py b/pantalaimon/daemon.py index 92bae48..815fd78 100755 --- a/pantalaimon/daemon.py +++ b/pantalaimon/daemon.py @@ -950,11 +950,7 @@ class ProxyDaemon: body=await response.transport_response.read(), ) - media_content = media_info.to_content(content["url"], - upload_info.filename, - content_msgtype, - upload_info.mimetype - ), + media_content = media_info.to_content(content, upload_info.mimetype) response = await client.room_send( room_id, msgtype, media_content, txnid, ignore_unverified diff --git a/pantalaimon/store.py b/pantalaimon/store.py index 3d8f681..911850d 100644 --- a/pantalaimon/store.py +++ b/pantalaimon/store.py @@ -48,26 +48,16 @@ class MediaInfo: iv = attr.ib(type=str) hashes = attr.ib(type=dict) - def to_content(self, url: str, file_name: str, msgtype: str, mime_type: str) -> Dict[Any, Any]: - content = { - "file": { + def to_content(self, content: Dict, mime_type: str) -> Dict[Any, Any]: + content["file"] = { "v": "v2", "key": self.key, "iv": self.iv, "hashes": self.hashes, - "url": url, + "url": content["url"], "mimetype": mime_type, - } } - if len(file_name) > 0: - content["body"] = file_name - else: - content["body"] = url - - if msgtype: - content["msgtype"] = msgtype - return content @attr.s