-use actix_web::{error::ErrorBadRequest, *};
+use actix_web::*;
use lemmy_api::Perform;
use lemmy_api_common::{comment::*, community::*, person::*, post::*, site::*, websocket::*};
use lemmy_api_crud::PerformCrud;
// Admin Actions
.route("", web::post().to(route_post_crud::<CreateSite>))
.route("", web::put().to(route_post_crud::<EditSite>))
- .route("/transfer", web::post().to(route_post::<TransferSite>))
.route("/config", web::get().to(route_get::<GetSiteConfig>))
.route("/config", web::put().to(route_post::<SaveSiteConfig>)),
)
.wrap(rate_limit.message())
.route(web::get().to(route_get::<Search>)),
)
+ .service(
+ web::resource("/resolve_object")
+ .wrap(rate_limit.message())
+ .route(web::get().to(route_get::<ResolveObject>)),
+ )
// Community
.service(
web::resource("/community")
.wrap(rate_limit.message())
.route("", web::get().to(route_get_crud::<GetCommunity>))
.route("", web::put().to(route_post_crud::<EditCommunity>))
+ .route("/hide", web::put().to(route_post_crud::<HideCommunity>))
.route("/list", web::get().to(route_get_crud::<ListCommunities>))
.route("/follow", web::post().to(route_post::<FollowCommunity>))
+ .route("/block", web::post().to(route_post::<BlockCommunity>))
.route(
"/delete",
web::post().to(route_post_crud::<DeleteCommunity>),
.route("", web::put().to(route_post_crud::<EditPost>))
.route("/delete", web::post().to(route_post_crud::<DeletePost>))
.route("/remove", web::post().to(route_post_crud::<RemovePost>))
+ .route(
+ "/mark_as_read",
+ web::post().to(route_post::<MarkPostAsRead>),
+ )
.route("/lock", web::post().to(route_post::<LockPost>))
.route("/sticky", web::post().to(route_post::<StickyPost>))
.route("/list", web::get().to(route_get_crud::<GetPosts>))
),
)
// Comment
+ .service(
+ // Handle POST to /comment separately to add the comment() rate limitter
+ web::resource("/comment")
+ .guard(guard::Post())
+ .wrap(rate_limit.comment())
+ .route(web::post().to(route_post_crud::<CreateComment>)),
+ )
.service(
web::scope("/comment")
.wrap(rate_limit.message())
- .route("", web::post().to(route_post_crud::<CreateComment>))
+ .route("", web::get().to(route_get_crud::<GetComment>))
.route("", web::put().to(route_post_crud::<EditComment>))
.route("/delete", web::post().to(route_post_crud::<DeleteComment>))
.route("/remove", web::post().to(route_post_crud::<RemoveComment>))
.wrap(rate_limit.register())
.route(web::post().to(route_post_crud::<Register>)),
)
+ .service(
+ // Handle captcha separately
+ web::resource("/user/get_captcha")
+ .wrap(rate_limit.post())
+ .route(web::get().to(route_get::<GetCaptcha>)),
+ )
// User actions
.service(
web::scope("/user")
web::post().to(route_post::<MarkPersonMentionAsRead>),
)
.route("/replies", web::get().to(route_get::<GetReplies>))
- .route(
- "/followed_communities",
- web::get().to(route_get::<GetFollowedCommunities>),
- )
.route("/join", web::post().to(route_post::<UserJoin>))
// Admin action. I don't like that it's in /user
.route("/ban", web::post().to(route_post::<BanPerson>))
+ .route("/banned", web::get().to(route_get::<GetBannedPersons>))
+ .route("/block", web::post().to(route_post::<BlockPerson>))
// Account actions. I don't like that they're in /user maybe /accounts
.route("/login", web::post().to(route_post::<Login>))
- .route("/get_captcha", web::get().to(route_get::<GetCaptcha>))
.route(
"/delete_account",
web::post().to(route_post_crud::<DeleteAccount>),
"/change_password",
web::put().to(route_post::<ChangePassword>),
)
- .route("/report_count", web::get().to(route_get::<GetReportCount>)),
+ .route("/report_count", web::get().to(route_get::<GetReportCount>))
+ .route("/unread_count", web::get().to(route_get::<GetUnreadCount>))
+ .route("/verify_email", web::post().to(route_post::<VerifyEmail>))
+ .route("/leave_admin", web::post().to(route_post::<LeaveAdmin>)),
)
// Admin Actions
.service(
- web::resource("/admin/add")
+ web::scope("/admin")
.wrap(rate_limit.message())
- .route(web::post().to(route_post::<AddAdmin>)),
+ .route("/add", web::post().to(route_post::<AddAdmin>))
+ .route(
+ "/registration_application/count",
+ web::get().to(route_get::<GetUnreadRegistrationApplicationCount>),
+ )
+ .route(
+ "/registration_application/list",
+ web::get().to(route_get::<ListRegistrationApplications>),
+ )
+ .route(
+ "/registration_application/approve",
+ web::put().to(route_post::<ApproveRegistrationApplication>),
+ ),
),
);
}
let res = data
.perform(&context, None)
.await
- .map(|json| HttpResponse::Ok().json(json))
- .map_err(ErrorBadRequest)?;
+ .map(|json| HttpResponse::Ok().json(json))?;
Ok(res)
}
let res = data
.perform(&context, None)
.await
- .map(|json| HttpResponse::Ok().json(json))
- .map_err(ErrorBadRequest)?;
+ .map(|json| HttpResponse::Ok().json(json))?;
Ok(res)
}