add option to have public nsfw/nsfl

This commit is contained in:
2026-06-03 13:07:24 +02:00
parent adc8431522
commit d5de02511b
3 changed files with 10 additions and 3 deletions

View File

@@ -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",

View File

@@ -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

View File

@@ -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 = {