2023-11-16 13:50:15 +00:00
|
|
|
use actix_web::web::{Data, Json, Query};
|
2022-04-13 18:12:25 +00:00
|
|
|
use lemmy_api_common::{
|
2022-11-28 14:29:33 +00:00
|
|
|
context::LemmyContext,
|
2022-04-13 18:12:25 +00:00
|
|
|
person::{GetReportCount, GetReportCountResponse},
|
2023-11-21 15:33:49 +00:00
|
|
|
utils::check_community_mod_of_any_or_admin_action,
|
2022-04-13 18:12:25 +00:00
|
|
|
};
|
2024-12-19 22:22:31 +00:00
|
|
|
use lemmy_db_views::structs::{LocalUserView, ReportCombinedViewInternal};
|
2024-04-10 14:14:11 +00:00
|
|
|
use lemmy_utils::error::LemmyResult;
|
2022-04-13 18:12:25 +00:00
|
|
|
|
2023-09-05 09:33:46 +00:00
|
|
|
#[tracing::instrument(skip(context))]
|
|
|
|
pub async fn report_count(
|
2023-11-16 13:50:15 +00:00
|
|
|
data: Query<GetReportCount>,
|
2023-09-05 09:33:46 +00:00
|
|
|
context: Data<LemmyContext>,
|
2023-09-21 10:42:28 +00:00
|
|
|
local_user_view: LocalUserView,
|
2024-04-10 14:14:11 +00:00
|
|
|
) -> LemmyResult<Json<GetReportCountResponse>> {
|
2023-11-21 15:33:49 +00:00
|
|
|
check_community_mod_of_any_or_admin_action(&local_user_view, &mut context.pool()).await?;
|
2023-10-13 13:48:18 +00:00
|
|
|
|
2024-12-19 22:22:31 +00:00
|
|
|
let count = ReportCombinedViewInternal::get_report_count(
|
|
|
|
&mut context.pool(),
|
|
|
|
&local_user_view,
|
|
|
|
data.community_id,
|
|
|
|
)
|
|
|
|
.await?;
|
2022-04-13 18:12:25 +00:00
|
|
|
|
2024-12-19 22:22:31 +00:00
|
|
|
Ok(Json(GetReportCountResponse { count }))
|
2022-04-13 18:12:25 +00:00
|
|
|
}
|