From 5b22c0c33b47ba6aff5987f12f2e7c7d66ad5c32 Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 11 May 2024 15:59:35 +0200 Subject: [PATCH] feat: added /api/v1/instance in mastodon api because aode relay blasts me of requests on that endpoint... aode you should limit how many fetches you do!!!!!!!!!! --- src/routes/mastodon/instance.rs | 22 ++++++++++++++++++++++ src/routes/mastodon/mod.rs | 3 +++ 2 files changed, 25 insertions(+) create mode 100644 src/routes/mastodon/instance.rs diff --git a/src/routes/mastodon/instance.rs b/src/routes/mastodon/instance.rs new file mode 100644 index 00000000..b1b8e23f --- /dev/null +++ b/src/routes/mastodon/instance.rs @@ -0,0 +1,22 @@ +use axum::{extract::State, Json}; + +use crate::server::Context; + + +pub async fn get( + State(ctx): State, +) -> crate::Result> { + Ok(Json(mastodon_async_entities::instance::Instance { + uri: ctx.domain().to_string(), + title: "μpub".to_string(), + description: "micro social network, federated".to_string(), + email: "me@alemi.dev".to_string(), + version: crate::VERSION.to_string(), + urls: None, + stats: None, + thumbnail: None, + languages: None, + contact_account: None, + max_toot_chars: None, + })) +} diff --git a/src/routes/mastodon/mod.rs b/src/routes/mastodon/mod.rs index faef270e..0ff1ceed 100644 --- a/src/routes/mastodon/mod.rs +++ b/src/routes/mastodon/mod.rs @@ -1,4 +1,5 @@ pub mod accounts; +pub mod instance; use axum::{http::StatusCode, routing::{delete, get, patch, post}, Router}; use crate::server::Context; @@ -70,6 +71,8 @@ impl MastodonRouter for Router { .route("/profile/avatar", delete(todo)) .route("/profile/header", delete(todo)) .route("/statuses", post(todo)) + // ... + .route("/instance", get(mas::instance::get)) ) } }