catch up on missed d->m messages when logging in

This commit is contained in:
Cadence Ember 2023-08-19 22:54:23 +12:00
parent 0f20dcab6d
commit 3436759504
16 changed files with 268 additions and 16 deletions

View file

@ -108,6 +108,13 @@ async function messageToEvent(message, guild, options = {}, di) {
addMention(repliedToEventSenderMxid)
}
let msgtype = "m.text"
// Handle message type 4, channel name changed
if (message.type === DiscordTypes.MessageType.ChannelNameChange) {
msgtype = "m.emote"
message.content = "changed the channel name to **" + message.content + "**"
}
// Text content appears first
if (message.content) {
let content = message.content
@ -188,7 +195,7 @@ async function messageToEvent(message, guild, options = {}, di) {
const newTextMessageEvent = {
$type: "m.room.message",
"m.mentions": mentions,
msgtype: "m.text",
msgtype,
body: body
}
@ -239,6 +246,22 @@ async function messageToEvent(message, guild, options = {}, di) {
size: attachment.size
}
}
} else if (attachment.content_type?.startsWith("video/") && attachment.width && attachment.height) {
return {
$type: "m.room.message",
"m.mentions": mentions,
msgtype: "m.video",
url: await file.uploadDiscordFileToMxc(attachment.url),
external_url: attachment.url,
body: attachment.description || attachment.filename,
filename: attachment.filename,
info: {
mimetype: attachment.content_type,
w: attachment.width,
h: attachment.height,
size: attachment.size
}
}
} else {
return {
$type: "m.room.message",