]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/activities/community/collection_add.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / apub / src / activities / community / collection_add.rs
index be5dd0fe34c242a5da0eb762324447768cee00bb..d08b0cb486d8c67e069a57423fba92bce0340a70 100644 (file)
@@ -119,7 +119,7 @@ impl ActivityHandler for CollectionAdd {
   async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
     insert_activity(&self.id, &self, false, false, context).await?;
     let (community, collection_type) =
-      Community::get_by_collection_url(context.pool(), &self.target.into()).await?;
+      Community::get_by_collection_url(&mut context.pool(), &self.target.into()).await?;
     match collection_type {
       CollectionType::Moderators => {
         let new_mod = ObjectId::<ApubPerson>::from(self.object)
@@ -130,13 +130,14 @@ impl ActivityHandler for CollectionAdd {
         // been added. Skip it here as it would result in a duplicate key error.
         let new_mod_id = new_mod.id;
         let moderated_communities =
-          CommunityModerator::get_person_moderated_communities(context.pool(), new_mod_id).await?;
+          CommunityModerator::get_person_moderated_communities(&mut context.pool(), new_mod_id)
+            .await?;
         if !moderated_communities.contains(&community.id) {
           let form = CommunityModeratorForm {
             community_id: community.id,
             person_id: new_mod.id,
           };
-          CommunityModerator::join(context.pool(), &form).await?;
+          CommunityModerator::join(&mut context.pool(), &form).await?;
 
           // write mod log
           let actor = self.actor.dereference(context).await?;
@@ -146,7 +147,7 @@ impl ActivityHandler for CollectionAdd {
             community_id: community.id,
             removed: Some(false),
           };
-          ModAddCommunity::create(context.pool(), &form).await?;
+          ModAddCommunity::create(&mut context.pool(), &form).await?;
         }
         // TODO: send websocket notification about added mod
       }
@@ -157,7 +158,7 @@ impl ActivityHandler for CollectionAdd {
         let form = PostUpdateForm::builder()
           .featured_community(Some(true))
           .build();
-        Post::update(context.pool(), post.id, &form).await?;
+        Post::update(&mut context.pool(), post.id, &form).await?;
       }
     }
     Ok(())
@@ -174,10 +175,10 @@ impl SendActivity for AddModToCommunity {
     context: &Data<LemmyContext>,
   ) -> Result<(), LemmyError> {
     let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
-    let community: ApubCommunity = Community::read(context.pool(), request.community_id)
+    let community: ApubCommunity = Community::read(&mut context.pool(), request.community_id)
       .await?
       .into();
-    let updated_mod: ApubPerson = Person::read(context.pool(), request.person_id)
+    let updated_mod: ApubPerson = Person::read(&mut context.pool(), request.person_id)
       .await?
       .into();
     if request.added {
@@ -210,7 +211,7 @@ impl SendActivity for FeaturePost {
     context: &Data<LemmyContext>,
   ) -> Result<(), LemmyError> {
     let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
-    let community = Community::read(context.pool(), response.post_view.community.id)
+    let community = Community::read(&mut context.pool(), response.post_view.community.id)
       .await?
       .into();
     let post = response.post_view.post.clone().into();