2 use actix_web::web::Data;
3 use lemmy_api_common::{
5 get_local_user_view_from_jwt,
6 person::{GetReportCount, GetReportCountResponse},
8 use lemmy_db_views::{comment_report_view::CommentReportView, post_report_view::PostReportView};
9 use lemmy_utils::{ConnectionId, LemmyError};
10 use lemmy_websocket::LemmyContext;
12 #[async_trait::async_trait(?Send)]
13 impl Perform for GetReportCount {
14 type Response = GetReportCountResponse;
16 #[tracing::instrument(skip(context, _websocket_id))]
19 context: &Data<LemmyContext>,
20 _websocket_id: Option<ConnectionId>,
21 ) -> Result<GetReportCountResponse, LemmyError> {
22 let data: &GetReportCount = self;
24 get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
26 let person_id = local_user_view.person.id;
27 let admin = local_user_view.person.admin;
28 let community_id = data.community_id;
30 let comment_reports = blocking(context.pool(), move |conn| {
31 CommentReportView::get_report_count(conn, person_id, admin, community_id)
35 let post_reports = blocking(context.pool(), move |conn| {
36 PostReportView::get_report_count(conn, person_id, admin, community_id)
40 let res = GetReportCountResponse {