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.
This commit is contained in:
@@ -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;
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user