feat: added manifest route

This commit is contained in:
əlemi 2024-08-15 16:20:03 +02:00
parent 1f412efdd2
commit 57e465090b
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 36 additions and 0 deletions

View file

@ -36,6 +36,7 @@ impl ActivityPubRouter for Router<upub::Context> {
.route("/auth", post(ap::auth::login)) .route("/auth", post(ap::auth::login))
.route("/auth", patch(ap::auth::refresh)) .route("/auth", patch(ap::auth::refresh))
// .well-known and discovery // .well-known and discovery
.route("/manifest.json", get(ap::well_known::manifest))
.route("/.well-known/webfinger", get(ap::well_known::webfinger)) .route("/.well-known/webfinger", get(ap::well_known::webfinger))
.route("/.well-known/host-meta", get(ap::well_known::host_meta)) .route("/.well-known/host-meta", get(ap::well_known::host_meta))
.route("/.well-known/nodeinfo", get(ap::well_known::nodeinfo_discovery)) .route("/.well-known/nodeinfo", get(ap::well_known::nodeinfo_discovery))

View file

@ -156,6 +156,41 @@ pub async fn webfinger(
})) }))
} }
pub async fn manifest(State(ctx): State<Context>) -> Json<ManifestResponse> {
axum::Json(ManifestResponse {
id: ctx.cfg().instance.domain.clone(),
name: ctx.cfg().instance.name.clone(),
short_name: ctx.cfg().instance.name.clone(),
description: ctx.cfg().instance.description.clone(),
start_url: "/web".to_string(),
scope: format!("https://{}/web", ctx.cfg().instance.domain),
display: "standalone".to_string(),
background_color: "#201f29".to_string(),
theme_color: "#bf616a".to_string(),
orientation: "portrait-primary".to_string(),
icons: vec![],
shortcuts: vec![],
categories: vec!["social".to_string()]
})
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct ManifestResponse {
background_color: String,
categories: Vec<String>,
description: String,
display: String, // "fullscreen", "standalone", "minima-ui", "browser"
icons: Vec<String>, // TODO Vec of objects: {stc: string, sizes: string, type: string? }
id: String,
name: String,
orientation: String, // "any", "natural", "landscape", "landscape-primary", "landscape-secondary", "portrait", "portrait-primary", "portrait-secondary"
scope: String,
short_name: String,
shortcuts: Vec<String>, // TODO Vec of objects: {name: string, url: string, description: string?}
start_url: String,
theme_color: String,
}
// i don't even want to bother with XML, im just returning a formatted xml string // i don't even want to bother with XML, im just returning a formatted xml string
pub async fn host_meta(State(ctx): State<Context>) -> Response { pub async fn host_meta(State(ctx): State<Context>) -> Response {
( (