Files
ThreadNet-Web/src/utils/createVoiceMessageContent.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-09-29 21:06:49 +02:00
/*
2024-09-09 14:57:16 +01:00
Copyright 2024 New Vector Ltd.
2022-09-29 21:06:49 +02:00
Copyright 2022 The Matrix.org Foundation C.I.C.
2024-09-09 14:57:16 +01:00
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
2022-09-29 21:06:49 +02:00
*/
import { MsgType } from "matrix-js-sdk/src/matrix";
import { EncryptedFile, RoomMessageEventContent } from "matrix-js-sdk/src/types";
2022-09-29 21:06:49 +02:00
/**
* @param {string} mxc MXC URL of the file
* @param {string} mimetype
* @param {number} duration Duration in milliseconds
* @param {number} size
* @param {number[]} [waveform]
* @param {EncryptedFile} [file] Encrypted file
2022-09-29 21:06:49 +02:00
*/
export const createVoiceMessageContent = (
mxc: string | undefined,
2022-09-29 21:06:49 +02:00
mimetype: string,
duration: number,
size: number,
file?: EncryptedFile,
2022-09-29 21:06:49 +02:00
waveform?: number[],
2024-03-25 12:48:48 +00:00
): RoomMessageEventContent => {
2022-09-29 21:06:49 +02:00
return {
"body": "Voice message",
//"msgtype": "org.matrix.msc2516.voice",
"msgtype": MsgType.Audio,
"url": mxc,
"file": file,
"info": {
duration,
mimetype,
size,
},
// MSC1767 + Ideals of MSC2516 as MSC3245
// https://github.com/matrix-org/matrix-doc/pull/3245
"org.matrix.msc1767.text": "Voice message",
"org.matrix.msc1767.file": {
url: mxc,
file,
name: "Voice message.ogg",
mimetype,
size,
},
"org.matrix.msc1767.audio": {
duration,
// https://github.com/matrix-org/matrix-doc/pull/3246
waveform,
},
"org.matrix.msc3245.voice": {}, // No content, this is a rendering hint
};
};