feat: use NodeInfo-resolved platform for provenance badges

detectPlatform() now checks item.platform first (set by conversations
API via NodeInfo) before falling back to URL heuristics. Mastodon gets
its own badge, Bluesky gets its own, all other fediverse software
shows the Fediverse badge, and webmention.io data uses Bridgy URL
heuristics as fallback.

Confab-Link: http://localhost:8080/sessions/184584f4-67e1-485a-aba8-02ac34a600fe
This commit is contained in:
Ricardo
2026-03-15 15:16:40 +01:00
parent ddf272dac9
commit 6046eceaac

View File

@@ -594,15 +594,23 @@
} }
function detectPlatform(item) { function detectPlatform(item) {
// Conversations API provides a resolved platform field via NodeInfo
if (item.platform) {
var p = item.platform.toLowerCase();
if (p === 'mastodon') return 'mastodon';
if (p === 'bluesky') return 'bluesky';
if (p === 'webmention') return 'webmention';
// All other fediverse software (pleroma, misskey, gotosocial, fedify, etc.)
return 'activitypub';
}
// Fallback: URL heuristics for webmention.io data and build-time cards
var source = item['wm-source'] || ''; var source = item['wm-source'] || '';
var authorUrl = (item.author && item.author.url) || ''; var authorUrl = (item.author && item.author.url) || '';
if (source.includes('brid.gy/') && source.includes('/mastodon/')) return 'mastodon'; if (source.includes('brid.gy/') && source.includes('/mastodon/')) return 'mastodon';
if (source.includes('brid.gy/') && source.includes('/bluesky/')) return 'bluesky'; if (source.includes('brid.gy/') && source.includes('/bluesky/')) return 'bluesky';
if (source.includes('fed.brid.gy')) return 'activitypub'; if (source.includes('fed.brid.gy')) return 'activitypub';
if (authorUrl.includes('bsky.app')) return 'bluesky'; if (authorUrl.includes('bsky.app')) return 'bluesky';
if (authorUrl.includes('mstdn') || authorUrl.includes('mastodon') || authorUrl.includes('social.') ||
authorUrl.includes('fosstodon.') || authorUrl.includes('hachyderm.') || authorUrl.includes('infosec.exchange') ||
authorUrl.includes('pleroma.') || authorUrl.includes('misskey.') || authorUrl.includes('pixelfed.')) return 'mastodon';
return 'webmention'; return 'webmention';
} }