This commit is contained in:
2026-08-13 21:38:51 +02:00
parent 22db479bc2
commit 82298681af
2 changed files with 10 additions and 13 deletions
+2 -11
View File
@@ -797,19 +797,10 @@ export default router => {
let guestTagFilter = db``;
if (!session) {
const nsflId = parseInt(cfg.nsfl_tag_id, 10) || 3;
const itemRatingTags = await db`SELECT tag_id FROM tags_assign WHERE item_id = ${+id} AND tag_id IN (1, 2, ${nsflId})`;
const hasRatingTag = itemRatingTags.length > 0;
if (!hasRatingTag && !cfg.websrv.public_untagged) {
return res.json({ success: false, msg: 'no items found' });
}
if (cfg.websrv.public_nsfw) {
guestTagFilter = cfg.websrv.public_untagged
? db`and (id in (select item_id from tags_assign where tag_id in (1, 2)) or not exists (select 1 from tags_assign where item_id = items.id and tag_id in (1, 2, ${nsflId})))`
: db`and id in (select item_id from tags_assign where tag_id in (1, 2))`;
guestTagFilter = db`and not exists (select 1 from tags_assign where item_id = items.id and tag_id = ${nsflId})`;
} else {
guestTagFilter = cfg.websrv.public_untagged
? db`and (id in (select item_id from tags_assign where tag_id = 1) or not exists (select 1 from tags_assign where item_id = items.id and tag_id in (1, 2, ${nsflId})))`
: db`and id in (select item_id from tags_assign where tag_id = 1)`;
guestTagFilter = db`and not exists (select 1 from tags_assign where item_id = items.id and tag_id in (2, ${nsflId}))`;
}
}