mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2024-10-01 03:35:38 -04:00
Encrypt Thumbnails
When a client sends a thumbnail with their media message, encrypt the thumbnail too.
This commit is contained in:
parent
73f68c76fb
commit
7b4cc0527d
@ -954,6 +954,17 @@ class ProxyDaemon:
|
||||
)
|
||||
|
||||
media_content = media_info.to_content(content, upload_info.mimetype)
|
||||
if media_content["info"].get("thumbnail_url", False):
|
||||
(
|
||||
thumb_upload_info,
|
||||
thumb_media_info,
|
||||
) = self._get_upload_and_media_info(
|
||||
"thumbnail_url", media_content["info"]
|
||||
)
|
||||
if thumb_upload_info and thumb_media_info:
|
||||
media_content = thumb_media_info.to_thumbnail(
|
||||
media_content, thumb_upload_info.mimetype
|
||||
)
|
||||
|
||||
response = await client.room_send(
|
||||
room_id, msgtype, media_content, txnid, ignore_unverified
|
||||
|
@ -60,6 +60,19 @@ class MediaInfo:
|
||||
|
||||
return content
|
||||
|
||||
def to_thumbnail(self, content: Dict, mime_type: str) -> Dict[Any, Any]:
|
||||
content["info"]["thumbnail_file"] = {
|
||||
"v": "v2",
|
||||
"key": self.key,
|
||||
"iv": self.iv,
|
||||
"hashes": self.hashes,
|
||||
"url": content["info"]["thumbnail_url"],
|
||||
"mimetype": mime_type,
|
||||
}
|
||||
|
||||
return content
|
||||
|
||||
|
||||
|
||||
@attr.s
|
||||
class UploadInfo:
|
||||
|
Loading…
Reference in New Issue
Block a user