Compare commits
No commits in common. "e44918b4c791505c2facc3a6749dea9990c34353" and "1657de4eefb45b8db0cfbcf4aa9b76f7a56f80fb" have entirely different histories.
e44918b4c7
...
1657de4eef
5 changed files with 4 additions and 80 deletions
|
@ -17,7 +17,7 @@ const createRoom = sync.require("../actions/create-room")
|
||||||
async function addReaction(data) {
|
async function addReaction(data) {
|
||||||
const user = data.member?.user
|
const user = data.member?.user
|
||||||
assert.ok(user && user.username)
|
assert.ok(user && user.username)
|
||||||
const parentID = select("event_message", "event_id", "WHERE message_id = ? AND part = 0").pluck().get(data.message_id) // 0 = primary
|
const parentID = select("event_message", "event_id", "WHERE message = ? AND part = 0").pluck().get(data.message_id) // 0 = primary
|
||||||
if (!parentID) return // Nothing can be done if the parent message was never bridged.
|
if (!parentID) return // Nothing can be done if the parent message was never bridged.
|
||||||
assert.equal(typeof parentID, "string")
|
assert.equal(typeof parentID, "string")
|
||||||
const roomID = await createRoom.ensureRoom(data.channel_id)
|
const roomID = await createRoom.ensureRoom(data.channel_id)
|
||||||
|
|
|
@ -181,7 +181,7 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
async onMessageUpdate(client, data) {
|
async onMessageUpdate(client, data) {
|
||||||
if (data.webhook_id) {
|
if (data.webhook_id) {
|
||||||
const row = select("webhook", "webhook_id", "WHERE webhook_id = ?").pluck().get(data.webhook_id)
|
const row = select("webhook", "1", "WHERE webhook_id = ?").pluck().get(message.webhook_id)
|
||||||
if (row) {
|
if (row) {
|
||||||
// The update was sent by the bridge's own webhook on discord. We don't want to reflect this back, so just drop it.
|
// The update was sent by the bridge's own webhook on discord. We don't want to reflect this back, so just drop it.
|
||||||
return
|
return
|
||||||
|
|
|
@ -67,12 +67,10 @@ INSERT INTO file (discord_url, mxc_url) VALUES
|
||||||
('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'),
|
('https://cdn.discordapp.com/emojis/230201364309868544.png', 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC');
|
||||||
('https://cdn.discordapp.com/emojis/393635038903926784.gif', 'mxc://cadence.moe/WbYqNlACRuicynBfdnPYtmvc');
|
|
||||||
|
|
||||||
INSERT INTO emoji (emoji_id, animated, mxc_url) VALUES
|
INSERT INTO emoji (emoji_id, animated, mxc_url) VALUES
|
||||||
('230201364309868544', 0, 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC'),
|
('230201364309868544', 0, 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC');
|
||||||
('393635038903926784', 1, 'mxc://cadence.moe/WbYqNlACRuicynBfdnPYtmvc');
|
|
||||||
|
|
||||||
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),
|
||||||
|
|
|
@ -117,28 +117,6 @@ turndownService.addRule("inlineLink", {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
turndownService.addRule("emoji", {
|
|
||||||
filter: function (node, options) {
|
|
||||||
if (node.nodeName !== "IMG" || !node.hasAttribute("data-mx-emoticon") || !node.getAttribute("src")) return false
|
|
||||||
const row = select("emoji", ["emoji_id", "animated"], "WHERE mxc_url = ?").get(node.getAttribute("src"))
|
|
||||||
if (!row) return false
|
|
||||||
node.setAttribute("data-emoji-id", row.emoji_id)
|
|
||||||
node.setAttribute("data-emoji-animated-char", row.animated ? "a" : "")
|
|
||||||
return true
|
|
||||||
},
|
|
||||||
|
|
||||||
replacement: function (content, node) {
|
|
||||||
/** @type {string} */
|
|
||||||
const id = node.getAttribute("data-emoji-id")
|
|
||||||
/** @type {string} */
|
|
||||||
const animatedChar = node.getAttribute("data-emoji-animated-char")
|
|
||||||
/** @type {string} */
|
|
||||||
const title = node.getAttribute("title") || "__"
|
|
||||||
const name = title.replace(/^:|:$/g, "")
|
|
||||||
return `<${animatedChar}:${name}:${id}>`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
turndownService.addRule("fencedCodeBlock", {
|
turndownService.addRule("fencedCodeBlock", {
|
||||||
filter: function (node, options) {
|
filter: function (node, options) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1692,55 +1692,3 @@ test("event2message: stickers work", async t => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("event2message: static emojis work", async t => {
|
|
||||||
t.deepEqual(
|
|
||||||
await eventToMessage({
|
|
||||||
type: "m.room.message",
|
|
||||||
sender: "@cadence:cadence.moe",
|
|
||||||
content: {
|
|
||||||
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:\">'
|
|
||||||
},
|
|
||||||
event_id: "$g07oYSZFWBkxohNEfywldwgcWj1hbhDzQ1sBAKvqOOU",
|
|
||||||
room_id: "!kLRqKKUQXcibIMtOpl:cadence.moe"
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
messagesToDelete: [],
|
|
||||||
messagesToEdit: [],
|
|
||||||
messagesToSend: [{
|
|
||||||
username: "cadence [they]",
|
|
||||||
content: "<:hippo:230201364309868544>",
|
|
||||||
avatar_url: undefined
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test("event2message: animated emojis work", async t => {
|
|
||||||
t.deepEqual(
|
|
||||||
await eventToMessage({
|
|
||||||
type: "m.room.message",
|
|
||||||
sender: "@cadence:cadence.moe",
|
|
||||||
content: {
|
|
||||||
msgtype: "m.text",
|
|
||||||
body: ":hippo:",
|
|
||||||
format: "org.matrix.custom.html",
|
|
||||||
formatted_body: '<img data-mx-emoticon height=\"32\" src=\"mxc://cadence.moe/WbYqNlACRuicynBfdnPYtmvc\" title=\":hipposcope:\" alt=\":hipposcope:\">'
|
|
||||||
},
|
|
||||||
event_id: "$g07oYSZFWBkxohNEfywldwgcWj1hbhDzQ1sBAKvqOOU",
|
|
||||||
room_id: "!kLRqKKUQXcibIMtOpl:cadence.moe"
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
messagesToDelete: [],
|
|
||||||
messagesToEdit: [],
|
|
||||||
messagesToSend: [{
|
|
||||||
username: "cadence [they]",
|
|
||||||
content: "<a:hipposcope:393635038903926784>",
|
|
||||||
avatar_url: undefined
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue