]> Untitled Git - lemmy.git/blobdiff - crates/api/src/community/hide.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / api / src / community / hide.rs
index f8d4b1fd7d200b97fe79063614e5a60d21074e23..313e3d84a5917b6a09c3887fc701d8a78cf184a3 100644 (file)
@@ -13,7 +13,7 @@ use lemmy_db_schema::{
   },
   traits::Crud,
 };
-use lemmy_utils::error::LemmyError;
+use lemmy_utils::error::{LemmyError, LemmyErrorExt, LemmyErrorType};
 
 #[async_trait::async_trait(?Send)]
 impl Perform for HideCommunity {
@@ -39,11 +39,11 @@ impl Perform for HideCommunity {
     };
 
     let community_id = data.community_id;
-    Community::update(context.pool(), community_id, &community_form)
+    Community::update(&mut context.pool(), community_id, &community_form)
       .await
-      .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_community_hidden_status"))?;
+      .with_lemmy_type(LemmyErrorType::CouldntUpdateCommunityHiddenStatus)?;
 
-    ModHideCommunity::create(context.pool(), &mod_hide_community_form).await?;
+    ModHideCommunity::create(&mut context.pool(), &mod_hide_community_form).await?;
 
     build_community_response(context, local_user_view, community_id).await
   }