From: Nutomic Date: Fri, 21 Jan 2022 21:00:17 +0000 (+0000) Subject: Put community last in webfinger response (fixes #2037) (#2047) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%7Bthis.state.thumbnail%7D?a=commitdiff_plain;h=2544341e47fdb044fc23b6e1b1a2d344e6ecb69b;p=lemmy.git Put community last in webfinger response (fixes #2037) (#2047) --- diff --git a/crates/routes/src/webfinger.rs b/crates/routes/src/webfinger.rs index db5e662c..82b8a619 100644 --- a/crates/routes/src/webfinger.rs +++ b/crates/routes/src/webfinger.rs @@ -43,21 +43,24 @@ async fn get_webfinger_response( .to_string(); let name_ = name.clone(); - let community_id: Option = blocking(context.pool(), move |conn| { - Community::read_from_name(conn, &name_) + let user_id: Option = blocking(context.pool(), move |conn| { + Person::find_by_name(conn, &name_) }) .await? .ok() .map(|c| c.actor_id.into()); - let user_id: Option = blocking(context.pool(), move |conn| { - Person::find_by_name(conn, &name) + let community_id: Option = blocking(context.pool(), move |conn| { + Community::read_from_name(conn, &name) }) .await? .ok() .map(|c| c.actor_id.into()); + + // Mastodon seems to prioritize the last webfinger item in case of duplicates. Put + // community last so that it gets prioritized. For Lemmy the order doesnt matter. let links = vec![ - webfinger_link_for_actor(community_id), webfinger_link_for_actor(user_id), + webfinger_link_for_actor(community_id), ] .into_iter() .flatten()