]> Untitled Git - lemmy.git/blobdiff - crates/api/src/comment_report/list.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / api / src / comment_report / list.rs
index 8aa3fcbcd87a02c9013c518b24301d2736be70a1..baa1bf45fee3112de801814c1ba6ebec6562c348 100644 (file)
@@ -3,10 +3,10 @@ use actix_web::web::Data;
 use lemmy_api_common::{
   comment::{ListCommentReports, ListCommentReportsResponse},
   context::LemmyContext,
-  utils::get_local_user_view_from_jwt,
+  utils::local_user_view_from_jwt,
 };
 use lemmy_db_views::comment_report_view::CommentReportQuery;
-use lemmy_utils::{error::LemmyError, ConnectionId};
+use lemmy_utils::error::LemmyError;
 
 /// Lists comment reports for a community if an id is supplied
 /// or returns all comment reports for communities a user moderates
@@ -14,15 +14,13 @@ use lemmy_utils::{error::LemmyError, ConnectionId};
 impl Perform for ListCommentReports {
   type Response = ListCommentReportsResponse;
 
-  #[tracing::instrument(skip(context, _websocket_id))]
+  #[tracing::instrument(skip(context))]
   async fn perform(
     &self,
     context: &Data<LemmyContext>,
-    _websocket_id: Option<ConnectionId>,
   ) -> Result<ListCommentReportsResponse, LemmyError> {
     let data: &ListCommentReports = 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;
@@ -32,7 +30,7 @@ impl Perform for ListCommentReports {
     let page = data.page;
     let limit = data.limit;
     let comment_reports = CommentReportQuery::builder()
-      .pool(context.pool())
+      .pool(&mut context.pool())
       .my_person_id(person_id)
       .admin(admin)
       .community_id(community_id)
@@ -43,8 +41,6 @@ impl Perform for ListCommentReports {
       .list()
       .await?;
 
-    let res = ListCommentReportsResponse { comment_reports };
-
-    Ok(res)
+    Ok(ListCommentReportsResponse { comment_reports })
   }
 }