]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/activities/community/lock_page.rs
Split activity table into sent and received parts (fixes #3103) (#3583)
[lemmy.git] / crates / apub / src / activities / community / lock_page.rs
index 26326efcbd9a810d8c3c4d7e091dee414b85fde6..94135ede900cf3579af8641b573cd20ad38d853d 100644 (file)
@@ -8,13 +8,9 @@ use crate::{
     verify_person_in_community,
   },
   activity_lists::AnnouncableActivities,
-  insert_activity,
+  insert_received_activity,
   protocol::{
-    activities::{
-      community::lock_page::{LockPage, LockType, UndoLockPage},
-      create_or_update::page::CreateOrUpdatePage,
-      CreateOrUpdateType,
-    },
+    activities::community::lock_page::{LockPage, LockType, UndoLockPage},
     InCommunity,
   },
   SendActivity,
@@ -64,7 +60,7 @@ impl ActivityHandler for LockPage {
   async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
     let form = PostUpdateForm::builder().locked(Some(true)).build();
     let post = self.object.dereference(context).await?;
-    Post::update(context.pool(), post.id, &form).await?;
+    Post::update(&mut context.pool(), post.id, &form).await?;
     Ok(())
   }
 }
@@ -83,6 +79,7 @@ impl ActivityHandler for UndoLockPage {
   }
 
   async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
+    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?;
@@ -98,10 +95,9 @@ impl ActivityHandler for UndoLockPage {
   }
 
   async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
-    insert_activity(&self.id, &self, false, false, context).await?;
     let form = PostUpdateForm::builder().locked(Some(false)).build();
     let post = self.object.object.dereference(context).await?;
-    Post::update(context.pool(), post.id, &form).await?;
+    Post::update(&mut context.pool(), post.id, &form).await?;
     Ok(())
   }
 }
@@ -116,14 +112,6 @@ impl SendActivity for LockPost {
     context: &Data<LemmyContext>,
   ) -> Result<(), LemmyError> {
     let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
-    // For backwards compat with 0.17
-    CreateOrUpdatePage::send(
-      &response.post_view.post,
-      local_user_view.person.id,
-      CreateOrUpdateType::Update,
-      context,
-    )
-    .await?;
     let id = generate_activity_id(
       LockType::Lock,
       &context.settings().get_protocol_and_hostname(),
@@ -157,7 +145,7 @@ impl SendActivity for LockPost {
       };
       AnnouncableActivities::UndoLockPost(undo)
     };
-    let community = Community::read(context.pool(), response.post_view.community.id).await?;
+    let community = Community::read(&mut context.pool(), response.post_view.community.id).await?;
     send_activity_in_community(
       activity,
       &local_user_view.person.into(),