forked from cadence/out-of-your-element
Compare commits
No commits in common. "ea94dfe6b9cc48961ef71dab48bfdce031f968c6" and "41c2131061c04956d1c476a5dad2a14567c737bd" have entirely different histories.
ea94dfe6b9
...
41c2131061
4 changed files with 13 additions and 23 deletions
|
|
@ -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${maybeWithin}${channelIDPart}\n${guildIDPart}`
|
||||
: `${maybeTopicWithNewlines}${maybeWithin}${channelIDPart}\n${guildIDPart}`;
|
||||
? `#${channel.name}${maybeTopicWithPipe}\n\n${channelIDPart}\n${maybeThreadWithinPart}${guildIDPart}`
|
||||
: `${maybeTopicWithNewlines}${channelIDPart}\n${maybeThreadWithinPart}${guildIDPart}`;
|
||||
|
||||
return [chosenName, convertedTopic];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,17 +158,13 @@ async function sendError(roomID, source, type, e, payload) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Wraps the function with an automated error catching and reporting mechanism
|
||||
* @template {Ty.Event.Outer<any>} 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<RETURNS>} fn Function to wrap
|
||||
* @returns {(event: EVENT, ...args: ARGS)=>Promise<RETURNS|undefined>} Wrapped function
|
||||
* @param {string} type
|
||||
* @param {(event: Ty.Event.Outer<any> & {type: any, redacts:any, state_key:any}, ...args: any)=>any} fn
|
||||
*/
|
||||
function guard(type, fn) {
|
||||
return async function(event, ...args) {
|
||||
return async function(/** @type {Ty.Event.Outer<any>} */ event, /** @type {any} */ ...args) {
|
||||
try {
|
||||
// @ts-ignore
|
||||
return await fn(event, ...args)
|
||||
} catch (e) {
|
||||
await sendError(event.room_id, "Matrix", type, e, event)
|
||||
|
|
|
|||
|
|
@ -257,11 +257,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -118,9 +118,8 @@ function getPosition(channel, channels) {
|
|||
* @param {DiscordTypes.APIGuild} guild
|
||||
* @param {Ty.R.Hierarchy[]} rooms
|
||||
* @param {string[]} roles
|
||||
* @param {string?} space
|
||||
*/
|
||||
function getChannelRoomsLinks(guild, rooms, roles, space) {
|
||||
function getChannelRoomsLinks(guild, rooms, roles) {
|
||||
let channelIDs = discord.guildChannelMap.get(guild.id)
|
||||
assert(channelIDs)
|
||||
|
||||
|
|
@ -150,7 +149,7 @@ function getChannelRoomsLinks(guild, rooms, roles, space) {
|
|||
let linkedRoomIDs = linkedChannels.map(c => c.room_id)
|
||||
let unlinkedRooms = [...rooms]
|
||||
let removedLinkedRooms = dUtils.filterTo(unlinkedRooms, r => !linkedRoomIDs.includes(r.room_id))
|
||||
let removedRootSpaceRooms = dUtils.filterTo(unlinkedRooms, r => r.room_id !== space)
|
||||
let removedWrongTypeRooms = []
|
||||
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
|
||||
|
|
@ -158,7 +157,7 @@ function getChannelRoomsLinks(guild, rooms, roles, space) {
|
|||
|
||||
return {
|
||||
linkedChannelsWithDetails, unlinkedChannels, unlinkedRooms,
|
||||
removedUncachedChannels, removedWrongTypeChannels, removedPrivateChannels, removedLinkedRooms, removedRootSpaceRooms, removedArchivedThreadRooms, removedEncryptedRooms
|
||||
removedUncachedChannels, removedWrongTypeChannels, removedPrivateChannels, removedLinkedRooms, removedWrongTypeRooms, removedArchivedThreadRooms, removedEncryptedRooms
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,14 +198,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, row.space_id)
|
||||
const links = getChannelRoomsLinks(guild, [], roles)
|
||||
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, row.space_id)
|
||||
const links = getChannelRoomsLinks(guild, rooms, roles)
|
||||
return pugSync.render(event, "guild.pug", {guild, guild_id, ...links, ...row})
|
||||
}))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue