From bc72bf1e027b38d9eee64b8f782c12fd741690c6 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Sat, 21 Mar 2026 12:06:49 +0100 Subject: [PATCH] feat: populate remote profile counts, fields, and join date Extract followers/following/statuses counts from AP collection totalItems, profile fields from actor attachments, and published date from the actor document. Previously showed 0/0/0 and today's date for all remote profiles. --- lib/mastodon/helpers/resolve-account.js | 46 ++++++++++++++++++++++++- package.json | 2 +- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/mastodon/helpers/resolve-account.js b/lib/mastodon/helpers/resolve-account.js index 7a79687..d83b08a 100644 --- a/lib/mastodon/helpers/resolve-account.js +++ b/lib/mastodon/helpers/resolve-account.js @@ -60,7 +60,42 @@ export async function resolveRemoteAccount(acct, pluginOptions, baseUrl) { headerUrl = image?.url?.href || ""; } catch { /* ignore */ } - return serializeAccount( + // Get collection counts (followers, following, outbox) + let followersCount = 0; + let followingCount = 0; + let statusesCount = 0; + try { + const followers = await actor.getFollowers(); + if (followers?.totalItems != null) followersCount = followers.totalItems; + } catch { /* ignore */ } + try { + const following = await actor.getFollowing(); + if (following?.totalItems != null) followingCount = following.totalItems; + } catch { /* ignore */ } + try { + const outbox = await actor.getOutbox(); + if (outbox?.totalItems != null) statusesCount = outbox.totalItems; + } catch { /* ignore */ } + + // Get published/created date + const published = actor.published + ? String(actor.published) + : null; + + // Profile fields from attachments + const fields = []; + try { + for await (const attachment of actor.getAttachments()) { + if (attachment?.name) { + fields.push({ + name: attachment.name?.toString() || "", + value: attachment.value?.toString() || "", + }); + } + } + } catch { /* ignore */ } + + const account = serializeAccount( { name, url: actorUrl, @@ -69,9 +104,18 @@ export async function resolveRemoteAccount(acct, pluginOptions, baseUrl) { summary, image: headerUrl, bot: actor.constructor?.name === "Service" || actor.constructor?.name === "Application", + attachments: fields.length > 0 ? fields : undefined, + createdAt: published || undefined, }, { baseUrl }, ); + + // Override counts with real data from AP collections + account.followers_count = followersCount; + account.following_count = followingCount; + account.statuses_count = statusesCount; + + return account; } catch (error) { console.warn(`[Mastodon API] Remote account resolution failed for ${acct}:`, error.message); return null; diff --git a/package.json b/package.json index 578f29b..485ce6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rmdes/indiekit-endpoint-activitypub", - "version": "3.6.4", + "version": "3.6.5", "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.", "keywords": [ "indiekit",