diff --git a/matrix/buffer.py b/matrix/buffer.py index 8501ed5..ca62bfe 100644 --- a/matrix/buffer.py +++ b/matrix/buffer.py @@ -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 diff --git a/matrix/message_renderer.py b/matrix/message_renderer.py index baa1fda..8a6f544 100644 --- a/matrix/message_renderer.py +++ b/matrix/message_renderer.py @@ -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" diff --git a/matrix/uploads.py b/matrix/uploads.py index 0b4e1f8..5757c60 100644 --- a/matrix/uploads.py +++ b/matrix/uploads.py @@ -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)