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(),
)
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

View File

@ -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