Skip to content

Commit

Permalink
Put community last in webfinger response (fixes #2037) (#2047)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic authored and dessalines committed Jan 27, 2022
1 parent ea291d5 commit 837c623
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/routes/src/webfinger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,24 @@ async fn get_webfinger_response(
.to_string();

let name_ = name.clone();
let community_id: Option<Url> = blocking(context.pool(), move |conn| {
Community::read_from_name(conn, &name_)
let user_id: Option<Url> = blocking(context.pool(), move |conn| {
Person::find_by_name(conn, &name_)
})
.await?
.ok()
.map(|c| c.actor_id.into());
let user_id: Option<Url> = blocking(context.pool(), move |conn| {
Person::find_by_name(conn, &name)
let community_id: Option<Url> = 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()
Expand Down

0 comments on commit 837c623

Please sign in to comment.