From 44e152783fdca0b046db96d5963f7159d9e76f92 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Fri, 15 May 2026 10:09:14 +0200 Subject: [PATCH] fix(feed): join remote_actors to get proper handle and avatar for remote authors --- crates/adapters/postgres/src/feed.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/adapters/postgres/src/feed.rs b/crates/adapters/postgres/src/feed.rs index ec672f1..e94441b 100644 --- a/crates/adapters/postgres/src/feed.rs +++ b/crates/adapters/postgres/src/feed.rs @@ -95,15 +95,23 @@ fn feed_select(viewer: Option) -> String { t.in_reply_to_id, t.in_reply_to_url, t.ap_id AS t_ap_id, t.visibility, t.content_warning, t.sensitive, t.local AS t_local, t.created_at AS thought_created_at, t.updated_at, - u.id AS author_id, u.username, u.email, u.password_hash, - u.display_name, u.bio, u.avatar_url, u.header_url, u.custom_css, + u.id AS author_id, + CASE WHEN NOT u.local AND ra.handle IS NOT NULL AND ra.handle != '' + THEN '@' || ra.handle ELSE u.username END AS username, + u.email, u.password_hash, + COALESCE(ra.display_name, u.display_name) AS display_name, + u.bio, + COALESCE(ra.avatar_url, u.avatar_url) AS avatar_url, + u.header_url, u.custom_css, u.local AS author_local, u.ap_id AS u_ap_id, u.inbox_url, u.created_at AS author_created_at, u.updated_at AS author_updated_at, (SELECT COUNT(*) FROM likes l WHERE l.thought_id=t.id) AS like_count, (SELECT COUNT(*) FROM boosts b WHERE b.thought_id=t.id) AS boost_count, (SELECT COUNT(*) FROM thoughts r WHERE r.in_reply_to_id=t.id) AS reply_count, {viewer_checks} - FROM thoughts t JOIN users u ON u.id=t.user_id" + FROM thoughts t + JOIN users u ON u.id=t.user_id + LEFT JOIN remote_actors ra ON u.ap_id = ra.url" ) }