Compare commits
No commits in common. "1657de4eefb45b8db0cfbcf4aa9b76f7a56f80fb" and "b31b7c794c0695933b57ee6f09e59c8316517f2a" have entirely different histories.
1657de4eef
...
b31b7c794c
6 changed files with 5 additions and 106 deletions
|
@ -29,9 +29,8 @@ async function emojisToState(emojis) {
|
||||||
},
|
},
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
db.prepare("INSERT OR IGNORE INTO emoji (emoji_id, animated, mxc_url) VALUES (?, ?, ?)").run(emoji.id, +!!emoji.animated, url)
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
if (e.data.errcode === "M_TOO_LARGE") { // Very unlikely to happen. Only possible for 3x-series emojis uploaded shortly after animated emojis were introduced, when there was no 256 KB size limit.
|
if (e.data.errcode === "M_TOO_LARGE") { // Lol.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.error(`Trying to handle emoji ${emoji.name} (${emoji.id}), but...`)
|
console.error(`Trying to handle emoji ${emoji.name} (${emoji.id}), but...`)
|
||||||
|
|
|
@ -41,12 +41,8 @@ function getDiscordParseCallbacks(message, useHTML) {
|
||||||
/** @param {{animated: boolean, name: string, id: string, type: "discordEmoji"}} node */
|
/** @param {{animated: boolean, name: string, id: string, type: "discordEmoji"}} node */
|
||||||
emoji: node => {
|
emoji: node => {
|
||||||
if (useHTML) {
|
if (useHTML) {
|
||||||
const mxc = select("emoji", "mxc_url", "WHERE emoji_id = ?").pluck().get(node.id)
|
// TODO: upload the emoji and actually use the right mxc!!
|
||||||
if (mxc) {
|
|
||||||
return `<img data-mx-emoticon height="32" src="${mxc}" title=":${node.name}:" alt=":${node.name}:">`
|
|
||||||
} else {
|
|
||||||
return `<img src="mxc://cadence.moe/${node.id}" data-mx-emoticon alt=":${node.name}:" title=":${node.name}:" height="24">`
|
return `<img src="mxc://cadence.moe/${node.id}" data-mx-emoticon alt=":${node.name}:" title=":${node.name}:" height="24">`
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return `:${node.name}:`
|
return `:${node.name}:`
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,27 +379,3 @@ test("message2event: thread start message reference", async t => {
|
||||||
"m.mentions": {}
|
"m.mentions": {}
|
||||||
}])
|
}])
|
||||||
})
|
})
|
||||||
|
|
||||||
test("message2event: single large bridged emoji", async t => {
|
|
||||||
const events = await messageToEvent(data.message.single_emoji, data.guild.general, {})
|
|
||||||
t.deepEqual(events, [{
|
|
||||||
$type: "m.room.message",
|
|
||||||
"m.mentions": {},
|
|
||||||
msgtype: "m.text",
|
|
||||||
body: ":hippo:",
|
|
||||||
format: "org.matrix.custom.html",
|
|
||||||
formatted_body: '<img data-mx-emoticon height="32" src="mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC" title=":hippo:" alt=":hippo:">'
|
|
||||||
}])
|
|
||||||
})
|
|
||||||
|
|
||||||
test("message2event: mid-message small bridged emoji", async t => {
|
|
||||||
const events = await messageToEvent(data.message.surrounded_emoji, data.guild.general, {})
|
|
||||||
t.deepEqual(events, [{
|
|
||||||
$type: "m.room.message",
|
|
||||||
"m.mentions": {},
|
|
||||||
msgtype: "m.text",
|
|
||||||
body: "h is for :hippo:!",
|
|
||||||
format: "org.matrix.custom.html",
|
|
||||||
formatted_body: 'h is for <img data-mx-emoticon height="32" src="mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC" title=":hippo:" alt=":hippo:">!'
|
|
||||||
}])
|
|
||||||
})
|
|
||||||
|
|
|
@ -66,11 +66,7 @@ INSERT INTO file (discord_url, mxc_url) VALUES
|
||||||
('https://cdn.discordapp.com/attachments/112760669178241024/1128084851023675515/RDT_20230704_0936184915846675925224905.jpg', 'mxc://cadence.moe/WlAbFSiNRIHPDEwKdyPeGywa'),
|
('https://cdn.discordapp.com/attachments/112760669178241024/1128084851023675515/RDT_20230704_0936184915846675925224905.jpg', 'mxc://cadence.moe/WlAbFSiNRIHPDEwKdyPeGywa'),
|
||||||
('https://cdn.discordapp.com/guilds/112760669178241024/users/134826546694193153/avatars/38dd359aa12bcd52dd3164126c587f8c.png?size=1024', 'mxc://cadence.moe/rfemHmAtcprjLEiPiEuzPhpl'),
|
('https://cdn.discordapp.com/guilds/112760669178241024/users/134826546694193153/avatars/38dd359aa12bcd52dd3164126c587f8c.png?size=1024', 'mxc://cadence.moe/rfemHmAtcprjLEiPiEuzPhpl'),
|
||||||
('https://cdn.discordapp.com/icons/112760669178241024/a_f83622e09ead74f0c5c527fe241f8f8c.png?size=1024', 'mxc://cadence.moe/zKXGZhmImMHuGQZWJEFKJbsF'),
|
('https://cdn.discordapp.com/icons/112760669178241024/a_f83622e09ead74f0c5c527fe241f8f8c.png?size=1024', 'mxc://cadence.moe/zKXGZhmImMHuGQZWJEFKJbsF'),
|
||||||
('https://cdn.discordapp.com/avatars/113340068197859328/b48302623a12bc7c59a71328f72ccb39.png?size=1024', 'mxc://cadence.moe/UpAeIqeclhKfeiZNdIWNcXXL'),
|
('https://cdn.discordapp.com/avatars/113340068197859328/b48302623a12bc7c59a71328f72ccb39.png?size=1024', 'mxc://cadence.moe/UpAeIqeclhKfeiZNdIWNcXXL');
|
||||||
('https://cdn.discordapp.com/emojis/230201364309868544.png', 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC');
|
|
||||||
|
|
||||||
INSERT INTO emoji (emoji_id, animated, mxc_url) VALUES
|
|
||||||
('230201364309868544', 0, 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC');
|
|
||||||
|
|
||||||
INSERT INTO member_cache (room_id, mxid, displayname, avatar_url) VALUES
|
INSERT INTO member_cache (room_id, mxid, displayname, avatar_url) VALUES
|
||||||
('!kLRqKKUQXcibIMtOpl:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', NULL),
|
('!kLRqKKUQXcibIMtOpl:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', NULL),
|
||||||
|
|
6
db/orm-utils.d.ts
vendored
6
db/orm-utils.d.ts
vendored
|
@ -62,12 +62,6 @@ export type Models = {
|
||||||
webhook_id: string
|
webhook_id: string
|
||||||
webhook_token: string
|
webhook_token: string
|
||||||
}
|
}
|
||||||
|
|
||||||
emoji: {
|
|
||||||
emoji_id: string
|
|
||||||
animated: number
|
|
||||||
mxc_url: string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Prepared<Row> = {
|
export type Prepared<Row> = {
|
||||||
|
|
64
test/data.js
64
test/data.js
|
@ -958,69 +958,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
attachments: [],
|
attachments: [],
|
||||||
guild_id: "112760669178241024"
|
guild_id: "112760669178241024"
|
||||||
},
|
}
|
||||||
single_emoji: {
|
|
||||||
id: "1126733830494093453",
|
|
||||||
type: 0,
|
|
||||||
content: "<:hippo:230201364309868544>",
|
|
||||||
channel_id: "112760669178241024",
|
|
||||||
author: {
|
|
||||||
id: "111604486476181504",
|
|
||||||
username: "kyuugryphon",
|
|
||||||
avatar: "e4ce31267ca524d19be80e684d4cafa1",
|
|
||||||
discriminator: "0",
|
|
||||||
public_flags: 0,
|
|
||||||
flags: 0,
|
|
||||||
banner: null,
|
|
||||||
accent_color: null,
|
|
||||||
global_name: "KyuuGryphon",
|
|
||||||
avatar_decoration: null,
|
|
||||||
display_name: "KyuuGryphon",
|
|
||||||
banner_color: null
|
|
||||||
},
|
|
||||||
attachments: [],
|
|
||||||
embeds: [],
|
|
||||||
mentions: [],
|
|
||||||
mention_roles: [],
|
|
||||||
pinned: false,
|
|
||||||
mention_everyone: false,
|
|
||||||
tts: false,
|
|
||||||
timestamp: "2023-07-07T04:37:58.892000+00:00",
|
|
||||||
edited_timestamp: null,
|
|
||||||
flags: 0,
|
|
||||||
components: []
|
|
||||||
},
|
|
||||||
surrounded_emoji: {
|
|
||||||
id: "1126733830494093453",
|
|
||||||
type: 0,
|
|
||||||
content: "h is for <:hippo:230201364309868544>!",
|
|
||||||
channel_id: "112760669178241024",
|
|
||||||
author: {
|
|
||||||
id: "111604486476181504",
|
|
||||||
username: "kyuugryphon",
|
|
||||||
avatar: "e4ce31267ca524d19be80e684d4cafa1",
|
|
||||||
discriminator: "0",
|
|
||||||
public_flags: 0,
|
|
||||||
flags: 0,
|
|
||||||
banner: null,
|
|
||||||
accent_color: null,
|
|
||||||
global_name: "KyuuGryphon",
|
|
||||||
avatar_decoration: null,
|
|
||||||
display_name: "KyuuGryphon",
|
|
||||||
banner_color: null
|
|
||||||
},
|
|
||||||
attachments: [],
|
|
||||||
embeds: [],
|
|
||||||
mentions: [],
|
|
||||||
mention_roles: [],
|
|
||||||
pinned: false,
|
|
||||||
mention_everyone: false,
|
|
||||||
tts: false,
|
|
||||||
timestamp: "2023-07-07T04:37:58.892000+00:00",
|
|
||||||
edited_timestamp: null,
|
|
||||||
flags: 0,
|
|
||||||
components: []
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
message_with_embeds: {
|
message_with_embeds: {
|
||||||
nothing_but_a_field: {
|
nothing_but_a_field: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue