From 34fdab4b853e90ee56aec649bd61e63a49e08e04 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Thu, 26 Mar 2026 08:21:54 +0100 Subject: [PATCH] feat: use replyTargets config for platform-to-syndicator mapping - Frontend now reads replyTargets from isOwner API to resolve which syndicator handles replies for each platform - Build-time reply buttons get platform from URL heuristics as fallback - enrichBuildTimeBadges upgrades to NodeInfo-resolved platform at runtime --- _includes/components/webmentions.njk | 12 +++++++++++- js/comments.js | 3 +++ js/webmentions.js | 9 ++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/_includes/components/webmentions.njk b/_includes/components/webmentions.njk index 97edcff..c7b3760 100644 --- a/_includes/components/webmentions.njk +++ b/_includes/components/webmentions.njk @@ -153,9 +153,19 @@
{{ reply.content.html | safe if reply.content.html else reply.content.text }}
+ {% set replySource = reply['wm-source'] | default('', true) %} + {% set replyAuthorUrl = reply.author.url | default('', true) %} + {% set buildPlatform = 'webmention' %} + {% if 'bsky.app' in replyAuthorUrl or ('brid.gy/' in replySource and '/bluesky/' in replySource) %} + {% set buildPlatform = 'bluesky' %} + {% elif 'brid.gy/' in replySource and '/mastodon/' in replySource %} + {% set buildPlatform = 'mastodon' %} + {% elif 'fed.brid.gy' in replySource %} + {% set buildPlatform = 'activitypub' %} + {% endif %} diff --git a/js/comments.js b/js/comments.js index 15def50..d373503 100644 --- a/js/comments.js +++ b/js/comments.js @@ -12,6 +12,7 @@ document.addEventListener("alpine:init", () => { isOwner: false, profile: null, syndicationTargets: {}, + replyTargets: {}, }); Alpine.data("commentsSection", (targetUrl) => ({ @@ -74,11 +75,13 @@ document.addEventListener("alpine:init", () => { photo: data.photo, }; this.syndicationTargets = data.syndicationTargets || {}; + this.replyTargets = data.replyTargets || {}; // Also update global store for webmentions component Alpine.store("owner").isOwner = true; Alpine.store("owner").profile = this.ownerProfile; Alpine.store("owner").syndicationTargets = this.syndicationTargets; + Alpine.store("owner").replyTargets = this.replyTargets; // Note: owner:detected event is dispatched from init() after // this completes, so the Alpine store is populated before the event fires diff --git a/js/webmentions.js b/js/webmentions.js index 2604412..3e3bade 100644 --- a/js/webmentions.js +++ b/js/webmentions.js @@ -803,12 +803,11 @@ btn.addEventListener('click', function() { var replyUrl = btn.dataset.replyUrl; var platform = btn.dataset.platform || 'webmention'; - // Map detected platform to syndicator by service.name + // Map platform to syndicator via replyTargets config var targets = ownerStore.syndicationTargets || {}; - var syndicateTo = null; - if (platform === 'bluesky') syndicateTo = targets['Bluesky'] || null; - if (platform === 'mastodon') syndicateTo = targets['Mastodon'] || null; - if (platform === 'activitypub') syndicateTo = targets['ActivityPub (Fediverse)'] || null; + var replyTargets = ownerStore.replyTargets || {}; + var serviceName = replyTargets[platform] || null; + var syndicateTo = serviceName ? (targets[serviceName] || null) : null; // Close any existing reply form closeActiveReplyForm();