mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-02 21:49:22 +00:00
f858d8cbce
* Remove explicit auth params (ref #3725) Only take auth via header or cookie. This requires a new version of lemmy-js-client for api tests to pass. * rework api_crud * remove remaining auth params, move logic to session middleware * fmt, fix test * update js client * remove auth param from api tests * Pass auth as header * add ! * url vars, setHeader * cleanup * fmt * update * Updating for new lemmy-js-client. --------- Co-authored-by: Dessalines <tyhou13@gmx.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
33 lines
986 B
Rust
33 lines
986 B
Rust
use actix_web::web::{Data, Json, Query};
|
|
use lemmy_api_common::{
|
|
context::LemmyContext,
|
|
post::{ListPostReports, ListPostReportsResponse},
|
|
};
|
|
use lemmy_db_views::{post_report_view::PostReportQuery, structs::LocalUserView};
|
|
use lemmy_utils::error::LemmyError;
|
|
|
|
/// Lists post reports for a community if an id is supplied
|
|
/// or returns all post reports for communities a user moderates
|
|
#[tracing::instrument(skip(context))]
|
|
pub async fn list_post_reports(
|
|
data: Query<ListPostReports>,
|
|
context: Data<LemmyContext>,
|
|
local_user_view: LocalUserView,
|
|
) -> Result<Json<ListPostReportsResponse>, LemmyError> {
|
|
let community_id = data.community_id;
|
|
let unresolved_only = data.unresolved_only.unwrap_or_default();
|
|
|
|
let page = data.page;
|
|
let limit = data.limit;
|
|
let post_reports = PostReportQuery {
|
|
community_id,
|
|
unresolved_only,
|
|
page,
|
|
limit,
|
|
}
|
|
.list(&mut context.pool(), &local_user_view)
|
|
.await?;
|
|
|
|
Ok(Json(ListPostReportsResponse { post_reports }))
|
|
}
|