]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/activities/community/collection_remove.rs
Split activity table into sent and received parts (fixes #3103) (#3583)
[lemmy.git] / crates / apub / src / activities / community / collection_remove.rs
index 8f920cf24522b36ce8db2a4e0dc2d1cc47305333..28214284b1b93d27a6f8539a0dd4d8a429b3e927 100644 (file)
@@ -7,7 +7,7 @@ use crate::{
     verify_person_in_community,
   },
   activity_lists::AnnouncableActivities,
-  insert_activity,
+  insert_received_activity,
   objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
   protocol::{activities::community::collection_remove::CollectionRemove, InCommunity},
 };
@@ -101,6 +101,7 @@ impl ActivityHandler for CollectionRemove {
 
   #[tracing::instrument(skip_all)]
   async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
+    insert_received_activity(&self.id, context).await?;
     verify_is_public(&self.to, &self.cc)?;
     let community = self.community(context).await?;
     verify_person_in_community(&self.actor, &community, context).await?;
@@ -110,9 +111,8 @@ impl ActivityHandler for CollectionRemove {
 
   #[tracing::instrument(skip_all)]
   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 remove_mod = ObjectId::<ApubPerson>::from(self.object)
@@ -123,7 +123,7 @@ impl ActivityHandler for CollectionRemove {
           community_id: community.id,
           person_id: remove_mod.id,
         };
-        CommunityModerator::leave(context.pool(), &form).await?;
+        CommunityModerator::leave(&mut context.pool(), &form).await?;
 
         // write mod log
         let actor = self.actor.dereference(context).await?;
@@ -133,7 +133,7 @@ impl ActivityHandler for CollectionRemove {
           community_id: community.id,
           removed: Some(true),
         };
-        ModAddCommunity::create(context.pool(), &form).await?;
+        ModAddCommunity::create(&mut context.pool(), &form).await?;
 
         // TODO: send websocket notification about removed mod
       }
@@ -144,7 +144,7 @@ impl ActivityHandler for CollectionRemove {
         let form = PostUpdateForm::builder()
           .featured_community(Some(false))
           .build();
-        Post::update(context.pool(), post.id, &form).await?;
+        Post::update(&mut context.pool(), post.id, &form).await?;
       }
     }
     Ok(())