mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-01 16:51:21 +00:00
Nutomic
ad90cd77f9
* add private visibility * filter private communities in post_view.rs * also filter in comment_view * community follower state * remove unused method * sql fmt * add CommunityFollower.approved_by * implement api endpoints * api changes * only admins can create private community for now * add local api tests * fix api tests * follow remote private community * use authorized fetch for content in private community * federate community visibility * dont mark content in private community as public * expose ApprovalRequired in api * also check content fetchable for outbox/featured * address private community content to followers * implement reject activity * fix tests * add files * remove local api tests * dont use delay * is_new_instance * single query for is_new_instance * return subscribed type for pending follow * working * need to catch errors in waitUntil * clippy * fix query * lint for unused async * diesel.toml comment * add comment * avoid db reads * rename approved_by to approver_id * add helper * form init * list pending follows should return items for all communities * clippy * ci * fix down migration * fix api tests * references * rename * run git diff * ci * fix schema check * fix joins * ci * ci * skip_serializing_none * fix test --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
44 lines
1.5 KiB
Rust
44 lines
1.5 KiB
Rust
use actix_web::web::{Data, Json};
|
|
use lemmy_api_common::{
|
|
context::LemmyContext,
|
|
post::{PostReportResponse, ResolvePostReport},
|
|
utils::check_community_mod_action,
|
|
};
|
|
use lemmy_db_schema::{source::post_report::PostReport, traits::Reportable};
|
|
use lemmy_db_views::structs::{LocalUserView, PostReportView};
|
|
use lemmy_utils::error::{LemmyErrorExt, LemmyErrorType, LemmyResult};
|
|
|
|
/// Resolves or unresolves a post report and notifies the moderators of the community
|
|
#[tracing::instrument(skip(context))]
|
|
pub async fn resolve_post_report(
|
|
data: Json<ResolvePostReport>,
|
|
context: Data<LemmyContext>,
|
|
local_user_view: LocalUserView,
|
|
) -> LemmyResult<Json<PostReportResponse>> {
|
|
let report_id = data.report_id;
|
|
let person_id = local_user_view.person.id;
|
|
let report = PostReportView::read(&mut context.pool(), report_id, person_id).await?;
|
|
|
|
let person_id = local_user_view.person.id;
|
|
check_community_mod_action(
|
|
&local_user_view.person,
|
|
&report.community,
|
|
true,
|
|
&mut context.pool(),
|
|
)
|
|
.await?;
|
|
|
|
if data.resolved {
|
|
PostReport::resolve(&mut context.pool(), report_id, person_id)
|
|
.await
|
|
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)?;
|
|
} else {
|
|
PostReport::unresolve(&mut context.pool(), report_id, person_id)
|
|
.await
|
|
.with_lemmy_type(LemmyErrorType::CouldntResolveReport)?;
|
|
}
|
|
|
|
let post_report_view = PostReportView::read(&mut context.pool(), report_id, person_id).await?;
|
|
|
|
Ok(Json(PostReportResponse { post_report_view }))
|
|
}
|