feat(chan): use /abyss/:board/:tid path format for thread scroller

This commit is contained in:
2026-09-26 16:07:56 +02:00
parent 875bc9fef2
commit 3d6e762dcc
4 changed files with 41 additions and 20 deletions
+3 -2
View File
@@ -545,15 +545,16 @@ export default new class {
};
async chanAuth(req, res, next) {
const isApi = (req.url?.pathname && req.url.pathname.startsWith('/api/')) || req.headers['x-requested-with'] === 'XMLHttpRequest' || req.headers['accept']?.includes('application/json');
if (!req.session || !req.session.user) {
if (req.headers['x-requested-with'] === 'XMLHttpRequest') {
if (isApi) {
return res.reply({ code: 401, body: JSON.stringify({ success: false, msg: "Unauthorized" }), type: 'application/json' });
}
return res.redirect('/login');
}
const hasGroup = req.session.admin || (Array.isArray(req.session.groups) && req.session.groups.includes('4chan'));
if (!hasGroup) {
if (req.headers['x-requested-with'] === 'XMLHttpRequest') {
if (isApi) {
return res.reply({ code: 403, body: JSON.stringify({ success: false, msg: "4chan group required" }), type: 'application/json' });
}
return res.reply({
+12
View File
@@ -5,6 +5,12 @@ import f0cklib from "../routeinc/f0cklib.mjs";
import { isAnonymizeSession, isAnonSession } from "../settings.mjs";
export default (router, tpl) => {
// Redirect /scroller to /abyss (preserving ID or fragment)
router.get(/^\/scroller(?:\/(?<id>[a-zA-Z0-9_\/-]+))?\/?$/, (req, res) => {
const id = req.params?.id || req.params?.[0];
return res.redirect(id ? `/abyss/${id}` : '/abyss');
});
// Serve the scroller page
router.get(/^\/abyss(?:\/(?<id>[a-zA-Z0-9_\/-]+))?\/?$/, async (req, res) => {
if (cfg.websrv.abyss_enabled === false) return res.reply({ code: 404, body: tpl.render('error', { message: 'Not found', tmp: null }, req) });
@@ -48,6 +54,12 @@ export default (router, tpl) => {
} catch (e) {
console.error('[SCROLLER] Failed to fetch meta for ID:', id, e);
}
} else if (id && /^([a-z0-9]+)\/(\d+)$/i.test(id.trim())) {
const chanMatch = id.trim().match(/^([a-z0-9]+)\/(\d+)$/i);
const [, board, tid] = chanMatch;
page_meta.title = `/${board}/${tid} — Abyss`;
page_meta.description = `Watch /${board}/ thread ${tid} in Abyss`;
page_meta.url = `https://${cfg.main.url.domain}/abyss/${board}/${tid}`;
}
return res.reply({