From c8bf730ec4a63d022c1fc9a472393a7152d70ab0 Mon Sep 17 00:00:00 2001 From: Guzio Date: Sun, 26 Apr 2026 13:07:39 +0000 Subject: [PATCH 1/3] Filter out the root space --- src/web/pug/guild.pug | 5 +++++ src/web/routes/guild.js | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/web/pug/guild.pug b/src/web/pug/guild.pug index 7314cea..a65efad 100644 --- a/src/web/pug/guild.pug +++ b/src/web/pug/guild.pug @@ -257,6 +257,11 @@ block body ul.my8.ml24 each row in removedEncryptedRooms li: a(href=`https://matrix.to/#/${row.room_id}`)= row.name + h3.mt24 Unavailable rooms: Root space + .s-card.p0 + ul.my8.ml24 + each row in removedRootSpaceRooms + li: a(href=`https://matrix.to/#/${row.room_id}`) (#{row.room_type}) #{row.name} h3.mt24 Unavailable rooms: Archived thread p If you still want to link with any of these rooms (eg. you accidentally unlinked it and want to bring it back, or you're migrating from a different bridge that happens to use OOYE's prefixes), please remove the [⛓️] or [🔒⛓️] prefix in Matrix's room settings and refresh the page. .s-card.p0 diff --git a/src/web/routes/guild.js b/src/web/routes/guild.js index 3cd003e..c4fd13c 100644 --- a/src/web/routes/guild.js +++ b/src/web/routes/guild.js @@ -118,8 +118,9 @@ function getPosition(channel, channels) { * @param {DiscordTypes.APIGuild} guild * @param {Ty.R.Hierarchy[]} rooms * @param {string[]} roles + * @param {string?} space */ -function getChannelRoomsLinks(guild, rooms, roles) { +function getChannelRoomsLinks(guild, rooms, roles, space) { let channelIDs = discord.guildChannelMap.get(guild.id) assert(channelIDs) @@ -149,7 +150,7 @@ function getChannelRoomsLinks(guild, rooms, roles) { let linkedRoomIDs = linkedChannels.map(c => c.room_id) let unlinkedRooms = [...rooms] let removedLinkedRooms = dUtils.filterTo(unlinkedRooms, r => !linkedRoomIDs.includes(r.room_id)) - let removedWrongTypeRooms = [] + let removedRootSpaceRooms = dUtils.filterTo(unlinkedRooms, r => r.room_id !== space) let removedEncryptedRooms = dUtils.filterTo(unlinkedRooms, r => !r.encryption && !r["im.nheko.summary.encryption"]) // https://discord.com/developers/docs/topics/threads#active-archived-threads // need to filter out linked archived threads from unlinkedRooms, will just do that by comparing against the name @@ -157,7 +158,7 @@ function getChannelRoomsLinks(guild, rooms, roles) { return { linkedChannelsWithDetails, unlinkedChannels, unlinkedRooms, - removedUncachedChannels, removedWrongTypeChannels, removedPrivateChannels, removedLinkedRooms, removedWrongTypeRooms, removedArchivedThreadRooms, removedEncryptedRooms + removedUncachedChannels, removedWrongTypeChannels, removedPrivateChannels, removedLinkedRooms, removedRootSpaceRooms, removedArchivedThreadRooms, removedEncryptedRooms } } @@ -198,14 +199,14 @@ as.router.get("/guild", defineEventHandler(async event => { // Easy mode guild that hasn't been linked yet - need to remove elements that would require an existing space if (!row.space_id) { - const links = getChannelRoomsLinks(guild, [], roles) + const links = getChannelRoomsLinks(guild, [], roles, row.space_id) return pugSync.render(event, "guild.pug", {guild, guild_id, ...links, ...row}) } // Linked guild const api = getAPI(event) const rooms = await api.getFullHierarchy(row.space_id) - const links = getChannelRoomsLinks(guild, rooms, roles) + const links = getChannelRoomsLinks(guild, rooms, roles, row.space_id) return pugSync.render(event, "guild.pug", {guild, guild_id, ...links, ...row}) })) From 32ba4d838563e5c5d2f788c19ac1429589af8229 Mon Sep 17 00:00:00 2001 From: Guzio Date: Sun, 26 Apr 2026 13:31:08 +0000 Subject: [PATCH 2/3] Finishing touches..... --- src/d2m/actions/create-room.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/d2m/actions/create-room.js b/src/d2m/actions/create-room.js index 2a76f56..f78ab27 100644 --- a/src/d2m/actions/create-room.js +++ b/src/d2m/actions/create-room.js @@ -55,7 +55,7 @@ function convertNameAndTopic(channel, guild, customName) { // @ts-ignore const parentChannel = discord.channels.get(channel.parent_id) let channelPrefix = - ( parentChannel?.type === DiscordTypes.ChannelType.GuildForum ? "[❓] " + ( parentChannel?.type === DiscordTypes.ChannelType.GuildForum ? "" : channel.type === DiscordTypes.ChannelType.PublicThread ? "[⛓️] " : channel.type === DiscordTypes.ChannelType.AnnouncementThread ? "[⛓️] " : channel.type === DiscordTypes.ChannelType.PrivateThread ? "[🔒⛓️] " @@ -64,13 +64,13 @@ function convertNameAndTopic(channel, guild, customName) { const chosenName = customName || (channelPrefix + channel.name); const maybeTopicWithPipe = channel.topic ? ` | ${channel.topic}` : ''; const maybeTopicWithNewlines = channel.topic ? `${channel.topic}\n\n` : ''; + const maybeWithin = parentChannel ? `Within: ${parentChannel.name} (ID: ${parentChannel.id})\n` : ''; const channelIDPart = `Channel ID: ${channel.id}`; const guildIDPart = `Guild ID: ${guild.id}`; - const maybeThreadWithinPart = parentChannel ? `Thread within: ${parentChannel.name} (ID: ${parentChannel.id})\n` : ''; const convertedTopic = customName - ? `#${channel.name}${maybeTopicWithPipe}\n\n${channelIDPart}\n${maybeThreadWithinPart}${guildIDPart}` - : `${maybeTopicWithNewlines}${channelIDPart}\n${maybeThreadWithinPart}${guildIDPart}`; + ? `#${channel.name}${maybeTopicWithPipe}\n\n${maybeWithin}${channelIDPart}\n${guildIDPart}` + : `${maybeTopicWithNewlines}${maybeWithin}${channelIDPart}\n${guildIDPart}`; return [chosenName, convertedTopic]; } From ea94dfe6b9cc48961ef71dab48bfdce031f968c6 Mon Sep 17 00:00:00 2001 From: Guzio Date: Sun, 26 Apr 2026 14:12:13 +0000 Subject: [PATCH 3/3] Fighting the demons of my past TECHNICALLY, I was asked to remove it. But now that I know that @template is a thing that exists in JSDoc (which was the one missing ingredient the last time), I think I can get this to be good enough that removal won't even be necessary, and now it just looks like regular, sane documentation (not the any-schizopost like last time). --- src/m2d/event-dispatcher.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/m2d/event-dispatcher.js b/src/m2d/event-dispatcher.js index 0849a93..f7191be 100644 --- a/src/m2d/event-dispatcher.js +++ b/src/m2d/event-dispatcher.js @@ -158,13 +158,17 @@ async function sendError(roomID, source, type, e, payload) { } /** - * @param {string} type - * @param {(event: Ty.Event.Outer & {type: any, redacts:any, state_key:any}, ...args: any)=>any} fn + * Wraps the function with an automated error catching and reporting mechanism + * @template {Ty.Event.Outer} EVENT The event that the wrapped function processes, its first argument. + * @template {[]} ARGS Other arguments of the wrapped function + * @template RETURNS The output of the wrapped function + * @param {string} type Type of the event, during the processing of which the error may occur. + * @param {(event: EVENT, ...args: ARGS)=>RETURNS|Promise} fn Function to wrap + * @returns {(event: EVENT, ...args: ARGS)=>Promise} Wrapped function */ function guard(type, fn) { - return async function(/** @type {Ty.Event.Outer} */ event, /** @type {any} */ ...args) { + return async function(event, ...args) { try { - // @ts-ignore return await fn(event, ...args) } catch (e) { await sendError(event.room_id, "Matrix", type, e, event)