Add NodeInfo endpoints (fixes #11)
This commit is contained in:
+27
-1
@@ -1,11 +1,12 @@
|
||||
use rocket::{request::Form, response::Redirect};
|
||||
use rocket_contrib::Template;
|
||||
use rocket_contrib::{Json, Template};
|
||||
use serde_json;
|
||||
|
||||
use BASE_URL;
|
||||
use activity_pub::inbox::Inbox;
|
||||
use db_conn::DbConn;
|
||||
use models::{
|
||||
comments::Comment,
|
||||
posts::Post,
|
||||
users::User,
|
||||
instance::*
|
||||
@@ -75,3 +76,28 @@ fn shared_inbox(conn: DbConn, data: String) -> String {
|
||||
instance.received(&*conn, act);
|
||||
String::from("")
|
||||
}
|
||||
|
||||
#[get("/nodeinfo")]
|
||||
fn nodeinfo(conn: DbConn) -> Json {
|
||||
Json(json!({
|
||||
"version": "2.0",
|
||||
"software": {
|
||||
"name": "Plume",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"protocols": ["activitypub"],
|
||||
"services": {
|
||||
"inbound": [],
|
||||
"outbound": []
|
||||
},
|
||||
"openRegistrations": true,
|
||||
"usage": {
|
||||
"users": {
|
||||
"total": User::count_local(&*conn)
|
||||
},
|
||||
"localPosts": Post::count_local(&*conn),
|
||||
"localComments": Comment::count_local(&*conn)
|
||||
},
|
||||
"metadata": {}
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -6,6 +6,18 @@ use activity_pub::{ap_url, webfinger::Webfinger};
|
||||
use db_conn::DbConn;
|
||||
use models::{blogs::Blog, users::User};
|
||||
|
||||
#[get("/.well-known/nodeinfo")]
|
||||
fn nodeinfo() -> Content<String> {
|
||||
Content(ContentType::new("application", "jrd+json"), json!({
|
||||
"links": [
|
||||
{
|
||||
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
||||
"href": ap_url(format!("{domain}/nodeinfo", domain = BASE_URL.as_str()))
|
||||
}
|
||||
]
|
||||
}).to_string())
|
||||
}
|
||||
|
||||
#[get("/.well-known/host-meta", format = "application/xml")]
|
||||
fn host_meta() -> String {
|
||||
format!(r#"
|
||||
|
||||
Reference in New Issue
Block a user