Compare commits
No commits in common. "cd5a501307e7e259892d66a4636aec8945c13da7" and "8d452102d5f7725479eb730e61636567ffd9db25" have entirely different histories.
cd5a501307
...
8d452102d5
4 changed files with 2 additions and 49 deletions
|
|
@ -268,7 +268,6 @@ async function messageToEvent(message, guild, options = {}, di) {
|
||||||
* @param {string} content Partial or complete Discord message content
|
* @param {string} content Partial or complete Discord message content
|
||||||
*/
|
*/
|
||||||
async function transformContentMessageLinks(content) {
|
async function transformContentMessageLinks(content) {
|
||||||
let offset = 0
|
|
||||||
for (const match of [...content.matchAll(/https:\/\/(?:ptb\.|canary\.|www\.)?discord(?:app)?\.com\/channels\/([0-9]+)\/([0-9]+)\/([0-9]+)/g)]) {
|
for (const match of [...content.matchAll(/https:\/\/(?:ptb\.|canary\.|www\.)?discord(?:app)?\.com\/channels\/([0-9]+)\/([0-9]+)\/([0-9]+)/g)]) {
|
||||||
assert(typeof match.index === "number")
|
assert(typeof match.index === "number")
|
||||||
const channelID = match[2]
|
const channelID = match[2]
|
||||||
|
|
@ -287,8 +286,7 @@ async function messageToEvent(message, guild, options = {}, di) {
|
||||||
} else {
|
} else {
|
||||||
result = `${match[0]} [event is from another server]`
|
result = `${match[0]} [event is from another server]`
|
||||||
}
|
}
|
||||||
content = content.slice(0, match.index + offset) + result + content.slice(match.index + match[0].length + offset)
|
content = content.slice(0, match.index) + result + content.slice(match.index + match[0].length)
|
||||||
offset += result.length - match[0].length
|
|
||||||
}
|
}
|
||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,19 +136,6 @@ test("message2event: message link that OOYE doesn't know about", async t => {
|
||||||
t.equal(called, 1, "getEventForTimestamp should be called once")
|
t.equal(called, 1, "getEventForTimestamp should be called once")
|
||||||
})
|
})
|
||||||
|
|
||||||
test("message2event: message link from another server", async t => {
|
|
||||||
const events = await messageToEvent(data.message.message_link_from_another_server, data.guild.general)
|
|
||||||
t.deepEqual(events, [{
|
|
||||||
$type: "m.room.message",
|
|
||||||
"m.mentions": {},
|
|
||||||
msgtype: "m.text",
|
|
||||||
body: "Neither of these servers are known to OOYE: https://discord.com/channels/111/222/333 [event is from another server] https://canary.discordapp.com/channels/444/555/666 [event is from another server]",
|
|
||||||
format: "org.matrix.custom.html",
|
|
||||||
formatted_body: 'Neither of these servers are known to OOYE: <a href="https://discord.com/channels/111/222/333">https://discord.com/channels/111/222/333</a> [event is from another server]'
|
|
||||||
+ ' <a href="https://canary.discordapp.com/channels/444/555/666">https://canary.discordapp.com/channels/444/555/666</a> [event is from another server]'
|
|
||||||
}])
|
|
||||||
})
|
|
||||||
|
|
||||||
test("message2event: attachment with no content", async t => {
|
test("message2event: attachment with no content", async t => {
|
||||||
const events = await messageToEvent(data.message.attachment_no_content, data.guild.general, {})
|
const events = await messageToEvent(data.message.attachment_no_content, data.guild.general, {})
|
||||||
t.deepEqual(events, [{
|
t.deepEqual(events, [{
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ class From {
|
||||||
/** @type {Pluck<Table, Select>} */
|
/** @type {Pluck<Table, Select>} */
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const r = this
|
const r = this
|
||||||
|
r.constructor = Pluck
|
||||||
r.cols = [col]
|
r.cols = [col]
|
||||||
r.isPluck = true
|
r.isPluck = true
|
||||||
return r
|
return r
|
||||||
|
|
@ -132,7 +133,6 @@ class From {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* c8 ignore start - this code is only used for types and does not actually execute */
|
|
||||||
/**
|
/**
|
||||||
* @template {keyof U.Models} Table
|
* @template {keyof U.Models} Table
|
||||||
* @template {keyof U.Merge<U.Models[Table]>} Col
|
* @template {keyof U.Merge<U.Models[Table]>} Col
|
||||||
|
|
@ -156,7 +156,6 @@ class Pluck extends From {
|
||||||
return prepared.all(..._)
|
return prepared.all(..._)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* c8 ignore stop */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template {keyof U.Models} Table
|
* @template {keyof U.Models} Table
|
||||||
|
|
|
||||||
31
test/data.js
31
test/data.js
|
|
@ -603,37 +603,6 @@ module.exports = {
|
||||||
flags: 0,
|
flags: 0,
|
||||||
components: []
|
components: []
|
||||||
},
|
},
|
||||||
message_link_from_another_server: {
|
|
||||||
id: "1160824382755708948",
|
|
||||||
type: 0,
|
|
||||||
content: "Neither of these servers are known to OOYE: https://discord.com/channels/111/222/333 https://canary.discordapp.com/channels/444/555/666",
|
|
||||||
channel_id: "112760669178241024",
|
|
||||||
author: {
|
|
||||||
id: "271237147401045000",
|
|
||||||
username: "jinx",
|
|
||||||
avatar: "a0ba563c16aff137289f67f38545807f",
|
|
||||||
discriminator: "0",
|
|
||||||
public_flags: 0,
|
|
||||||
premium_type: 0,
|
|
||||||
flags: 0,
|
|
||||||
banner: null,
|
|
||||||
accent_color: null,
|
|
||||||
global_name: "Jinx",
|
|
||||||
avatar_decoration_data: null,
|
|
||||||
banner_color: null
|
|
||||||
},
|
|
||||||
attachments: [],
|
|
||||||
embeds: [],
|
|
||||||
mentions: [],
|
|
||||||
mention_roles: [],
|
|
||||||
pinned: false,
|
|
||||||
mention_everyone: false,
|
|
||||||
tts: false,
|
|
||||||
timestamp: '2023-10-09T06:21:39.923000+00:00',
|
|
||||||
edited_timestamp: null,
|
|
||||||
flags: 0,
|
|
||||||
components: []
|
|
||||||
},
|
|
||||||
simple_written_at_mention_for_matrix: {
|
simple_written_at_mention_for_matrix: {
|
||||||
id: "1159030564049915915",
|
id: "1159030564049915915",
|
||||||
type: 0,
|
type: 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue