From b9c7e24757bdc0b1d5d1c1314e8bba1756d74335 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Sun, 9 Aug 2026 02:54:26 +0200 Subject: [PATCH] hgdf --- config_example.json | 1 + src/inc/routeinc/f0cklib.mjs | 6 +++++- src/inc/routes/apiv2/index.mjs | 6 +++++- src/inc/routes/comments.mjs | 6 ++++-- src/index.mjs | 1 + views/item-partial-legacy.html | 2 +- views/item-partial-modern.html | 2 +- 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/config_example.json b/config_example.json index b2d9090..7df3fba 100644 --- a/config_example.json +++ b/config_example.json @@ -129,6 +129,7 @@ "user_alternative_infobox": false, "user_banner_enabled": true, "user_alternative_steuerung": false, + "expose_repost_links_to_guests": false, "enable_swf": false, "swf_thumb": "/s/img/swf.png", "enable_archive": true, diff --git a/src/inc/routeinc/f0cklib.mjs b/src/inc/routeinc/f0cklib.mjs index 091e5e8..3fc7d37 100644 --- a/src/inc/routeinc/f0cklib.mjs +++ b/src/inc/routeinc/f0cklib.mjs @@ -7,7 +7,11 @@ import queue from "../queue.mjs"; import fs from "fs"; import url from "url"; -const getGlobalfilter = () => cfg.nsfp?.length ? cfg.nsfp.map(n => `tag_id = ${n}`).join(" or ") : null; +const getGlobalfilter = () => { + if (!cfg.nsfp?.length) return null; + const filteredTags = cfg.websrv.public_nsfw ? cfg.nsfp.filter(id => id !== 2) : cfg.nsfp; + return filteredTags.length ? filteredTags.map(n => `tag_id = ${n}`).join(" or ") : null; +}; // All MIME types that map to the 'swf' extension in config (e.g. application/x-shockwave-flash, application/vnd.adobe.flash.movie) const flashMimes = Object.entries(cfg.mimes || {}).filter(([, ext]) => ext === 'swf').map(([mime]) => mime); diff --git a/src/inc/routes/apiv2/index.mjs b/src/inc/routes/apiv2/index.mjs index c08f62a..c13720a 100644 --- a/src/inc/routes/apiv2/index.mjs +++ b/src/inc/routes/apiv2/index.mjs @@ -13,7 +13,11 @@ import { purgeExpiredUploads } from '../../lib_delete.mjs'; import { calculateExpiresAt } from './upload.mjs'; const allowedMimes = ["audio", "image", "video", "%"]; -const getGlobalfilter = () => cfg.nsfp?.length ? cfg.nsfp.map(n => `tag_id = ${n}`).join(' or ') : null; +const getGlobalfilter = () => { + if (!cfg.nsfp?.length) return null; + const filteredTags = cfg.websrv.public_nsfw ? cfg.nsfp.filter(id => id !== 2) : cfg.nsfp; + return filteredTags.length ? filteredTags.map(n => `tag_id = ${n}`).join(' or ') : null; +}; const metaCache = new Map(); const MAX_META_CACHE = 2000; diff --git a/src/inc/routes/comments.mjs b/src/inc/routes/comments.mjs index 44023c2..a7e10e8 100644 --- a/src/inc/routes/comments.mjs +++ b/src/inc/routes/comments.mjs @@ -156,7 +156,8 @@ export default (router, tpl) => { } - const globalfilter = cfg.nsfp.map(n => `tag_id = ${n}`).join(' or '); + const globalfilterTags = cfg.websrv.public_nsfw ? (cfg.nsfp || []).filter(id => id !== 2) : (cfg.nsfp || []); + const globalfilter = globalfilterTags.length ? globalfilterTags.map(n => `tag_id = ${n}`).join(' or ') : null; const excludedTags = req.session ? (req.session.excluded_tags || []) : []; /* */ // prioritize query mode (from AJAX) over session default @@ -1001,7 +1002,8 @@ export default (router, tpl) => { // Build mode SQL — replace items.id alias with i.id used in the activity query const modequery = (multiRatingSQL ?? lib.getMode(mode)).replace(/items\.id/g, 'i.id'); - const globalfilter = cfg.nsfp.map(n => `tag_id = ${n}`).join(' or '); + const globalfilterTags = cfg.websrv.public_nsfw ? (cfg.nsfp || []).filter(id => id !== 2) : (cfg.nsfp || []); + const globalfilter = globalfilterTags.length ? globalfilterTags.map(n => `tag_id = ${n}`).join(' or ') : null; const excludedTags = req.session ? (req.session.excluded_tags || []) : []; const comments = await db` diff --git a/src/index.mjs b/src/index.mjs index 7178f7e..2a5c9a9 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -1428,6 +1428,7 @@ process.on('uncaughtException', err => { scroller_mime_cats: Array.isArray(cfg.allowedMimes) ? cfg.allowedMimes.filter(c => ['video','image','audio'].includes(c)) : ['video','image','audio'], themes_json: JSON.stringify(cfg.websrv.themes || []), enable_profile_description: !!cfg.websrv.enable_profile_description, + expose_repost_links_to_guests: !!(cfg.websrv.expose_repost_links_to_guests || cfg.websrv.expose_repost_links), get private_messages() { return getPrivateMessages(); }, get dm_attachments() { return getDmAttachments(); }, get dm_unencrypted() { return getDmUnencrypted(); }, diff --git a/views/item-partial-legacy.html b/views/item-partial-legacy.html index 7e21624..7d67099 100644 --- a/views/item-partial-legacy.html +++ b/views/item-partial-legacy.html @@ -329,7 +329,7 @@
{{ item.checksum.split('_bypass_')[0] }}
@endif - @if(item.is_repost || (item.reposts && item.reposts.length > 0)) + @if((session || expose_repost_links_to_guests) && (item.is_repost || (item.reposts && item.reposts.length > 0))) Repost diff --git a/views/item-partial-modern.html b/views/item-partial-modern.html index 74b4b7f..5498fce 100644 --- a/views/item-partial-modern.html +++ b/views/item-partial-modern.html @@ -274,7 +274,7 @@
{{ item.checksum.split('_bypass_')[0] }}
@endif - @if(item.is_repost || (item.reposts && item.reposts.length > 0)) + @if((session || expose_repost_links_to_guests) && (item.is_repost || (item.reposts && item.reposts.length > 0))) Repost