use crate::Perform;
use actix_web::web::Data;
use lemmy_api_common::{
+ context::LemmyContext,
post::{ListPostReports, ListPostReportsResponse},
- utils::get_local_user_view_from_jwt,
- LemmyContext,
+ utils::local_user_view_from_jwt,
};
use lemmy_db_views::post_report_view::PostReportQuery;
-use lemmy_utils::{error::LemmyError, ConnectionId};
+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
impl Perform for ListPostReports {
type Response = ListPostReportsResponse;
- #[tracing::instrument(skip(context, _websocket_id))]
+ #[tracing::instrument(skip(context))]
async fn perform(
&self,
context: &Data<LemmyContext>,
- _websocket_id: Option<ConnectionId>,
) -> Result<ListPostReportsResponse, LemmyError> {
let data: &ListPostReports = self;
- let local_user_view =
- get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
+ let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let person_id = local_user_view.person.id;
let admin = local_user_view.person.admin;
let page = data.page;
let limit = data.limit;
let post_reports = PostReportQuery::builder()
- .pool(context.pool())
+ .pool(&mut context.pool())
.my_person_id(person_id)
.admin(admin)
.community_id(community_id)
.list()
.await?;
- let res = ListPostReportsResponse { post_reports };
-
- Ok(res)
+ Ok(ListPostReportsResponse { post_reports })
}
}