]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/impls/comment_report.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / db_schema / src / impls / comment_report.rs
index b299e9517f86445788fe35410fba4c2102c7f0ad..ff93915e1c0c7d732f730db733055303088c710f 100644 (file)
@@ -1,11 +1,16 @@
 use crate::{
   newtypes::{CommentReportId, PersonId},
-  schema::comment_report::dsl::*,
+  schema::comment_report::dsl::{comment_report, resolved, resolver_id, updated},
   source::comment_report::{CommentReport, CommentReportForm},
   traits::Reportable,
   utils::{get_conn, naive_now, DbPool},
 };
-use diesel::{dsl::*, result::Error, ExpressionMethods, QueryDsl};
+use diesel::{
+  dsl::{insert_into, update},
+  result::Error,
+  ExpressionMethods,
+  QueryDsl,
+};
 use diesel_async::RunQueryDsl;
 
 #[async_trait]
@@ -16,7 +21,10 @@ impl Reportable for CommentReport {
   ///
   /// * `conn` - the postgres connection
   /// * `comment_report_form` - the filled CommentReportForm to insert
-  async fn report(pool: &DbPool, comment_report_form: &CommentReportForm) -> Result<Self, Error> {
+  async fn report(
+    pool: &mut DbPool<'_>,
+    comment_report_form: &CommentReportForm,
+  ) -> Result<Self, Error> {
     let conn = &mut get_conn(pool).await?;
     insert_into(comment_report)
       .values(comment_report_form)
@@ -30,7 +38,7 @@ impl Reportable for CommentReport {
   /// * `report_id` - the id of the report to resolve
   /// * `by_resolver_id` - the id of the user resolving the report
   async fn resolve(
-    pool: &DbPool,
+    pool: &mut DbPool<'_>,
     report_id_: Self::IdType,
     by_resolver_id: PersonId,
   ) -> Result<usize, Error> {
@@ -51,7 +59,7 @@ impl Reportable for CommentReport {
   /// * `report_id` - the id of the report to unresolve
   /// * `by_resolver_id` - the id of the user unresolving the report
   async fn unresolve(
-    pool: &DbPool,
+    pool: &mut DbPool<'_>,
     report_id_: Self::IdType,
     by_resolver_id: PersonId,
   ) -> Result<usize, Error> {