getting things ready for release
This commit is contained in:
@@ -593,6 +593,23 @@ export default router => {
|
||||
}
|
||||
});
|
||||
|
||||
// Update alternative infobox preference (per-user toggle for the rich author block)
|
||||
group.put(/\/alternative_infobox/, lib.loggedin, async (req, res) => {
|
||||
const use_alternative_infobox = req.post.use_alternative_infobox === true || req.post.use_alternative_infobox === 'true';
|
||||
try {
|
||||
await db`
|
||||
update user_options
|
||||
set use_alternative_infobox = ${use_alternative_infobox}
|
||||
where user_id = ${+req.session.id}
|
||||
`;
|
||||
if (req.session) req.session.use_alternative_infobox = use_alternative_infobox;
|
||||
return res.json({ success: true, use_alternative_infobox }, 200);
|
||||
} catch (e) {
|
||||
console.error('Update alternative_infobox error:', e);
|
||||
return res.json({ success: false, msg: 'Error updating preference' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// Update per-user language preference
|
||||
group.put(/\/language/, lib.loggedin, async (req, res) => {
|
||||
if (cfg.websrv.allow_language_change === false) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import fs from "fs/promises";
|
||||
export default (router, tpl) => {
|
||||
// Main Halls Overview
|
||||
router.get(/^\/halls$/, async (req, res) => {
|
||||
if (cfg.websrv.halls_enabled === false) return res.reply({ code: 404, body: tpl.render('error', { message: 'Not found', tmp: null }, req) });
|
||||
const mode = req.mode ?? 0;
|
||||
const excludedTags = req.session ? (req.session.excluded_tags || []) : [];
|
||||
|
||||
|
||||
@@ -202,6 +202,11 @@ export default (router, tpl) => {
|
||||
const tRouteStart = Date.now();
|
||||
const mode = req.params.itemid ? 'item' : 'index';
|
||||
|
||||
// Feature flag guards for disabled features
|
||||
if (cfg.websrv.halls_enabled === false && req.params.hall) {
|
||||
return res.reply({ code: 404, body: tpl.render('error', { message: 'Not found', tmp: null }, req) });
|
||||
}
|
||||
|
||||
// Auto-persist strict mode from URL to session if it's there
|
||||
if (req.session && (req.query?.strict !== undefined || req.url.qs?.strict !== undefined)) {
|
||||
req.session.strict_mode = (req.query?.strict === '1' || req.url.qs?.strict === '1');
|
||||
@@ -341,6 +346,8 @@ export default (router, tpl) => {
|
||||
data.current_hall_slug = (data.tmp && data.tmp.hall && typeof data.tmp.hall === 'object') ? data.tmp.hall.slug : (data.tmp && data.tmp.hall ? data.tmp.hall : '');
|
||||
data.current_user_hall_slug = (data.tmp && data.tmp.userHall && typeof data.tmp.userHall === 'object') ? data.tmp.userHall.slug : (data.tmp && data.tmp.userHall ? data.tmp.userHall : '');
|
||||
data.current_user_hall_owner = (data.tmp && data.tmp.userHallOwner) ? data.tmp.userHallOwner : '';
|
||||
// Per-user alternative infobox preference overrides the site-wide config default
|
||||
if (session) data.user_alternative_infobox = !!session.use_alternative_infobox;
|
||||
}
|
||||
|
||||
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
|
||||
|
||||
@@ -5,6 +5,7 @@ import lib from "../lib.mjs";
|
||||
export default (router, tpl) => {
|
||||
// Serve the scroller page
|
||||
router.get(/^\/abyss\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.abyss_enabled === false) return res.reply({ code: 404, body: tpl.render('error', { message: 'Not found', tmp: null }, req) });
|
||||
if (cfg.websrv.private_society && !req.session) {
|
||||
return res.reply({ code: 502, body: '<html><body>502 Bad Gateway</body></html>' });
|
||||
}
|
||||
@@ -26,6 +27,7 @@ export default (router, tpl) => {
|
||||
// Lightweight meta refresh — returns live counts + tags for a batch of item IDs
|
||||
// GET /api/v2/scroller/meta?ids=1,2,3
|
||||
router.get(/^\/api\/v2\/scroller\/meta\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.abyss_enabled === false) return res.reply({ code: 404, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ success: false }) });
|
||||
if (cfg.websrv.private_society && !req.session) {
|
||||
return res.reply({ code: 502, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}) });
|
||||
}
|
||||
@@ -66,6 +68,7 @@ export default (router, tpl) => {
|
||||
|
||||
// Tag autocomplete endpoint
|
||||
router.get(/^\/api\/v2\/scroller\/tags\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.abyss_enabled === false) return res.reply({ code: 404, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify([]) });
|
||||
if (cfg.websrv.private_society && !req.session) {
|
||||
return res.reply({ code: 502, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify([]) });
|
||||
}
|
||||
@@ -97,6 +100,11 @@ export default (router, tpl) => {
|
||||
|
||||
// JSON API: returns a batch of items for the scroller
|
||||
router.get(/^\/api\/v2\/scroller\/feed\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.abyss_enabled === false) return res.reply({
|
||||
code: 404,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ success: false, items: [] })
|
||||
});
|
||||
if (cfg.websrv.private_society && !req.session) {
|
||||
return res.reply({
|
||||
code: 502,
|
||||
|
||||
@@ -43,6 +43,7 @@ export default (router, tpl) => {
|
||||
|
||||
// List halls for a user
|
||||
router.get(/^\/user\/(?<owner>[^/]+)\/halls\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.userhalls_enabled === false) return res.reply({ code: 404, body: tpl.render('error', { message: 'Not found', tmp: null }, req) });
|
||||
const ownerName = decodeURIComponent(req.params.owner);
|
||||
const mode = req.mode ?? 0;
|
||||
const excludedTags = req.session ? (req.session.excluded_tags || []) : [];
|
||||
@@ -79,6 +80,7 @@ export default (router, tpl) => {
|
||||
|
||||
// Item grid for a user hall
|
||||
router.get(/^\/user\/(?<owner>[^/]+)\/hall\/(?<slug>[^/]+)(?:\/p\/(?<page>\d+))?\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.userhalls_enabled === false) return res.reply({ code: 404, body: tpl.render('error', { message: 'Not found', tmp: null }, req) });
|
||||
const ownerName = decodeURIComponent(req.params.owner);
|
||||
const slug = decodeURIComponent(req.params.slug);
|
||||
|
||||
@@ -124,6 +126,7 @@ export default (router, tpl) => {
|
||||
|
||||
// Single item within a user hall
|
||||
router.get(/^\/user\/(?<owner>[^/]+)\/hall\/(?<slug>[^/]+)\/(?<itemid>\d+)\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.userhalls_enabled === false) return res.reply({ code: 404, body: tpl.render('error', { message: 'Not found', tmp: null }, req) });
|
||||
const ownerName = decodeURIComponent(req.params.owner);
|
||||
const slug = decodeURIComponent(req.params.slug);
|
||||
|
||||
@@ -249,6 +252,7 @@ export default (router, tpl) => {
|
||||
|
||||
// ── API: list own halls (for modal) ────────────────────────────────────────
|
||||
router.get(/^\/api\/v2\/me\/halls\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.userhalls_enabled === false) return res.writeHead(404, { 'Content-Type': 'application/json' }).end(JSON.stringify({ success: false }));
|
||||
if (!requireLogin(req, res)) return;
|
||||
try {
|
||||
const halls = await f0cklib.getUserHalls(req.session.id, 3, [], req.session.id);
|
||||
@@ -261,6 +265,7 @@ export default (router, tpl) => {
|
||||
|
||||
// ── API: create hall ────────────────────────────────────────────────────────
|
||||
router.post(/^\/api\/v2\/me\/halls\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.userhalls_enabled === false) return res.writeHead(404, { 'Content-Type': 'application/json' }).end(JSON.stringify({ success: false }));
|
||||
if (!requireLogin(req, res)) return;
|
||||
const name = (req.post.name || '').trim();
|
||||
const slug = slugify(req.post.slug || name);
|
||||
@@ -279,6 +284,7 @@ export default (router, tpl) => {
|
||||
|
||||
// ── API: update hall ────────────────────────────────────────────────────────
|
||||
router.patch(/^\/api\/v2\/me\/halls\/(?<slug>[^/]+)\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.userhalls_enabled === false) return res.writeHead(404, { 'Content-Type': 'application/json' }).end(JSON.stringify({ success: false }));
|
||||
if (!requireLogin(req, res)) return;
|
||||
const slug = decodeURIComponent(req.params.slug);
|
||||
const { name, slug: newSlugRaw, description, is_private } = req.post;
|
||||
@@ -297,6 +303,7 @@ export default (router, tpl) => {
|
||||
|
||||
// ── API: delete hall ────────────────────────────────────────────────────────
|
||||
router.delete(/^\/api\/v2\/me\/halls\/(?<slug>[^/]+)\/?$/, async (req, res) => {
|
||||
if (cfg.websrv.userhalls_enabled === false) return res.writeHead(404, { 'Content-Type': 'application/json' }).end(JSON.stringify({ success: false }));
|
||||
if (!requireLogin(req, res)) return;
|
||||
const slug = decodeURIComponent(req.params.slug);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user