override existing content

This commit is contained in:
Andrea Spacca 2021-01-07 18:11:02 +01:00
parent a24f80c4d0
commit 266b049cfc
2 changed files with 4 additions and 18 deletions

View File

@ -950,11 +950,7 @@ class ProxyDaemon:
body=await response.transport_response.read(), body=await response.transport_response.read(),
) )
media_content = media_info.to_content(content["url"], media_content = media_info.to_content(content, upload_info.mimetype)
upload_info.filename,
content_msgtype,
upload_info.mimetype
),
response = await client.room_send( response = await client.room_send(
room_id, msgtype, media_content, txnid, ignore_unverified room_id, msgtype, media_content, txnid, ignore_unverified

View File

@ -48,25 +48,15 @@ class MediaInfo:
iv = attr.ib(type=str) iv = attr.ib(type=str)
hashes = attr.ib(type=dict) hashes = attr.ib(type=dict)
def to_content(self, url: str, file_name: str, msgtype: str, mime_type: str) -> Dict[Any, Any]: def to_content(self, content: Dict, mime_type: str) -> Dict[Any, Any]:
content = { content["file"] = {
"file": {
"v": "v2", "v": "v2",
"key": self.key, "key": self.key,
"iv": self.iv, "iv": self.iv,
"hashes": self.hashes, "hashes": self.hashes,
"url": url, "url": content["url"],
"mimetype": mime_type, "mimetype": mime_type,
} }
}
if len(file_name) > 0:
content["body"] = file_name
else:
content["body"] = url
if msgtype:
content["msgtype"] = msgtype
return content return content