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 }, ), );