diff --git a/config_example.json b/config_example.json index 0638e29..9f969b8 100644 --- a/config_example.json +++ b/config_example.json @@ -126,6 +126,7 @@ "open_registration_require_mail_andor_token": false, "private_society": false, "private_society_gate": "cloudflare", + "public_nsfw": false, "paths": { "images": "/b", "thumbnails": "/t", diff --git a/src/index.mjs b/src/index.mjs index 7140bda..e4b9e87 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -663,9 +663,14 @@ process.on('uncaughtException', err => { const queryMode = req.url.qs?.mode !== undefined ? +req.url.qs.mode : undefined; req.mode = queryMode !== undefined ? queryMode : (req.session ? +(req.session.mode ?? 0) : +(req.cookies?.mode ?? 0)); - // Guest protection: Strictly enforce SFW mode (0) for non-logged-in users + // public_nsfw: when true, the *default* for guests is mode 3 (all content). + // Only applies when the guest has no explicit mode preference (no ?mode= param, no cookie). + // If the guest has chosen a filter (e.g. SFW), that choice is always respected. if (!req.session) { - req.mode = 0; + const hasExplicitMode = queryMode !== undefined || req.cookies?.mode !== undefined; + if (!hasExplicitMode) { + req.mode = cfg.websrv.public_nsfw ? 3 : 0; + } } // Private Society gate — require login for all content when enabled diff --git a/views/snippets/footer.html b/views/snippets/footer.html index 54ed0df..29ebd7a 100644 --- a/views/snippets/footer.html +++ b/views/snippets/footer.html @@ -416,7 +416,8 @@ dm_attachments: @if(dm_attachments) true @else false @endif, dm_unencrypted: @if(dm_unencrypted) true @else false @endif, allow_comment_deletion: @if(allow_comment_deletion) true @else false @endif, - enable_comment_polls: @if(enable_comment_polls) true @else false @endif + enable_comment_polls: @if(enable_comment_polls) true @else false @endif, + mode: {{ mode !== undefined ? mode : 0 }} }; window.f0ckDebug = window.f0ckSession.development ? console.log.bind(console) : () => {}; window.f0ckI18n = {