This commit is contained in:
2026-08-09 03:24:21 +02:00
parent 3e20394c85
commit a8a093450f
2 changed files with 33 additions and 4 deletions
+15 -2
View File
@@ -780,17 +780,30 @@ export default router => {
});
}
let guestTagFilter = db``;
if (!session) {
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))`
: db`and id in (select item_id from tags_assign where tag_id in (1, 2))`;
} 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))`
: db`and id in (select item_id from tags_assign where tag_id = 1)`;
}
}
const next = await db`
select id
from "items"
where id > ${+id} and active = true and coalesce(visibility, 0) = 0
where id > ${+id} and active = true and coalesce(visibility, 0) = 0 ${guestTagFilter}
order by id
limit 1
`;
const prev = await db`
select id
from "items"
where id < ${+id} and active = true and coalesce(visibility, 0) = 0
where id < ${+id} and active = true and coalesce(visibility, 0) = 0 ${guestTagFilter}
order by id desc
limit 1
`;