[object Object]

← back to Norma

IG cadence: dedup by IMAGE filename (not just product handle) — stops creating same-image duplicates (multiple handles share one image, e.g. Quick Ship Durable Walls)

191eee113766fe0a5b551ac9b126db3b04ecdc1a · 2026-08-15 07:57:31 -0700 · Steve

Files touched

Diff

commit 191eee113766fe0a5b551ac9b126db3b04ecdc1a
Author: Steve <steve@designerwallcoverings.com>
Date:   Sat Aug 15 07:57:31 2026 -0700

    IG cadence: dedup by IMAGE filename (not just product handle) — stops creating same-image duplicates (multiple handles share one image, e.g. Quick Ship Durable Walls)
---
 agents/instagram-agent/daily-cadence.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/agents/instagram-agent/daily-cadence.js b/agents/instagram-agent/daily-cadence.js
index 0dd7ba7..5c23afd 100644
--- a/agents/instagram-agent/daily-cadence.js
+++ b/agents/instagram-agent/daily-cadence.js
@@ -54,6 +54,10 @@ function needsPost(h) {
   return (nowMs - last) >= MIN_GAP_MS;
 }
 const everPosted = new Set(rows.map((r) => r.product_handle)); // avoid reusing a product
+// Also dedup by IMAGE identity (filename), not just handle — several handles can share one image
+// (e.g. the "Quick Ship Durable Walls" variants), which was silently creating same-image duplicates.
+const imgKey = (u) => String(u || '').split('/').pop().split('?')[0].toLowerCase();
+const everPostedImg = new Set(rows.map((r) => imgKey(r.image_url)).filter(Boolean));
 
 function themeFor(h) {
   const o = themes[h] || {};
@@ -70,6 +74,7 @@ async function findProduct(keyword) {
     if (everPosted.has(p.handle)) continue; // don't repost a product
     try {
       const r = await content.resolveProduct(p.handle); // throws on leak/no-image (guard)
+      if (everPostedImg.has(imgKey(r.image_url))) continue; // same image already posted — skip (no dup)
       return { handle: p.handle, title: r.title, image_url: r.image_url };
     } catch { /* leak or imageless — next */ }
   }

← eb6bf21 IG: duplicate-image detector — md5-hash each post's image pe  ·  back to Norma  ·  Norma IG cadence: fresh-source via Boost API (fixes clean-pr 43de9ea →