Apply strictNullChecks to src/utils/exportUtils (#10379)

* Apply `strictNullChecks` to `src/utils/exportUtils`

* strict fix

* test coverage

* lint

* test coverage

* one more test
This commit is contained in:
Kerry 2023-03-30 10:47:07 +13:00 committed by GitHub
parent 1447829543
commit 9a733a6444
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 178 additions and 9 deletions

View file

@ -47,7 +47,8 @@ export class DecryptError extends Error {
* @param {IMediaEventInfo} info The info parameter taken from the matrix event.
* @returns {Promise<Blob>} Resolves to a Blob of the file.
*/
export async function decryptFile(file: IEncryptedFile, info?: IMediaEventInfo): Promise<Blob> {
export async function decryptFile(file?: IEncryptedFile, info?: IMediaEventInfo): Promise<Blob> {
// throws if file is falsy
const media = mediaFromContent({ file });
let responseData: ArrayBuffer;
@ -64,7 +65,7 @@ export async function decryptFile(file: IEncryptedFile, info?: IMediaEventInfo):
try {
// Decrypt the array buffer using the information taken from the event content.
const dataArray = await encrypt.decryptAttachment(responseData, file);
const dataArray = await encrypt.decryptAttachment(responseData, file!);
// Turn the array into a Blob and give it the correct MIME-type.
// IMPORTANT: we must not allow scriptable mime-types into Blobs otherwise