fix: deduplicate cross-source webmentions

webmention.io cache and conversations API can report the same
interaction (e.g. a like) with different wm-id formats. Deduplicate
by author URL + interaction type after URL filtering to prevent
the same like/reply appearing twice.
This commit is contained in:
Ricardo
2026-02-23 10:06:19 +01:00
parent e1f4b2cd90
commit a7bc472e87

View File

@@ -484,7 +484,21 @@ export default function (eleventyConfig) {
}
// Filter merged data matching any of our URLs
return merged.filter((wm) => urlsToCheck.has(wm["wm-target"]));
const matched = merged.filter((wm) => urlsToCheck.has(wm["wm-target"]));
// Deduplicate cross-source: same author + same interaction type = same mention
// (webmention.io and conversations API may both report the same like/reply)
const deduped = [];
const authorActions = new Set();
for (const wm of matched) {
const authorUrl = wm.author?.url || wm.url || "";
const action = wm["wm-property"] || "mention";
const key = `${authorUrl}::${action}`;
if (authorActions.has(key)) continue;
authorActions.add(key);
deduped.push(wm);
}
return deduped;
});
eleventyConfig.addFilter("webmentionsByType", function (mentions, type) {