From a80aeec930d3b56a4c2ca4601a401c9b87f762a7 Mon Sep 17 00:00:00 2001 From: zefie Date: Thu, 13 Oct 2022 03:07:02 -0400 Subject: [PATCH] update wtv-news:/news attachment handling --- .../ServiceVault/wtv-news/news.js | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-news/news.js b/zefie_wtvp_minisrv/ServiceVault/wtv-news/news.js index 3c937f4a..b8c066fb 100644 --- a/zefie_wtvp_minisrv/ServiceVault/wtv-news/news.js +++ b/zefie_wtvp_minisrv/ServiceVault/wtv-news/news.js @@ -556,26 +556,19 @@ ${wtvshared.htmlEntitize(message_body, true)} data += "

"; if (attachments) { + var supported_images = /image\/(jpe?g|png|gif|x-wtv-bitmap)/; + var supported_audio = /audio\/(mp[eg|2|3]|midi?|wav|x-wav|mod|x-mod)/; attachments.forEach((v, k) => { - if (v) { - switch (v.content_type) { - case "image/jpeg": - case "image/png": - case "image/gif": - data += `

`; - break; - case "audio/wav": - case "audio/mp2": - case "audio/mp3": - case "audio/mid": - case "audio/midi": - data += ` + if (v.content_type) { + if (v.content_type.match(supported_images)) + data += `

`; + else if (v.content_type.match(supported_audio)) + data += `
  ${(v.filename) ? (v.filename) : "Audio file"} (${v.content_type.split('/')[1]} attachment) -


- `; - break; - } +

`; + else + data += `
A file ${(v.filename) ? `(${v.filename}) ` : ''}that WebTV cannot use, with type ${v.content_type} is attached to this message.` } }); }