fedimbed: attempt to fallback media type when uploading

This commit is contained in:
Cynthia Foxwell 2023-01-06 11:21:32 -07:00
parent 44779f7a23
commit a5dfd6395a
1 changed files with 14 additions and 6 deletions

View File

@ -465,7 +465,11 @@ async function processUrl(msg, url) {
.then((buf) => Buffer.from(buf));
files.push({
name: attachment.type.replace("/", "."),
name:
attachment.type.indexOf("/") > -1
? attachment.type.replace("/", ".")
: attachment.type +
(url.match(/\.([a-z0-9]{3,4})$/)?.[0] ?? "mp4"),
contents: file,
});
}
@ -492,11 +496,15 @@ async function processUrl(msg, url) {
.then((buf) => Buffer.from(buf));
files.push({
name: attachment.type
.replace("/", ".")
.replace("mpeg", "mp3")
.replace("vnd.wave", "wav")
.replace("x-wav", "wav"),
name:
attachment.type.indexOf("/") > -1
? attachment.type
.replace("/", ".")
.replace("mpeg", "mp3")
.replace("vnd.wave", "wav")
.replace("x-wav", "wav")
: attachment.type +
(url.match(/\.([a-z0-9]{3,4})$/)?.[0] ?? "mp3"),
contents: file,
});
}