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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 },
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user