Add media mimetype to emxc:// urls
This commit is contained in:
parent
79805d02c4
commit
82d25e88ae
3 changed files with 5 additions and 3 deletions
|
@ -1375,7 +1375,7 @@ class RoomBuffer(object):
|
|||
else:
|
||||
data = Render.encrypted_media(
|
||||
event.url, event.body, event.key["k"], event.hashes["sha256"],
|
||||
event.iv, self.homeserver.geturl()
|
||||
event.iv, self.homeserver.geturl(), event.mimetype,
|
||||
)
|
||||
|
||||
extra_prefix = (self.warning_prefix if event.decrypted
|
||||
|
|
|
@ -42,14 +42,15 @@ class Render(object):
|
|||
return Render._media(url, description)
|
||||
|
||||
@staticmethod
|
||||
def encrypted_media(mxc, body, key, hash, iv, homeserver=None):
|
||||
def encrypted_media(mxc, body, key, hash, iv, homeserver=None, mime=None):
|
||||
"""Render a mxc media URI of an encrypted file."""
|
||||
http_url = Api.encrypted_mxc_to_plumb(
|
||||
mxc,
|
||||
key,
|
||||
hash,
|
||||
iv,
|
||||
homeserver
|
||||
homeserver,
|
||||
mime,
|
||||
)
|
||||
url = http_url if http_url else mxc
|
||||
description = "{}".format(body) if body else "file"
|
||||
|
|
|
@ -214,6 +214,7 @@ class Upload(object):
|
|||
self.file_keys["key"]["k"],
|
||||
self.file_keys["hashes"]["sha256"],
|
||||
self.file_keys["iv"],
|
||||
mimetype=self.file_keys.get("mimetype"),
|
||||
)
|
||||
|
||||
return Render.media(self.content_uri, self.file_name)
|
||||
|
|
Loading…
Reference in a new issue