Compare commits
No commits in common. "eb676256e45466cd53d3a2fc187eee38294c654f" and "191a98e1dcf339f0601c4f1ff0c405edb6c00a8a" have entirely different histories.
eb676256e4
...
191a98e1dc
3 changed files with 3 additions and 82 deletions
|
|
@ -821,7 +821,7 @@ async function eventToMessage(event, guild, channel, di) {
|
|||
}
|
||||
|
||||
// Handling mentions of Discord users
|
||||
input = input.replace(/("https:\/\/matrix.to\/#\/((?:@|%40)[^"]+)")/g, (whole, attributeValue, mxid) => {
|
||||
input = input.replace(/("https:\/\/matrix.to\/#\/((?:@|%40)[^"]+)")>/g, (whole, attributeValue, mxid) => {
|
||||
mxid = decodeURIComponent(mxid)
|
||||
if (mxUtils.eventSenderIsFromDiscord(mxid)) {
|
||||
// Handle mention of an OOYE sim user by their mxid
|
||||
|
|
@ -892,9 +892,7 @@ async function eventToMessage(event, guild, channel, di) {
|
|||
}
|
||||
// Check for incompatible backticks in code blocks
|
||||
let preNode
|
||||
let isBackticksTextInPre = node.nodeType === 3 && node.nodeValue.includes("```") && (preNode = nodeIsChildOf(node, ["PRE"]))
|
||||
let isLongPre = node.tagName === "PRE" && node.textContent.length > 1800 && (preNode = node)
|
||||
if (isBackticksTextInPre || isLongPre) {
|
||||
if (node.nodeType === 3 && node.nodeValue.includes("```") && (preNode = nodeIsChildOf(node, ["PRE"]))) {
|
||||
if (preNode.firstChild?.nodeName === "CODE") {
|
||||
let ext = preNode.firstChild.className.match(/language-(\S+)/)?.[1]
|
||||
if (!dUtils.supportedPlaintextPreviewExtensions.has(ext)) ext = "txt"
|
||||
|
|
|
|||
|
|
@ -1219,38 +1219,6 @@ test("event2message: code blocks are uploaded as attachments instead if they con
|
|||
)
|
||||
})
|
||||
|
||||
test("event2message: code blocks are uploaded as attachments instead if they are really long", async t => {
|
||||
t.deepEqual(
|
||||
await eventToMessage({
|
||||
type: "m.room.message",
|
||||
sender: "@cadence:cadence.moe",
|
||||
content: {
|
||||
msgtype: "m.text",
|
||||
body: "wrong body",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `So if you run code like this<pre><code class="language-js">${"A".repeat(2000)}</code></pre>it should print a markdown formatted code block`
|
||||
},
|
||||
event_id: "$pGkWQuGVmrPNByrFELxhzI6MCBgJecr5I2J3z88Gc2s",
|
||||
room_id: "!kLRqKKUQXcibIMtOpl:cadence.moe"
|
||||
}),
|
||||
{
|
||||
ensureJoined: [],
|
||||
messagesToDelete: [],
|
||||
messagesToEdit: [],
|
||||
messagesToSend: [{
|
||||
username: "cadence [they]",
|
||||
content: "So if you run code like this `[inline_code.js]` it should print a markdown formatted code block",
|
||||
attachments: [{id: "0", filename: "inline_code.js"}],
|
||||
pendingFiles: [{name: "inline_code.js", buffer: Buffer.from("A".repeat(2000))}],
|
||||
avatar_url: undefined,
|
||||
allowed_mentions: {
|
||||
parse: ["users", "roles"]
|
||||
}
|
||||
}]
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("event2message: characters are encoded properly in code blocks", async t => {
|
||||
t.deepEqual(
|
||||
await eventToMessage({
|
||||
|
|
@ -3425,50 +3393,6 @@ test("event2message: mentioning discord users works", async t => {
|
|||
)
|
||||
})
|
||||
|
||||
test("event2message: mentioning discord users with extra html attributes works", async t => {
|
||||
t.deepEqual(
|
||||
await eventToMessage({
|
||||
type: "m.room.message",
|
||||
sender: "@lavender.pet:queer.sh",
|
||||
content: {
|
||||
msgtype: "m.text",
|
||||
body: "also @_ooye_ampflower:cadence.moe fun fact at some point there is plans for FTE to have a built in map editor",
|
||||
"m.mentions": {
|
||||
user_ids: [
|
||||
"@_ooye_ampflower:cadence.moe"
|
||||
]
|
||||
},
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: "<p>also <a href=\"https://matrix.to/#/@_ooye_ampflower:cadence.moe\" target=\"_blank\" rel=\"noreferrer noopener\">@Ampflower</a> fun fact at some point there is plans for FTE to have a built in map editor </p>"
|
||||
},
|
||||
room_id: "!qzDBLKlildpzrrOnFZ:cadence.moe",
|
||||
origin_server_ts: 1778616745263,
|
||||
unsigned: {
|
||||
age: 100363692,
|
||||
membership: "join"
|
||||
},
|
||||
event_id: "$AHCkieLEVCrCEA3INTCl0rh44V29fCASlZpBKw7DzQU",
|
||||
user_id: "@lavender.pet:queer.sh",
|
||||
age: 100363692
|
||||
}),
|
||||
{
|
||||
ensureJoined: [],
|
||||
messagesToDelete: [],
|
||||
messagesToEdit: [],
|
||||
messagesToSend: [{
|
||||
username: "lavender.pet",
|
||||
avatar_url: undefined,
|
||||
content: "also <@196188877885538304> fun fact at some point there is plans for FTE to have a built in map editor",
|
||||
allowed_mentions: {
|
||||
parse: ["roles"],
|
||||
users: ["196188877885538304"]
|
||||
}
|
||||
}]
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
test("event2message: mentioning discord users works when URL encoded", async t => {
|
||||
t.deepEqual(
|
||||
await eventToMessage({
|
||||
|
|
@ -4304,7 +4228,7 @@ test("event2message: caches the member if the member is not known", async t => {
|
|||
}
|
||||
)
|
||||
|
||||
t.deepEqual(select("member_cache", ["avatar_url", "displayname", "mxid"], {room_id: "!qzDBLKlildpzrrOnFZ:cadence.moe", mxid: "@should_be_newly_cached:cadence.moe"}).all(), [
|
||||
t.deepEqual(select("member_cache", ["avatar_url", "displayname", "mxid"], {room_id: "!qzDBLKlildpzrrOnFZ:cadence.moe"}).all(), [
|
||||
{avatar_url: "mxc://cadence.moe/this_is_the_avatar", displayname: null, mxid: "@should_be_newly_cached:cadence.moe"}
|
||||
])
|
||||
t.equal(called, 1, "getStateEvent should be called once")
|
||||
|
|
|
|||
|
|
@ -192,7 +192,6 @@ INSERT INTO member_cache (room_id, mxid, displayname, avatar_url, power_level) V
|
|||
('!TqlyQmifxGUggEmdBN:cadence.moe', '@ampflower:matrix.org', 'Ampflower 🌺', 'mxc://cadence.moe/PRfhXYBTOalvgQYtmCLeUXko', 0),
|
||||
('!TqlyQmifxGUggEmdBN:cadence.moe', '@aflower:syndicated.gay', 'Rose', 'mxc://syndicated.gay/ZkBUPXCiXTjdJvONpLJmcbKP', 0),
|
||||
('!TqlyQmifxGUggEmdBN:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', NULL, 0),
|
||||
('!qzDBLKlildpzrrOnFZ:cadence.moe', '@lavender.pet:queer.sh', 'lavender.pet', NULL, 0),
|
||||
('!iSyXgNxQcEuXoXpsSn:pussthecat.org', '@austin:tchncs.de', 'Austin Huang', 'mxc://tchncs.de/090a2b5e07eed2f71e84edad5207221e6c8f8b8e', 0),
|
||||
('!zq94fae5bVKUubZLp7:agiadn.org', '@underscore_x:agiadn.org', 'underscore_x', NULL, 100);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue