Skip to content

Commit

Permalink
fix: correct urls in AP user
Browse files Browse the repository at this point in the history
  • Loading branch information
CutestNekoAqua committed Jul 17, 2024
1 parent d33de46 commit 071f6dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,17 @@ pub async fn webfinger(
let res = resolve("acct:".to_string() + name + "@" + &LYSAND_DOMAIN, true)
.await
.unwrap();
user = db_user_from_url(Url::parse(res.links.get(0).clone().unwrap().href.clone().unwrap().as_str())?).await?;
user = db_user_from_url(Url::parse(
res.links
.get(0)
.clone()
.unwrap()
.href
.clone()
.unwrap()
.as_str(),
)?)
.await?;
}
Ok(HttpResponse::Ok().json(build_webfinger_response(
query.resource.clone(),
Expand Down
15 changes: 11 additions & 4 deletions src/lysand/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,27 @@ async fn fetch_user(
None => return Ok(HttpResponse::NotFound().finish()),
};

let bridge_user_url = generate_user_id(&API_DOMAIN, &user.id)?;
let inbox = Url::parse(&format!(
"https://{}/{}/inbox",
API_DOMAIN.to_string(),
&user.username.clone()
))?;

Ok(HttpResponse::Ok()
.content_type(FEDERATION_CONTENT_TYPE)
.json(WithContext::new_default(crate::objects::person::Person {
kind: Default::default(),
id: generate_user_id(&API_DOMAIN, &user.id)?.into(),
id: bridge_user_url.clone().into(),
preferred_username: user.username.clone(),
name: user.name.clone(),
summary: user.summary.clone(),
url: Url::parse(user.url.as_str()).unwrap(),
inbox: Url::parse(user.inbox.as_str()).unwrap(),
inbox,
public_key: PublicKey {
owner: Url::parse(user.url.as_str()).unwrap(),
owner: bridge_user_url.clone(),
public_key_pem: user.public_key,
id: format!("{}#main-key", Url::parse(user.url.as_str()).unwrap()),
id: format!("{}#main-key", bridge_user_url.clone()),
},
})))
}
Expand Down

0 comments on commit 071f6dc

Please sign in to comment.