alotta good shit

This commit is contained in:
2026-09-19 06:20:37 +02:00
parent 74f7884525
commit 1477d56658
45 changed files with 4363 additions and 2069 deletions
+13 -2
View File
@@ -829,7 +829,9 @@ const f0cklib = {
const rows = (await db`
select
items.id,
items.title,
items.slug,
items.stamp,
items.visibility,
items.mime,
items.dest,
@@ -842,9 +844,10 @@ const f0cklib = {
items.album_count,
${user_id ? db`max(coalesce(uvv.view_count, 0)) as my_views,` : db``}
${user_id ? db`EXISTS (SELECT 1 FROM notifications WHERE user_id = ${user_id} AND item_id = items.id AND is_read = false) as has_notification,` : db`false as has_notification,`}
(case when min(ta.tag_id) = 1 then 'SFW' when min(ta.tag_id) = 2 then 'NSFW' else 'NSFL' end) as tag,
(case when min(ta.tag_id) = 1 then 'SFW' when min(ta.tag_id) = 2 then 'NSFW' when min(ta.tag_id) = ${cfg.nsfl_tag_id || 3} then 'NSFL' else null end) as tag,
min(ta.tag_id) as tag_id,
max(uo.display_name) as display_name,
max(uo.username_color) as username_color,
${cfg.websrv.enable_dynamic_thumbs ? db`
(
(SELECT count(*) FROM favorites WHERE item_id = items.id) +
@@ -866,6 +869,9 @@ const f0cklib = {
row.xd_tier = meta.tier;
row.xd_label = meta.label;
row.is_audio = !!(row.mime && row.mime.startsWith('audio/'));
const tId = row.tag_id != null ? Number(row.tag_id) : null;
row.rating_class = tId === 1 ? 'sfw' : (tId === 2 ? 'nsfw' : (tId === nsflId ? 'nsfl' : 'untagged'));
row.rating_label = tId === 1 ? 'SFW' : (tId === 2 ? 'NSFW' : (tId === nsflId ? 'NSFL' : '?'));
}
if (rows.some(r => r.is_album)) {
@@ -2385,7 +2391,11 @@ const f0cklib = {
}
const items = rows.map(r => r.slug || String(r.id));
return { items, total: items.length, sampled: items.length >= 10000 };
const idMap = {};
for (const r of rows) {
if (r.slug) idMap[r.slug] = r.id;
}
return { items, id_map: idMap, total: items.length, sampled: items.length >= 10000 };
},
getComments: async (itemId, sort = 'new', process = true) => {
const numericId = await resolveNumericItemId(itemId);
@@ -2556,6 +2566,7 @@ const f0cklib = {
}
},
getSubscriptionStatus: async (userId, itemId) => {
if (cfg.enable_comments === false) return false;
const numericId = await resolveNumericItemId(itemId);
if (!userId || !numericId) return false;
const tStart = Date.now();