From 88fc872df60d4cc2088bb42fcfc1fa46bc660a39 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Sun, 24 May 2026 17:51:16 +0200 Subject: [PATCH] display reposts in info modal --- src/inc/routeinc/f0cklib.mjs | 30 +++++++++++++++++++++++++++++- views/item-partial-legacy.html | 10 ++++++++++ views/item-partial-modern.html | 10 ++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/inc/routeinc/f0cklib.mjs b/src/inc/routeinc/f0cklib.mjs index 36fd34a..52e021f 100644 --- a/src/inc/routeinc/f0cklib.mjs +++ b/src/inc/routeinc/f0cklib.mjs @@ -577,6 +577,32 @@ export default { where "favorites".item_id = ${itemid} `; + // Detect reposts: items uploaded with bypass_duplicate_check have checksum = `{hash}_bypass_{ts}` + // Find all items (including this one) that share the same base checksum. + let repostItems = []; + if (actitem.checksum && actitem.checksum.includes('_bypass_')) { + const baseChecksum = actitem.checksum.split('_bypass_')[0]; + const repostRows = await db` + SELECT id, username, stamp FROM items + WHERE active = true + AND id != ${itemid} + AND (checksum = ${baseChecksum} OR checksum LIKE ${baseChecksum + '_bypass_%'}) + ORDER BY id ASC + `; + repostItems = repostRows.map(r => ({ id: r.id, username: r.username, stamp: r.stamp })); + } else if (actitem.checksum) { + // Even without bypass, check if other bypass-entries exist with this same hash + const baseChecksum = actitem.checksum; + const repostRows = await db` + SELECT id, username, stamp FROM items + WHERE active = true + AND id != ${itemid} + AND checksum LIKE ${baseChecksum + '_bypass_%'} + ORDER BY id ASC + `; + repostItems = repostRows.map(r => ({ id: r.id, username: r.username, stamp: r.stamp })); + } + // Efficient coverart fallback const coverartUrl = actitem.has_coverart ? `${cfg.websrv.paths.coverarts}/${actitem.id}.webp` @@ -656,7 +682,9 @@ export default { is_sfw: isSfw, is_pinned: actitem.is_pinned || false, is_comments_locked: actitem.is_comments_locked || false, - is_oc: actitem.is_oc || false + is_oc: actitem.is_oc || false, + is_repost: actitem.checksum ? actitem.checksum.includes('_bypass_') : false, + reposts: repostItems }, title: `${actitem.id} - ${cfg.websrv.domain}`, pagination: { diff --git a/views/item-partial-legacy.html b/views/item-partial-legacy.html index 64da84c..44ca596 100644 --- a/views/item-partial-legacy.html +++ b/views/item-partial-legacy.html @@ -212,6 +212,16 @@ {{ item.checksum.split('_bypass_')[0] }} @endif + @if(item.is_repost || (item.reposts && item.reposts.length > 0)) + + Repost + + @each(item.reposts as rp) + #{{ rp.id }} + @endeach + + + @endif {{ t('info_modal.direct_url') || 'Direct URL' }} diff --git a/views/item-partial-modern.html b/views/item-partial-modern.html index cc8f8de..f0702c3 100644 --- a/views/item-partial-modern.html +++ b/views/item-partial-modern.html @@ -184,6 +184,16 @@ {{ item.checksum.split('_bypass_')[0] }} @endif + @if(item.is_repost || (item.reposts && item.reposts.length > 0)) + + Repost + + @each(item.reposts as rp) + #{{ rp.id }} + @endeach + + + @endif {{ t('info_modal.direct_url') || 'Direct URL' }}