Correct url for nodeinfo version (#4734)

* Correct url for nodeinfo version

* add compat redirect

---------

Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
This commit is contained in:
Nutomic 2024-05-23 16:59:56 +02:00 committed by GitHub
parent d8dc38eb06
commit b2c1a14234
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<LemmyContext>) -> LemmyResult<HttpResponse> {
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(),
))?,
}],