Commit 1f08f147 authored by Zachary Dunn's avatar Zachary Dunn

Fix support for multiple nodeinfo versions

parent 042ea57e
......@@ -90,6 +90,10 @@ pub fn nodeinfo_jrd(site: State<Site>) -> Content<String> {
{
"href": format!("{host}/nodeinfo/2.0", host=&site.h_card.url),
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.0"
},
{
"href": format!("{host}/nodeinfo/2.1", host=&site.h_card.url),
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.1"
}
]
})
......@@ -98,19 +102,19 @@ pub fn nodeinfo_jrd(site: State<Site>) -> Content<String> {
Content(content_type, doc)
}
#[get("/nodeinfo/2.0")]
pub fn nodeinfo(site: State<Site>) -> Content<String> {
#[get("/nodeinfo/<version>")]
pub fn nodeinfo(site: State<Site>, version: String) -> Content<String> {
// TODO: Make return type a result and return 404 if version not 2.0 | 2.1
let content_type = ContentType::with_params(
"application",
"json",
("profile", "http://nodeinfo.diaspora.software/ns/schema/2.0#,"),
);
let doc = json!({
"version": 2.0,
let mut doc = json!({
"version": version,
"software": {
"name": env!("CARGO_PKG_NAME"),
"version": env!("CARGO_PKG_VERSION"),
"repository": env!("CARGO_PKG_REPOSITORY"),
},
"protocols": ["webmention"],
"services": {
......@@ -128,11 +132,15 @@ pub fn nodeinfo(site: State<Site>) -> Content<String> {
"nodeName": &site.name,
"nodeDescription": &site.description,
"software": {
"homepage": env!("CARGO_PKG_HOMEPAGE")
"homepage": env!("CARGO_PKG_HOMEPAGE"),
"repository": env!("CARGO_PKG_REPOSITORY"),
}
}
})
.to_string();
});
Content(content_type, doc)
if version == "2.1" {
doc["software"]["repository"] = json!(env!("CARGO_PKG_REPOSITORY"));
}
Content(content_type, doc.to_string())
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment