Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6893 from jaiwanth-v/voice-export
Browse files Browse the repository at this point in the history
  • Loading branch information
germain-gg authored Oct 1, 2021
2 parents 17f5913 + 5568d53 commit b86d646
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/utils/exportUtils/Exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import { IExportOptions, ExportType } from "./exportUtils";
import { decryptFile } from "../DecryptFile";
import { mediaFromContent } from "../../customisations/Media";
import { formatFullDateNoDay } from "../../DateUtils";
import { isVoiceMessage } from "../EventUtils";
import { MatrixClient } from "matrix-js-sdk/src/client";
import { Direction } from "matrix-js-sdk/src/models/event-timeline";
import { IMediaEventContent } from "../../customisations/models/IMediaEventContent";
import { saveAs } from "file-saver";
import { _t } from "../../languageHandler";
import SdkConfig from "../../SdkConfig";
Expand Down Expand Up @@ -200,13 +202,12 @@ export default abstract class Exporter {
let blob: Blob;
try {
const isEncrypted = event.isEncrypted();
const content = event.getContent();
const shouldDecrypt = isEncrypted && !content.hasOwnProperty("org.matrix.msc1767.file")
&& event.getType() !== "m.sticker";
const content: IMediaEventContent = event.getContent();
const shouldDecrypt = isEncrypted && content.hasOwnProperty("file") && event.getType() !== "m.sticker";
if (shouldDecrypt) {
blob = await decryptFile(content.file);
} else {
const media = mediaFromContent(event.getContent());
const media = mediaFromContent(content);
const image = await fetch(media.srcHttp);
blob = await image.blob();
}
Expand Down Expand Up @@ -242,7 +243,10 @@ export default abstract class Exporter {
}
const fileDate = formatFullDateNoDay(new Date(event.getTs()));
let [fileName, fileExt] = this.splitFileName(event.getContent().body);

if (event.getType() === "m.sticker") fileExt = ".png";
if (isVoiceMessage(event)) fileExt = ".ogg";

return fileDirectory + "/" + fileName + '-' + fileDate + fileExt;
}

Expand Down

0 comments on commit b86d646

Please sign in to comment.