remove web::

This commit is contained in:
Felix Ableitner 2024-11-28 15:56:34 +01:00
parent a7942e53a0
commit 8ac9e2b2d4
2 changed files with 268 additions and 274 deletions

View file

@ -1,4 +1,4 @@
use actix_web::{guard, web}; use actix_web::{guard, web::*};
use lemmy_api::{ use lemmy_api::{
comment::{ comment::{
distinguish::distinguish_comment, distinguish::distinguish_comment,
@ -137,137 +137,137 @@ use lemmy_apub::api::{
use lemmy_routes::images::image_proxy; use lemmy_routes::images::image_proxy;
use lemmy_utils::rate_limit::RateLimitCell; use lemmy_utils::rate_limit::RateLimitCell;
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) { pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
cfg.service( cfg.service(
web::scope("/api/v3") scope("/api/v3")
.route("/image_proxy", web::get().to(image_proxy)) .route("/image_proxy", get().to(image_proxy))
// Site // Site
.service( .service(
web::scope("/site") scope("/site")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("", web::get().to(get_site_v3)) .route("", get().to(get_site_v3))
// Admin Actions // Admin Actions
.route("", web::post().to(create_site)) .route("", post().to(create_site))
.route("", web::put().to(update_site)) .route("", put().to(update_site))
.route("/block", web::post().to(block_instance)), .route("/block", post().to(block_instance)),
) )
.service( .service(
web::resource("/modlog") resource("/modlog")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route(web::get().to(get_mod_log)), .route(get().to(get_mod_log)),
) )
.service( .service(
web::resource("/search") resource("/search")
.wrap(rate_limit.search()) .wrap(rate_limit.search())
.route(web::get().to(search)), .route(get().to(search)),
) )
.service( .service(
web::resource("/resolve_object") resource("/resolve_object")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route(web::get().to(resolve_object)), .route(get().to(resolve_object)),
) )
// Community // Community
.service( .service(
web::resource("/community") resource("/community")
.guard(guard::Post()) .guard(guard::Post())
.wrap(rate_limit.register()) .wrap(rate_limit.register())
.route(web::post().to(create_community)), .route(post().to(create_community)),
) )
.service( .service(
web::scope("/community") scope("/community")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("", web::get().to(get_community)) .route("", get().to(get_community))
.route("", web::put().to(update_community)) .route("", put().to(update_community))
.route("/hide", web::put().to(hide_community)) .route("/hide", put().to(hide_community))
.route("/list", web::get().to(list_communities)) .route("/list", get().to(list_communities))
.route("/follow", web::post().to(follow_community)) .route("/follow", post().to(follow_community))
.route("/block", web::post().to(block_community)) .route("/block", post().to(block_community))
.route("/delete", web::post().to(delete_community)) .route("/delete", post().to(delete_community))
// Mod Actions // Mod Actions
.route("/remove", web::post().to(remove_community)) .route("/remove", post().to(remove_community))
.route("/transfer", web::post().to(transfer_community)) .route("/transfer", post().to(transfer_community))
.route("/ban_user", web::post().to(ban_from_community)) .route("/ban_user", post().to(ban_from_community))
.route("/mod", web::post().to(add_mod_to_community)), .route("/mod", post().to(add_mod_to_community)),
) )
.service( .service(
web::scope("/federated_instances") scope("/federated_instances")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("", web::get().to(get_federated_instances)), .route("", get().to(get_federated_instances)),
) )
// Post // Post
.service( .service(
// Handle POST to /post separately to add the post() rate limitter // Handle POST to /post separately to add the post() rate limitter
web::resource("/post") resource("/post")
.guard(guard::Post()) .guard(guard::Post())
.wrap(rate_limit.post()) .wrap(rate_limit.post())
.route(web::post().to(create_post)), .route(post().to(create_post)),
) )
.service( .service(
web::scope("/post") scope("/post")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("", web::get().to(get_post)) .route("", get().to(get_post))
.route("", web::put().to(update_post)) .route("", put().to(update_post))
.route("/delete", web::post().to(delete_post)) .route("/delete", post().to(delete_post))
.route("/remove", web::post().to(remove_post)) .route("/remove", post().to(remove_post))
.route("/mark_as_read", web::post().to(mark_post_as_read)) .route("/mark_as_read", post().to(mark_post_as_read))
.route("/hide", web::post().to(hide_post)) .route("/hide", post().to(hide_post))
.route("/lock", web::post().to(lock_post)) .route("/lock", post().to(lock_post))
.route("/feature", web::post().to(feature_post)) .route("/feature", post().to(feature_post))
.route("/list", web::get().to(list_posts)) .route("/list", get().to(list_posts))
.route("/like", web::post().to(like_post)) .route("/like", post().to(like_post))
.route("/like/list", web::get().to(list_post_likes)) .route("/like/list", get().to(list_post_likes))
.route("/save", web::put().to(save_post)) .route("/save", put().to(save_post))
.route("/report", web::post().to(create_post_report)) .route("/report", post().to(create_post_report))
.route("/report/resolve", web::put().to(resolve_post_report)) .route("/report/resolve", put().to(resolve_post_report))
.route("/report/list", web::get().to(list_post_reports)) .route("/report/list", get().to(list_post_reports))
.route("/site_metadata", web::get().to(get_link_metadata)), .route("/site_metadata", get().to(get_link_metadata)),
) )
// Comment // Comment
.service( .service(
// Handle POST to /comment separately to add the comment() rate limitter // Handle POST to /comment separately to add the comment() rate limitter
web::resource("/comment") resource("/comment")
.guard(guard::Post()) .guard(guard::Post())
.wrap(rate_limit.comment()) .wrap(rate_limit.comment())
.route(web::post().to(create_comment)), .route(post().to(create_comment)),
) )
.service( .service(
web::scope("/comment") scope("/comment")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("", web::get().to(get_comment)) .route("", get().to(get_comment))
.route("", web::put().to(update_comment)) .route("", put().to(update_comment))
.route("/delete", web::post().to(delete_comment)) .route("/delete", post().to(delete_comment))
.route("/remove", web::post().to(remove_comment)) .route("/remove", post().to(remove_comment))
.route("/mark_as_read", web::post().to(mark_reply_as_read)) .route("/mark_as_read", post().to(mark_reply_as_read))
.route("/distinguish", web::post().to(distinguish_comment)) .route("/distinguish", post().to(distinguish_comment))
.route("/like", web::post().to(like_comment)) .route("/like", post().to(like_comment))
.route("/like/list", web::get().to(list_comment_likes)) .route("/like/list", get().to(list_comment_likes))
.route("/save", web::put().to(save_comment)) .route("/save", put().to(save_comment))
.route("/list", web::get().to(list_comments)) .route("/list", get().to(list_comments))
.route("/report", web::post().to(create_comment_report)) .route("/report", post().to(create_comment_report))
.route("/report/resolve", web::put().to(resolve_comment_report)) .route("/report/resolve", put().to(resolve_comment_report))
.route("/report/list", web::get().to(list_comment_reports)), .route("/report/list", get().to(list_comment_reports)),
) )
// Private Message // Private Message
.service( .service(
web::scope("/private_message") scope("/private_message")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("/list", web::get().to(get_private_message)) .route("/list", get().to(get_private_message))
.route("", web::post().to(create_private_message)) .route("", post().to(create_private_message))
.route("", web::put().to(update_private_message)) .route("", put().to(update_private_message))
.route("/delete", web::post().to(delete_private_message)) .route("/delete", post().to(delete_private_message))
.route("/mark_as_read", web::post().to(mark_pm_as_read)) .route("/mark_as_read", post().to(mark_pm_as_read))
.route("/report", web::post().to(create_pm_report)) .route("/report", post().to(create_pm_report))
.route("/report/resolve", web::put().to(resolve_pm_report)) .route("/report/resolve", put().to(resolve_pm_report))
.route("/report/list", web::get().to(list_pm_reports)), .route("/report/list", get().to(list_pm_reports)),
) )
// User // User
.service( .service(
// Account action, I don't like that it's in /user maybe /accounts // Account action, I don't like that it's in /user maybe /accounts
// Handle /user/register separately to add the register() rate limiter // Handle /user/register separately to add the register() rate limiter
web::resource("/user/register") resource("/user/register")
.guard(guard::Post()) .guard(guard::Post())
.wrap(rate_limit.register()) .wrap(rate_limit.register())
.route(web::post().to(register)), .route(post().to(register)),
) )
// User // User
.service( .service(
@ -275,117 +275,111 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
// TODO: pretty annoying way to apply rate limits for register and login, we should // TODO: pretty annoying way to apply rate limits for register and login, we should
// group them under a common path so that rate limit is only applied once (eg under // group them under a common path so that rate limit is only applied once (eg under
// /account). // /account).
web::resource("/user/login") resource("/user/login")
.guard(guard::Post()) .guard(guard::Post())
.wrap(rate_limit.register()) .wrap(rate_limit.register())
.route(web::post().to(login)), .route(post().to(login)),
) )
.service( .service(
web::resource("/user/password_reset") resource("/user/password_reset")
.wrap(rate_limit.register()) .wrap(rate_limit.register())
.route(web::post().to(reset_password)), .route(post().to(reset_password)),
) )
.service( .service(
// Handle captcha separately // Handle captcha separately
web::resource("/user/get_captcha") resource("/user/get_captcha")
.wrap(rate_limit.post()) .wrap(rate_limit.post())
.route(web::get().to(get_captcha)), .route(get().to(get_captcha)),
) )
.service( .service(
web::resource("/user/export_settings") resource("/user/export_settings")
.wrap(rate_limit.import_user_settings()) .wrap(rate_limit.import_user_settings())
.route(web::get().to(export_settings)), .route(get().to(export_settings)),
) )
.service( .service(
web::resource("/user/import_settings") resource("/user/import_settings")
.wrap(rate_limit.import_user_settings()) .wrap(rate_limit.import_user_settings())
.route(web::post().to(import_settings)), .route(post().to(import_settings)),
) )
// TODO, all the current account related actions under /user need to get moved here eventually // TODO, all the current account related actions under /user need to get moved here eventually
.service( .service(
web::scope("/account") scope("/account")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("/list_media", web::get().to(list_media)), .route("/list_media", get().to(list_media)),
) )
// User actions // User actions
.service( .service(
web::scope("/user") scope("/user")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("", web::get().to(read_person)) .route("", get().to(read_person))
.route("/mention", web::get().to(list_mentions)) .route("/mention", get().to(list_mentions))
.route( .route(
"/mention/mark_as_read", "/mention/mark_as_read",
web::post().to(mark_person_mention_as_read), post().to(mark_person_mention_as_read),
) )
.route("/replies", web::get().to(list_replies)) .route("/replies", get().to(list_replies))
// Admin action. I don't like that it's in /user // Admin action. I don't like that it's in /user
.route("/ban", web::post().to(ban_from_site)) .route("/ban", post().to(ban_from_site))
.route("/banned", web::get().to(list_banned_users)) .route("/banned", get().to(list_banned_users))
.route("/block", web::post().to(block_person)) .route("/block", post().to(block_person))
// TODO Account actions. I don't like that they're in /user maybe /accounts // TODO Account actions. I don't like that they're in /user maybe /accounts
.route("/logout", web::post().to(logout)) .route("/logout", post().to(logout))
.route("/delete_account", web::post().to(delete_account)) .route("/delete_account", post().to(delete_account))
.route( .route("/password_change", post().to(change_password_after_reset))
"/password_change",
web::post().to(change_password_after_reset),
)
// TODO mark_all_as_read feels off being in this section as well // TODO mark_all_as_read feels off being in this section as well
.route( .route("/mark_all_as_read", post().to(mark_all_notifications_read))
"/mark_all_as_read", .route("/save_user_settings", put().to(save_user_settings))
web::post().to(mark_all_notifications_read), .route("/change_password", put().to(change_password))
) .route("/report_count", get().to(report_count))
.route("/save_user_settings", web::put().to(save_user_settings)) .route("/unread_count", get().to(unread_count))
.route("/change_password", web::put().to(change_password)) .route("/verify_email", post().to(verify_email))
.route("/report_count", web::get().to(report_count)) .route("/leave_admin", post().to(leave_admin))
.route("/unread_count", web::get().to(unread_count)) .route("/totp/generate", post().to(generate_totp_secret))
.route("/verify_email", web::post().to(verify_email)) .route("/totp/update", post().to(update_totp))
.route("/leave_admin", web::post().to(leave_admin)) .route("/list_logins", get().to(list_logins))
.route("/totp/generate", web::post().to(generate_totp_secret)) .route("/validate_auth", get().to(validate_auth)),
.route("/totp/update", web::post().to(update_totp))
.route("/list_logins", web::get().to(list_logins))
.route("/validate_auth", web::get().to(validate_auth)),
) )
// Admin Actions // Admin Actions
.service( .service(
web::scope("/admin") scope("/admin")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("/add", web::post().to(add_admin)) .route("/add", post().to(add_admin))
.route( .route(
"/registration_application/count", "/registration_application/count",
web::get().to(get_unread_registration_application_count), get().to(get_unread_registration_application_count),
) )
.route( .route(
"/registration_application/list", "/registration_application/list",
web::get().to(list_registration_applications), get().to(list_registration_applications),
) )
.route( .route(
"/registration_application/approve", "/registration_application/approve",
web::put().to(approve_registration_application), put().to(approve_registration_application),
) )
.route( .route(
"/registration_application", "/registration_application",
web::get().to(get_registration_application), get().to(get_registration_application),
) )
.route("/list_all_media", web::get().to(list_all_media)) .route("/list_all_media", get().to(list_all_media))
.service( .service(
web::scope("/purge") scope("/purge")
.route("/person", web::post().to(purge_person)) .route("/person", post().to(purge_person))
.route("/community", web::post().to(purge_community)) .route("/community", post().to(purge_community))
.route("/post", web::post().to(purge_post)) .route("/post", post().to(purge_post))
.route("/comment", web::post().to(purge_comment)), .route("/comment", post().to(purge_comment)),
), ),
) )
.service( .service(
web::scope("/custom_emoji") scope("/custom_emoji")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("", web::post().to(create_custom_emoji)) .route("", post().to(create_custom_emoji))
.route("", web::put().to(update_custom_emoji)) .route("", put().to(update_custom_emoji))
.route("/delete", web::post().to(delete_custom_emoji)), .route("/delete", post().to(delete_custom_emoji)),
), ),
); );
cfg.service( cfg.service(
web::scope("/sitemap.xml") scope("/sitemap.xml")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("", web::get().to(get_sitemap)), .route("", get().to(get_sitemap)),
); );
} }

View file

@ -1,4 +1,4 @@
use actix_web::{guard, web}; use actix_web::{guard, web::*};
use lemmy_api::{ use lemmy_api::{
comment::{ comment::{
distinguish::distinguish_comment, distinguish::distinguish_comment,
@ -160,230 +160,230 @@ use lemmy_apub::api::{
use lemmy_routes::images::image_proxy; use lemmy_routes::images::image_proxy;
use lemmy_utils::rate_limit::RateLimitCell; use lemmy_utils::rate_limit::RateLimitCell;
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) { pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
cfg.service( cfg.service(
web::scope("/api/v4") scope("/api/v4")
.wrap(rate_limit.message()) .wrap(rate_limit.message())
.route("/image_proxy", web::get().to(image_proxy)) .route("/image_proxy", get().to(image_proxy))
// Site // Site
.service( .service(
web::scope("/site") scope("/site")
.route("", web::get().to(get_site_v4)) .route("", get().to(get_site_v4))
// Admin Actions // Admin Actions
.route("", web::post().to(create_site)) .route("", post().to(create_site))
.route("", web::put().to(update_site)) .route("", put().to(update_site))
.route("/block", web::post().to(block_instance)), .route("/block", post().to(block_instance)),
) )
.route("/modlog", web::get().to(get_mod_log)) .route("/modlog", get().to(get_mod_log))
.service( .service(
web::resource("/search") resource("/search")
.wrap(rate_limit.search()) .wrap(rate_limit.search())
.route(web::get().to(search)), .route(get().to(search)),
) )
.route("/resolve_object", web::get().to(resolve_object)) .route("/resolve_object", get().to(resolve_object))
// Community // Community
.service( .service(
web::resource("/community") resource("/community")
.guard(guard::Post()) .guard(guard::Post())
.wrap(rate_limit.register()) .wrap(rate_limit.register())
.route(web::post().to(create_community)), .route(post().to(create_community)),
) )
.service( .service(
web::scope("/community") scope("/community")
.route("", web::get().to(get_community)) .route("", get().to(get_community))
.route("", web::put().to(update_community)) .route("", put().to(update_community))
.route("/random", web::get().to(get_random_community)) .route("/random", get().to(get_random_community))
.route("/hide", web::put().to(hide_community)) .route("/hide", put().to(hide_community))
.route("/list", web::get().to(list_communities)) .route("/list", get().to(list_communities))
.route("/follow", web::post().to(follow_community)) .route("/follow", post().to(follow_community))
.route("/block", web::post().to(block_community)) .route("/block", post().to(block_community))
.route("/delete", web::post().to(delete_community)) .route("/delete", post().to(delete_community))
// Mod Actions // Mod Actions
.route("/remove", web::post().to(remove_community)) .route("/remove", post().to(remove_community))
.route("/transfer", web::post().to(transfer_community)) .route("/transfer", post().to(transfer_community))
.route("/ban_user", web::post().to(ban_from_community)) .route("/ban_user", post().to(ban_from_community))
.route("/mod", web::post().to(add_mod_to_community)) .route("/mod", post().to(add_mod_to_community))
.service( .service(
web::scope("/pending_follows") scope("/pending_follows")
.route("/count", web::get().to(get_pending_follows_count)) .route("/count", get().to(get_pending_follows_count))
.route("/list", web::get().to(get_pending_follows_list)) .route("/list", get().to(get_pending_follows_list))
.route("/approve", web::post().to(post_pending_follows_approve)), .route("/approve", post().to(post_pending_follows_approve)),
), ),
) )
.route( .route(
"/federated_instances", "/federated_instances",
web::get().to(get_federated_instances), get().to(get_federated_instances),
) )
// Post // Post
.service( .service(
// Handle POST to /post separately to add the post() rate limitter // Handle POST to /post separately to add the post() rate limitter
web::resource("/post") resource("/post")
.guard(guard::Post()) .guard(guard::Post())
.wrap(rate_limit.post()) .wrap(rate_limit.post())
.route(web::post().to(create_post)), .route(post().to(create_post)),
) )
.service( .service(
web::scope("/post") scope("/post")
.route("", web::get().to(get_post)) .route("", get().to(get_post))
.route("", web::put().to(update_post)) .route("", put().to(update_post))
.route("/delete", web::post().to(delete_post)) .route("/delete", post().to(delete_post))
.route("/remove", web::post().to(remove_post)) .route("/remove", post().to(remove_post))
.route("/mark_as_read", web::post().to(mark_post_as_read)) .route("/mark_as_read", post().to(mark_post_as_read))
.route("/mark_many_as_read", web::post().to(mark_posts_as_read)) .route("/mark_many_as_read", post().to(mark_posts_as_read))
.route("/hide", web::post().to(hide_post)) .route("/hide", post().to(hide_post))
.route("/lock", web::post().to(lock_post)) .route("/lock", post().to(lock_post))
.route("/feature", web::post().to(feature_post)) .route("/feature", post().to(feature_post))
.route("/list", web::get().to(list_posts)) .route("/list", get().to(list_posts))
.route("/like", web::post().to(like_post)) .route("/like", post().to(like_post))
.route("/like/list", web::get().to(list_post_likes)) .route("/like/list", get().to(list_post_likes))
.route("/save", web::put().to(save_post)) .route("/save", put().to(save_post))
.route("/report", web::post().to(create_post_report)) .route("/report", post().to(create_post_report))
.route("/report/resolve", web::put().to(resolve_post_report)) .route("/report/resolve", put().to(resolve_post_report))
.route("/report/list", web::get().to(list_post_reports)) .route("/report/list", get().to(list_post_reports))
.route("/site_metadata", web::get().to(get_link_metadata)), .route("/site_metadata", get().to(get_link_metadata)),
) )
// Comment // Comment
.service( .service(
// Handle POST to /comment separately to add the comment() rate limitter // Handle POST to /comment separately to add the comment() rate limitter
web::resource("/comment") resource("/comment")
.guard(guard::Post()) .guard(guard::Post())
.wrap(rate_limit.comment()) .wrap(rate_limit.comment())
.route(web::post().to(create_comment)), .route(post().to(create_comment)),
) )
.service( .service(
web::scope("/comment") scope("/comment")
.route("", web::get().to(get_comment)) .route("", get().to(get_comment))
.route("", web::put().to(update_comment)) .route("", put().to(update_comment))
.route("/delete", web::post().to(delete_comment)) .route("/delete", post().to(delete_comment))
.route("/remove", web::post().to(remove_comment)) .route("/remove", post().to(remove_comment))
.route("/mark_as_read", web::post().to(mark_reply_as_read)) .route("/mark_as_read", post().to(mark_reply_as_read))
.route("/distinguish", web::post().to(distinguish_comment)) .route("/distinguish", post().to(distinguish_comment))
.route("/like", web::post().to(like_comment)) .route("/like", post().to(like_comment))
.route("/like/list", web::get().to(list_comment_likes)) .route("/like/list", get().to(list_comment_likes))
.route("/save", web::put().to(save_comment)) .route("/save", put().to(save_comment))
.route("/list", web::get().to(list_comments)) .route("/list", get().to(list_comments))
.route("/report", web::post().to(create_comment_report)) .route("/report", post().to(create_comment_report))
.route("/report/resolve", web::put().to(resolve_comment_report)) .route("/report/resolve", put().to(resolve_comment_report))
.route("/report/list", web::get().to(list_comment_reports)), .route("/report/list", get().to(list_comment_reports)),
) )
// Private Message // Private Message
.service( .service(
web::scope("/private_message") scope("/private_message")
.route("/list", web::get().to(get_private_message)) .route("/list", get().to(get_private_message))
.route("", web::post().to(create_private_message)) .route("", post().to(create_private_message))
.route("", web::put().to(update_private_message)) .route("", put().to(update_private_message))
.route("/delete", web::post().to(delete_private_message)) .route("/delete", post().to(delete_private_message))
.route("/mark_as_read", web::post().to(mark_pm_as_read)) .route("/mark_as_read", post().to(mark_pm_as_read))
.route("/report", web::post().to(create_pm_report)) .route("/report", post().to(create_pm_report))
.route("/report/resolve", web::put().to(resolve_pm_report)) .route("/report/resolve", put().to(resolve_pm_report))
.route("/report/list", web::get().to(list_pm_reports)), .route("/report/list", get().to(list_pm_reports)),
) )
// User // User
.service( .service(
web::scope("/account/auth") scope("/account/auth")
.guard(guard::Post()) .guard(guard::Post())
.wrap(rate_limit.register()) .wrap(rate_limit.register())
.route("/register", web::post().to(register)) .route("/register", post().to(register))
.route("/login", web::post().to(login)) .route("/login", post().to(login))
.route("/logout", web::post().to(logout)) .route("/logout", post().to(logout))
.route("/password_reset", web::post().to(reset_password)) .route("/password_reset", post().to(reset_password))
.route("/get_captcha", web::get().to(get_captcha)) .route("/get_captcha", get().to(get_captcha))
.route( .route(
"/password_change", "/password_change",
web::post().to(change_password_after_reset), post().to(change_password_after_reset),
) )
.route("/change_password", web::put().to(change_password)) .route("/change_password", put().to(change_password))
.route("/totp/generate", web::post().to(generate_totp_secret)) .route("/totp/generate", post().to(generate_totp_secret))
.route("/totp/update", web::post().to(update_totp)) .route("/totp/update", post().to(update_totp))
.route("/verify_email", web::post().to(verify_email)), .route("/verify_email", post().to(verify_email)),
) )
.service( .service(
web::scope("/account/settings") scope("/account/settings")
.wrap(rate_limit.import_user_settings()) .wrap(rate_limit.import_user_settings())
.route("/export", web::get().to(export_settings)) .route("/export", get().to(export_settings))
.route("/import", web::post().to(import_settings)), .route("/import", post().to(import_settings)),
) )
.service( .service(
web::scope("/account") scope("/account")
.route("/my_user", web::get().to(get_my_user)) .route("/my_user", get().to(get_my_user))
.route("/list_media", web::get().to(list_media)) .route("/list_media", get().to(list_media))
.route("/mention", web::get().to(list_mentions)) .route("/mention", get().to(list_mentions))
.route("/replies", web::get().to(list_replies)) .route("/replies", get().to(list_replies))
.route("/block", web::post().to(block_person)) .route("/block", post().to(block_person))
.route("/delete", web::post().to(delete_account)) .route("/delete", post().to(delete_account))
.route( .route(
"/mention/mark_as_read", "/mention/mark_as_read",
web::post().to(mark_person_mention_as_read), post().to(mark_person_mention_as_read),
) )
.route( .route(
"/mention/mark_all_as_read", "/mention/mark_all_as_read",
web::post().to(mark_all_notifications_read), post().to(mark_all_notifications_read),
) )
.route("/settings/save", web::put().to(save_user_settings)) .route("/settings/save", put().to(save_user_settings))
.route("/report_count", web::get().to(report_count)) .route("/report_count", get().to(report_count))
.route("/unread_count", web::get().to(unread_count)) .route("/unread_count", get().to(unread_count))
.route("/list_logins", web::get().to(list_logins)) .route("/list_logins", get().to(list_logins))
.route("/validate_auth", web::get().to(validate_auth)), .route("/validate_auth", get().to(validate_auth)),
) )
// User actions // User actions
.route("/person", web::get().to(read_person)) .route("/person", get().to(read_person))
// Admin Actions // Admin Actions
.service( .service(
web::scope("/admin") scope("/admin")
.route("/add", web::post().to(add_admin)) .route("/add", post().to(add_admin))
.route( .route(
"/registration_application/count", "/registration_application/count",
web::get().to(get_unread_registration_application_count), get().to(get_unread_registration_application_count),
) )
.route( .route(
"/registration_application/list", "/registration_application/list",
web::get().to(list_registration_applications), get().to(list_registration_applications),
) )
.route( .route(
"/registration_application/approve", "/registration_application/approve",
web::put().to(approve_registration_application), put().to(approve_registration_application),
) )
.route( .route(
"/registration_application", "/registration_application",
web::get().to(get_registration_application), get().to(get_registration_application),
) )
.route("/list_all_media", web::get().to(list_all_media)) .route("/list_all_media", get().to(list_all_media))
.service( .service(
web::scope("/purge") scope("/purge")
.route("/person", web::post().to(purge_person)) .route("/person", post().to(purge_person))
.route("/community", web::post().to(purge_community)) .route("/community", post().to(purge_community))
.route("/post", web::post().to(purge_post)) .route("/post", post().to(purge_post))
.route("/comment", web::post().to(purge_comment)), .route("/comment", post().to(purge_comment)),
) )
.service( .service(
web::scope("/tagline") scope("/tagline")
.route("", web::post().to(create_tagline)) .route("", post().to(create_tagline))
.route("", web::put().to(update_tagline)) .route("", put().to(update_tagline))
.route("/delete", web::post().to(delete_tagline)) .route("/delete", post().to(delete_tagline))
.route("/list", web::get().to(list_taglines)), .route("/list", get().to(list_taglines)),
) )
.route("/ban", web::post().to(ban_from_site)) .route("/ban", post().to(ban_from_site))
.route("/banned", web::get().to(list_banned_users)) .route("/banned", get().to(list_banned_users))
.route("/leave", web::post().to(leave_admin)), .route("/leave", post().to(leave_admin)),
) )
.service( .service(
web::scope("/custom_emoji") scope("/custom_emoji")
.route("", web::post().to(create_custom_emoji)) .route("", post().to(create_custom_emoji))
.route("", web::put().to(update_custom_emoji)) .route("", put().to(update_custom_emoji))
.route("/delete", web::post().to(delete_custom_emoji)) .route("/delete", post().to(delete_custom_emoji))
.route("/list", web::get().to(list_custom_emojis)), .route("/list", get().to(list_custom_emojis)),
) )
.service( .service(
web::scope("/oauth_provider") scope("/oauth_provider")
.route("", web::post().to(create_oauth_provider)) .route("", post().to(create_oauth_provider))
.route("", web::put().to(update_oauth_provider)) .route("", put().to(update_oauth_provider))
.route("/delete", web::post().to(delete_oauth_provider)), .route("/delete", post().to(delete_oauth_provider)),
) )
.service( .service(
web::scope("/oauth") scope("/oauth")
.wrap(rate_limit.register()) .wrap(rate_limit.register())
.route("/authenticate", web::post().to(authenticate_with_oauth)), .route("/authenticate", post().to(authenticate_with_oauth)),
) )
.route("/sitemap.xml", web::get().to(get_sitemap)), .route("/sitemap.xml", get().to(get_sitemap)),
); );
} }