From a62422275107a46a627be2dd4130677d869d0a5a Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 6 Apr 2024 17:20:44 +0200 Subject: [PATCH] feat: listed half of mastodon's api routes --- Cargo.toml | 1 + src/main.rs | 1 + src/mastodon/README.md | 3 ++ src/mastodon/mod.rs | 69 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 src/mastodon/README.md create mode 100644 src/mastodon/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 5f27c11..8da19d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,3 +32,4 @@ sha256 = "1.5.0" openssl = "0.10.64" base64 = "0.22.0" http-signature-normalization = "0.7.0" +mastodon-async-entities = "1.1.0" diff --git a/src/main.rs b/src/main.rs index 0902257..d060bf9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ mod errors; mod auth; mod dispatcher; mod fetcher; +mod mastodon; use clap::{Parser, Subcommand}; use sea_orm::{ConnectOptions, Database, EntityTrait, IntoActiveModel}; diff --git a/src/mastodon/README.md b/src/mastodon/README.md new file mode 100644 index 0000000..ec070f4 --- /dev/null +++ b/src/mastodon/README.md @@ -0,0 +1,3 @@ +# mastodon + +here live the Mastodon API routes for this application diff --git a/src/mastodon/mod.rs b/src/mastodon/mod.rs new file mode 100644 index 0000000..b1dd944 --- /dev/null +++ b/src/mastodon/mod.rs @@ -0,0 +1,69 @@ +use axum::{http::StatusCode, routing::{delete, get, patch, post}, Router}; +use crate::server::Context; + +#[allow(unused)] +async fn todo() -> StatusCode { StatusCode::NOT_IMPLEMENTED } + +#[allow(unused)] +pub async fn mastodon_api_routes(router: Router) -> Router { + router.nest( + // TODO Oauth is just under /oauth + "/api/v1", Router::new() + .route("/apps", post(todo)) // create an application + .route("/apps/verify_credentials", post(todo)) // confirm that the app's oauth2 credentials work + .route("/emails/confirmations", post(todo)) + .route("/accounts", post(todo)) + .route("/accounts/verify_credentials", get(todo)) + .route("/accounts/update_credentials", patch(todo)) + .route("/accounts/:id", get(todo)) + .route("/accounts/:id/statuses", get(todo)) + .route("/accounts/:id/followers", get(todo)) + .route("/accounts/:id/following", get(todo)) + .route("/accounts/:id/featured_tags", get(todo)) + .route("/accounts/:id/lists", get(todo)) + .route("/accounts/:id/follow", post(todo)) + .route("/accounts/:id/unfollow", post(todo)) + .route("/accounts/:id/remove_from_followers", post(todo)) + .route("/accounts/:id/block", post(todo)) + .route("/accounts/:id/unblock", post(todo)) + .route("/accounts/:id/mute", post(todo)) + .route("/accounts/:id/unmute", post(todo)) + .route("/accounts/:id/pin", post(todo)) + .route("/accounts/:id/unpin", post(todo)) + .route("/accounts/:id/note", post(todo)) + .route("/accounts/relationships", get(todo)) + .route("/accounts/familiar_followers", get(todo)) + .route("/accounts/search", get(todo)) + .route("/accounts/lookup", get(todo)) + .route("/accounts/:id/identity_proofs", get(todo)) + .route("/bookmarks", get(todo)) + .route("/favourites", get(todo)) + .route("/mutes", get(todo)) + .route("/blocks", get(todo)) + .route("/domain_blocks", get(todo)) + .route("/domain_blocks", post(todo)) + .route("/domain_blocks", delete(todo)) + // TODO filters! api v2 + .route("/reports", post(todo)) + .route("/follow_requests", get(todo)) + .route("/follow_requests/:account_id/authorize", get(todo)) + .route("/follow_requests/:account_id/reject", get(todo)) + .route("/endorsements", get(todo)) + .route("/featured_tags", get(todo)) + .route("/featured_tags", post(todo)) + .route("/featured_tags/:id", delete(todo)) + .route("/featured_tags/suggestions", get(todo)) + .route("/preferences", get(todo)) + .route("/followed_tags", get(todo)) + // TODO suggestions! api v2 + .route("/suggestions", get(todo)) + .route("/suggestions/:account_id", delete(todo)) + .route("/tags/:id", get(todo)) + .route("/tags/:id/follow", post(todo)) + .route("/tags/:id/unfollow", post(todo)) + .route("/profile/avatar", delete(todo)) + .route("/profile/header", delete(todo)) + .route("/statuses", post(todo)) + + ) +}