Compare commits
No commits in common. "main" and "v3.5" have entirely different histories.
5 changed files with 24 additions and 57 deletions
24
package-lock.json
generated
24
package-lock.json
generated
|
|
@ -276,9 +276,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@emnapi/runtime": {
|
"node_modules/@emnapi/runtime": {
|
||||||
"version": "1.9.1",
|
"version": "1.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.0.tgz",
|
||||||
"integrity": "sha512-VYi5+ZVLhpgK4hQ0TAjiQiZ6ol0oe4mBx7mVv7IflsiEp0OWoVsp/+f9Vc1hOhE0TtkORVrI1GvzyreqpgWtkA==",
|
"integrity": "sha512-QN75eB0IH2ywSpRpNddCRfQIhmJYBCJ1x5Lb3IscKAL8bMnVAKnRg8dCoXbHzVLLH7P38N2Z3mtulB7W0J0FKw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
@ -1488,9 +1488,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/domino": {
|
"node_modules/domino": {
|
||||||
"version": "2.1.7",
|
"version": "2.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/domino/-/domino-2.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/domino/-/domino-2.1.6.tgz",
|
||||||
"integrity": "sha512-3rcXhx0ixJV2nj8J0tljzejTF73A35LVVdnTQu79UAqTBFEgYPMgGtykMuu/BDqaOZphATku1ddRUn/RtqUHYQ==",
|
"integrity": "sha512-3VdM/SXBZX2omc9JF9nOPCtDaYQ67BGp5CoLpIQlO2KCAPETs8TcDHacF26jXadGbvUteZzRTeos2fhID5+ucQ==",
|
||||||
"license": "BSD-2-Clause"
|
"license": "BSD-2-Clause"
|
||||||
},
|
},
|
||||||
"node_modules/emoji-regex": {
|
"node_modules/emoji-regex": {
|
||||||
|
|
@ -1617,9 +1617,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/fullstore": {
|
"node_modules/fullstore": {
|
||||||
"version": "4.0.2",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/fullstore/-/fullstore-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/fullstore/-/fullstore-4.0.0.tgz",
|
||||||
"integrity": "sha512-syOev4kA0lZy4VkfBJZ99ZL4cIiSgiKt0G8SpP0kla1tpM1c+V/jBOVY/OqqGtR2XLVcM83SjFPFC3R2YIwqjQ==",
|
"integrity": "sha512-Y9hN79Q1CFU8akjGnTZoBnTzlA/o8wmtBijJOI8dKCmdC7GLX7OekpLxmbaeRetTOi4OdFGjfsg4c5dxP3jgPw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
@ -1937,9 +1937,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/json-with-bigint": {
|
"node_modules/json-with-bigint": {
|
||||||
"version": "3.5.8",
|
"version": "3.5.7",
|
||||||
"resolved": "https://registry.npmjs.org/json-with-bigint/-/json-with-bigint-3.5.8.tgz",
|
"resolved": "https://registry.npmjs.org/json-with-bigint/-/json-with-bigint-3.5.7.tgz",
|
||||||
"integrity": "sha512-eq/4KP6K34kwa7TcFdtvnftvHCD9KvHOGGICWwMFc4dOOKF5t4iYqnfLK8otCRCRv06FXOzGGyqE8h8ElMvvdw==",
|
"integrity": "sha512-7ei3MdAI5+fJPVnKlW77TKNKwQ5ppSzWvhPuSuINT/GYW9ZOC1eRKOuhV9yHG5aEsUPj9BBx5JIekkmoLHxZOw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -193,16 +193,6 @@ async function channelToKState(channel, guild, di) {
|
||||||
// Don't overwrite room topic if the topic has been customised
|
// Don't overwrite room topic if the topic has been customised
|
||||||
if (hasCustomTopic) delete channelKState["m.room.topic/"]
|
if (hasCustomTopic) delete channelKState["m.room.topic/"]
|
||||||
|
|
||||||
// Make voice channels be a Matrix voice room (MSC3417)
|
|
||||||
if (channel.type === DiscordTypes.ChannelType.GuildVoice) {
|
|
||||||
creationContent.type = "org.matrix.msc3417.call"
|
|
||||||
channelKState["org.matrix.msc3401.call/"] = {
|
|
||||||
"m.intent": "m.room",
|
|
||||||
"m.type": "m.voice",
|
|
||||||
"m.name": customName || channel.name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't add a space parent if it's self service
|
// Don't add a space parent if it's self service
|
||||||
// (The person setting up self-service has already put it in their preferred space to be able to get this far.)
|
// (The person setting up self-service has already put it in their preferred space to be able to get this far.)
|
||||||
const autocreate = select("guild_active", "autocreate", {guild_id: guild.id}).pluck().get()
|
const autocreate = select("guild_active", "autocreate", {guild_id: guild.id}).pluck().get()
|
||||||
|
|
|
||||||
|
|
@ -190,17 +190,6 @@ test("channel2room: read-only discord channel", async t => {
|
||||||
t.equal(api.getCalled(), 2)
|
t.equal(api.getCalled(), 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("channel2room: voice channel", async t => {
|
|
||||||
const api = mockAPI(t)
|
|
||||||
const state = kstateStripConditionals(await channelToKState(testData.channel.voice, testData.guild.general, {api}).then(x => x.channelKState))
|
|
||||||
t.equal(state["m.room.create/"].type, "org.matrix.msc3417.call")
|
|
||||||
t.deepEqual(state["org.matrix.msc3401.call/"], {
|
|
||||||
"m.intent": "m.room",
|
|
||||||
"m.name": "🍞丨[8user] Piece",
|
|
||||||
"m.type": "m.voice"
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("convertNameAndTopic: custom name and topic", t => {
|
test("convertNameAndTopic: custom name and topic", t => {
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
_convertNameAndTopic({id: "123", name: "the-twilight-zone", topic: "Spooky stuff here. :ghost:", type: 0}, {id: "456"}, "hauntings"),
|
_convertNameAndTopic({id: "123", name: "the-twilight-zone", topic: "Spooky stuff here. :ghost:", type: 0}, {id: "456"}, "hauntings"),
|
||||||
|
|
|
||||||
|
|
@ -816,6 +816,16 @@ async function eventToMessage(event, guild, channel, di) {
|
||||||
if (shouldProcessTextEvent) {
|
if (shouldProcessTextEvent) {
|
||||||
if (event.content.format === "org.matrix.custom.html" && event.content.formatted_body) {
|
if (event.content.format === "org.matrix.custom.html" && event.content.formatted_body) {
|
||||||
let input = event.content.formatted_body
|
let input = event.content.formatted_body
|
||||||
|
if (perMessageProfile?.has_fallback) {
|
||||||
|
// Strip fallback elements added for clients that don't support per-message profiles.
|
||||||
|
// Deviates from recommended regexp in MSC to be less strict. Avoiding an HTML parser for performance reasons.
|
||||||
|
// ┌────A────┐ Opening HTML tag: capture tag name and stay within tag
|
||||||
|
// ┆ ┆┌─────────────B────────────┐ This text in the tag somewhere, presumably an attribute name
|
||||||
|
// ┆ ┆┆ ┆┌─C──┐ Rest of the opening tag
|
||||||
|
// ┆ ┆┆ ┆┆ ┆┌─D─┐ Tag content (no more tags allowed within)
|
||||||
|
// ┆ ┆┆ ┆┆ ┆┆ ┆┌─E──┐ Closing tag matching opening tag name
|
||||||
|
input = input.replace(/<(\w+)[^>]*\bdata-mx-profile-fallback\b[^>]*>[^<]*<\/\1>/g, "")
|
||||||
|
}
|
||||||
if (event.content.msgtype === "m.emote") {
|
if (event.content.msgtype === "m.emote") {
|
||||||
input = `* ${displayName} ${input}`
|
input = `* ${displayName} ${input}`
|
||||||
}
|
}
|
||||||
|
|
@ -876,9 +886,8 @@ async function eventToMessage(event, guild, channel, di) {
|
||||||
const doc = domino.createDocument(
|
const doc = domino.createDocument(
|
||||||
// DOM parsers arrange elements in the <head> and <body>. Wrapping in a custom element ensures elements are reliably arranged in a single element.
|
// DOM parsers arrange elements in the <head> and <body>. Wrapping in a custom element ensures elements are reliably arranged in a single element.
|
||||||
'<x-turndown id="turndown-root">' + input + '</x-turndown>'
|
'<x-turndown id="turndown-root">' + input + '</x-turndown>'
|
||||||
)
|
);
|
||||||
const root = doc.getElementById("turndown-root")
|
const root = doc.getElementById("turndown-root");
|
||||||
assert(root)
|
|
||||||
async function forEachNode(event, node) {
|
async function forEachNode(event, node) {
|
||||||
for (; node; node = node.nextSibling) {
|
for (; node; node = node.nextSibling) {
|
||||||
// Check written mentions
|
// Check written mentions
|
||||||
|
|
@ -931,7 +940,6 @@ async function eventToMessage(event, guild, channel, di) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await forEachNode(event, root)
|
await forEachNode(event, root)
|
||||||
if (perMessageProfile?.has_fallback) root.querySelectorAll("[data-mx-profile-fallback]").forEach(x => x.remove())
|
|
||||||
|
|
||||||
// SPRITE SHEET EMOJIS FEATURE: Emojis at the end of the message that we don't know about will be reuploaded as a sprite sheet.
|
// SPRITE SHEET EMOJIS FEATURE: Emojis at the end of the message that we don't know about will be reuploaded as a sprite sheet.
|
||||||
// First we need to determine which emojis are at the end.
|
// First we need to determine which emojis are at the end.
|
||||||
|
|
|
||||||
20
test/data.js
20
test/data.js
|
|
@ -19,26 +19,6 @@ module.exports = {
|
||||||
default_thread_rate_limit_per_user: 0,
|
default_thread_rate_limit_per_user: 0,
|
||||||
guild_id: "112760669178241024"
|
guild_id: "112760669178241024"
|
||||||
},
|
},
|
||||||
voice: {
|
|
||||||
voice_background_display: null,
|
|
||||||
version: 1774469910848,
|
|
||||||
user_limit: 0,
|
|
||||||
type: 2,
|
|
||||||
theme_color: null,
|
|
||||||
status: null,
|
|
||||||
rtc_region: null,
|
|
||||||
rate_limit_per_user: 0,
|
|
||||||
position: 0,
|
|
||||||
permission_overwrites: [],
|
|
||||||
parent_id: "805261291908104252",
|
|
||||||
nsfw: false,
|
|
||||||
name: "🍞丨[8user] Piece",
|
|
||||||
last_message_id: "1459912691098325137",
|
|
||||||
id: "1036840786093953084",
|
|
||||||
flags: 0,
|
|
||||||
bitrate: 256000,
|
|
||||||
guild_id: "112760669178241024"
|
|
||||||
},
|
|
||||||
updates: {
|
updates: {
|
||||||
type: 0,
|
type: 0,
|
||||||
topic: "Updates and release announcements for Out Of Your Element.",
|
topic: "Updates and release announcements for Out Of Your Element.",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue