Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

markdown: Utilize ![title](url) for audio uploads.

Rohan Gudimetlac6041c1e69d2
diff --git a/web/src/upload.ts b/web/src/upload.ts
index 8d179744cb7..5adb67f9793 100644
--- a/web/src/upload.ts
+++ b/web/src/upload.ts
@@ -47,6 +47,14 @@ export function is_supported_image_type(file_type: string): boolean {
return SUPPORTED_IMAGE_TYPES.has(file_type);
}
+// This list should be kept identical to the one defined as
+// AUDIO_INLINE_MIME_TYPES defined in zerver/lib/mime_types.py
+const SUPPORTED_AUDIO_TYPES = new Set([".aac", ".flac", ".mp4", ".mpeg", ".wav", ".webm"]);
+
+function is_supported_audio_type(file_name: string): boolean {
+ return SUPPORTED_AUDIO_TYPES.has(file_name.slice(file_name.lastIndexOf(".")));
+}
+
export function compose_upload_cancel(): void {
compose_upload_object.cancelAll();
}
@@ -606,7 +614,7 @@ export function setup_upload(config: Config): Uppy<ZulipMeta, TusBody> {
const filtered_filename = file.name.replaceAll("[", "").replaceAll("]", "");
let syntax_to_insert = "[" + filtered_filename + "](" + file.meta.zulip_url + ")";
- if (is_supported_image_type(file.type)) {
+ if (is_supported_image_type(file.type) || is_supported_audio_type(file.name)) {
syntax_to_insert = "!" + syntax_to_insert;
}