From b2c1a14234b9c5ad543929f84da0d0cbbd61fc2b Mon Sep 17 00:00:00 2001 From: Nutomic Date: Thu, 23 May 2024 16:59:56 +0200 Subject: [PATCH] Correct url for nodeinfo version (#4734) * Correct url for nodeinfo version * add compat redirect --------- Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> --- crates/routes/src/nodeinfo.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/routes/src/nodeinfo.rs b/crates/routes/src/nodeinfo.rs index 665756864..f64bb72c5 100644 --- a/crates/routes/src/nodeinfo.rs +++ b/crates/routes/src/nodeinfo.rs @@ -14,10 +14,12 @@ use url::Url; pub fn config(cfg: &mut web::ServiceConfig) { cfg .route( - "/nodeinfo/2.0.json", + "/nodeinfo/2.1.json", web::get().to(node_info).wrap(cache_1hour()), ) - .service(web::redirect("/version", "/nodeinfo/2.0.json")) + .service(web::redirect("/version", "/nodeinfo/2.1.json")) + // For backwards compatibility, can be removed after Lemmy 0.20 + .service(web::redirect("/nodeinfo/2.0.json", "/nodeinfo/2.1.json")) .route( "/.well-known/nodeinfo", web::get().to(node_info_well_known).wrap(cache_3days()), @@ -27,9 +29,9 @@ pub fn config(cfg: &mut web::ServiceConfig) { async fn node_info_well_known(context: web::Data) -> LemmyResult { let node_info = NodeInfoWellKnown { links: vec![NodeInfoWellKnownLinks { - rel: Url::parse("http://nodeinfo.diaspora.software/ns/schema/2.0")?, + rel: Url::parse("http://nodeinfo.diaspora.software/ns/schema/2.1")?, href: Url::parse(&format!( - "{}/nodeinfo/2.0.json", + "{}/nodeinfo/2.1.json", &context.settings().get_protocol_and_hostname(), ))?, }],