2023-05-12 05:35:37 +00:00
|
|
|
const {test} = require("supertape")
|
|
|
|
const assert = require("assert")
|
|
|
|
const {messageToEvent} = require("./message-to-event")
|
|
|
|
const data = require("../../test/data")
|
|
|
|
|
2023-07-01 13:41:31 +00:00
|
|
|
test("message2event: attachment with no content", async t => {
|
|
|
|
const events = await messageToEvent(data.message.attachment_no_content, data.guild.general)
|
|
|
|
t.deepEqual(events, [{
|
|
|
|
$type: "m.room.message",
|
|
|
|
msgtype: "m.image",
|
|
|
|
url: "mxc://cadence.moe/qXoZktDqNtEGuOCZEADAMvhM",
|
|
|
|
body: "image.png",
|
|
|
|
external_url: "https://cdn.discordapp.com/attachments/497161332244742154/1124628646431297546/image.png",
|
|
|
|
info: {
|
|
|
|
mimetype: "image/png",
|
|
|
|
w: 466,
|
|
|
|
h: 85,
|
|
|
|
size: 12919,
|
|
|
|
},
|
|
|
|
}])
|
|
|
|
})
|
|
|
|
|
2023-05-12 05:35:37 +00:00
|
|
|
test("message2event: stickers", async t => {
|
2023-06-28 12:06:56 +00:00
|
|
|
const events = await messageToEvent(data.message.sticker, data.guild.general)
|
2023-05-12 05:35:37 +00:00
|
|
|
t.deepEqual(events, [{
|
|
|
|
$type: "m.room.message",
|
|
|
|
msgtype: "m.text",
|
|
|
|
body: "can have attachments too"
|
|
|
|
}, {
|
|
|
|
$type: "m.room.message",
|
|
|
|
msgtype: "m.image",
|
|
|
|
url: "mxc://cadence.moe/ZDCNYnkPszxGKgObUIFmvjus",
|
|
|
|
body: "image.png",
|
|
|
|
external_url: "https://cdn.discordapp.com/attachments/122155380120748034/1106366167486038016/image.png",
|
|
|
|
info: {
|
|
|
|
mimetype: "image/png",
|
|
|
|
w: 333,
|
|
|
|
h: 287,
|
|
|
|
size: 127373,
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
$type: "m.sticker",
|
2023-05-15 05:25:05 +00:00
|
|
|
body: "pomu puff - damn that tiny lil bitch really chuffing. puffing that fat ass dart",
|
|
|
|
info: {
|
|
|
|
mimetype: "image/png"
|
|
|
|
// thumbnail_url
|
|
|
|
// thumbnail_info
|
|
|
|
},
|
2023-06-28 12:06:56 +00:00
|
|
|
url: "mxc://cadence.moe/UuUaLwXhkxFRwwWCXipDlBHn"
|
2023-05-12 05:35:37 +00:00
|
|
|
}])
|
|
|
|
})
|