mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-01-09 14:39:34 -05:00
override existing content
This commit is contained in:
parent
a24f80c4d0
commit
266b049cfc
@ -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
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user