};
use lemmy_utils::{error::LemmyError, location_info, WebfingerLink, WebfingerResponse};
use serde::Deserialize;
+use std::collections::HashMap;
use url::Url;
#[derive(Deserialize)]
// 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(user_id),
- webfinger_link_for_actor(community_id),
+ webfinger_link_for_actor(user_id, "Person"),
+ webfinger_link_for_actor(community_id, "Group"),
]
.into_iter()
.flatten()
Ok(HttpResponse::Ok().json(json))
}
-fn webfinger_link_for_actor(url: Option<Url>) -> Vec<WebfingerLink> {
+fn webfinger_link_for_actor(url: Option<Url>, kind: &str) -> Vec<WebfingerLink> {
if let Some(url) = url {
+ let mut properties = HashMap::new();
+ properties.insert(
+ "https://www.w3.org/ns/activitystreams#type".to_string(),
+ kind.to_string(),
+ );
vec![
WebfingerLink {
rel: Some("http://webfinger.net/rel/profile-page".to_string()),
kind: Some("text/html".to_string()),
href: Some(url.clone()),
+ properties: Default::default(),
},
WebfingerLink {
rel: Some("self".to_string()),
kind: Some("application/activity+json".to_string()),
href: Some(url),
+ properties,
},
]
} else {
pub mod version;
use serde::{Deserialize, Serialize};
-use std::{fmt, time::Duration};
+use std::{collections::HashMap, fmt, time::Duration};
use url::Url;
pub type ConnectionId = usize;
#[serde(rename = "type")]
pub kind: Option<String>,
pub href: Option<Url>,
+ pub properties: HashMap<String, String>,
}
#[derive(Serialize, Deserialize, Debug)]