]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/activities/following/follow.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / apub / src / activities / following / follow.rs
index 4e2acd518f530c02f9a5679d101674801b07e9a8..073784da12d32def1068771e1ca725de613dbdf3 100644 (file)
@@ -24,7 +24,7 @@ use activitypub_federation::{
 use lemmy_api_common::{
   community::{BlockCommunity, BlockCommunityResponse},
   context::LemmyContext,
-  utils::get_local_user_view_from_jwt,
+  utils::local_user_view_from_jwt,
 };
 use lemmy_db_schema::{
   source::{
@@ -65,7 +65,7 @@ impl Follow {
       person_id: actor.id,
       pending: true,
     };
-    CommunityFollower::follow(context.pool(), &community_follower_form)
+    CommunityFollower::follow(&mut context.pool(), &community_follower_form)
       .await
       .ok();
 
@@ -113,7 +113,7 @@ impl ActivityHandler for Follow {
           follower_id: actor.id,
           pending: false,
         };
-        PersonFollower::follow(context.pool(), &form).await?;
+        PersonFollower::follow(&mut context.pool(), &form).await?;
       }
       UserOrCommunity::Community(c) => {
         let form = CommunityFollowerForm {
@@ -121,7 +121,7 @@ impl ActivityHandler for Follow {
           person_id: actor.id,
           pending: false,
         };
-        CommunityFollower::follow(context.pool(), &form).await?;
+        CommunityFollower::follow(&mut context.pool(), &form).await?;
       }
     }
 
@@ -138,9 +138,8 @@ impl SendActivity for BlockCommunity {
     _response: &Self::Response,
     context: &Data<LemmyContext>,
   ) -> Result<(), LemmyError> {
-    let local_user_view =
-      get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
-    let community = Community::read(context.pool(), request.community_id).await?;
+    let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+    let community = Community::read(&mut context.pool(), request.community_id).await?;
     UndoFollow::send(&local_user_view.person.into(), &community.into(), context).await
   }
 }