|
|
@ -9,7 +9,6 @@ use lemmy_api_common::{
|
|
|
|
DistinguishComment,
|
|
|
|
DistinguishComment,
|
|
|
|
EditComment,
|
|
|
|
EditComment,
|
|
|
|
GetComment,
|
|
|
|
GetComment,
|
|
|
|
GetComments,
|
|
|
|
|
|
|
|
ListCommentReports,
|
|
|
|
ListCommentReports,
|
|
|
|
RemoveComment,
|
|
|
|
RemoveComment,
|
|
|
|
ResolveCommentReport,
|
|
|
|
ResolveCommentReport,
|
|
|
@ -23,7 +22,6 @@ use lemmy_api_common::{
|
|
|
|
DeleteCommunity,
|
|
|
|
DeleteCommunity,
|
|
|
|
EditCommunity,
|
|
|
|
EditCommunity,
|
|
|
|
FollowCommunity,
|
|
|
|
FollowCommunity,
|
|
|
|
GetCommunity,
|
|
|
|
|
|
|
|
HideCommunity,
|
|
|
|
HideCommunity,
|
|
|
|
ListCommunities,
|
|
|
|
ListCommunities,
|
|
|
|
RemoveCommunity,
|
|
|
|
RemoveCommunity,
|
|
|
@ -39,7 +37,6 @@ use lemmy_api_common::{
|
|
|
|
DeleteAccount,
|
|
|
|
DeleteAccount,
|
|
|
|
GetBannedPersons,
|
|
|
|
GetBannedPersons,
|
|
|
|
GetCaptcha,
|
|
|
|
GetCaptcha,
|
|
|
|
GetPersonDetails,
|
|
|
|
|
|
|
|
GetPersonMentions,
|
|
|
|
GetPersonMentions,
|
|
|
|
GetReplies,
|
|
|
|
GetReplies,
|
|
|
|
GetReportCount,
|
|
|
|
GetReportCount,
|
|
|
@ -62,7 +59,6 @@ use lemmy_api_common::{
|
|
|
|
EditPost,
|
|
|
|
EditPost,
|
|
|
|
FeaturePost,
|
|
|
|
FeaturePost,
|
|
|
|
GetPost,
|
|
|
|
GetPost,
|
|
|
|
GetPosts,
|
|
|
|
|
|
|
|
GetSiteMetadata,
|
|
|
|
GetSiteMetadata,
|
|
|
|
ListPostReports,
|
|
|
|
ListPostReports,
|
|
|
|
LockPost,
|
|
|
|
LockPost,
|
|
|
@ -95,12 +91,20 @@ use lemmy_api_common::{
|
|
|
|
PurgeCommunity,
|
|
|
|
PurgeCommunity,
|
|
|
|
PurgePerson,
|
|
|
|
PurgePerson,
|
|
|
|
PurgePost,
|
|
|
|
PurgePost,
|
|
|
|
ResolveObject,
|
|
|
|
|
|
|
|
Search,
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use lemmy_api_crud::PerformCrud;
|
|
|
|
use lemmy_api_crud::PerformCrud;
|
|
|
|
use lemmy_apub::{api::PerformApub, SendActivity};
|
|
|
|
use lemmy_apub::{
|
|
|
|
|
|
|
|
api::{
|
|
|
|
|
|
|
|
list_comments::list_comments,
|
|
|
|
|
|
|
|
list_posts::list_posts,
|
|
|
|
|
|
|
|
read_community::read_community,
|
|
|
|
|
|
|
|
read_person::read_person,
|
|
|
|
|
|
|
|
resolve_object::resolve_object,
|
|
|
|
|
|
|
|
search::search,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
SendActivity,
|
|
|
|
|
|
|
|
};
|
|
|
|
use lemmy_utils::rate_limit::RateLimitCell;
|
|
|
|
use lemmy_utils::rate_limit::RateLimitCell;
|
|
|
|
use serde::Deserialize;
|
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
|
|
|
|
|
@ -124,12 +128,12 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
|
|
|
.service(
|
|
|
|
.service(
|
|
|
|
web::resource("/search")
|
|
|
|
web::resource("/search")
|
|
|
|
.wrap(rate_limit.search())
|
|
|
|
.wrap(rate_limit.search())
|
|
|
|
.route(web::get().to(route_get_apub::<Search>)),
|
|
|
|
.route(web::get().to(search)),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.service(
|
|
|
|
.service(
|
|
|
|
web::resource("/resolve_object")
|
|
|
|
web::resource("/resolve_object")
|
|
|
|
.wrap(rate_limit.message())
|
|
|
|
.wrap(rate_limit.message())
|
|
|
|
.route(web::get().to(route_get_apub::<ResolveObject>)),
|
|
|
|
.route(web::get().to(resolve_object)),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
// Community
|
|
|
|
// Community
|
|
|
|
.service(
|
|
|
|
.service(
|
|
|
@ -141,7 +145,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
|
|
|
.service(
|
|
|
|
.service(
|
|
|
|
web::scope("/community")
|
|
|
|
web::scope("/community")
|
|
|
|
.wrap(rate_limit.message())
|
|
|
|
.wrap(rate_limit.message())
|
|
|
|
.route("", web::get().to(route_get_apub::<GetCommunity>))
|
|
|
|
.route("", web::get().to(read_community))
|
|
|
|
.route("", web::put().to(route_post_crud::<EditCommunity>))
|
|
|
|
.route("", web::put().to(route_post_crud::<EditCommunity>))
|
|
|
|
.route("/hide", web::put().to(route_post::<HideCommunity>))
|
|
|
|
.route("/hide", web::put().to(route_post::<HideCommunity>))
|
|
|
|
.route("/list", web::get().to(route_get_crud::<ListCommunities>))
|
|
|
|
.route("/list", web::get().to(route_get_crud::<ListCommunities>))
|
|
|
@ -186,7 +190,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.route("/lock", web::post().to(route_post::<LockPost>))
|
|
|
|
.route("/lock", web::post().to(route_post::<LockPost>))
|
|
|
|
.route("/feature", web::post().to(route_post::<FeaturePost>))
|
|
|
|
.route("/feature", web::post().to(route_post::<FeaturePost>))
|
|
|
|
.route("/list", web::get().to(route_get_apub::<GetPosts>))
|
|
|
|
.route("/list", web::get().to(list_posts))
|
|
|
|
.route("/like", web::post().to(route_post::<CreatePostLike>))
|
|
|
|
.route("/like", web::post().to(route_post::<CreatePostLike>))
|
|
|
|
.route("/save", web::put().to(route_post::<SavePost>))
|
|
|
|
.route("/save", web::put().to(route_post::<SavePost>))
|
|
|
|
.route("/report", web::post().to(route_post::<CreatePostReport>))
|
|
|
|
.route("/report", web::post().to(route_post::<CreatePostReport>))
|
|
|
@ -225,7 +229,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.route("/like", web::post().to(route_post::<CreateCommentLike>))
|
|
|
|
.route("/like", web::post().to(route_post::<CreateCommentLike>))
|
|
|
|
.route("/save", web::put().to(route_post::<SaveComment>))
|
|
|
|
.route("/save", web::put().to(route_post::<SaveComment>))
|
|
|
|
.route("/list", web::get().to(route_get_apub::<GetComments>))
|
|
|
|
.route("/list", web::get().to(list_comments))
|
|
|
|
.route("/report", web::post().to(route_post::<CreateCommentReport>))
|
|
|
|
.route("/report", web::post().to(route_post::<CreateCommentReport>))
|
|
|
|
.route(
|
|
|
|
.route(
|
|
|
|
"/report/resolve",
|
|
|
|
"/report/resolve",
|
|
|
@ -283,7 +287,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
|
|
|
.service(
|
|
|
|
.service(
|
|
|
|
web::scope("/user")
|
|
|
|
web::scope("/user")
|
|
|
|
.wrap(rate_limit.message())
|
|
|
|
.wrap(rate_limit.message())
|
|
|
|
.route("", web::get().to(route_get_apub::<GetPersonDetails>))
|
|
|
|
.route("", web::get().to(read_person))
|
|
|
|
.route("/mention", web::get().to(route_get::<GetPersonMentions>))
|
|
|
|
.route("/mention", web::get().to(route_get::<GetPersonMentions>))
|
|
|
|
.route(
|
|
|
|
.route(
|
|
|
|
"/mention/mark_as_read",
|
|
|
|
"/mention/mark_as_read",
|
|
|
@ -398,23 +402,6 @@ where
|
|
|
|
perform::<Data>(data.0, context, apub_data).await
|
|
|
|
perform::<Data>(data.0, context, apub_data).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn route_get_apub<'a, Data>(
|
|
|
|
|
|
|
|
data: web::Query<Data>,
|
|
|
|
|
|
|
|
context: activitypub_federation::config::Data<LemmyContext>,
|
|
|
|
|
|
|
|
) -> Result<HttpResponse, Error>
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
Data: PerformApub
|
|
|
|
|
|
|
|
+ SendActivity<Response = <Data as PerformApub>::Response>
|
|
|
|
|
|
|
|
+ Clone
|
|
|
|
|
|
|
|
+ Deserialize<'a>
|
|
|
|
|
|
|
|
+ Send
|
|
|
|
|
|
|
|
+ 'static,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let res = data.perform(&context).await?;
|
|
|
|
|
|
|
|
SendActivity::send_activity(&data.0, &res, &context).await?;
|
|
|
|
|
|
|
|
Ok(HttpResponse::Ok().json(res))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async fn route_post<'a, Data>(
|
|
|
|
async fn route_post<'a, Data>(
|
|
|
|
data: web::Json<Data>,
|
|
|
|
data: web::Json<Data>,
|
|
|
|
context: web::Data<LemmyContext>,
|
|
|
|
context: web::Data<LemmyContext>,
|
|
|
|