use the mimetype from the info property rather than the EncryptedFile

the mimetype in EncryptedFile is undocumented and redundant.
see https://github.com/matrix-org/matrix-doc/pull/2582
This commit is contained in:
Hubert Chathi 2021-08-10 19:25:56 -04:00
parent d7cb855419
commit 3b9810719f
3 changed files with 26 additions and 13 deletions

View file

@ -76,7 +76,8 @@ export class MediaEventHelper implements IDestroyable {
private fetchSource = () => {
if (this.media.isEncrypted) {
return decryptFile(this.event.getContent<IMediaEventContent>().file);
const content = this.event.getContent<IMediaEventContent>();
return decryptFile(content.file, content.info);
}
return this.media.downloadSource().then(r => r.blob());
};
@ -87,7 +88,7 @@ export class MediaEventHelper implements IDestroyable {
if (this.media.isEncrypted) {
const content = this.event.getContent<IMediaEventContent>();
if (content.info?.thumbnail_file) {
return decryptFile(content.info.thumbnail_file);
return decryptFile(content.info.thumbnail_file, content.info.thumbnail_info);
} else {
// "Should never happen"
console.warn("Media claims to have thumbnail and is encrypted, but no thumbnail_file found");