From c64b7877a22e7ff1af5d318e873aa87900980538 Mon Sep 17 00:00:00 2001 From: svemagie <869694+svemagie@users.noreply.github.com> Date: Sat, 25 Apr 2026 18:12:29 +0200 Subject: [PATCH] fix: populate header image in profile lookups and timeline enrichment - accounts/lookup: add bannerUrl to ap_following path (was missing, follower path was correct) - account-cache: store headerUrl alongside counts and avatarUrl - resolve-account: pass headerUrl to cacheAccountStats - enrich-accounts: apply cached.headerUrl to account.header/header_static Co-Authored-By: Claude Sonnet 4.6 --- lib/mastodon/helpers/account-cache.js | 2 +- lib/mastodon/helpers/enrich-accounts.js | 4 ++++ lib/mastodon/helpers/resolve-account.js | 3 ++- lib/mastodon/routes/accounts.js | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/mastodon/helpers/account-cache.js b/lib/mastodon/helpers/account-cache.js index 2a9c45c..1ce16a5 100644 --- a/lib/mastodon/helpers/account-cache.js +++ b/lib/mastodon/helpers/account-cache.js @@ -21,7 +21,7 @@ const idToUrl = new Map(); /** * Store account stats in cache. * @param {string} actorUrl - The actor's URL (cache key) - * @param {object} stats - { followersCount, followingCount, statusesCount, createdAt, avatarUrl } + * @param {object} stats - { followersCount, followingCount, statusesCount, createdAt, avatarUrl, headerUrl } */ export function cacheAccountStats(actorUrl, stats) { if (!actorUrl) return; diff --git a/lib/mastodon/helpers/enrich-accounts.js b/lib/mastodon/helpers/enrich-accounts.js index 9070d1a..dcd4c49 100644 --- a/lib/mastodon/helpers/enrich-accounts.js +++ b/lib/mastodon/helpers/enrich-accounts.js @@ -60,6 +60,10 @@ function applyCachedOrCollect(account, uncachedUrls) { account.avatar = cached.avatarUrl; account.avatar_static = cached.avatarUrl; } + if (cached.headerUrl) { + account.header = cached.headerUrl; + account.header_static = cached.headerUrl; + } return; } diff --git a/lib/mastodon/helpers/resolve-account.js b/lib/mastodon/helpers/resolve-account.js index 49bfcf1..229d4ce 100644 --- a/lib/mastodon/helpers/resolve-account.js +++ b/lib/mastodon/helpers/resolve-account.js @@ -133,13 +133,14 @@ export async function resolveRemoteAccount(acct, pluginOptions, baseUrl, collect account.following_count = followingCount; account.statuses_count = statusesCount; - // Cache stats (+ avatar URL) so embedded account objects in statuses can use them + // Cache stats (+ avatar + header) so embedded account objects in statuses can use them cacheAccountStats(actorUrl, { followersCount, followingCount, statusesCount, createdAt: published || undefined, avatarUrl: avatarUrl || undefined, + headerUrl: headerUrl || undefined, }); // Persist actor URL mapping to MongoDB so follow/unfollow survives server restarts diff --git a/lib/mastodon/routes/accounts.js b/lib/mastodon/routes/accounts.js index 1d9cce9..96e90ad 100644 --- a/lib/mastodon/routes/accounts.js +++ b/lib/mastodon/routes/accounts.js @@ -126,7 +126,7 @@ router.get("/api/v1/accounts/lookup", async (req, res, next) => { if (following) { return res.json( serializeAccount( - { name: following.name, url: following.actorUrl, photo: following.avatar, handle: following.handle, createdAt: following.createdAt || undefined }, + { name: following.name, url: following.actorUrl, photo: following.avatar, handle: following.handle, bannerUrl: following.banner || "", createdAt: following.createdAt || undefined }, { baseUrl }, ), );