From 9cbeef9efb6970b12ff2cf76b5d1e3ed3d6b7e38 Mon Sep 17 00:00:00 2001 From: Guzio Date: Sun, 26 Apr 2026 09:42:11 +0000 Subject: [PATCH 1/2] fell asleep --- src/web/routes/guild.js | 5 ++++- src/web/routes/link.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/web/routes/guild.js b/src/web/routes/guild.js index a8be516..78cf7a5 100644 --- a/src/web/routes/guild.js +++ b/src/web/routes/guild.js @@ -211,7 +211,10 @@ as.router.get("/guild", defineEventHandler(async event => { as.router.get("/explain", defineEventHandler(async event => { const {type} = await getValidatedQuery(event, schema.explain.parse) - const msg = type+" is unsupported" //TODO: actually explain (I'm sure I messed something up anyway, I'll leave it for now) + const rule = linkRules.get(Number.parseInt(type)) + if (!rule) return pugSync.render(event, "explain.pug", {msg: "You cannot bridge type-" + type + " channels because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) + else if (rule.unsupported) throw createError({status:400, message: "Bad Request", data: "You cannot bridge " + (rule ? (rule.humanName+"(type-" + channel.type+" channels)") : ("unknown-type ("+channel.type+") channels")) + " because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) + else throw createError({status:400, message: "Bad Request", data: "You cannot bridge " + (rule ? (rule.humanName+"(type-" + channel.type+" channels)") : ("unknown-type ("+channel.type+") channels")) + " because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) return pugSync.render(event, "explain.pug", {msg}) })) diff --git a/src/web/routes/link.js b/src/web/routes/link.js index 2992249..8394a9e 100644 --- a/src/web/routes/link.js +++ b/src/web/routes/link.js @@ -201,7 +201,7 @@ as.router.post("/api/link", defineEventHandler(async event => { //Ensure link rules are upheld const rule = guildRoute.linkRules.get(channel.type) - if (!rule || rule.unsupported) throw createError({status:400, message: "Bad Request", data: "You cannot bridge " + (rule ? (rule.humanName+"(type-" + channel.type+" channels)") : ("unknown-type ("+channel.type+") channels")) + " because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) + if (!rule || rule.unsupported) throw createError({status:400, message: "Bad Request", data: "You cannot bridge " + (rule ? (rule.humanName+"(type-"+channel.type+" channels)") : ("unknown-type ("+channel.type+") channels")) + " because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) else if (foundSpace && rule.type === "TYPING") throw createError({status: 400, message: "Bad Request", data: "Matrix room cannot be of type m.space when bridging to "+rule.humanName}) else if (!foundSpace && rule.type === "SPACE") throw createError({status: 400, message: "Bad Request", data: "Matrix room must be of type m.space when bridging to "+rule.humanName}) From 511138e31fbb23b5bf10e663a752e2dbcc4aee4e Mon Sep 17 00:00:00 2001 From: Guzio Date: Sun, 26 Apr 2026 09:57:26 +0000 Subject: [PATCH 2/2] Link Rules system DONE! --- src/web/routes/guild.js | 7 +++---- src/web/routes/link.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/web/routes/guild.js b/src/web/routes/guild.js index 78cf7a5..adf85d9 100644 --- a/src/web/routes/guild.js +++ b/src/web/routes/guild.js @@ -212,10 +212,9 @@ as.router.get("/guild", defineEventHandler(async event => { as.router.get("/explain", defineEventHandler(async event => { const {type} = await getValidatedQuery(event, schema.explain.parse) const rule = linkRules.get(Number.parseInt(type)) - if (!rule) return pugSync.render(event, "explain.pug", {msg: "You cannot bridge type-" + type + " channels because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) - else if (rule.unsupported) throw createError({status:400, message: "Bad Request", data: "You cannot bridge " + (rule ? (rule.humanName+"(type-" + channel.type+" channels)") : ("unknown-type ("+channel.type+") channels")) + " because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) - else throw createError({status:400, message: "Bad Request", data: "You cannot bridge " + (rule ? (rule.humanName+"(type-" + channel.type+" channels)") : ("unknown-type ("+channel.type+") channels")) + " because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) - return pugSync.render(event, "explain.pug", {msg}) + if (!rule) return pugSync.render(event, "explain.pug", {msg: "You cannot bridge to type-" + type + " channels because OOYE doesn't even know what they are yet."}) + else if (rule.unsupported) return pugSync.render(event, "explain.pug", {msg: "You cannot bridge to " + rule.humanName + " (type-" + type + " channels) because: " + rule.unsupported}) + else return pugSync.render(event, "explain.pug", {msg: "You can bridge to " + rule.humanName + " (type-" + type + " channels) just fine. Why are you even here?"}) })) as.router.get("/qr", defineEventHandler(async event => { diff --git a/src/web/routes/link.js b/src/web/routes/link.js index 8394a9e..1ec34a5 100644 --- a/src/web/routes/link.js +++ b/src/web/routes/link.js @@ -201,7 +201,7 @@ as.router.post("/api/link", defineEventHandler(async event => { //Ensure link rules are upheld const rule = guildRoute.linkRules.get(channel.type) - if (!rule || rule.unsupported) throw createError({status:400, message: "Bad Request", data: "You cannot bridge " + (rule ? (rule.humanName+"(type-"+channel.type+" channels)") : ("unknown-type ("+channel.type+") channels")) + " because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) + if (!rule || rule.unsupported) throw createError({status:400, message: "Bad Request", data: "You cannot bridge to " + (rule ? (rule.humanName+"(type-"+channel.type+" channels)") : ("unknown-type ("+channel.type+") channels")) + " because: " + (rule ? rule.unsupported : "OOYE doesn't even know what they are yet.")}) else if (foundSpace && rule.type === "TYPING") throw createError({status: 400, message: "Bad Request", data: "Matrix room cannot be of type m.space when bridging to "+rule.humanName}) else if (!foundSpace && rule.type === "SPACE") throw createError({status: 400, message: "Bad Request", data: "Matrix room must be of type m.space when bridging to "+rule.humanName})