Update nodeinfo #446

Merged
zcdunn merged 4 commits from update_nodeinfo_433 into master 5 years ago

@ -2,6 +2,7 @@
authors = ["Plume contributors"]
name = "plume"
version = "0.2.0"
repository = "https://github.com/Plume-org/Plume"
[dependencies]
activitypub = "0.1.3"

@ -216,20 +216,25 @@ pub fn shared_inbox(conn: DbConn, data: SignedJson<serde_json::Value>, headers:
})
}
#[get("/nodeinfo")]
pub fn nodeinfo(conn: DbConn) -> Result<Json<serde_json::Value>, ErrorPage> {
Ok(Json(json!({
"version": "2.0",
#[get("/nodeinfo/<version>")]
pub fn nodeinfo(conn: DbConn, version: String) -> Result<Json<serde_json::Value>, ErrorPage> {
if version != "2.0" || version != "2.1" {
return Err(ErrorPage::from(Error::NotFound));
}
let local_inst = Instance::get_local(&*conn)?;
let mut doc = json!({
"version": version,
"software": {
"name": "Plume",
"version": env!("CARGO_PKG_VERSION")
"name": env!("CARGO_PKG_NAME"),
"version": env!("CARGO_PKG_VERSION"),
},
"protocols": ["activitypub"],
"services": {
"inbound": [],
"outbound": []
},
"openRegistrations": true,
"openRegistrations": local_inst.open_registrations,
"usage": {
"users": {
"total": User::count_local(&*conn)?
@ -237,8 +242,17 @@ pub fn nodeinfo(conn: DbConn) -> Result<Json<serde_json::Value>, ErrorPage> {
"localPosts": Post::count_local(&*conn)?,
"localComments": Comment::count_local(&*conn)?
},
"metadata": {}
})))
"metadata": {
"nodeName": local_inst.name,
"nodeDescription": local_inst.short_description
}
});
if version == "2.1" {
doc["software"]["repository"] = json!(env!("CARGO_PKG_REPOSITORY"));
}
Ok(Json(doc))
}
#[get("/about")]

@ -11,7 +11,11 @@ pub fn nodeinfo() -> Content<String> {
"links": [
{
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",
"href": ap_url(&format!("{domain}/nodeinfo", domain = BASE_URL.as_str()))
"href": ap_url(&format!("{domain}/nodeinfo/2.0", domain = BASE_URL.as_str()))
},
{
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.1",
"href": ap_url(&format!("{domain}/nodeinfo/2.1", domain = BASE_URL.as_str()))
}
]
}).to_string())

Loading…
Cancel
Save