]> Untitled Git - lemmy.git/blobdiff - crates/api/src/community/ban.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / api / src / community / ban.rs
index 1d3865e138022f95cdc958e49b434fa161d4bfa2..33f6ef83305db2cc4e0868ad1abd66dd2a1c0668 100644 (file)
@@ -41,7 +41,7 @@ impl Perform for BanFromCommunity {
     let expires = data.expires.map(naive_from_unix);
 
     // Verify that only mods or admins can ban
-    is_mod_or_admin(context.pool(), local_user_view.person.id, community_id).await?;
+    is_mod_or_admin(&mut context.pool(), local_user_view.person.id, community_id).await?;
     is_valid_body_field(&data.reason, false)?;
 
     let community_user_ban_form = CommunityPersonBanForm {
@@ -51,7 +51,7 @@ impl Perform for BanFromCommunity {
     };
 
     if data.ban {
-      CommunityPersonBan::ban(context.pool(), &community_user_ban_form)
+      CommunityPersonBan::ban(&mut context.pool(), &community_user_ban_form)
         .await
         .with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)?;
 
@@ -62,18 +62,18 @@ impl Perform for BanFromCommunity {
         pending: false,
       };
 
-      CommunityFollower::unfollow(context.pool(), &community_follower_form)
+      CommunityFollower::unfollow(&mut context.pool(), &community_follower_form)
         .await
         .ok();
     } else {
-      CommunityPersonBan::unban(context.pool(), &community_user_ban_form)
+      CommunityPersonBan::unban(&mut context.pool(), &community_user_ban_form)
         .await
         .with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)?;
     }
 
     // Remove/Restore their data if that's desired
     if remove_data {
-      remove_user_data_in_community(community_id, banned_person_id, context.pool()).await?;
+      remove_user_data_in_community(community_id, banned_person_id, &mut context.pool()).await?;
     }
 
     // Mod tables
@@ -86,10 +86,10 @@ impl Perform for BanFromCommunity {
       expires,
     };
 
-    ModBanFromCommunity::create(context.pool(), &form).await?;
+    ModBanFromCommunity::create(&mut context.pool(), &form).await?;
 
     let person_id = data.person_id;
-    let person_view = PersonView::read(context.pool(), person_id).await?;
+    let person_view = PersonView::read(&mut context.pool(), person_id).await?;
 
     Ok(BanFromCommunityResponse {
       person_view,