mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2025-01-09 14:25:25 +00:00
Add support for building webfinger for multiple URLs with type
Update `build_webfinger_response` to accept `Vec<(Url, Option<&str>)>` where `Url` is the ActivityPub ID and `&str` is the optional type.
This commit is contained in:
parent
c56f526914
commit
3f70586e63
1 changed files with 27 additions and 15 deletions
|
@ -95,10 +95,11 @@ where
|
||||||
/// build_webfinger_response(subject, url);
|
/// build_webfinger_response(subject, url);
|
||||||
/// # Ok::<(), anyhow::Error>(())
|
/// # Ok::<(), anyhow::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn build_webfinger_response(subject: String, url: Url) -> Webfinger {
|
pub fn build_webfinger_response(subject: String, url: Vec<(Url, Option<&str>)>) -> Webfinger {
|
||||||
Webfinger {
|
Webfinger {
|
||||||
subject,
|
subject,
|
||||||
links: vec![
|
links: url.iter().fold(vec![], |mut acc, (url, kind)| {
|
||||||
|
acc.extend(vec![
|
||||||
WebfingerLink {
|
WebfingerLink {
|
||||||
rel: Some("http://webfinger.net/rel/profile-page".to_string()),
|
rel: Some("http://webfinger.net/rel/profile-page".to_string()),
|
||||||
kind: Some("text/html".to_string()),
|
kind: Some("text/html".to_string()),
|
||||||
|
@ -108,10 +109,21 @@ pub fn build_webfinger_response(subject: String, url: Url) -> Webfinger {
|
||||||
WebfingerLink {
|
WebfingerLink {
|
||||||
rel: Some("self".to_string()),
|
rel: Some("self".to_string()),
|
||||||
kind: Some(FEDERATION_CONTENT_TYPE.to_string()),
|
kind: Some(FEDERATION_CONTENT_TYPE.to_string()),
|
||||||
href: Some(url),
|
href: Some(url.clone()),
|
||||||
properties: Default::default(),
|
properties: kind
|
||||||
|
.map(|kind| {
|
||||||
|
HashMap::from([(
|
||||||
|
"https://www.w3.org/ns/activitystreams#type"
|
||||||
|
.parse::<Url>()
|
||||||
|
.expect("parse url"),
|
||||||
|
kind.to_string(),
|
||||||
|
)])
|
||||||
|
})
|
||||||
|
.unwrap_or_default(),
|
||||||
},
|
},
|
||||||
],
|
]);
|
||||||
|
acc
|
||||||
|
}),
|
||||||
aliases: vec![],
|
aliases: vec![],
|
||||||
properties: Default::default(),
|
properties: Default::default(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue