mirror of
https://github.com/LemmyNet/activitypub-federation-rust
synced 2024-11-10 06:04:19 +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);
|
||||
/// # 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 {
|
||||
subject,
|
||||
links: vec![
|
||||
links: url.iter().fold(vec![], |mut acc, (url, kind)| {
|
||||
acc.extend(vec![
|
||||
WebfingerLink {
|
||||
rel: Some("http://webfinger.net/rel/profile-page".to_string()),
|
||||
kind: Some("text/html".to_string()),
|
||||
|
@ -108,10 +109,21 @@ pub fn build_webfinger_response(subject: String, url: Url) -> Webfinger {
|
|||
WebfingerLink {
|
||||
rel: Some("self".to_string()),
|
||||
kind: Some(FEDERATION_CONTENT_TYPE.to_string()),
|
||||
href: Some(url),
|
||||
properties: Default::default(),
|
||||
href: Some(url.clone()),
|
||||
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![],
|
||||
properties: Default::default(),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue