Compare commits
25 Commits
Author | SHA1 | Date |
---|---|---|
Cadence Ember | 1f5865b0d8 | |
Cadence Ember | b6b65992f7 | |
Cadence Ember | 5f0e765934 | |
Cadence Ember | 642be26313 | |
Cadence Ember | ff7af39802 | |
Cadence Ember | 7a00b95883 | |
Cadence Ember | 566b2a9d9e | |
Cadence Ember | 0deb415511 | |
Cadence Ember | bce3d0f2c9 | |
Cadence Ember | c615ea1e61 | |
Cadence Ember | 23d85547f3 | |
Cadence Ember | d01c888d02 | |
Cadence Ember | 955310b759 | |
Cadence Ember | 08c01e8664 | |
Cadence Ember | f5ffc09fab | |
Cadence Ember | 25cd8cb289 | |
Cadence Ember | cc9e1de49e | |
Cadence Ember | a190e690b1 | |
Cadence Ember | 12d85c982e | |
Cadence Ember | 0f1cf7a20c | |
Cadence Ember | 043f178d1e | |
Cadence Ember | bf3d219716 | |
Cadence Ember | 2fb68900c7 | |
Cadence Ember | e2d0ea41d5 | |
Cadence Ember | 1e8066ca0a |
|
@ -12,6 +12,8 @@ const file = sync.require("../../matrix/file")
|
|||
const api = sync.require("../../matrix/api")
|
||||
/** @type {import("../../matrix/kstate")} */
|
||||
const ks = sync.require("../../matrix/kstate")
|
||||
/** @type {import("../../discord/utils")} */
|
||||
const utils = sync.require("../../discord/utils")
|
||||
/** @type {import("./create-space")}) */
|
||||
const createSpace = sync.require("./create-space") // watch out for the require loop
|
||||
|
||||
|
@ -57,13 +59,16 @@ function applyKStateDiffToRoom(roomID, kstate) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {{id: string, name: string, topic?: string?, type: number}} channel
|
||||
* @param {{id: string, name: string, topic?: string?, type: number, parent_id?: string?}} channel
|
||||
* @param {{id: string}} guild
|
||||
* @param {string | null | undefined} customName
|
||||
*/
|
||||
function convertNameAndTopic(channel, guild, customName) {
|
||||
// @ts-ignore
|
||||
const parentChannel = discord.channels.get(channel.parent_id)
|
||||
let channelPrefix =
|
||||
( channel.type === DiscordTypes.ChannelType.PublicThread ? "[⛓️] "
|
||||
( parentChannel?.type === DiscordTypes.ChannelType.GuildForum ? ""
|
||||
: channel.type === DiscordTypes.ChannelType.PublicThread ? "[⛓️] "
|
||||
: channel.type === DiscordTypes.ChannelType.PrivateThread ? "[🔒⛓️] "
|
||||
: channel.type === DiscordTypes.ChannelType.GuildVoice ? "[🔊] "
|
||||
: "")
|
||||
|
@ -86,9 +91,24 @@ function convertNameAndTopic(channel, guild, customName) {
|
|||
* @param {DiscordTypes.APIGuild} guild
|
||||
*/
|
||||
async function channelToKState(channel, guild) {
|
||||
const spaceID = await createSpace.ensureSpace(guild)
|
||||
assert(typeof spaceID === "string")
|
||||
const privacyLevel = select("guild_space", "privacy_level", {space_id: spaceID}).pluck().get()
|
||||
// @ts-ignore
|
||||
const parentChannel = discord.channels.get(channel.parent_id)
|
||||
/** Used for membership/permission checks. */
|
||||
let guildSpaceID
|
||||
/** Used as the literal parent on Matrix, for categorisation. Will be the same as `guildSpaceID` unless it's a forum channel's thread, in which case a different space is used to group those threads. */
|
||||
let parentSpaceID
|
||||
let privacyLevel
|
||||
if (parentChannel?.type === DiscordTypes.ChannelType.GuildForum) { // it's a forum channel's thread, so use a different space to group those threads
|
||||
guildSpaceID = await createSpace.ensureSpace(guild)
|
||||
parentSpaceID = await ensureRoom(channel.parent_id)
|
||||
privacyLevel = select("guild_space", "privacy_level", {space_id: guildSpaceID}).pluck().get()
|
||||
} else { // otherwise use the guild's space like usual
|
||||
parentSpaceID = await createSpace.ensureSpace(guild)
|
||||
guildSpaceID = parentSpaceID
|
||||
privacyLevel = select("guild_space", "privacy_level", {space_id: parentSpaceID}).pluck().get()
|
||||
}
|
||||
assert(typeof parentSpaceID === "string")
|
||||
assert(typeof guildSpaceID === "string")
|
||||
assert(typeof privacyLevel === "number")
|
||||
|
||||
const row = select("channel_room", ["nick", "custom_avatar"], {channel_id: channel.id}).get()
|
||||
|
@ -112,20 +132,23 @@ async function channelToKState(channel, guild) {
|
|||
join_rule: "restricted",
|
||||
allow: [{
|
||||
type: "m.room_membership",
|
||||
room_id: spaceID
|
||||
room_id: guildSpaceID
|
||||
}]
|
||||
}
|
||||
if (PRIVACY_ENUMS.ROOM_JOIN_RULES[privacyLevel] !== "restricted") {
|
||||
join_rules = {join_rule: PRIVACY_ENUMS.ROOM_JOIN_RULES[privacyLevel]}
|
||||
}
|
||||
|
||||
const everyonePermissions = utils.getPermissions([], guild.roles, undefined, channel.permission_overwrites)
|
||||
const everyoneCanMentionEveryone = utils.hasAllPermissions(everyonePermissions, ["MentionEveryone"])
|
||||
|
||||
const channelKState = {
|
||||
"m.room.name/": {name: convertedName},
|
||||
"m.room.topic/": {topic: convertedTopic},
|
||||
"m.room.avatar/": avatarEventContent,
|
||||
"m.room.guest_access/": {guest_access: PRIVACY_ENUMS.GUEST_ACCESS[privacyLevel]},
|
||||
"m.room.history_visibility/": {history_visibility},
|
||||
[`m.space.parent/${spaceID}`]: {
|
||||
[`m.space.parent/${parentSpaceID}`]: {
|
||||
via: [reg.ooye.server_name],
|
||||
canonical: true
|
||||
},
|
||||
|
@ -135,6 +158,9 @@ async function channelToKState(channel, guild) {
|
|||
events: {
|
||||
"m.room.avatar": 0
|
||||
},
|
||||
notifications: {
|
||||
room: everyoneCanMentionEveryone ? 0 : 20
|
||||
},
|
||||
users: reg.ooye.invite.reduce((a, c) => (a[c] = 100, a), {})
|
||||
},
|
||||
"chat.schildi.hide_ui/read_receipts": {
|
||||
|
@ -159,7 +185,7 @@ async function channelToKState(channel, guild) {
|
|||
}
|
||||
}
|
||||
|
||||
return {spaceID, privacyLevel, channelKState}
|
||||
return {spaceID: parentSpaceID, privacyLevel, channelKState}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,6 +201,9 @@ async function createRoom(channel, guild, spaceID, kstate, privacyLevel) {
|
|||
let threadParent = null
|
||||
if (channel.type === DiscordTypes.ChannelType.PublicThread) threadParent = channel.parent_id
|
||||
|
||||
let spaceCreationContent = {}
|
||||
if (channel.type === DiscordTypes.ChannelType.GuildForum) spaceCreationContent = {creation_content: {type: "m.space"}}
|
||||
|
||||
// Name and topic can be done earlier in room creation rather than in initial_state
|
||||
// https://spec.matrix.org/latest/client-server-api/#creation
|
||||
const name = kstate["m.room.name/"].name
|
||||
|
@ -191,7 +220,8 @@ async function createRoom(channel, guild, spaceID, kstate, privacyLevel) {
|
|||
preset: PRIVACY_ENUMS.PRESET[privacyLevel], // This is closest to what we want, but properties from kstate override it anyway
|
||||
visibility: PRIVACY_ENUMS.VISIBILITY[privacyLevel],
|
||||
invite: [],
|
||||
initial_state: ks.kstateToState(kstate)
|
||||
initial_state: ks.kstateToState(kstate),
|
||||
...spaceCreationContent
|
||||
})
|
||||
|
||||
db.prepare("INSERT INTO channel_room (channel_id, room_id, name, nick, thread_parent) VALUES (?, ?, ?, NULL, ?)").run(channel.id, roomID, channel.name, threadParent)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// @ts-check
|
||||
|
||||
const mixin = require("mixin-deep")
|
||||
const {channelToKState, _convertNameAndTopic} = require("./create-room")
|
||||
const {kstateStripConditionals} = require("../../matrix/kstate")
|
||||
const {test} = require("supertape")
|
||||
|
@ -39,6 +40,16 @@ test("channel2room: invite-only privacy room", async t => {
|
|||
)
|
||||
})
|
||||
|
||||
test("channel2room: room where limited people can mention everyone", async t => {
|
||||
const limitedGuild = mixin({}, testData.guild.general)
|
||||
limitedGuild.roles[0].permissions = (BigInt(limitedGuild.roles[0].permissions) - 131072n).toString()
|
||||
const limitedRoom = mixin({}, testData.room.general, {"m.room.power_levels/": {notifications: {room: 20}}})
|
||||
t.deepEqual(
|
||||
kstateStripConditionals(await channelToKState(testData.channel.general, limitedGuild).then(x => x.channelKState)),
|
||||
limitedRoom
|
||||
)
|
||||
})
|
||||
|
||||
test("convertNameAndTopic: custom name and topic", t => {
|
||||
t.deepEqual(
|
||||
_convertNameAndTopic({id: "123", name: "the-twilight-zone", topic: "Spooky stuff here. :ghost:", type: 0}, {id: "456"}, "hauntings"),
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// @ts-check
|
||||
|
||||
const assert = require("assert").strict
|
||||
const {isDeepStrictEqual} = require("util")
|
||||
const DiscordTypes = require("discord-api-types/v10")
|
||||
const deepEqual = require("deep-equal")
|
||||
const Ty = require("../../types")
|
||||
const reg = require("../../matrix/read-registration")
|
||||
|
||||
const passthrough = require("../../passthrough")
|
||||
|
@ -181,9 +182,16 @@ async function syncSpaceFully(guildID) {
|
|||
const spaceDiff = ks.diffKState(spaceKState, guildKState)
|
||||
await createRoom.applyKStateDiffToRoom(spaceID, spaceDiff)
|
||||
|
||||
const childRooms = ks.kstateToState(spaceKState).filter(({type, content}) => {
|
||||
return type === "m.space.child" && "via" in content
|
||||
}).map(({state_key}) => state_key)
|
||||
/** @type {string[]} room IDs */
|
||||
let childRooms = []
|
||||
/** @type {string | undefined} */
|
||||
let nextBatch = undefined
|
||||
do {
|
||||
/** @type {Ty.HierarchyPagination<Ty.R.Hierarchy>} */
|
||||
const res = await api.getHierarchy(spaceID, {from: nextBatch})
|
||||
childRooms.push(...res.rooms.map(room => room.room_id))
|
||||
nextBatch = res.next_batch
|
||||
} while (nextBatch)
|
||||
|
||||
for (const roomID of childRooms) {
|
||||
const channelID = select("channel_room", "channel_id", {room_id: roomID}).pluck().get()
|
||||
|
@ -226,7 +234,7 @@ async function syncSpaceExpressions(data, checkBeforeSync) {
|
|||
// State event not found. This space doesn't have any existing emojis. We create a dummy empty event for comparison's sake.
|
||||
existing = fn([])
|
||||
}
|
||||
if (deepEqual(existing, content, {strict: true})) return
|
||||
if (isDeepStrictEqual(existing, content)) return
|
||||
}
|
||||
api.sendState(spaceID, "im.ponies.room_emotes", eventKey, content)
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ async function syncUser(author, pkMessage, roomID) {
|
|||
db.prepare("INSERT OR IGNORE INTO sim_proxy (user_id, proxy_owner_id, displayname) VALUES (?, ?, ?)").run(pkMessage.member.uuid, pkMessage.sender, author.username)
|
||||
// Sync the member state
|
||||
const content = await memberToStateContent(pkMessage, author)
|
||||
const currentHash = registerUser._hashProfileContent(content)
|
||||
const currentHash = registerUser._hashProfileContent(content, 0)
|
||||
const existingHash = select("sim_member", "hashed_profile_content", {room_id: roomID, mxid}).safeIntegers().pluck().get()
|
||||
// only do the actual sync if the hash has changed since we last looked
|
||||
if (existingHash !== currentHash) {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// @ts-check
|
||||
|
||||
const assert = require("assert")
|
||||
const assert = require("assert").strict
|
||||
const reg = require("../../matrix/read-registration")
|
||||
const DiscordTypes = require("discord-api-types/v10")
|
||||
const mixin = require("mixin-deep")
|
||||
|
||||
const passthrough = require("../../passthrough")
|
||||
const {discord, sync, db, select} = passthrough
|
||||
|
@ -9,6 +11,8 @@ const {discord, sync, db, select} = passthrough
|
|||
const api = sync.require("../../matrix/api")
|
||||
/** @type {import("../../matrix/file")} */
|
||||
const file = sync.require("../../matrix/file")
|
||||
/** @type {import("../../discord/utils")} */
|
||||
const utils = sync.require("../../discord/utils")
|
||||
/** @type {import("../converters/user-to-mxid")} */
|
||||
const userToMxid = sync.require("../converters/user-to-mxid")
|
||||
/** @type {import("xxhash-wasm").XXHashAPI} */ // @ts-ignore
|
||||
|
@ -18,7 +22,7 @@ require("xxhash-wasm")().then(h => hasher = h)
|
|||
|
||||
/**
|
||||
* A sim is an account that is being simulated by the bridge to copy events from the other side.
|
||||
* @param {import("discord-api-types/v10").APIUser} user
|
||||
* @param {DiscordTypes.APIUser} user
|
||||
* @returns mxid
|
||||
*/
|
||||
async function createSim(user) {
|
||||
|
@ -46,7 +50,7 @@ async function createSim(user) {
|
|||
/**
|
||||
* Ensure a sim is registered for the user.
|
||||
* If there is already a sim, use that one. If there isn't one yet, register a new sim.
|
||||
* @param {import("discord-api-types/v10").APIUser} user
|
||||
* @param {DiscordTypes.APIUser} user
|
||||
* @returns {Promise<string>} mxid
|
||||
*/
|
||||
async function ensureSim(user) {
|
||||
|
@ -62,7 +66,7 @@ async function ensureSim(user) {
|
|||
|
||||
/**
|
||||
* Ensure a sim is registered for the user and is joined to the room.
|
||||
* @param {import("discord-api-types/v10").APIUser} user
|
||||
* @param {DiscordTypes.APIUser} user
|
||||
* @param {string} roomID
|
||||
* @returns {Promise<string>} mxid
|
||||
*/
|
||||
|
@ -92,8 +96,8 @@ async function ensureSimJoined(user, roomID) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {import("discord-api-types/v10").APIUser} user
|
||||
* @param {Omit<import("discord-api-types/v10").APIGuildMember, "user">} member
|
||||
* @param {DiscordTypes.APIUser} user
|
||||
* @param {Omit<DiscordTypes.APIGuildMember, "user">} member
|
||||
*/
|
||||
async function memberToStateContent(user, member, guildID) {
|
||||
let displayname = user.username
|
||||
|
@ -123,8 +127,46 @@ async function memberToStateContent(user, member, guildID) {
|
|||
return content
|
||||
}
|
||||
|
||||
function _hashProfileContent(content) {
|
||||
const unsignedHash = hasher.h64(`${content.displayname}\u0000${content.avatar_url}`)
|
||||
/**
|
||||
* https://gitdab.com/cadence/out-of-your-element/issues/9
|
||||
* @param {DiscordTypes.APIUser} user
|
||||
* @param {Omit<DiscordTypes.APIGuildMember, "user">} member
|
||||
* @param {DiscordTypes.APIGuild} guild
|
||||
* @param {DiscordTypes.APIGuildChannel} channel
|
||||
* @returns {number} 0 to 100
|
||||
*/
|
||||
function memberToPowerLevel(user, member, guild, channel) {
|
||||
const permissions = utils.getPermissions(member.roles, guild.roles, user.id, channel.permission_overwrites)
|
||||
/*
|
||||
* PL 100 = Administrator = People who can brick the room. RATIONALE:
|
||||
* - Administrator.
|
||||
* - Manage Webhooks: People who remove the webhook can break the room.
|
||||
* - Manage Guild: People who can manage guild can add bots.
|
||||
* - Manage Channels: People who can manage the channel can delete it.
|
||||
* (Setting sim users to PL 100 is safe because even though we can't demote the sims we can use code to make the sims demote themselves.)
|
||||
*/
|
||||
if (guild.owner_id === user.id || utils.hasSomePermissions(permissions, ["Administrator", "ManageWebhooks", "ManageGuild", "ManageChannels"])) return 100
|
||||
/*
|
||||
* PL 50 = Moderator = People who can manage people and messages in many ways. RATIONALE:
|
||||
* - Manage Messages: Can moderate by pinning or deleting the conversation.
|
||||
* - Manage Nicknames: Can moderate by removing inappropriate nicknames.
|
||||
* - Manage Threads: Can moderate by deleting conversations.
|
||||
* - Kick Members & Ban Members: Can moderate by removing disruptive people.
|
||||
* - Mute Members & Deafen Members: Can moderate by silencing disruptive people in ways they can't undo.
|
||||
* - Moderate Members.
|
||||
*/
|
||||
if (utils.hasSomePermissions(permissions, ["ManageMessages", "ManageNicknames", "ManageThreads", "KickMembers", "BanMembers", "MuteMembers", "DeafenMembers", "ModerateMembers"])) return 50
|
||||
/* PL 20 = Mention Everyone for technical reasons. */
|
||||
if (utils.hasSomePermissions(permissions, ["MentionEveryone"])) return 20
|
||||
return 0
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} content
|
||||
* @param {number} powerLevel
|
||||
*/
|
||||
function _hashProfileContent(content, powerLevel) {
|
||||
const unsignedHash = hasher.h64(`${content.displayname}\u0000${content.avatar_url}\u0000${powerLevel}`)
|
||||
const signedHash = unsignedHash - 0x8000000000000000n // shifting down to signed 64-bit range
|
||||
return signedHash
|
||||
}
|
||||
|
@ -133,48 +175,65 @@ function _hashProfileContent(content) {
|
|||
* Sync profile data for a sim user. This function follows the following process:
|
||||
* 1. Join the sim to the room if needed
|
||||
* 2. Make an object of what the new room member state content would be, including uploading the profile picture if it hasn't been done before
|
||||
* 3. Compare against the previously known state content, which is helpfully stored in the database
|
||||
* 4. If the state content has changed, send it to Matrix and update it in the database for next time
|
||||
* @param {import("discord-api-types/v10").APIUser} user
|
||||
* @param {Omit<import("discord-api-types/v10").APIGuildMember, "user">} member
|
||||
* 3. Calculate the power level the user should get based on their Discord permissions
|
||||
* 4. Compare against the previously known state content, which is helpfully stored in the database
|
||||
* 5. If the state content or power level have changed, send them to Matrix and update them in the database for next time
|
||||
* @param {DiscordTypes.APIUser} user
|
||||
* @param {Omit<DiscordTypes.APIGuildMember, "user">} member
|
||||
* @param {DiscordTypes.APIGuildChannel} channel
|
||||
* @param {DiscordTypes.APIGuild} guild
|
||||
* @param {string} roomID
|
||||
* @returns {Promise<string>} mxid of the updated sim
|
||||
*/
|
||||
async function syncUser(user, member, guildID, roomID) {
|
||||
async function syncUser(user, member, channel, guild, roomID) {
|
||||
const mxid = await ensureSimJoined(user, roomID)
|
||||
const content = await memberToStateContent(user, member, guildID)
|
||||
const currentHash = _hashProfileContent(content)
|
||||
const content = await memberToStateContent(user, member, guild.id)
|
||||
const powerLevel = memberToPowerLevel(user, member, guild, channel)
|
||||
const currentHash = _hashProfileContent(content, powerLevel)
|
||||
const existingHash = select("sim_member", "hashed_profile_content", {room_id: roomID, mxid}).safeIntegers().pluck().get()
|
||||
// only do the actual sync if the hash has changed since we last looked
|
||||
if (existingHash !== currentHash) {
|
||||
// Update room member state
|
||||
await api.sendState(roomID, "m.room.member", mxid, content, mxid)
|
||||
// Update power levels
|
||||
const powerLevelsStateContent = await api.getStateEvent(roomID, "m.room.power_levels", "")
|
||||
mixin(powerLevelsStateContent, {users: {[mxid]: powerLevel}})
|
||||
if (powerLevel === 0) delete powerLevelsStateContent.users[mxid] // keep the event compact
|
||||
await api.sendState(roomID, "m.room.power_levels", "", powerLevelsStateContent)
|
||||
// Update cached hash
|
||||
db.prepare("UPDATE sim_member SET hashed_profile_content = ? WHERE room_id = ? AND mxid = ?").run(currentHash, roomID, mxid)
|
||||
}
|
||||
return mxid
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} roomID
|
||||
*/
|
||||
async function syncAllUsersInRoom(roomID) {
|
||||
const mxids = select("sim_member", "mxid", {room_id: roomID}).pluck().all()
|
||||
|
||||
const channelID = select("channel_room", "channel_id", {room_id: roomID}).pluck().get()
|
||||
assert.ok(typeof channelID === "string")
|
||||
|
||||
/** @ts-ignore @type {import("discord-api-types/v10").APIGuildChannel} */
|
||||
/** @ts-ignore @type {DiscordTypes.APIGuildChannel} */
|
||||
const channel = discord.channels.get(channelID)
|
||||
const guildID = channel.guild_id
|
||||
assert.ok(typeof guildID === "string")
|
||||
/** @ts-ignore @type {DiscordTypes.APIGuild} */
|
||||
const guild = discord.guilds.get(guildID)
|
||||
|
||||
for (const mxid of mxids) {
|
||||
const userID = select("sim", "user_id", {mxid}).pluck().get()
|
||||
assert.ok(typeof userID === "string")
|
||||
|
||||
/** @ts-ignore @type {Required<import("discord-api-types/v10").APIGuildMember>} */
|
||||
/** @ts-ignore @type {Required<DiscordTypes.APIGuildMember>} */
|
||||
const member = await discord.snow.guild.getGuildMember(guildID, userID)
|
||||
/** @ts-ignore @type {Required<import("discord-api-types/v10").APIUser>} user */
|
||||
/** @ts-ignore @type {Required<DiscordTypes.APIUser>} user */
|
||||
const user = member.user
|
||||
assert.ok(user)
|
||||
|
||||
console.log(`[user sync] to matrix: ${user.username} in ${channel.name}`)
|
||||
await syncUser(user, member, guildID, roomID)
|
||||
await syncUser(user, member, channel, guild, roomID)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
const assert = require("assert")
|
||||
const assert = require("assert").strict
|
||||
const DiscordTypes = require("discord-api-types/v10")
|
||||
|
||||
const passthrough = require("../../passthrough")
|
||||
const { discord, sync, db } = passthrough
|
||||
|
@ -18,17 +19,20 @@ const createRoom = sync.require("../actions/create-room")
|
|||
const dUtils = sync.require("../../discord/utils")
|
||||
|
||||
/**
|
||||
* @param {import("discord-api-types/v10").GatewayMessageCreateDispatchData} message
|
||||
* @param {import("discord-api-types/v10").APIGuild} guild
|
||||
* @param {DiscordTypes.GatewayMessageCreateDispatchData} message
|
||||
* @param {DiscordTypes.APIGuildChannel} channel
|
||||
* @param {DiscordTypes.APIGuild} guild
|
||||
* @param {{speedbump_id: string, speedbump_webhook_id: string} | null} row data about the webhook which is proxying messages in this channel
|
||||
*/
|
||||
async function sendMessage(message, guild, row) {
|
||||
async function sendMessage(message, channel, guild, row) {
|
||||
const roomID = await createRoom.ensureRoom(message.channel_id)
|
||||
|
||||
let senderMxid = null
|
||||
if (!dUtils.isWebhookMessage(message)) {
|
||||
if (message.member) { // available on a gateway message create event
|
||||
senderMxid = await registerUser.syncUser(message.author, message.member, message.guild_id, roomID)
|
||||
if (message.author.id === discord.application.id) {
|
||||
// no need to sync the bot's own user
|
||||
} else if (message.member) { // available on a gateway message create event
|
||||
senderMxid = await registerUser.syncUser(message.author, message.member, channel, guild, roomID)
|
||||
} else { // well, good enough...
|
||||
senderMxid = await registerUser.ensureSimJoined(message.author, roomID)
|
||||
}
|
||||
|
|
|
@ -3,13 +3,24 @@
|
|||
const assert = require("assert").strict
|
||||
|
||||
const passthrough = require("../../passthrough")
|
||||
const {discord, sync, db, select, from} = passthrough
|
||||
const {sync, select, from} = passthrough
|
||||
/** @type {import("./message-to-event")} */
|
||||
const messageToEvent = sync.require("../converters/message-to-event")
|
||||
/** @type {import("../actions/register-user")} */
|
||||
const registerUser = sync.require("../actions/register-user")
|
||||
/** @type {import("../actions/create-room")} */
|
||||
const createRoom = sync.require("../actions/create-room")
|
||||
/** @type {import("../../m2d/converters/utils")} */
|
||||
const utils = sync.require("../../m2d/converters/utils")
|
||||
|
||||
function eventCanBeEdited(ev) {
|
||||
// Discord does not allow files, images, attachments, or videos to be edited.
|
||||
if (ev.old.event_type === "m.room.message" && ev.old.event_subtype !== "m.text" && ev.old.event_subtype !== "m.emote" && ev.old.event_subtype !== "m.notice") {
|
||||
return false
|
||||
}
|
||||
// Discord does not allow stickers to be edited.
|
||||
if (ev.old.event_type === "m.sticker") {
|
||||
return false
|
||||
}
|
||||
// Anything else is fair game.
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("discord-api-types/v10").GatewayMessageCreateDispatchData} message
|
||||
|
@ -19,12 +30,27 @@ const createRoom = sync.require("../actions/create-room")
|
|||
* @param {import("../../matrix/api")} api simple-as-nails dependency injection for the matrix API
|
||||
*/
|
||||
async function editToChanges(message, guild, api) {
|
||||
// If it is a user edit, allow deleting old messages (e.g. they might have removed text from an image). If it is the system adding a generated embed to a message, don't delete old messages since the system only sends partial data.
|
||||
|
||||
const isGeneratedEmbed = !("content" in message)
|
||||
|
||||
// Figure out what events we will be replacing
|
||||
|
||||
const roomID = select("channel_room", "room_id", {channel_id: message.channel_id}).pluck().get()
|
||||
assert(roomID)
|
||||
/** @type {string?} Null if we don't have a sender in the room, which will happen if it's a webhook's message. The bridge bot will do the edit instead. */
|
||||
const senderMxid = from("sim").join("sim_member", "mxid").where({user_id: message.author.id, room_id: roomID}).pluck("mxid").get() || null
|
||||
let senderMxid = null
|
||||
if (message.author) {
|
||||
senderMxid = from("sim").join("sim_member", "mxid").where({user_id: message.author.id, room_id: roomID}).pluck("mxid").get() || null
|
||||
} else {
|
||||
// Should be a system generated embed. We want the embed to be sent by the same user who sent the message, so that the messages get grouped in most clients.
|
||||
const eventID = select("event_message", "event_id", {message_id: message.id}).pluck().get()
|
||||
assert(eventID) // this should have been checked earlier in a calling function
|
||||
const event = await api.getEvent(roomID, eventID)
|
||||
if (utils.eventSenderIsFromDiscord(event.sender)) {
|
||||
senderMxid = event.sender
|
||||
}
|
||||
}
|
||||
|
||||
const oldEventRows = select("event_message", ["event_id", "event_type", "event_subtype", "part", "reaction_part"], {message_id: message.id}).all()
|
||||
|
||||
|
@ -48,7 +74,8 @@ async function editToChanges(message, guild, api) {
|
|||
let eventsToRedact = []
|
||||
/** 3. Events that are present in the new version only, and should be sent as new, with references back to the context */
|
||||
let eventsToSend = []
|
||||
// 4. Events that are matched and have definitely not changed, so they don't need to be edited or replaced at all. This is represented as nothing.
|
||||
/** 4. Events that are matched and have definitely not changed, so they don't need to be edited or replaced at all. */
|
||||
let unchangedEvents = []
|
||||
|
||||
function shift() {
|
||||
newFallbackContent.shift()
|
||||
|
@ -81,22 +108,35 @@ async function editToChanges(message, guild, api) {
|
|||
shift()
|
||||
}
|
||||
// Anything remaining in oldEventRows is present in the old version only and should be redacted.
|
||||
eventsToRedact = oldEventRows
|
||||
eventsToRedact = oldEventRows.map(e => ({old: e}))
|
||||
|
||||
// If this is a generated embed update, only allow the embeds to be updated, since the system only sends data about events. Ignore changes to other things.
|
||||
if (isGeneratedEmbed) {
|
||||
unchangedEvents.push(...eventsToRedact.filter(e => e.old.event_subtype !== "m.notice")) // Move them from eventsToRedact to unchangedEvents.
|
||||
eventsToRedact = eventsToRedact.filter(e => e.old.event_subtype === "m.notice")
|
||||
}
|
||||
|
||||
// Now, everything in eventsToSend and eventsToRedact is a real change, but everything in eventsToReplace might not have actually changed!
|
||||
// (Example: a MESSAGE_UPDATE for a text+image message - Discord does not allow the image to be changed, but the text might have been.)
|
||||
// So we'll remove entries from eventsToReplace that *definitely* cannot have changed. (This is category 4 mentioned above.) Everything remaining *may* have changed.
|
||||
unchangedEvents.push(...eventsToReplace.filter(ev => !eventCanBeEdited(ev))) // Move them from eventsToRedact to unchangedEvents.
|
||||
eventsToReplace = eventsToReplace.filter(eventCanBeEdited)
|
||||
|
||||
// We want to maintain exactly one part = 0 and one reaction_part = 0 database row at all times.
|
||||
/** @type {({column: string, eventID: string} | {column: string, nextEvent: true})[]} */
|
||||
const promotions = []
|
||||
for (const column of ["part", "reaction_part"]) {
|
||||
const candidatesForParts = unchangedEvents.concat(eventsToReplace)
|
||||
// If no events with part = 0 exist (or will exist), we need to do some management.
|
||||
if (!eventsToReplace.some(e => e.old[column] === 0)) {
|
||||
if (eventsToReplace.length) {
|
||||
if (!candidatesForParts.some(e => e.old[column] === 0)) {
|
||||
if (candidatesForParts.length) {
|
||||
// We can choose an existing event to promote. Bigger order is better.
|
||||
const order = e => 2*+(e.event_type === "m.room.message") + 1*+(e.event_subtype === "m.text")
|
||||
eventsToReplace.sort((a, b) => order(b) - order(a))
|
||||
const order = e => 2*+(e.event_type === "m.room.message") + 1*+(e.old.event_subtype === "m.text")
|
||||
candidatesForParts.sort((a, b) => order(b) - order(a))
|
||||
if (column === "part") {
|
||||
promotions.push({column, eventID: eventsToReplace[0].old.event_id}) // part should be the first one
|
||||
promotions.push({column, eventID: candidatesForParts[0].old.event_id}) // part should be the first one
|
||||
} else {
|
||||
promotions.push({column, eventID: eventsToReplace[eventsToReplace.length - 1].old.event_id}) // reaction_part should be the last one
|
||||
promotions.push({column, eventID: candidatesForParts[candidatesForParts.length - 1].old.event_id}) // reaction_part should be the last one
|
||||
}
|
||||
} else {
|
||||
// No existing events to promote, but new events are being sent. Whatever gets sent will be the next part = 0.
|
||||
|
@ -105,24 +145,8 @@ async function editToChanges(message, guild, api) {
|
|||
}
|
||||
}
|
||||
|
||||
// Now, everything in eventsToSend and eventsToRedact is a real change, but everything in eventsToReplace might not have actually changed!
|
||||
// (Example: a MESSAGE_UPDATE for a text+image message - Discord does not allow the image to be changed, but the text might have been.)
|
||||
// So we'll remove entries from eventsToReplace that *definitely* cannot have changed. (This is category 4 mentioned above.) Everything remaining *may* have changed.
|
||||
eventsToReplace = eventsToReplace.filter(ev => {
|
||||
// Discord does not allow files, images, attachments, or videos to be edited.
|
||||
if (ev.old.event_type === "m.room.message" && ev.old.event_subtype !== "m.text" && ev.old.event_subtype !== "m.emote" && ev.old.event_subtype !== "m.notice") {
|
||||
return false
|
||||
}
|
||||
// Discord does not allow stickers to be edited.
|
||||
if (ev.old.event_type === "m.sticker") {
|
||||
return false
|
||||
}
|
||||
// Anything else is fair game.
|
||||
return true
|
||||
})
|
||||
|
||||
// Removing unnecessary properties before returning
|
||||
eventsToRedact = eventsToRedact.map(e => e.event_id)
|
||||
eventsToRedact = eventsToRedact.map(e => e.old.event_id)
|
||||
eventsToReplace = eventsToReplace.map(e => ({oldID: e.old.event_id, newContent: makeReplacementEventContent(e.old.event_id, e.newFallbackContent, e.newInnerContent)}))
|
||||
|
||||
return {roomID, eventsToReplace, eventsToRedact, eventsToSend, senderMxid, promotions}
|
||||
|
|
|
@ -235,3 +235,38 @@ test("edit2changes: promotes the text event when multiple rows have part = 1 (sh
|
|||
}
|
||||
])
|
||||
})
|
||||
|
||||
test("edit2changes: generated embed", async t => {
|
||||
let called = 0
|
||||
const {senderMxid, eventsToRedact, eventsToReplace, eventsToSend, promotions} = await editToChanges(data.message_update.embed_generated_social_media_image, data.guild.general, {
|
||||
async getEvent(roomID, eventID) {
|
||||
called++
|
||||
t.equal(roomID, "!kLRqKKUQXcibIMtOpl:cadence.moe")
|
||||
t.equal(eventID, "$mPSzglkCu-6cZHbYro0RW2u5mHvbH9aXDjO5FCzosc0")
|
||||
return {sender: "@_ooye_cadence:cadence.moe"}
|
||||
}
|
||||
})
|
||||
t.deepEqual(eventsToRedact, [])
|
||||
t.deepEqual(eventsToReplace, [])
|
||||
t.deepEqual(eventsToSend, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.notice",
|
||||
body: "| via hthrflwrs on cohost"
|
||||
+ "\n| \n| ## This post nerdsniped me, so here's some RULES FOR REAL-LIFE BALATRO https://cohost.org/jkap/post/4794219-empty"
|
||||
+ "\n| \n| 1v1 physical card game. Each player gets one standard deck of cards with a different backing to differentiate. Every turn proceeds as follows:"
|
||||
+ "\n| \n| * Both players draw eight cards"
|
||||
+ "\n| * Both players may choose up to eight cards to discard, then draw that number of cards to put back in their hand"
|
||||
+ "\n| * Both players present their best five-or-less-card pok...",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<blockquote><p><sub>hthrflwrs on cohost</sub>`
|
||||
+ `</p><p><strong><a href="https://cohost.org/jkap/post/4794219-empty">This post nerdsniped me, so here's some RULES FOR REAL-LIFE BALATRO</a></strong>`
|
||||
+ `</p><p>1v1 physical card game. Each player gets one standard deck of cards with a different backing to differentiate. Every turn proceeds as follows:`
|
||||
+ `<br><br><ul><li>Both players draw eight cards`
|
||||
+ `</li><li>Both players may choose up to eight cards to discard, then draw that number of cards to put back in their hand`
|
||||
+ `</li><li>Both players present their best five-or-less-card pok...</li></ul></p></blockquote>`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
t.deepEqual(promotions, []) // TODO: it would be ideal to promote this to reaction_part = 0. this is OK to do because the main message won't have had any reactions yet.
|
||||
t.equal(senderMxid, "@_ooye_cadence:cadence.moe")
|
||||
t.equal(called, 1)
|
||||
})
|
||||
|
|
|
@ -27,7 +27,6 @@ test("message2event embeds: reply with just an embed", async t => {
|
|||
msgtype: "m.notice",
|
||||
"m.mentions": {},
|
||||
body: "| ## ⏺️ dynastic (@dynastic) https://twitter.com/i/user/719631291747078145"
|
||||
+ "\n| \n| ## https://twitter.com/i/status/1707484191963648161"
|
||||
+ "\n| \n| does anyone know where to find that one video of the really mysterious yam-like object being held up to a bunch of random objects, like clocks, and they have unexplained impossible reactions to it?"
|
||||
+ "\n| \n| ### Retweets"
|
||||
+ "\n| 119"
|
||||
|
@ -35,8 +34,7 @@ test("message2event embeds: reply with just an embed", async t => {
|
|||
+ "\n| 5581"
|
||||
+ "\n| — Twitter",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: '<blockquote><p><strong><a href="https://twitter.com/i/user/719631291747078145">⏺️ dynastic (@dynastic)</a></strong></p>'
|
||||
+ '<p><strong><a href="https://twitter.com/i/status/1707484191963648161">https://twitter.com/i/status/1707484191963648161</a></strong>'
|
||||
formatted_body: '<blockquote><p><strong><a href="https://twitter.com/i/user/719631291747078145">⏺️ dynastic (@dynastic)</a></strong>'
|
||||
+ '</p><p>does anyone know where to find that one video of the really mysterious yam-like object being held up to a bunch of random objects, like clocks, and they have unexplained impossible reactions to it?'
|
||||
+ '</p><p><strong>Retweets</strong><br>119</p><p><strong>Likes</strong><br>5581</p>— Twitter</blockquote>'
|
||||
}])
|
||||
|
@ -141,3 +139,180 @@ test("message2event embeds: crazy html is all escaped", async t => {
|
|||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event embeds: title without url", async t => {
|
||||
const events = await messageToEvent(data.message_with_embeds.title_without_url, data.guild.general)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.notice",
|
||||
body: "| ## Hi, I'm Amanda!\n| \n| I condone pirating music!",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<blockquote><p><strong>Hi, I'm Amanda!</strong></p><p>I condone pirating music!</p></blockquote>`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event embeds: url without title", async t => {
|
||||
const events = await messageToEvent(data.message_with_embeds.url_without_title, data.guild.general)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.notice",
|
||||
body: "| I condone pirating music!",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<blockquote><p>I condone pirating music!</p></blockquote>`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event embeds: author without url", async t => {
|
||||
const events = await messageToEvent(data.message_with_embeds.author_without_url, data.guild.general)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.notice",
|
||||
body: "| ## Amanda\n| \n| I condone pirating music!",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<blockquote><p><strong>Amanda</strong></p><p>I condone pirating music!</p></blockquote>`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event embeds: author url without name", async t => {
|
||||
const events = await messageToEvent(data.message_with_embeds.author_url_without_name, data.guild.general)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.notice",
|
||||
body: "| I condone pirating music!",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<blockquote><p>I condone pirating music!</p></blockquote>`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event embeds: vx image", async t => {
|
||||
const events = await messageToEvent(data.message_with_embeds.vx_image, data.guild.general)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "https://vxtwitter.com/TomorrowCorp/status/1760330671074287875 we got a release date!!!",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: '<a href="https://vxtwitter.com/TomorrowCorp/status/1760330671074287875">https://vxtwitter.com/TomorrowCorp/status/1760330671074287875</a> we got a release date!!!',
|
||||
"m.mentions": {}
|
||||
}, {
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.notice",
|
||||
body: "| via vxTwitter / fixvx https://github.com/dylanpdx/BetterTwitFix"
|
||||
+ "\n| "
|
||||
+ "\n| ## Twitter https://twitter.com/tomorrowcorp/status/1760330671074287875"
|
||||
+ "\n| "
|
||||
+ "\n| ## Tomorrow Corporation (@TomorrowCorp) https://vxtwitter.com/TomorrowCorp/status/1760330671074287875"
|
||||
+ "\n| "
|
||||
+ "\n| Mark your calendar with a wet black stain! World of Goo 2 releases on May 23, 2024 on Nintendo Switch, Epic Games Store (Win/Mac), and http://WorldOfGoo2.com (Win/Mac/Linux)."
|
||||
+ "\n| "
|
||||
+ "\n| https://tomorrowcorporation.com/posts/world-of-goo-2-now-with-100-more-release-dates-and-platforms"
|
||||
+ "\n| "
|
||||
+ "\n| 💖 123 🔁 36"
|
||||
+ "\n| "
|
||||
+ "\n| 📸 https://pbs.twimg.com/media/GG3zUMGbIAAxs3h.jpg",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<blockquote><p><sub><a href="https://github.com/dylanpdx/BetterTwitFix">vxTwitter / fixvx</a></sub>`
|
||||
+ `</p><p><strong><a href="https://twitter.com/tomorrowcorp/status/1760330671074287875">Twitter</a></strong>`
|
||||
+ `</p><p><strong><a href="https://vxtwitter.com/TomorrowCorp/status/1760330671074287875">Tomorrow Corporation (@TomorrowCorp)</a></strong>`
|
||||
+ `</p><p>Mark your calendar with a wet black stain! World of Goo 2 releases on May 23, 2024 on Nintendo Switch, Epic Games Store (Win/Mac), and <a href="http://WorldOfGoo2.com">http://WorldOfGoo2.com</a> (Win/Mac/Linux).`
|
||||
+ `<br><br><a href="https://tomorrowcorporation.com/posts/world-of-goo-2-now-with-100-more-release-dates-and-platforms">https://tomorrowcorporation.com/posts/world-of-goo-2-now-with-100-more-release-dates-and-platforms</a>`
|
||||
+ `<br><br>💖 123 🔁 36`
|
||||
+ `</p><p>📸 https://pbs.twimg.com/media/GG3zUMGbIAAxs3h.jpg</p></blockquote>`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event embeds: vx video", async t => {
|
||||
const events = await messageToEvent(data.message_with_embeds.vx_video, data.guild.general)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "https://vxtwitter.com/McDonalds/status/1759971752254341417",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: '<a href="https://vxtwitter.com/McDonalds/status/1759971752254341417">https://vxtwitter.com/McDonalds/status/1759971752254341417</a>',
|
||||
"m.mentions": {}
|
||||
}, {
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.notice",
|
||||
body: "| via vxTwitter / fixvx https://github.com/dylanpdx/BetterTwitFix"
|
||||
+ "\n| \n| ## McDonald’s🤝@studiopierrot"
|
||||
+ "\n| \n| 💖 89 🔁 21 https://twitter.com/McDonalds/status/1759971752254341417"
|
||||
+ "\n| \n| ## McDonald's (@McDonalds) https://vxtwitter.com/McDonalds/status/1759971752254341417"
|
||||
+ "\n| \n| 🎞️ https://video.twimg.com/ext_tw_video/1759967449548541952/pu/vid/avc1/1280x720/XN1LFIJqAFBdtaoh.mp4?tag=12",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<blockquote><p><sub><a href="https://github.com/dylanpdx/BetterTwitFix">vxTwitter / fixvx</a></sub>`
|
||||
+ `</p><p><strong><a href="https://twitter.com/McDonalds/status/1759971752254341417">McDonald’s🤝@studiopierrot\n\n💖 89 🔁 21</a></strong>`
|
||||
+ `</p><p><strong><a href="https://vxtwitter.com/McDonalds/status/1759971752254341417">McDonald's (@McDonalds)</a></strong>`
|
||||
+ `</p><p>🎞️ https://video.twimg.com/ext_tw_video/1759967449548541952/pu/vid/avc1/1280x720/XN1LFIJqAFBdtaoh.mp4?tag=12</p></blockquote>`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event embeds: youtube video", async t => {
|
||||
const events = await messageToEvent(data.message_with_embeds.youtube_video, data.guild.general)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "https://youtu.be/kDMHHw8JqLE?si=NaqNjVTtXugHeG_E\n\n\nJutomi I'm gonna make these sounds in your walls tonight",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<a href="https://youtu.be/kDMHHw8JqLE?si=NaqNjVTtXugHeG_E">https://youtu.be/kDMHHw8JqLE?si=NaqNjVTtXugHeG_E</a><br><br><br>Jutomi I'm gonna make these sounds in your walls tonight`,
|
||||
"m.mentions": {}
|
||||
}, {
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.notice",
|
||||
body: "| via YouTube https://www.youtube.com"
|
||||
+ "\n| \n| ## Happy O Funny https://www.youtube.com/channel/UCEpQ9aEb1NafpvWp5Aoizrg"
|
||||
+ "\n| \n| ## Shoebill stork clattering sounds like machine guun~!! (Japan Matsue... https://www.youtube.com/watch?v=kDMHHw8JqLE"
|
||||
+ "\n| \n| twitter"
|
||||
+ "\n| https://twitter.com/matsuevogelpark"
|
||||
+ "\n| \n| The shoebill (Balaeniceps rex) also known as whalehead, whale-headed stork, or shoe-billed stork, is a very large stork-like bird. It derives its name from its enormous shoe-shaped bill"
|
||||
+ "\n| some people also called them the living dinosaur~~"
|
||||
+ "\n| \n| #shoebill #livingdinosaur #happyofunny #weirdcreature #weirdsoun..."
|
||||
+ "\n| \n| 🎞️ https://www.youtube.com/embed/kDMHHw8JqLE",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<blockquote><p><sub><a href="https://www.youtube.com">YouTube</a></sub></p>`
|
||||
+ `<p><strong><a href="https://www.youtube.com/channel/UCEpQ9aEb1NafpvWp5Aoizrg">Happy O Funny</a></strong>`
|
||||
+ `</p><p><strong><a href="https://www.youtube.com/watch?v=kDMHHw8JqLE">Shoebill stork clattering sounds like machine guun~!! (Japan Matsue...</a></strong>`
|
||||
+ `</p><p>twitter<br><a href="https://twitter.com/matsuevogelpark">https://twitter.com/matsuevogelpark</a><br><br>The shoebill (Balaeniceps rex) also known as whalehead, whale-headed stork, or shoe-billed stork, is a very large stork-like bird. It derives its name from its enormous shoe-shaped bill<br>some people also called them the living dinosaur~~<br><br>#shoebill #livingdinosaur #happyofunny #weirdcreature #weirdsoun...`
|
||||
+ `</p><p>🎞️ https://www.youtube.com/embed/kDMHHw8JqLE`
|
||||
+ `</p></blockquote>`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event embeds: if discord creates an embed preview for a discord channel link, don't copy that embed", async t => {
|
||||
const events = await messageToEvent(data.message_with_embeds.discord_server_included_punctuation_bad_discord, data.guild.general, {}, {
|
||||
api: {
|
||||
async getStateEvent(roomID, type, key) {
|
||||
t.equal(roomID, "!TqlyQmifxGUggEmdBN:cadence.moe")
|
||||
t.equal(type, "m.room.power_levels")
|
||||
t.equal(key, "")
|
||||
return {
|
||||
users: {
|
||||
"@_ooye_bot:cadence.moe": 100
|
||||
}
|
||||
}
|
||||
},
|
||||
async getJoinedMembers(roomID) {
|
||||
t.equal(roomID, "!TqlyQmifxGUggEmdBN:cadence.moe")
|
||||
return {
|
||||
joined: {
|
||||
"@_ooye_bot:cadence.moe": {display_name: null, avatar_url: null},
|
||||
"@user:matrix.org": {display_name: null, avatar_url: null}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "(test https://matrix.to/#/!TqlyQmifxGUggEmdBN:cadence.moe/$NB6nPgO2tfXyIwwDSF0Ga0BUrsgX1S-0Xl-jAvI8ucU?via=cadence.moe&via=matrix.org)",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `(test <a href="https://matrix.to/#/!TqlyQmifxGUggEmdBN:cadence.moe/$NB6nPgO2tfXyIwwDSF0Ga0BUrsgX1S-0Xl-jAvI8ucU?via=cadence.moe&via=matrix.org">https://matrix.to/#/!TqlyQmifxGUggEmdBN:cadence.moe/$NB6nPgO2tfXyIwwDSF0Ga0BUrsgX1S-0Xl-jAvI8ucU?via=cadence.moe&via=matrix.org</a>)`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
|
|
@ -249,6 +249,8 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
let repliedToEventRow = null
|
||||
let repliedToEventSenderMxid = null
|
||||
|
||||
if (message.mention_everyone) mentions.room = true
|
||||
|
||||
function addMention(mxid) {
|
||||
if (!mentions.user_ids) mentions.user_ids = []
|
||||
if (!mentions.user_ids.includes(mxid)) mentions.user_ids.push(mxid)
|
||||
|
@ -478,32 +480,35 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
message.content = "changed the channel name to **" + message.content + "**"
|
||||
}
|
||||
|
||||
// Mentions scenario 3: scan the message content for written @mentions of matrix users. Allows for up to one space between @ and mention.
|
||||
const matches = [...message.content.matchAll(/@ ?([a-z0-9._]+)\b/gi)]
|
||||
if (matches.length && matches.some(m => m[1].match(/[a-z]/i))) {
|
||||
const writtenMentionsText = matches.map(m => m[1].toLowerCase())
|
||||
const roomID = select("channel_room", "room_id", {channel_id: message.channel_id}).pluck().get()
|
||||
assert(roomID)
|
||||
const {joined} = await di.api.getJoinedMembers(roomID)
|
||||
for (const [mxid, member] of Object.entries(joined)) {
|
||||
if (!userRegex.some(rx => mxid.match(rx))) {
|
||||
const localpart = mxid.match(/@([^:]*)/)
|
||||
assert(localpart)
|
||||
const displayName = member.display_name || localpart[1]
|
||||
if (writtenMentionsText.includes(localpart[1].toLowerCase()) || writtenMentionsText.includes(displayName.toLowerCase())) addMention(mxid)
|
||||
|
||||
if (message.content) {
|
||||
// Mentions scenario 3: scan the message content for written @mentions of matrix users. Allows for up to one space between @ and mention.
|
||||
const matches = [...message.content.matchAll(/@ ?([a-z0-9._]+)\b/gi)]
|
||||
if (matches.length && matches.some(m => m[1].match(/[a-z]/i) && m[1] !== "everyone" && m[1] !== "here")) {
|
||||
const writtenMentionsText = matches.map(m => m[1].toLowerCase())
|
||||
const roomID = select("channel_room", "room_id", {channel_id: message.channel_id}).pluck().get()
|
||||
assert(roomID)
|
||||
const {joined} = await di.api.getJoinedMembers(roomID)
|
||||
for (const [mxid, member] of Object.entries(joined)) {
|
||||
if (!userRegex.some(rx => mxid.match(rx))) {
|
||||
const localpart = mxid.match(/@([^:]*)/)
|
||||
assert(localpart)
|
||||
const displayName = member.display_name || localpart[1]
|
||||
if (writtenMentionsText.includes(localpart[1].toLowerCase()) || writtenMentionsText.includes(displayName.toLowerCase())) addMention(mxid)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Text content appears first
|
||||
if (message.content) {
|
||||
// Text content appears first
|
||||
const {body, html} = await transformContent(message.content)
|
||||
await addTextEvent(body, html, msgtype, {scanMentions: true})
|
||||
}
|
||||
|
||||
// Then attachments
|
||||
const attachmentEvents = await Promise.all(message.attachments.map(attachmentToEvent.bind(null, mentions)))
|
||||
events.push(...attachmentEvents)
|
||||
if (message.attachments) {
|
||||
const attachmentEvents = await Promise.all(message.attachments.map(attachmentToEvent.bind(null, mentions)))
|
||||
events.push(...attachmentEvents)
|
||||
}
|
||||
|
||||
// Then embeds
|
||||
for (const embed of message.embeds || []) {
|
||||
|
@ -511,13 +516,26 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
continue // Matrix's own URL previews are fine for images.
|
||||
}
|
||||
|
||||
if (embed.url?.startsWith("https://discord.com/")) {
|
||||
continue // If discord creates an embed preview for a discord channel link, don't copy that embed
|
||||
}
|
||||
|
||||
// Start building up a replica ("rep") of the embed in Discord-markdown format, which we will convert into both plaintext and formatted body at once
|
||||
const rep = new mxUtils.MatrixStringBuilder()
|
||||
|
||||
// Provider
|
||||
if (embed.provider?.name) {
|
||||
if (embed.provider.url) {
|
||||
rep.addParagraph(`via ${embed.provider.name} ${embed.provider.url}`, tag`<sub><a href="${embed.provider.url}">${embed.provider.name}</a></sub>`)
|
||||
} else {
|
||||
rep.addParagraph(`via ${embed.provider.name}`, tag`<sub>${embed.provider.name}</sub>`)
|
||||
}
|
||||
}
|
||||
|
||||
// Author and URL into a paragraph
|
||||
let authorNameText = embed.author?.name || ""
|
||||
if (authorNameText && embed.author?.icon_url) authorNameText = `⏺️ ${authorNameText}` // using the emoji instead of an image
|
||||
if (authorNameText || embed.author?.url) {
|
||||
if (authorNameText) {
|
||||
if (embed.author?.url) {
|
||||
const authorURL = await transformContentMessageLinks(embed.author.url)
|
||||
rep.addParagraph(`## ${authorNameText} ${authorURL}`, tag`<strong><a href="${authorURL}">${authorNameText}</a></strong>`)
|
||||
|
@ -534,11 +552,11 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
} else {
|
||||
rep.addParagraph(`## ${body}`, `<strong>${html}</strong>`)
|
||||
}
|
||||
} else if (embed.url) {
|
||||
rep.addParagraph(`## ${embed.url}`, tag`<strong><a href="${embed.url}">${embed.url}</a></strong>`)
|
||||
}
|
||||
|
||||
if (embed.description) {
|
||||
let embedTypeShouldShowDescription = embed.type !== "video" // Discord doesn't display descriptions for videos
|
||||
if (embed.provider?.name === "YouTube") embedTypeShouldShowDescription = true // But I personally like showing the descriptions for YouTube videos specifically
|
||||
if (embed.description && embedTypeShouldShowDescription) {
|
||||
const {body, html} = await transformContent(embed.description)
|
||||
rep.addParagraph(body, html)
|
||||
}
|
||||
|
@ -552,7 +570,11 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||
rep.addParagraph(fieldRep.get().body, fieldRep.get().formatted_body)
|
||||
}
|
||||
|
||||
if (embed.image?.url) rep.addParagraph(`📸 ${embed.image.url}`)
|
||||
let chosenImage = embed.image?.url
|
||||
// the thumbnail seems to be used for "article" type but displayed big at the bottom by discord
|
||||
if (embed.type === "article" && embed.thumbnail?.url && !chosenImage) chosenImage = embed.thumbnail.url
|
||||
if (chosenImage) rep.addParagraph(`📸 ${chosenImage}`)
|
||||
|
||||
if (embed.video?.url) rep.addParagraph(`🎞️ ${embed.video.url}`)
|
||||
|
||||
if (embed.footer?.text) rep.addLine(`— ${embed.footer.text}`, tag`— ${embed.footer.text}`)
|
||||
|
|
|
@ -789,3 +789,63 @@ test("message2event: crossposted announcements say where they are crossposted fr
|
|||
formatted_body: "🔀 <strong>Chewey Bot Official Server #announcements</strong><br>All text based commands are now inactive on Chewey Bot<br>To continue using commands you'll need to use them as slash commands"
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event: @everyone", async t => {
|
||||
const events = await messageToEvent(data.message_mention_everyone.at_everyone)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "@room",
|
||||
"m.mentions": {
|
||||
room: true
|
||||
}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event: @here", async t => {
|
||||
const events = await messageToEvent(data.message_mention_everyone.at_here)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "@room",
|
||||
"m.mentions": {
|
||||
room: true
|
||||
}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event: @everyone without permission", async t => {
|
||||
const events = await messageToEvent(data.message_mention_everyone.at_everyone_without_permission)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "@everyone <-- this is testing that it DOESN'T mention. if this mentions everyone then my apologies.",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: "@everyone <-- this is testing that it DOESN'T mention. if this mentions everyone then my apologies.",
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event: @here without permission", async t => {
|
||||
const events = await messageToEvent(data.message_mention_everyone.at_here_without_permission)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "@here <-- this is testing that it DOESN'T mention. if this mentions people then my apologies.",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: "@here <-- this is testing that it DOESN'T mention. if this mentions people then my apologies.",
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
||||
test("message2event: @everyone within a link", async t => {
|
||||
const events = await messageToEvent(data.message_mention_everyone.at_everyone_within_link)
|
||||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "https://github.com/@everyone",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: `<a href="https://github.com/@everyone">https://github.com/@everyone</a>`,
|
||||
"m.mentions": {}
|
||||
}])
|
||||
})
|
||||
|
|
|
@ -12,7 +12,7 @@ const utils = sync.require("../../m2d/converters/utils")
|
|||
* @typedef ReactionRemoveRequest
|
||||
* @prop {string} eventID
|
||||
* @prop {string | null} mxid
|
||||
* @prop {BigInt} [hash]
|
||||
* @prop {bigint} [hash]
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -115,8 +115,7 @@ module.exports = {
|
|||
if (!member) return
|
||||
if (!("permission_overwrites" in channel)) continue
|
||||
const permissions = dUtils.getPermissions(member.roles, guild.roles, client.user.id, channel.permission_overwrites)
|
||||
const wants = BigInt(1 << 10) | BigInt(1 << 16) // VIEW_CHANNEL + READ_MESSAGE_HISTORY
|
||||
if ((permissions & wants) !== wants) continue // We don't have permission to look back in this channel
|
||||
if (!dUtils.hasAllPermissions(permissions, ["ViewChannel", "ReadMessageHistory"])) continue // We don't have permission to look back in this channel
|
||||
|
||||
/** More recent messages come first. */
|
||||
// console.log(`[check missed messages] in ${channel.id} (${guild.name} / ${channel.name}) because its last message ${channel.last_message_id} is not in the database`)
|
||||
|
@ -164,8 +163,7 @@ module.exports = {
|
|||
|
||||
// Permissions check
|
||||
const permissions = dUtils.getPermissions(member.roles, guild.roles, client.user.id, channel.permission_overwrites)
|
||||
const wants = BigInt(1 << 10) | BigInt(1 << 16) // VIEW_CHANNEL + READ_MESSAGE_HISTORY
|
||||
if ((permissions & wants) !== wants) continue // We don't have permission to look up the pins in this channel
|
||||
if (!dUtils.hasAllPermissions(permissions, ["ViewChannel", "ReadMessageHistory"])) continue // We don't have permission to look up the pins in this channel
|
||||
|
||||
const row = select("channel_room", ["room_id", "last_bridged_pin_timestamp"], {channel_id: channel.id}).get()
|
||||
if (!row) continue // Only care about already bridged channels
|
||||
|
@ -246,11 +244,13 @@ module.exports = {
|
|||
if (row) return // The message was sent by the bridge's own webhook on discord. We don't want to reflect this back, so just drop it.
|
||||
}
|
||||
|
||||
if (dUtils.isEphemeralMessage(message)) return // Ephemeral messages are for the eyes of the receiver only!
|
||||
|
||||
const {affected, row} = await speedbump.maybeDoSpeedbump(message.channel_id, message.id)
|
||||
if (affected) return
|
||||
|
||||
// @ts-ignore
|
||||
await sendMessage.sendMessage(message, guild, row),
|
||||
await sendMessage.sendMessage(message, channel, guild, row),
|
||||
await discordCommandHandler.execute(message, channel, guild)
|
||||
},
|
||||
|
||||
|
@ -264,13 +264,16 @@ module.exports = {
|
|||
if (row) return // The message was sent by the bridge's own webhook on discord. We don't want to reflect this back, so just drop it.
|
||||
}
|
||||
|
||||
if (dUtils.isEphemeralMessage(data)) return // Ephemeral messages are for the eyes of the receiver only!
|
||||
|
||||
// Edits need to go through the speedbump as well. If the message is delayed but the edit isn't, we don't have anything to edit from.
|
||||
const {affected, row} = await speedbump.maybeDoSpeedbump(data.channel_id, data.id)
|
||||
if (affected) return
|
||||
|
||||
// Based on looking at data they've sent me over the gateway, this is the best way to check for meaningful changes.
|
||||
// If the message content is a string then it includes all interesting fields and is meaningful.
|
||||
if (typeof data.content === "string") {
|
||||
// Otherwise, if there are embeds, then the system generated URL preview embeds.
|
||||
if (typeof data.content === "string" || "embeds" in data) {
|
||||
/** @type {DiscordTypes.GatewayMessageCreateDispatchData} */
|
||||
// @ts-ignore
|
||||
const message = data
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
a. If the bridge bot sim already has the correct ID:
|
||||
- No rows updated.
|
||||
|
||||
b. If the bridge bot sim has the wrong ID but there's no duplicate:
|
||||
- One row updated.
|
||||
|
||||
c. If the bridge bot sim has the wrong ID and there's a duplicate:
|
||||
- One row updated (replaces an existing row).
|
||||
*/
|
||||
|
||||
module.exports = async function(db) {
|
||||
const config = require("../../config")
|
||||
const id = Buffer.from(config.discordToken.split(".")[0], "base64").toString()
|
||||
db.prepare("UPDATE OR REPLACE sim SET user_id = ? WHERE user_id = '0'").run(id)
|
||||
}
|
|
@ -100,7 +100,7 @@ export type Prepared<Row> = {
|
|||
safeIntegers: () => Prepared<{[K in keyof Row]: Row[K] extends number ? BigInt : Row[K]}>
|
||||
raw: () => Prepared<Row[keyof Row][]>
|
||||
all: (..._: any[]) => Row[]
|
||||
get: (..._: any[]) => Row | null
|
||||
get: (..._: any[]) => Row | null | undefined
|
||||
}
|
||||
|
||||
export type AllKeys<U> = U extends any ? keyof U : never
|
||||
|
|
|
@ -51,5 +51,5 @@ test("orm: from: join direction works", t => {
|
|||
const hasNoOwner = from("sim").join("sim_proxy", "user_id", "left").select("user_id", "proxy_owner_id").where({sim_name: "crunch_god"}).get()
|
||||
t.deepEqual(hasNoOwner, {user_id: "820865262526005258", proxy_owner_id: null})
|
||||
const hasNoOwnerInner = from("sim").join("sim_proxy", "user_id", "inner").select("user_id", "proxy_owner_id").where({sim_name: "crunch_god"}).get()
|
||||
t.deepEqual(hasNoOwnerInner, null)
|
||||
t.deepEqual(hasNoOwnerInner, undefined)
|
||||
})
|
||||
|
|
|
@ -137,7 +137,7 @@ const commands = [{
|
|||
// Check CREATE_INSTANT_INVITE permission
|
||||
assert(message.member)
|
||||
const guildPermissions = utils.getPermissions(message.member.roles, guild.roles)
|
||||
if (!(guildPermissions & BigInt(1))) {
|
||||
if (!(guildPermissions & DiscordTypes.PermissionFlagsBits.CreateInstantInvite)) {
|
||||
return discord.snow.channel.createMessage(channel.id, {
|
||||
...ctx,
|
||||
content: "You don't have permission to invite people to this Discord server."
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
const DiscordTypes = require("discord-api-types/v10")
|
||||
const assert = require("assert").strict
|
||||
|
||||
const EPOCH = 1420070400000
|
||||
|
||||
|
@ -25,7 +26,7 @@ function getPermissions(userRoles, guildRoles, userID, channelOverwrites) {
|
|||
}
|
||||
|
||||
if (channelOverwrites) {
|
||||
/** @type {((overwrite: Required<DiscordTypes.APIGuildChannel>["permission_overwrites"][0]) => any)[]} */
|
||||
/** @type {((overwrite: Required<DiscordTypes.APIOverwrite>) => any)[]} */
|
||||
const actions = [
|
||||
// Channel @everyone deny
|
||||
overwrite => overwrite.id === everyoneID && (allowed &= ~BigInt(overwrite.deny)),
|
||||
|
@ -49,6 +50,48 @@ function getPermissions(userRoles, guildRoles, userID, channelOverwrites) {
|
|||
return allowed
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: You can only provide one permission bit to permissionToCheckFor. To check multiple permissions, call `hasAllPermissions` or `hasSomePermissions`.
|
||||
* It is designed like this to avoid developer error with bit manipulations.
|
||||
*
|
||||
* @param {bigint} resolvedPermissions
|
||||
* @param {bigint} permissionToCheckFor
|
||||
* @returns {boolean} whether the user has the requested permission
|
||||
* @example
|
||||
* const permissions = getPermissions(userRoles, guildRoles, userID, channelOverwrites)
|
||||
* hasPermission(permissions, DiscordTypes.PermissionFlagsBits.ViewChannel)
|
||||
*/
|
||||
function hasPermission(resolvedPermissions, permissionToCheckFor) {
|
||||
// Make sure permissionToCheckFor has exactly one permission in it
|
||||
assert.equal(permissionToCheckFor.toString(2).match(/1/g)?.length, 1)
|
||||
// Do the actual calculation
|
||||
return (resolvedPermissions & permissionToCheckFor) === permissionToCheckFor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {bigint} resolvedPermissions
|
||||
* @param {(keyof DiscordTypes.PermissionFlagsBits)[]} permissionsToCheckFor
|
||||
* @returns {boolean} whether the user has any of the requested permissions
|
||||
* @example
|
||||
* const permissions = getPermissions(userRoles, guildRoles, userID, channelOverwrites)
|
||||
* hasSomePermissions(permissions, ["ViewChannel", "ReadMessageHistory"])
|
||||
*/
|
||||
function hasSomePermissions(resolvedPermissions, permissionsToCheckFor) {
|
||||
return permissionsToCheckFor.some(x => hasPermission(resolvedPermissions, DiscordTypes.PermissionFlagsBits[x]))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {bigint} resolvedPermissions
|
||||
* @param {(keyof DiscordTypes.PermissionFlagsBits)[]} permissionsToCheckFor
|
||||
* @returns {boolean} whether the user has all of the requested permissions
|
||||
* @example
|
||||
* const permissions = getPermissions(userRoles, guildRoles, userID, channelOverwrites)
|
||||
* hasAllPermissions(permissions, ["ViewChannel", "ReadMessageHistory"])
|
||||
*/
|
||||
function hasAllPermissions(resolvedPermissions, permissionsToCheckFor) {
|
||||
return permissionsToCheckFor.every(x => hasPermission(resolvedPermissions, DiscordTypes.PermissionFlagsBits[x]))
|
||||
}
|
||||
|
||||
/**
|
||||
* Command interaction responses have a webhook_id for some reason, but still have real author info of a real bot user in the server.
|
||||
* @param {DiscordTypes.APIMessage} message
|
||||
|
@ -58,6 +101,14 @@ function isWebhookMessage(message) {
|
|||
return message.webhook_id && !isInteractionResponse
|
||||
}
|
||||
|
||||
/**
|
||||
* Ephemeral messages can be generated if a slash command is attached to the same bot that OOYE is running on
|
||||
* @param {DiscordTypes.APIMessage} message
|
||||
*/
|
||||
function isEphemeralMessage(message) {
|
||||
return message.flags & (1 << 6);
|
||||
}
|
||||
|
||||
/** @param {string} snowflake */
|
||||
function snowflakeToTimestampExact(snowflake) {
|
||||
return Number(BigInt(snowflake) >> 22n) + EPOCH
|
||||
|
@ -69,6 +120,10 @@ function timestampToSnowflakeInexact(timestamp) {
|
|||
}
|
||||
|
||||
module.exports.getPermissions = getPermissions
|
||||
module.exports.hasPermission = hasPermission
|
||||
module.exports.hasSomePermissions = hasSomePermissions
|
||||
module.exports.hasAllPermissions = hasAllPermissions
|
||||
module.exports.isWebhookMessage = isWebhookMessage
|
||||
module.exports.isEphemeralMessage = isEphemeralMessage
|
||||
module.exports.snowflakeToTimestampExact = snowflakeToTimestampExact
|
||||
module.exports.timestampToSnowflakeInexact = timestampToSnowflakeInexact
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const DiscordTypes = require("discord-api-types/v10")
|
||||
const {test} = require("supertape")
|
||||
const data = require("../test/data")
|
||||
const utils = require("./utils")
|
||||
|
@ -82,3 +83,27 @@ test("getPermissions: channel overwrite to allow role works", t => {
|
|||
const want = BigInt(1 << 10 | 1 << 16)
|
||||
t.equal((permissions & want), want)
|
||||
})
|
||||
|
||||
test("hasSomePermissions: detects the permission", t => {
|
||||
const userPermissions = DiscordTypes.PermissionFlagsBits.MentionEveryone | DiscordTypes.PermissionFlagsBits.BanMembers
|
||||
const canRemoveMembers = utils.hasSomePermissions(userPermissions, ["KickMembers", "BanMembers"])
|
||||
t.equal(canRemoveMembers, true)
|
||||
})
|
||||
|
||||
test("hasSomePermissions: doesn't detect not the permission", t => {
|
||||
const userPermissions = DiscordTypes.PermissionFlagsBits.MentionEveryone | DiscordTypes.PermissionFlagsBits.SendMessages
|
||||
const canRemoveMembers = utils.hasSomePermissions(userPermissions, ["KickMembers", "BanMembers"])
|
||||
t.equal(canRemoveMembers, false)
|
||||
})
|
||||
|
||||
test("hasAllPermissions: detects the permissions", t => {
|
||||
const userPermissions = DiscordTypes.PermissionFlagsBits.KickMembers | DiscordTypes.PermissionFlagsBits.BanMembers | DiscordTypes.PermissionFlagsBits.MentionEveryone
|
||||
const canRemoveMembers = utils.hasAllPermissions(userPermissions, ["KickMembers", "BanMembers"])
|
||||
t.equal(canRemoveMembers, true)
|
||||
})
|
||||
|
||||
test("hasAllPermissions: doesn't detect not the permissions", t => {
|
||||
const userPermissions = DiscordTypes.PermissionFlagsBits.MentionEveryone | DiscordTypes.PermissionFlagsBits.SendMessages | DiscordTypes.PermissionFlagsBits.KickMembers
|
||||
const canRemoveMembers = utils.hasAllPermissions(userPermissions, ["KickMembers", "BanMembers"])
|
||||
t.equal(canRemoveMembers, false)
|
||||
})
|
||||
|
|
|
@ -57,7 +57,7 @@ async function withWebhook(channelID, callback) {
|
|||
*/
|
||||
async function sendMessageWithWebhook(channelID, data, threadID) {
|
||||
const result = await withWebhook(channelID, async webhook => {
|
||||
return discord.snow.webhook.executeWebhook(webhook.id, webhook.token, data, {wait: true, thread_id: threadID, disableEveryone: true})
|
||||
return discord.snow.webhook.executeWebhook(webhook.id, webhook.token, data, {wait: true, thread_id: threadID})
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ async function deleteMessage(event) {
|
|||
db.prepare("DELETE FROM event_message WHERE event_id = ?").run(event.event_id)
|
||||
for (const row of rows) {
|
||||
db.prepare("DELETE FROM message_channel WHERE message_id = ?").run(row.message_id)
|
||||
discord.snow.channel.deleteMessage(row.channel_id, row.message_id, event.content.reason)
|
||||
await discord.snow.channel.deleteMessage(row.channel_id, row.message_id, event.content.reason)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ const eventToMessage = sync.require("../converters/event-to-message")
|
|||
const api = sync.require("../../matrix/api")
|
||||
/** @type {import("../../d2m/actions/register-user")} */
|
||||
const registerUser = sync.require("../../d2m/actions/register-user")
|
||||
/** @type {import("../../d2m/actions/edit-message")} */
|
||||
const editMessage = sync.require("../../d2m/actions/edit-message")
|
||||
/** @type {import("../actions/emoji-sheet")} */
|
||||
const emojiSheet = sync.require("../actions/emoji-sheet")
|
||||
|
||||
|
@ -88,6 +90,7 @@ async function sendEvent(event) {
|
|||
}))
|
||||
|
||||
let eventPart = 0 // 0 is primary, 1 is supporting
|
||||
const pendingEdits = []
|
||||
|
||||
/** @type {DiscordTypes.APIMessage[]} */
|
||||
const messageResponses = []
|
||||
|
@ -111,12 +114,33 @@ async function sendEvent(event) {
|
|||
|
||||
eventPart = 1
|
||||
messageResponses.push(messageResponse)
|
||||
|
||||
/*
|
||||
If the Discord system has a cached link preview embed for one of the links just sent,
|
||||
it will be instantly added as part of `embeds` and there won't be a MESSAGE_UPDATE.
|
||||
To reflect the generated embed back to Matrix, we pretend the message was updated right away.
|
||||
*/
|
||||
const sentEmbedsCount = message.embeds?.length || 0
|
||||
if (messageResponse.embeds.length > sentEmbedsCount) {
|
||||
// not awaiting here because requests to Matrix shouldn't block requests to Discord
|
||||
pendingEdits.push(() =>
|
||||
// @ts-ignore this is a valid message edit payload
|
||||
editMessage.editMessage({
|
||||
id: messageResponse.id,
|
||||
channel_id: messageResponse.channel_id,
|
||||
guild_id: guild.id,
|
||||
embeds: messageResponse.embeds
|
||||
}, guild, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
for (const user of ensureJoined) {
|
||||
registerUser.ensureSimJoined(user, event.room_id)
|
||||
}
|
||||
|
||||
await Promise.all(pendingEdits.map(f => f())) // `await` will propagate any errors during editing
|
||||
|
||||
return messageResponses
|
||||
}
|
||||
|
||||
|
|
|
@ -384,19 +384,35 @@ async function handleRoomOrMessageLinks(input, di) {
|
|||
|
||||
/**
|
||||
* @param {string} content
|
||||
* @param {string} senderMxid
|
||||
* @param {string} roomID
|
||||
* @param {DiscordTypes.APIGuild} guild
|
||||
* @param {{api: import("../../matrix/api"), snow: import("snowtransfer").SnowTransfer, fetch: import("node-fetch")["default"]}} di
|
||||
*/
|
||||
async function checkWrittenMentions(content, guild, di) {
|
||||
async function checkWrittenMentions(content, senderMxid, roomID, guild, di) {
|
||||
let writtenMentionMatch = content.match(/(?:^|[^"[<>/A-Za-z0-9])@([A-Za-z][A-Za-z0-9._\[\]\(\)-]+):?/d) // /d flag for indices requires node.js 16+
|
||||
if (writtenMentionMatch) {
|
||||
const results = await di.snow.guild.searchGuildMembers(guild.id, {query: writtenMentionMatch[1]})
|
||||
if (results[0]) {
|
||||
assert(results[0].user)
|
||||
return {
|
||||
// @ts-ignore - typescript doesn't know about indices yet
|
||||
content: content.slice(0, writtenMentionMatch.indices[1][0]-1) + `<@${results[0].user.id}>` + content.slice(writtenMentionMatch.indices[1][1]),
|
||||
ensureJoined: results[0].user
|
||||
if (writtenMentionMatch[1] === "room") { // convert @room to @everyone
|
||||
const powerLevels = await di.api.getStateEvent(roomID, "m.room.power_levels", "")
|
||||
const userPower = powerLevels.users?.[senderMxid] || 0
|
||||
if (userPower >= powerLevels.notifications?.room) {
|
||||
return {
|
||||
// @ts-ignore - typescript doesn't know about indices yet
|
||||
content: content.slice(0, writtenMentionMatch.indices[1][0]-1) + `@everyone` + content.slice(writtenMentionMatch.indices[1][1]),
|
||||
ensureJoined: [],
|
||||
allowedMentionsParse: ["everyone"]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const results = await di.snow.guild.searchGuildMembers(guild.id, {query: writtenMentionMatch[1]})
|
||||
if (results[0]) {
|
||||
assert(results[0].user)
|
||||
return {
|
||||
// @ts-ignore - typescript doesn't know about indices yet
|
||||
content: content.slice(0, writtenMentionMatch.indices[1][0]-1) + `<@${results[0].user.id}>` + content.slice(writtenMentionMatch.indices[1][1]),
|
||||
ensureJoined: [results[0].user],
|
||||
allowedMentionsParse: []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -425,11 +441,9 @@ const attachmentEmojis = new Map([
|
|||
* @param {{api: import("../../matrix/api"), snow: import("snowtransfer").SnowTransfer, fetch: import("node-fetch")["default"], mxcDownloader: (mxc: string) => Promise<Buffer | undefined>}} di simple-as-nails dependency injection for the matrix API
|
||||
*/
|
||||
async function eventToMessage(event, guild, di) {
|
||||
/** @type {(DiscordTypes.RESTPostAPIWebhookWithTokenJSONBody & {files?: {name: string, file: Buffer | Readable}[]})[]} */
|
||||
let messages = []
|
||||
|
||||
let displayName = event.sender
|
||||
let avatarURL = undefined
|
||||
const allowedMentionsParse = ["users", "roles"]
|
||||
/** @type {string[]} */
|
||||
let messageIDsToEdit = []
|
||||
let replyLine = ""
|
||||
|
@ -659,10 +673,11 @@ async function eventToMessage(event, guild, di) {
|
|||
for (; node; node = node.nextSibling) {
|
||||
// Check written mentions
|
||||
if (node.nodeType === 3 && node.nodeValue.includes("@") && !nodeIsChildOf(node, ["A", "CODE", "PRE"])) {
|
||||
const result = await checkWrittenMentions(node.nodeValue, guild, di)
|
||||
const result = await checkWrittenMentions(node.nodeValue, event.sender, event.room_id, guild, di)
|
||||
if (result) {
|
||||
node.nodeValue = result.content
|
||||
ensureJoined.push(result.ensureJoined)
|
||||
ensureJoined.push(...result.ensureJoined)
|
||||
allowedMentionsParse.push(...result.allowedMentionsParse)
|
||||
}
|
||||
}
|
||||
// Check for incompatible backticks in code blocks
|
||||
|
@ -709,7 +724,7 @@ async function eventToMessage(event, guild, di) {
|
|||
content = turndownService.turndown(root)
|
||||
|
||||
// Put < > around any surviving matrix.to links to hide the URL previews
|
||||
content = content.replace(/\bhttps?:\/\/matrix\.to\/[^ )]*/, "<$&>")
|
||||
content = content.replace(/\bhttps?:\/\/matrix\.to\/[^ )]*/g, "<$&>")
|
||||
|
||||
// It's designed for commonmark, we need to replace the space-space-newline with just newline
|
||||
content = content.replace(/ \n/g, "\n")
|
||||
|
@ -730,10 +745,11 @@ async function eventToMessage(event, guild, di) {
|
|||
content = await handleRoomOrMessageLinks(content, di) // Replace matrix.to links with discord.com equivalents where possible
|
||||
content = content.replace(/\bhttps?:\/\/matrix\.to\/[^ )]*/, "<$&>") // Put < > around any surviving matrix.to links to hide the URL previews
|
||||
|
||||
const result = await checkWrittenMentions(content, guild, di)
|
||||
const result = await checkWrittenMentions(content, event.sender, event.room_id, guild, di)
|
||||
if (result) {
|
||||
content = result.content
|
||||
ensureJoined.push(result.ensureJoined)
|
||||
ensureJoined.push(...result.ensureJoined)
|
||||
allowedMentionsParse.push(...result.allowedMentionsParse)
|
||||
}
|
||||
|
||||
// Markdown needs to be escaped, though take care not to escape the middle of links
|
||||
|
@ -786,11 +802,15 @@ async function eventToMessage(event, guild, di) {
|
|||
|
||||
// Split into 2000 character chunks
|
||||
const chunks = chunk(content, 2000)
|
||||
messages = messages.concat(chunks.map(content => ({
|
||||
/** @type {(DiscordTypes.RESTPostAPIWebhookWithTokenJSONBody & {files?: {name: string, file: Buffer | Readable}[]})[]} */
|
||||
const messages = chunks.map(content => ({
|
||||
content,
|
||||
allowed_mentions: {
|
||||
parse: allowedMentionsParse
|
||||
},
|
||||
username: displayNameShortened,
|
||||
avatar_url: avatarURL
|
||||
})))
|
||||
}))
|
||||
|
||||
if (attachments.length) {
|
||||
// If content is empty (should be the case when uploading a file) then chunk-text will create 0 messages.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -121,6 +121,19 @@ function getJoinedMembers(roomID) {
|
|||
return mreq.mreq("GET", `/client/v3/rooms/${roomID}/joined_members`)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} roomID
|
||||
* @param {{from?: string, limit?: any}} pagination
|
||||
* @returns {Promise<Ty.HierarchyPagination<Ty.R.Hierarchy>>}
|
||||
*/
|
||||
function getHierarchy(roomID, pagination) {
|
||||
let path = `/client/v1/rooms/${roomID}/hierarchy`
|
||||
if (!pagination.from) delete pagination.from
|
||||
if (!pagination.limit) pagination.limit = 50
|
||||
path += `?${new URLSearchParams(pagination)}`
|
||||
return mreq.mreq("GET", path)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} roomID
|
||||
* @param {string} eventID
|
||||
|
@ -239,6 +252,7 @@ module.exports.getEventForTimestamp = getEventForTimestamp
|
|||
module.exports.getAllState = getAllState
|
||||
module.exports.getStateEvent = getStateEvent
|
||||
module.exports.getJoinedMembers = getJoinedMembers
|
||||
module.exports.getHierarchy = getHierarchy
|
||||
module.exports.getRelations = getRelations
|
||||
module.exports.sendState = sendState
|
||||
module.exports.sendEvent = sendEvent
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const assert = require("assert").strict
|
||||
const mixin = require("mixin-deep")
|
||||
const deepEqual = require("deep-equal")
|
||||
const {isDeepStrictEqual} = require("util")
|
||||
|
||||
/** Mutates the input. */
|
||||
function kstateStripConditionals(kstate) {
|
||||
|
@ -51,14 +51,14 @@ function diffKState(actual, target) {
|
|||
// Special handling for power levels, we want to deep merge the actual and target into the final state.
|
||||
if (!(key in actual)) throw new Error(`want to apply a power levels diff, but original power level data is missing\nstarted with: ${JSON.stringify(actual)}\nwant to apply: ${JSON.stringify(target)}`)
|
||||
const temp = mixin({}, actual[key], target[key])
|
||||
if (!deepEqual(actual[key], temp, {strict: true})) {
|
||||
if (!isDeepStrictEqual(actual[key], temp)) {
|
||||
// they differ. use the newly prepared object as the diff.
|
||||
diff[key] = temp
|
||||
}
|
||||
|
||||
} else if (key in actual) {
|
||||
// diff
|
||||
if (!deepEqual(actual[key], target[key], {strict: true})) {
|
||||
if (!isDeepStrictEqual(actual[key], target[key])) {
|
||||
// they differ. use the target as the diff.
|
||||
diff[key] = target[key]
|
||||
}
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
"better-sqlite3": "^9.0.0",
|
||||
"chunk-text": "^2.0.1",
|
||||
"cloudstorm": "^0.10.8",
|
||||
"deep-equal": "^2.2.3",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#2881b447954fcea10510f212fa4c1dbbdc0a57a3",
|
||||
"entities": "^4.5.0",
|
||||
"get-stream": "^6.0.1",
|
||||
"giframe": "github:cloudrac3r/giframe#v0.4.1",
|
||||
"giframe": "github:cloudrac3r/giframe#v0.4.2",
|
||||
"heatsync": "^2.4.1",
|
||||
"html-template-tag": "github:cloudrac3r/html-template-tag#v5.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
|
@ -41,7 +40,7 @@
|
|||
"colorette": "^1.4.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"discord-api-types": "^0.37.60",
|
||||
"supertape": "^10.3.0",
|
||||
"supertape": "^10.4.0",
|
||||
"tap-dot": "github:cloudrac3r/tap-dot#9dd7750ececeae3a96afba91905be812b6b2cc2d"
|
||||
}
|
||||
},
|
||||
|
@ -548,18 +547,6 @@
|
|||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||
},
|
||||
"node_modules/array-buffer-byte-length": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz",
|
||||
"integrity": "sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"is-array-buffer": "^3.0.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/array-flatten": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
|
@ -580,17 +567,6 @@
|
|||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/available-typed-arrays": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz",
|
||||
"integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/b4a": {
|
||||
"version": "1.6.4",
|
||||
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.4.tgz",
|
||||
|
@ -797,13 +773,18 @@
|
|||
}
|
||||
},
|
||||
"node_modules/call-bind": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz",
|
||||
"integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
|
||||
"integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
|
||||
"dependencies": {
|
||||
"es-define-property": "^1.0.0",
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2",
|
||||
"get-intrinsic": "^1.2.1",
|
||||
"set-function-length": "^1.1.1"
|
||||
"get-intrinsic": "^1.2.4",
|
||||
"set-function-length": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
|
@ -1080,37 +1061,6 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/deep-equal": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz",
|
||||
"integrity": "sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==",
|
||||
"dependencies": {
|
||||
"array-buffer-byte-length": "^1.0.0",
|
||||
"call-bind": "^1.0.5",
|
||||
"es-get-iterator": "^1.1.3",
|
||||
"get-intrinsic": "^1.2.2",
|
||||
"is-arguments": "^1.1.1",
|
||||
"is-array-buffer": "^3.0.2",
|
||||
"is-date-object": "^1.0.5",
|
||||
"is-regex": "^1.1.4",
|
||||
"is-shared-array-buffer": "^1.0.2",
|
||||
"isarray": "^2.0.5",
|
||||
"object-is": "^1.1.5",
|
||||
"object-keys": "^1.1.1",
|
||||
"object.assign": "^4.1.4",
|
||||
"regexp.prototype.flags": "^1.5.1",
|
||||
"side-channel": "^1.0.4",
|
||||
"which-boxed-primitive": "^1.0.2",
|
||||
"which-collection": "^1.0.1",
|
||||
"which-typed-array": "^1.1.13"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/deep-extend": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
|
||||
|
@ -1120,25 +1070,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/define-data-property": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz",
|
||||
"integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==",
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
|
||||
"integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
|
||||
"dependencies": {
|
||||
"get-intrinsic": "^1.2.1",
|
||||
"gopd": "^1.0.1",
|
||||
"has-property-descriptors": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/define-properties": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz",
|
||||
"integrity": "sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==",
|
||||
"dependencies": {
|
||||
"has-property-descriptors": "^1.0.0",
|
||||
"object-keys": "^1.1.1"
|
||||
"es-define-property": "^1.0.0",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
|
@ -1252,23 +1190,23 @@
|
|||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/es-get-iterator": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz",
|
||||
"integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==",
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
|
||||
"integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"get-intrinsic": "^1.1.3",
|
||||
"has-symbols": "^1.0.3",
|
||||
"is-arguments": "^1.1.1",
|
||||
"is-map": "^2.0.2",
|
||||
"is-set": "^2.0.2",
|
||||
"is-string": "^1.0.7",
|
||||
"isarray": "^2.0.5",
|
||||
"stop-iteration-iterator": "^1.0.0"
|
||||
"get-intrinsic": "^1.2.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
|
@ -1465,14 +1403,6 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/for-each": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
|
||||
"integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==",
|
||||
"dependencies": {
|
||||
"is-callable": "^1.1.3"
|
||||
}
|
||||
},
|
||||
"node_modules/foreground-child": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz",
|
||||
|
@ -1544,14 +1474,6 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/functions-have-names": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz",
|
||||
"integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-caller-file": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||
|
@ -1562,15 +1484,19 @@
|
|||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz",
|
||||
"integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==",
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
|
||||
"integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2",
|
||||
"has-proto": "^1.0.1",
|
||||
"has-symbols": "^1.0.3",
|
||||
"hasown": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
|
@ -1597,8 +1523,8 @@
|
|||
}
|
||||
},
|
||||
"node_modules/giframe": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "git+ssh://git@github.com/cloudrac3r/giframe.git#1630f4d3b2bf5acd197409c85edd11e0da72d0a1",
|
||||
"version": "0.4.2",
|
||||
"resolved": "git+ssh://git@github.com/cloudrac3r/giframe.git#39b9d9af4184ea9df72c0ccd4db96da51bd1082c",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/github-from-package": {
|
||||
|
@ -1667,25 +1593,6 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/has-bigints": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz",
|
||||
"integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
|
@ -1696,11 +1603,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/has-property-descriptors": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz",
|
||||
"integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
|
||||
"integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
|
||||
"dependencies": {
|
||||
"get-intrinsic": "^1.1.1"
|
||||
"es-define-property": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
|
@ -1728,20 +1635,6 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-tostringtag": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz",
|
||||
"integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==",
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz",
|
||||
|
@ -1845,19 +1738,6 @@
|
|||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
|
||||
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
|
||||
},
|
||||
"node_modules/internal-slot": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.5.tgz",
|
||||
"integrity": "sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==",
|
||||
"dependencies": {
|
||||
"get-intrinsic": "^1.2.0",
|
||||
"has": "^1.0.3",
|
||||
"side-channel": "^1.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/ipaddr.js": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
||||
|
@ -1866,76 +1746,11 @@
|
|||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/is-arguments": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz",
|
||||
"integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"has-tostringtag": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-array-buffer": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz",
|
||||
"integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"get-intrinsic": "^1.2.0",
|
||||
"is-typed-array": "^1.1.10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-arrayish": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
|
||||
"integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
|
||||
},
|
||||
"node_modules/is-bigint": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz",
|
||||
"integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==",
|
||||
"dependencies": {
|
||||
"has-bigints": "^1.0.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-boolean-object": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz",
|
||||
"integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"has-tostringtag": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-callable": {
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
|
||||
"integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-core-module": {
|
||||
"version": "2.13.1",
|
||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz",
|
||||
|
@ -1948,20 +1763,6 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-date-object": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz",
|
||||
"integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==",
|
||||
"dependencies": {
|
||||
"has-tostringtag": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-fullwidth-code-point": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
|
@ -1971,133 +1772,6 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/is-map": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz",
|
||||
"integrity": "sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-number-object": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz",
|
||||
"integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==",
|
||||
"dependencies": {
|
||||
"has-tostringtag": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-regex": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz",
|
||||
"integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"has-tostringtag": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-set": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.2.tgz",
|
||||
"integrity": "sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-shared-array-buffer": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz",
|
||||
"integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-string": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz",
|
||||
"integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==",
|
||||
"dependencies": {
|
||||
"has-tostringtag": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-symbol": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz",
|
||||
"integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==",
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-typed-array": {
|
||||
"version": "1.1.10",
|
||||
"resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz",
|
||||
"integrity": "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==",
|
||||
"dependencies": {
|
||||
"available-typed-arrays": "^1.0.5",
|
||||
"call-bind": "^1.0.2",
|
||||
"for-each": "^0.3.3",
|
||||
"gopd": "^1.0.1",
|
||||
"has-tostringtag": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-weakmap": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz",
|
||||
"integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-weakset": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.2.tgz",
|
||||
"integrity": "sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"get-intrinsic": "^1.1.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/isarray": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
|
||||
"integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="
|
||||
},
|
||||
"node_modules/isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
|
@ -2448,46 +2122,6 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/object-is": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz",
|
||||
"integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"define-properties": "^1.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/object-keys": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
||||
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/object.assign": {
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz",
|
||||
"integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"define-properties": "^1.1.4",
|
||||
"has-symbols": "^1.0.3",
|
||||
"object-keys": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/on-finished": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
||||
|
@ -2839,22 +2473,6 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/regexp.prototype.flags": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.1.tgz",
|
||||
"integrity": "sha512-sy6TXMN+hnP/wMy+ISxg3krXx7BAtWVO4UouuCN/ziM9UEne0euamVNafDfvC83bRNr95y0V5iijeDQFUNpvrg==",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"define-properties": "^1.2.0",
|
||||
"set-function-name": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
|
@ -3027,27 +2645,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/set-function-length": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz",
|
||||
"integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==",
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz",
|
||||
"integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==",
|
||||
"dependencies": {
|
||||
"define-data-property": "^1.1.1",
|
||||
"get-intrinsic": "^1.2.1",
|
||||
"define-data-property": "^1.1.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2",
|
||||
"get-intrinsic": "^1.2.3",
|
||||
"gopd": "^1.0.1",
|
||||
"has-property-descriptors": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/set-function-name": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.1.tgz",
|
||||
"integrity": "sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==",
|
||||
"dependencies": {
|
||||
"define-data-property": "^1.0.1",
|
||||
"functions-have-names": "^1.2.3",
|
||||
"has-property-descriptors": "^1.0.0"
|
||||
"has-property-descriptors": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
|
@ -3250,17 +2857,6 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/stop-iteration-iterator": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz",
|
||||
"integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==",
|
||||
"dependencies": {
|
||||
"internal-slot": "^1.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/stream-head": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/stream-head/-/stream-head-2.0.2.tgz",
|
||||
|
@ -3435,9 +3031,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/supertape": {
|
||||
"version": "10.3.0",
|
||||
"resolved": "https://registry.npmjs.org/supertape/-/supertape-10.3.0.tgz",
|
||||
"integrity": "sha512-z/HQbwB1+UMpmCQZXxxSU2zhzc+0yQq1Q9naCpyVDcRr2/cO/Bo3YhbSXJpEPVbvGy3BADl+vt5cfbXRJYFO0g==",
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/supertape/-/supertape-10.4.0.tgz",
|
||||
"integrity": "sha512-mQbcPU3jyDQsbncbS2flHELhZ7qEIF9q4Swnn/0782aN+rMQBzcJR3yapVn+9k3pUoUi64IcTaGxs24WSLDCvQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cloudcmd/stub": "^4.0.0",
|
||||
|
@ -3452,7 +3048,6 @@
|
|||
"@supertape/formatter-time": "^1.0.0",
|
||||
"@supertape/operator-stub": "^3.0.0",
|
||||
"cli-progress": "^3.8.2",
|
||||
"deep-equal": "^2.0.3",
|
||||
"fullstore": "^3.0.0",
|
||||
"glob": "^10.3.10",
|
||||
"jest-diff": "^29.0.1",
|
||||
|
@ -3816,53 +3411,6 @@
|
|||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/which-boxed-primitive": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz",
|
||||
"integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==",
|
||||
"dependencies": {
|
||||
"is-bigint": "^1.0.1",
|
||||
"is-boolean-object": "^1.1.0",
|
||||
"is-number-object": "^1.0.4",
|
||||
"is-string": "^1.0.5",
|
||||
"is-symbol": "^1.0.3"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/which-collection": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz",
|
||||
"integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==",
|
||||
"dependencies": {
|
||||
"is-map": "^2.0.1",
|
||||
"is-set": "^2.0.1",
|
||||
"is-weakmap": "^2.0.1",
|
||||
"is-weakset": "^2.0.1"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/which-typed-array": {
|
||||
"version": "1.1.13",
|
||||
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.13.tgz",
|
||||
"integrity": "sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow==",
|
||||
"dependencies": {
|
||||
"available-typed-arrays": "^1.0.5",
|
||||
"call-bind": "^1.0.4",
|
||||
"for-each": "^0.3.3",
|
||||
"gopd": "^1.0.1",
|
||||
"has-tostringtag": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
"better-sqlite3": "^9.0.0",
|
||||
"chunk-text": "^2.0.1",
|
||||
"cloudstorm": "^0.10.8",
|
||||
"deep-equal": "^2.2.3",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#2881b447954fcea10510f212fa4c1dbbdc0a57a3",
|
||||
"entities": "^4.5.0",
|
||||
"get-stream": "^6.0.1",
|
||||
"giframe": "github:cloudrac3r/giframe#v0.4.1",
|
||||
"giframe": "github:cloudrac3r/giframe#v0.4.2",
|
||||
"heatsync": "^2.4.1",
|
||||
"html-template-tag": "github:cloudrac3r/html-template-tag#v5.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
|
@ -47,7 +46,7 @@
|
|||
"colorette": "^1.4.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"discord-api-types": "^0.37.60",
|
||||
"supertape": "^10.3.0",
|
||||
"supertape": "^10.4.0",
|
||||
"tap-dot": "github:cloudrac3r/tap-dot#9dd7750ececeae3a96afba91905be812b6b2cc2d"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -167,7 +167,6 @@ To get into the rooms on your Matrix account, either add yourself to `invite` in
|
|||
* (1) chunk-text: It does what I want.
|
||||
* (0) cloudstorm: Discord gateway library with bring-your-own-caching that I trust.
|
||||
* (8) snowtransfer: Discord API library with bring-your-own-caching that I trust.
|
||||
* (0) deep-equal: It's already pulled in by supertape.
|
||||
* (1) discord-markdown: This is my fork!
|
||||
* (0) get-stream: Only needed if content_length_workaround is true.
|
||||
* (0) giframe: This is my fork!
|
||||
|
|
|
@ -37,7 +37,7 @@ passthrough.discord = discord
|
|||
})()
|
||||
|
||||
const events = new sqlite("scripts/events.db")
|
||||
const sql = "INSERT INTO \"update\" (json, " + interestingFields.join(", ") + ") VALUES (" + "?".repeat(interestingFields.length + 1).split("").join(", ") + ")"
|
||||
const sql = "INSERT INTO update_event (json, " + interestingFields.join(", ") + ") VALUES (" + "?".repeat(interestingFields.length + 1).split("").join(", ") + ")"
|
||||
console.log(sql)
|
||||
const prepared = events.prepare(sql)
|
||||
|
||||
|
|
|
@ -53,17 +53,19 @@ async function uploadAutoEmoji(guild, name, filename) {
|
|||
const mxid = `@${reg.sender_localpart}:${reg.ooye.server_name}`
|
||||
|
||||
// ensure registration is correctly set...
|
||||
assert(reg.sender_localpart.startsWith(reg.ooye.namespace_prefix)) // appservice's localpart must be in the namespace it controls
|
||||
assert(utils.eventSenderIsFromDiscord(mxid)) // appservice's mxid must be in the namespace it controls
|
||||
assert(reg.ooye.server_origin.match(/^https?:\/\//)) // must start with http or https
|
||||
assert.notEqual(reg.ooye.server_origin.slice(-1), "/") // must not end in slash
|
||||
assert(reg.sender_localpart.startsWith(reg.ooye.namespace_prefix), "appservice's localpart must be in the namespace it controls")
|
||||
assert(utils.eventSenderIsFromDiscord(mxid), "appservice's mxid must be in the namespace it controls")
|
||||
assert(reg.ooye.server_origin.match(/^https?:\/\//), "server origin must start with http or https")
|
||||
assert.notEqual(reg.ooye.server_origin.slice(-1), "/", "server origin must not end in slash")
|
||||
const botID = Buffer.from(config.discordToken.split(".")[0], "base64").toString()
|
||||
assert(botID.match(/^[0-9]{10,}$/), "discord token must follow the correct format")
|
||||
console.log("✅ Configuration looks good...")
|
||||
|
||||
// database ddl...
|
||||
await migrate.migrate(db)
|
||||
|
||||
// add initial rows to database, like adding the bot to sim...
|
||||
db.prepare("INSERT OR IGNORE INTO sim (user_id, sim_name, localpart, mxid) VALUES (?, ?, ?, ?)").run("0", reg.sender_localpart.slice(reg.ooye.namespace_prefix.length), reg.sender_localpart, mxid)
|
||||
db.prepare("INSERT OR IGNORE INTO sim (user_id, sim_name, localpart, mxid) VALUES (?, ?, ?, ?)").run(botID, reg.sender_localpart.slice(reg.ooye.namespace_prefix.length), reg.sender_localpart, mxid)
|
||||
|
||||
console.log("✅ Database is ready...")
|
||||
|
||||
|
|
663
test/data.js
663
test/data.js
|
@ -47,6 +47,9 @@ module.exports = {
|
|||
},
|
||||
users: {
|
||||
"@test_auto_invite:example.org": 100
|
||||
},
|
||||
notifications: {
|
||||
room: 0
|
||||
}
|
||||
},
|
||||
"chat.schildi.hide_ui/read_receipts": {hidden: true},
|
||||
|
@ -98,7 +101,6 @@ module.exports = {
|
|||
icon: "a_f83622e09ead74f0c5c527fe241f8f8c",
|
||||
emojis: [
|
||||
{
|
||||
version: 0,
|
||||
roles: [],
|
||||
require_colons: true,
|
||||
name: "hippo",
|
||||
|
@ -108,7 +110,6 @@ module.exports = {
|
|||
animated: false
|
||||
},
|
||||
{
|
||||
version: 0,
|
||||
roles: [],
|
||||
require_colons: true,
|
||||
name: "hipposcope",
|
||||
|
@ -121,7 +122,20 @@ module.exports = {
|
|||
premium_subscription_count: 14,
|
||||
roles: [
|
||||
{
|
||||
version: 1696964862461,
|
||||
unicode_emoji: null,
|
||||
tags: {},
|
||||
position: 0,
|
||||
permissions: '559623605575360',
|
||||
name: '@everyone',
|
||||
mentionable: false,
|
||||
managed: false,
|
||||
id: '112760669178241024',
|
||||
icon: null,
|
||||
hoist: false,
|
||||
flags: 0,
|
||||
color: 0
|
||||
},
|
||||
{
|
||||
unicode_emoji: null,
|
||||
tags: {},
|
||||
position: 22,
|
||||
|
@ -135,7 +149,6 @@ module.exports = {
|
|||
flags: 0,
|
||||
color: 0
|
||||
}, {
|
||||
version: 1696964862776,
|
||||
unicode_emoji: null,
|
||||
tags: {},
|
||||
position: 131,
|
||||
|
@ -149,7 +162,6 @@ module.exports = {
|
|||
flags: 0,
|
||||
color: 11076095
|
||||
}, {
|
||||
version: 1696964862698,
|
||||
unicode_emoji: '🍂',
|
||||
tags: {},
|
||||
position: 102,
|
||||
|
@ -1925,6 +1937,163 @@ module.exports = {
|
|||
webhook_id: "1195662438662680720"
|
||||
}
|
||||
},
|
||||
message_mention_everyone: {
|
||||
at_everyone: {
|
||||
id: "1214510099058655252",
|
||||
type: 0,
|
||||
content: "@everyone",
|
||||
channel_id: "1100319550446252084",
|
||||
author: {
|
||||
id: "772659086046658620",
|
||||
username: "cadence.worm",
|
||||
avatar: "4b5c4b28051144e4c111f0113a0f1cf1",
|
||||
discriminator: "0",
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "cadence",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: true,
|
||||
tts: false,
|
||||
timestamp: "2024-03-05T09:49:32.122000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
},
|
||||
at_here: {
|
||||
id: "1214510192230797332",
|
||||
type: 0,
|
||||
content: "@here",
|
||||
channel_id: "1100319550446252084",
|
||||
author: {
|
||||
id: "772659086046658620",
|
||||
username: "cadence.worm",
|
||||
avatar: "4b5c4b28051144e4c111f0113a0f1cf1",
|
||||
discriminator: "0",
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "cadence",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: true,
|
||||
tts: false,
|
||||
timestamp: "2024-03-05T09:49:54.336000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
},
|
||||
at_everyone_without_permission: {
|
||||
id: "1214510346623258654",
|
||||
type: 0,
|
||||
content: "@everyone <-- this is testing that it DOESN'T mention. if this mentions everyone then my apologies.",
|
||||
channel_id: "112760669178241024",
|
||||
author: {
|
||||
id: "772659086046658620",
|
||||
username: "cadence.worm",
|
||||
avatar: "4b5c4b28051144e4c111f0113a0f1cf1",
|
||||
discriminator: "0",
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "cadence",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2024-03-05T09:50:31.146000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
},
|
||||
at_here_without_permission: {
|
||||
id: "1214510346623258654",
|
||||
type: 0,
|
||||
content: "@here <-- this is testing that it DOESN'T mention. if this mentions people then my apologies.",
|
||||
channel_id: "112760669178241024",
|
||||
author: {
|
||||
id: "772659086046658620",
|
||||
username: "cadence.worm",
|
||||
avatar: "4b5c4b28051144e4c111f0113a0f1cf1",
|
||||
discriminator: "0",
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "cadence",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2024-03-05T09:50:31.146000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
},
|
||||
at_everyone_within_link: {
|
||||
id: "1214510225885888563",
|
||||
type: 0,
|
||||
content: "https://github.com/@everyone",
|
||||
channel_id: "1100319550446252084",
|
||||
author: {
|
||||
id: "772659086046658620",
|
||||
username: "cadence.worm",
|
||||
avatar: "4b5c4b28051144e4c111f0113a0f1cf1",
|
||||
discriminator: "0",
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "cadence",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2024-03-05T09:50:02.360000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
}
|
||||
},
|
||||
message_with_embeds: {
|
||||
nothing_but_a_field: {
|
||||
guild_id: "497159726455455754",
|
||||
|
@ -2123,6 +2292,185 @@ module.exports = {
|
|||
attachments: [],
|
||||
guild_id: "1150201337112449045"
|
||||
},
|
||||
vx_image: {
|
||||
id: "1209926442981269544",
|
||||
type: 0,
|
||||
content: "https://vxtwitter.com/TomorrowCorp/status/1760330671074287875 we got a release date!!!",
|
||||
channel_id: "288058913985789953",
|
||||
author: {
|
||||
id: "113340068197859328",
|
||||
username: "kumaccino",
|
||||
avatar: "b48302623a12bc7c59a71328f72ccb39",
|
||||
discriminator: "0",
|
||||
public_flags: 128,
|
||||
premium_type: 0,
|
||||
flags: 128,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "kumaccino",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: "article",
|
||||
url: "https://vxtwitter.com/TomorrowCorp/status/1760330671074287875",
|
||||
title: "Tomorrow Corporation (@TomorrowCorp)",
|
||||
description: "Mark your calendar with a wet black stain! World of Goo 2 releases on May 23, 2024 on Nintendo Switch, Epic Games Store (Win/Mac), and http://WorldOfGoo2.com (Win/Mac/Linux).\n" +
|
||||
"\n" +
|
||||
"https://tomorrowcorporation.com/posts/world-of-goo-2-now-with-100-more-release-dates-and-platforms\n" +
|
||||
"\n" +
|
||||
"💖 123 🔁 36",
|
||||
color: 8388564,
|
||||
author: {
|
||||
name: "Twitter",
|
||||
url: "https://twitter.com/tomorrowcorp/status/1760330671074287875"
|
||||
},
|
||||
provider: {
|
||||
name: "vxTwitter / fixvx",
|
||||
url: "https://github.com/dylanpdx/BetterTwitFix"
|
||||
},
|
||||
thumbnail: {
|
||||
url: "https://pbs.twimg.com/media/GG3zUMGbIAAxs3h.jpg",
|
||||
proxy_url: "https://images-ext-2.discordapp.net/external/eqA-NKoXzJ0Y_l-MlwN6shFDJibC0TbPxMNWSU5IpKY/https/pbs.twimg.com/media/GG3zUMGbIAAxs3h.jpg",
|
||||
width: 1200,
|
||||
height: 1200,
|
||||
placeholder: "5SgKDwTIlqiPjIhzlspniIiNaN8It3AD",
|
||||
placeholder_version: 1
|
||||
}
|
||||
}
|
||||
],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2024-02-21T18:15:43.353000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
},
|
||||
vx_video: {
|
||||
id: "1209804622206599190",
|
||||
type: 0,
|
||||
content: "https://vxtwitter.com/McDonalds/status/1759971752254341417",
|
||||
channel_id: "112760669178241024",
|
||||
author: {
|
||||
id: "113340068197859328",
|
||||
username: "kumaccino",
|
||||
avatar: "b48302623a12bc7c59a71328f72ccb39",
|
||||
discriminator: "0",
|
||||
public_flags: 128,
|
||||
premium_type: 0,
|
||||
flags: 128,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "kumaccino",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: "video",
|
||||
url: "https://vxtwitter.com/McDonalds/status/1759971752254341417",
|
||||
title: "McDonald's (@McDonalds)",
|
||||
description: "McDonald’s🤝@studiopierrot\n\n💖 89 🔁 21",
|
||||
color: 8388564,
|
||||
author: {
|
||||
name: "McDonald’s🤝@studiopierrot\n\n💖 89 🔁 21",
|
||||
url: "https://twitter.com/McDonalds/status/1759971752254341417"
|
||||
},
|
||||
provider: {
|
||||
name: "vxTwitter / fixvx",
|
||||
url: "https://github.com/dylanpdx/BetterTwitFix"
|
||||
},
|
||||
video: {
|
||||
url: "https://video.twimg.com/ext_tw_video/1759967449548541952/pu/vid/avc1/1280x720/XN1LFIJqAFBdtaoh.mp4?tag=12",
|
||||
proxy_url: "https://images-ext-1.discordapp.net/external/TInoGDskHFBRSQR0ErWEmvmzi75EO28aSyiEXs3SB8E/%3Ftag%3D12/https/video.twimg.com/ext_tw_video/1759967449548541952/pu/vid/avc1/1280x720/XN1LFIJqAFBdtaoh.mp4",
|
||||
width: 1280,
|
||||
height: 720,
|
||||
placeholder: "AggGBIAIp4iGeYdxjHgAAAAAAA==",
|
||||
placeholder_version: 1
|
||||
}
|
||||
}
|
||||
],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2024-02-21T10:11:39.017000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
},
|
||||
youtube_video: {
|
||||
id: "1214383754479534100",
|
||||
type: 0,
|
||||
content: "https://youtu.be/kDMHHw8JqLE?si=NaqNjVTtXugHeG_E\n\n\nJutomi I'm gonna make these sounds in your walls tonight",
|
||||
channel_id: "112760669178241024",
|
||||
author: {
|
||||
id: "1060361805152669766",
|
||||
username: "occimyy",
|
||||
avatar: "3bf268de3eab1c5441da9585534d8aa5",
|
||||
discriminator: "0",
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "Occimyy",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: "video",
|
||||
url: "https://www.youtube.com/watch?v=kDMHHw8JqLE",
|
||||
title: "Shoebill stork clattering sounds like machine guun~!! (Japan Matsue...",
|
||||
description: "twitter\n" +
|
||||
"https://twitter.com/matsuevogelpark\n" +
|
||||
"\n" +
|
||||
"The shoebill (Balaeniceps rex) also known as whalehead, whale-headed stork, or shoe-billed stork, is a very large stork-like bird. It derives its name from its enormous shoe-shaped bill\n" +
|
||||
"some people also called them the living dinosaur~~\n" +
|
||||
"\n" +
|
||||
"#shoebill #livingdinosaur #happyofunny #weirdcreature #weirdsoun...",
|
||||
color: 16711680,
|
||||
author: {
|
||||
name: "Happy O Funny",
|
||||
url: "https://www.youtube.com/channel/UCEpQ9aEb1NafpvWp5Aoizrg"
|
||||
},
|
||||
provider: { name: "YouTube", url: "https://www.youtube.com" },
|
||||
thumbnail: {
|
||||
url: "https://i.ytimg.com/vi/kDMHHw8JqLE/maxresdefault.jpg",
|
||||
proxy_url: "https://images-ext-1.discordapp.net/external/eEPOxZQXfTHqvPQJBWqsgG3wxTQN20b8LXqw3jSqyRM/https/i.ytimg.com/vi/kDMHHw8JqLE/maxresdefault.jpg",
|
||||
width: 1280,
|
||||
height: 720,
|
||||
placeholder: "WAgSDIIIdIprl4h4h4dNoEoEaQ==",
|
||||
placeholder_version: 1
|
||||
},
|
||||
video: {
|
||||
url: "https://www.youtube.com/embed/kDMHHw8JqLE",
|
||||
width: 1280,
|
||||
height: 720,
|
||||
placeholder: "WAgSDIIIdIprl4h4h4dNoEoEaQ==",
|
||||
placeholder_version: 1
|
||||
}
|
||||
}
|
||||
],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2024-03-05T01:27:29.227000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
},
|
||||
image_embed_and_attachment: {
|
||||
id: "1157854642810654821",
|
||||
type: 0,
|
||||
|
@ -2282,6 +2630,286 @@ module.exports = {
|
|||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
},
|
||||
title_without_url: {
|
||||
guild_id: "497159726455455754",
|
||||
mentions: [],
|
||||
id: "1141934888862351440",
|
||||
type: 20,
|
||||
content: "",
|
||||
channel_id: "497161350934560778",
|
||||
author: {
|
||||
id: "1109360903096369153",
|
||||
username: "Amanda 🎵",
|
||||
avatar: "d56cd1b26e043ae512edae2214962faa",
|
||||
discriminator: "2192",
|
||||
public_flags: 524288,
|
||||
flags: 524288,
|
||||
bot: true,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: null,
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: "rich",
|
||||
color: 3092790,
|
||||
title: "Hi, I'm Amanda!",
|
||||
description: "I condone pirating music!"
|
||||
}
|
||||
],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2023-08-18T03:21:33.629000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: [],
|
||||
application_id: "1109360903096369153",
|
||||
interaction: {
|
||||
id: "1141934887608254475",
|
||||
type: 2,
|
||||
name: "stats",
|
||||
user: {
|
||||
id: "320067006521147393",
|
||||
username: "papiophidian",
|
||||
avatar: "47a19b0445069b826e136da4df4259bb",
|
||||
discriminator: "0",
|
||||
public_flags: 4194880,
|
||||
flags: 4194880,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "PapiOphidian",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
}
|
||||
},
|
||||
webhook_id: "1109360903096369153"
|
||||
},
|
||||
url_without_title: {
|
||||
guild_id: "497159726455455754",
|
||||
mentions: [],
|
||||
id: "1141934888862351440",
|
||||
type: 20,
|
||||
content: "",
|
||||
channel_id: "497161350934560778",
|
||||
author: {
|
||||
id: "1109360903096369153",
|
||||
username: "Amanda 🎵",
|
||||
avatar: "d56cd1b26e043ae512edae2214962faa",
|
||||
discriminator: "2192",
|
||||
public_flags: 524288,
|
||||
flags: 524288,
|
||||
bot: true,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: null,
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: "rich",
|
||||
color: 3092790,
|
||||
url: "https://amanda.moe",
|
||||
description: "I condone pirating music!"
|
||||
}
|
||||
],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2023-08-18T03:21:33.629000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: [],
|
||||
application_id: "1109360903096369153",
|
||||
interaction: {
|
||||
id: "1141934887608254475",
|
||||
type: 2,
|
||||
name: "stats",
|
||||
user: {
|
||||
id: "320067006521147393",
|
||||
username: "papiophidian",
|
||||
avatar: "47a19b0445069b826e136da4df4259bb",
|
||||
discriminator: "0",
|
||||
public_flags: 4194880,
|
||||
flags: 4194880,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "PapiOphidian",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
}
|
||||
},
|
||||
webhook_id: "1109360903096369153"
|
||||
},
|
||||
author_without_url: {
|
||||
guild_id: "497159726455455754",
|
||||
mentions: [],
|
||||
id: "1141934888862351440",
|
||||
type: 20,
|
||||
content: "",
|
||||
channel_id: "497161350934560778",
|
||||
author: {
|
||||
id: "1109360903096369153",
|
||||
username: "Amanda 🎵",
|
||||
avatar: "d56cd1b26e043ae512edae2214962faa",
|
||||
discriminator: "2192",
|
||||
public_flags: 524288,
|
||||
flags: 524288,
|
||||
bot: true,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: null,
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: "rich",
|
||||
color: 3092790,
|
||||
author: {
|
||||
name: "Amanda"
|
||||
},
|
||||
description: "I condone pirating music!"
|
||||
}
|
||||
],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2023-08-18T03:21:33.629000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: [],
|
||||
application_id: "1109360903096369153",
|
||||
interaction: {
|
||||
id: "1141934887608254475",
|
||||
type: 2,
|
||||
name: "stats",
|
||||
user: {
|
||||
id: "320067006521147393",
|
||||
username: "papiophidian",
|
||||
avatar: "47a19b0445069b826e136da4df4259bb",
|
||||
discriminator: "0",
|
||||
public_flags: 4194880,
|
||||
flags: 4194880,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "PapiOphidian",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
}
|
||||
},
|
||||
webhook_id: "1109360903096369153"
|
||||
},
|
||||
author_url_without_name: {
|
||||
guild_id: "497159726455455754",
|
||||
mentions: [],
|
||||
id: "1141934888862351440",
|
||||
type: 20,
|
||||
content: "",
|
||||
channel_id: "497161350934560778",
|
||||
author: {
|
||||
id: "1109360903096369153",
|
||||
username: "Amanda 🎵",
|
||||
avatar: "d56cd1b26e043ae512edae2214962faa",
|
||||
discriminator: "2192",
|
||||
public_flags: 524288,
|
||||
flags: 524288,
|
||||
bot: true,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: null,
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: "rich",
|
||||
color: 3092790,
|
||||
author: {
|
||||
url: "https://amanda.moe"
|
||||
},
|
||||
description: "I condone pirating music!"
|
||||
}
|
||||
],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2023-08-18T03:21:33.629000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: [],
|
||||
application_id: "1109360903096369153",
|
||||
interaction: {
|
||||
id: "1141934887608254475",
|
||||
type: 2,
|
||||
name: "stats",
|
||||
user: {
|
||||
id: "320067006521147393",
|
||||
username: "papiophidian",
|
||||
avatar: "47a19b0445069b826e136da4df4259bb",
|
||||
discriminator: "0",
|
||||
public_flags: 4194880,
|
||||
flags: 4194880,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "PapiOphidian",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
}
|
||||
},
|
||||
webhook_id: "1109360903096369153"
|
||||
},
|
||||
discord_server_included_punctuation_bad_discord: {
|
||||
id: "1221672425792606349",
|
||||
type: 0,
|
||||
content: "(test https://discord.com/channels/1160894080998461480/1160894080998461480/1202543413652881428)",
|
||||
channel_id: "1160894080998461480",
|
||||
author: {
|
||||
id: "772659086046658620",
|
||||
username: "cadence.worm",
|
||||
avatar: "4b5c4b28051144e4c111f0113a0f1cf1",
|
||||
discriminator: "0",
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: "cadence",
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: "article",
|
||||
url: "https://discord.com/channels/1160894080998461480/1160894080998461480/1202543413652881428)",
|
||||
title: "Discord - A New Way to Chat with Friends & Communities",
|
||||
description: "Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.",
|
||||
provider: { name: "Discord" },
|
||||
content_scan_version: 0
|
||||
}
|
||||
],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: "2024-03-25T04:10:03.885000+00:00",
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: []
|
||||
}
|
||||
},
|
||||
message_update: {
|
||||
|
@ -2881,6 +3509,31 @@ module.exports = {
|
|||
}
|
||||
],
|
||||
guild_id: "112760669178241024"
|
||||
},
|
||||
embed_generated_social_media_image: {
|
||||
channel_id: "112760669178241024",
|
||||
embeds: [
|
||||
{
|
||||
color: 8594767,
|
||||
description: "1v1 physical card game. Each player gets one standard deck of cards with a different backing to differentiate. Every turn proceeds as follows:\n\n * Both players draw eight cards\n * Both players may choose up to eight cards to discard, then draw that number of cards to put back in their hand\n * Both players present their best five-or-less-card pok...",
|
||||
provider: {
|
||||
name: "hthrflwrs on cohost"
|
||||
},
|
||||
thumbnail: {
|
||||
height: 1587,
|
||||
placeholder: "GpoKP5BJZphshnhwmmmYlmh3l7+m+mwJ",
|
||||
placeholder_version: 1,
|
||||
proxy_url: "https://images-ext-2.discordapp.net/external/9vTXIzlXU4wyUZvWfmlmQkck8nGLUL-A090W4lWsZ48/https/staging.cohostcdn.org/avatar/292-6b64b03c-4ada-42f6-8452-109275bfe68d-profile.png",
|
||||
url: "https://staging.cohostcdn.org/avatar/292-6b64b03c-4ada-42f6-8452-109275bfe68d-profile.png",
|
||||
width: 1644
|
||||
},
|
||||
title: "This post nerdsniped me, so here's some RULES FOR REAL-LIFE BALATRO",
|
||||
type: "link",
|
||||
url: "https://cohost.org/jkap/post/4794219-empty"
|
||||
}
|
||||
],
|
||||
guild_id: "112760669178241024",
|
||||
id: "1210387798297682020"
|
||||
}
|
||||
},
|
||||
special_message: {
|
||||
|
|
|
@ -53,7 +53,8 @@ INSERT INTO message_channel (message_id, channel_id) VALUES
|
|||
('1158842413025071135', '176333891320283136'),
|
||||
('1197612733600895076', '112760669178241024'),
|
||||
('1202543413652881428', '1160894080998461480'),
|
||||
('1207486471489986620', '1160894080998461480');
|
||||
('1207486471489986620', '1160894080998461480'),
|
||||
('1210387798297682020', '112760669178241024');
|
||||
|
||||
INSERT INTO event_message (event_id, event_type, event_subtype, message_id, part, reaction_part, source) VALUES
|
||||
('$X16nfVks1wsrhq4E9SSLiqrf2N8KD0erD0scZG7U5xg', 'm.room.message', 'm.text', '1126786462646550579', 0, 0, 1),
|
||||
|
@ -87,7 +88,8 @@ INSERT INTO event_message (event_id, event_type, event_subtype, message_id, part
|
|||
('$dVCLyj6kxb3DaAWDtjcv2kdSny8JMMHdDhCMz8mDxVo', 'm.room.message', 'm.text', '1158842413025071135', 0, 0, 1),
|
||||
('$7tJoMw1h44n2gxgLUE1T_YinGrLbK0x-TDY1z6M7GBw', 'm.room.message', 'm.text', '1197612733600895076', 0, 0, 1),
|
||||
('$NB6nPgO2tfXyIwwDSF0Ga0BUrsgX1S-0Xl-jAvI8ucU', 'm.room.message', 'm.text', '1202543413652881428', 0, 0, 0),
|
||||
('$OEEK-Wam2FTh6J-6kVnnJ6KnLA_lLRnLTHatKKL62-Y', 'm.room.message', 'm.image', '1207486471489986620', 0, 0, 0);
|
||||
('$OEEK-Wam2FTh6J-6kVnnJ6KnLA_lLRnLTHatKKL62-Y', 'm.room.message', 'm.image', '1207486471489986620', 0, 0, 0),
|
||||
('$mPSzglkCu-6cZHbYro0RW2u5mHvbH9aXDjO5FCzosc0', 'm.room.message', 'm.text', '1210387798297682020', 0, 0, 1);
|
||||
|
||||
INSERT INTO file (discord_url, mxc_url) VALUES
|
||||
('https://cdn.discordapp.com/attachments/497161332244742154/1124628646431297546/image.png', 'mxc://cadence.moe/qXoZktDqNtEGuOCZEADAMvhM'),
|
||||
|
|
|
@ -257,6 +257,18 @@ export namespace R {
|
|||
export type EventRedacted = {
|
||||
event_id: string
|
||||
}
|
||||
|
||||
export type Hierarchy = {
|
||||
avatar_url?: string
|
||||
canonical_alias?: string
|
||||
children_state: {}
|
||||
guest_can_join: boolean
|
||||
join_rule?: string
|
||||
name?: string
|
||||
num_joined_members: number
|
||||
room_id: string
|
||||
room_type?: string
|
||||
}
|
||||
}
|
||||
|
||||
export type Pagination<T> = {
|
||||
|
@ -264,3 +276,8 @@ export type Pagination<T> = {
|
|||
next_batch?: string
|
||||
prev_match?: string
|
||||
}
|
||||
|
||||
export type HierarchyPagination<T> = {
|
||||
rooms: T[]
|
||||
next_batch?: string
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue