|
|
|
|
@@ -252,6 +252,7 @@ export default {
|
|
|
|
|
${hallFilter}
|
|
|
|
|
${userHallFilter}
|
|
|
|
|
${!session && getGlobalfilter() ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(getGlobalfilter())}))` : db``}
|
|
|
|
|
${!session && cfg.websrv.public_untagged === false ? db`and exists (select 1 from tags_assign where item_id = items.id)` : db``}
|
|
|
|
|
${excludedTags.length > 0 ? db`and not exists (select 1 from tags_assign where item_id = items.id and tag_id = any(${excludedTags}::int[]))` : db``}
|
|
|
|
|
${newerThan ? db`and items.id > ${newerThan}` : db``}
|
|
|
|
|
${xdFilter}
|
|
|
|
|
@@ -294,6 +295,7 @@ export default {
|
|
|
|
|
${hallFilter}
|
|
|
|
|
${userHallFilter}
|
|
|
|
|
${!session && getGlobalfilter() ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(getGlobalfilter())}))` : db``}
|
|
|
|
|
${!session && cfg.websrv.public_untagged === false ? db`and exists (select 1 from tags_assign where item_id = items.id)` : db``}
|
|
|
|
|
${excludedTags.length > 0 ? db`and not exists (select 1 from tags_assign where item_id = items.id and tag_id = any(${excludedTags}::int[]))` : db``}
|
|
|
|
|
${newerThan ? db`and items.id > ${newerThan}` : db``}
|
|
|
|
|
${xdFilter}
|
|
|
|
|
@@ -516,6 +518,7 @@ export default {
|
|
|
|
|
${!fav && user ? db`and items.username ilike ${user}` : db``}
|
|
|
|
|
${mimeSQL}
|
|
|
|
|
${!session && getGlobalfilter() ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(getGlobalfilter())}))` : db``}
|
|
|
|
|
${!session && cfg.websrv.public_untagged === false ? db`and exists (select 1 from tags_assign where item_id = items.id)` : db``}
|
|
|
|
|
${excludedTags.length > 0 ? db`and not exists (select 1 from tags_assign where item_id = items.id and tag_id = any(${excludedTags}::int[]))` : db``}
|
|
|
|
|
`;
|
|
|
|
|
};
|
|
|
|
|
@@ -552,6 +555,7 @@ export default {
|
|
|
|
|
items.id = ${itemid} and
|
|
|
|
|
items.active = true
|
|
|
|
|
${!session && getGlobalfilter() ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(getGlobalfilter())}))` : db``}
|
|
|
|
|
${!session && cfg.websrv.public_untagged === false ? db`and exists (select 1 from tags_assign where item_id = items.id)` : db``}
|
|
|
|
|
limit 1
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
@@ -569,7 +573,7 @@ export default {
|
|
|
|
|
|
|
|
|
|
if (!actitem) {
|
|
|
|
|
// Item not found or filtered out - check if it exists but was filtered (for OG meta tags)
|
|
|
|
|
if (!session && getGlobalfilter()) {
|
|
|
|
|
if (!session && (getGlobalfilter() || cfg.websrv.public_untagged === false)) {
|
|
|
|
|
const unfilteredItem = await db`
|
|
|
|
|
select id from items where id = ${itemid} and active = true limit 1
|
|
|
|
|
`;
|
|
|
|
|
@@ -925,6 +929,7 @@ export default {
|
|
|
|
|
AND items.title IS NOT NULL
|
|
|
|
|
${mimeSQL}
|
|
|
|
|
${!session && getGlobalfilter() ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(getGlobalfilter())}))` : db``}
|
|
|
|
|
${!session && cfg.websrv.public_untagged === false ? db`and exists (select 1 from tags_assign where item_id = items.id)` : db``}
|
|
|
|
|
${excludedTags.length > 0 ? db`and not exists (select 1 from tags_assign where item_id = items.id and tag_id = any(${excludedTags}::int[]))` : db``}
|
|
|
|
|
ORDER BY random()
|
|
|
|
|
LIMIT 1
|
|
|
|
|
@@ -945,6 +950,7 @@ export default {
|
|
|
|
|
and items.active = true
|
|
|
|
|
${mimeSQL}
|
|
|
|
|
${!session && getGlobalfilter() ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(getGlobalfilter())}))` : db``}
|
|
|
|
|
${!session && cfg.websrv.public_untagged === false ? db`and exists (select 1 from tags_assign where item_id = items.id)` : db``}
|
|
|
|
|
group by items.id
|
|
|
|
|
order by random()
|
|
|
|
|
limit 1
|
|
|
|
|
@@ -987,6 +993,7 @@ export default {
|
|
|
|
|
${hall ? db`and items.id in (select item_id from halls_assign ha join halls h on h.id = ha.hall_id where h.slug = ${hall})` : db``}
|
|
|
|
|
${mimeSQL}
|
|
|
|
|
${!session && getGlobalfilter() ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(getGlobalfilter())}))` : db``}
|
|
|
|
|
${!session && cfg.websrv.public_untagged === false ? db`and exists (select 1 from tags_assign where item_id = items.id)` : db``}
|
|
|
|
|
${excludedTags.length > 0 ? db`and not exists (select 1 from tags_assign where item_id = items.id and tag_id = any(${excludedTags}::int[]))` : db``}
|
|
|
|
|
group by items.id, tags.tag
|
|
|
|
|
order by random()
|
|
|
|
|
@@ -1006,6 +1013,7 @@ export default {
|
|
|
|
|
and items.active = true
|
|
|
|
|
${mimeSQL}
|
|
|
|
|
${!session && getGlobalfilter() ? db`and not exists (select 1 from tags_assign where item_id = items.id and (${db.unsafe(getGlobalfilter())}))` : db``}
|
|
|
|
|
${!session && cfg.websrv.public_untagged === false ? db`and exists (select 1 from tags_assign where item_id = items.id)` : db``}
|
|
|
|
|
${excludedTags.length > 0 ? db`and not exists (select 1 from tags_assign where item_id = items.id and tag_id = any(${excludedTags}::int[]))` : db``}
|
|
|
|
|
order by random()
|
|
|
|
|
limit 1
|
|
|
|
|
|