1
0
Fork 0

d->m bridge other attachments as m.file

This commit is contained in:
Cadence Ember 2023-08-29 17:08:00 +12:00
parent 0d9191ed5c
commit c9c22cdf40
2 changed files with 25 additions and 3 deletions

View file

@ -289,12 +289,34 @@ async function messageToEvent(message, guild, options = {}, di) {
size: attachment.size
}
}
} else if (attachment.content_type?.startsWith("audio/")) {
return {
$type: "m.room.message",
"m.mentions": mentions,
msgtype: "m.audio",
url: await file.uploadDiscordFileToMxc(attachment.url),
external_url: attachment.url,
body: attachment.description || attachment.filename,
filename: attachment.filename,
info: {
mimetype: attachment.content_type,
size: attachment.size,
duration: attachment.duration_secs ? attachment.duration_secs * 1000 : undefined
}
}
} else {
return {
$type: "m.room.message",
"m.mentions": mentions,
msgtype: "m.text",
body: `Unsupported attachment:\n${JSON.stringify(attachment, null, 2)}\n${attachment.url}`
msgtype: "m.file",
url: await file.uploadDiscordFileToMxc(attachment.url),
external_url: attachment.url,
body: attachment.filename,
// TODO: filename: attachment.filename and then use body as the caption
info: {
mimetype: attachment.content_type,
size: attachment.size
}
}
}
}))