]> Untitled Git - lemmy.git/commitdiff
Dont announce comments, edited posts to Pleroma/Mastodon followers
authorFelix Ableitner <me@nutomic.com>
Thu, 18 Nov 2021 15:20:35 +0000 (16:20 +0100)
committerFelix Ableitner <me@nutomic.com>
Thu, 18 Nov 2021 17:41:43 +0000 (18:41 +0100)
crates/apub/src/activities/community/announce.rs
crates/apub/src/activity_lists.rs
crates/apub/src/protocol/activities/mod.rs
crates/apub/src/protocol/objects/note.rs

index 4eebcce38d7bf6331d5882f06c28581371f22690..7db646bb21cb5de42b99e8a66d6caa515d7224d3 100644 (file)
@@ -4,7 +4,7 @@ use crate::{
   http::{is_activity_already_known, ActivityCommonFields},
   insert_activity,
   objects::community::ApubCommunity,
-  protocol::activities::community::announce::AnnounceActivity,
+  protocol::activities::{community::announce::AnnounceActivity, CreateOrUpdateType},
 };
 use activitystreams::{activity::kind::AnnounceType, public};
 use lemmy_apub_lib::{
@@ -61,13 +61,11 @@ impl AnnounceActivity {
     )
     .await?;
 
-    // Pleroma (and likely Mastodon) can't handle activities like Announce/Create/Page. So for
-    // compatibility to allow them to follow Lemmy communities, we also send Announce/Page and
-    // Announce/Note (for new and updated posts/comments).
+    // Pleroma and Mastodon can't handle activities like Announce/Create/Page. So for
+    // compatibility, we also send Announce/Page so that they can follow Lemmy communities.
     use AnnouncableActivities::*;
     let object = match object {
-      CreateOrUpdatePost(c) => Page(c.object),
-      CreateOrUpdateComment(c) => Note(c.object),
+      CreateOrUpdatePost(c) if c.kind == CreateOrUpdateType::Create => Page(c.object),
       _ => return Ok(()),
     };
     let announce_compat = AnnounceActivity::new(object, community, context)?;
index 00d2d439f4da7a643095beb984e24e8818293a06..d9b9764964b57459ebd59f3f9cb9322c27d22b99 100644 (file)
@@ -26,7 +26,7 @@ use crate::{
       },
       voting::{undo_vote::UndoVote, vote::Vote},
     },
-    objects::{note::Note, page::Page},
+    objects::page::Page,
   },
 };
 use lemmy_apub_lib::traits::ActivityHandler;
@@ -84,8 +84,6 @@ pub enum AnnouncableActivities {
   RemoveMod(RemoveMod),
   // For compatibility with Pleroma/Mastodon (send only)
   Page(Page),
-  // For compatibility with Pleroma/Mastodon (send only)
-  Note(Note),
 }
 
 #[async_trait::async_trait(?Send)]
@@ -109,7 +107,6 @@ impl GetCommunity for AnnouncableActivities {
       AddMod(a) => a.get_community(context, request_counter).await?,
       RemoveMod(a) => a.get_community(context, request_counter).await?,
       Page(_) => unimplemented!(),
-      Note(_) => unimplemented!(),
     };
     Ok(community)
   }
index 23575c2797ab013c6a43fd2a7e826c0330c14bdb..63bd7656bda8b22fbcc55bf2e8a98082bedeac06 100644 (file)
@@ -8,7 +8,7 @@ pub mod following;
 pub mod private_message;
 pub mod voting;
 
-#[derive(Clone, Debug, ToString, Deserialize, Serialize)]
+#[derive(Clone, Debug, ToString, Deserialize, Serialize, PartialEq)]
 pub enum CreateOrUpdateType {
   Create,
   Update,
index fdd6ddd96849e812a567f5b1047ba90c7685cb33..883a1a994fcb5ab9269be498e092c53e9edf4a1e 100644 (file)
@@ -4,15 +4,9 @@ use crate::{
   protocol::Source,
 };
 use activitystreams::{link::Mention, object::kind::NoteType, unparsed::Unparsed};
-use anyhow::anyhow;
 use chrono::{DateTime, FixedOffset};
 use lemmy_api_common::blocking;
-use lemmy_apub_lib::{
-  data::Data,
-  object_id::ObjectId,
-  traits::ActivityHandler,
-  values::MediaTypeHtml,
-};
+use lemmy_apub_lib::{object_id::ObjectId, values::MediaTypeHtml};
 use lemmy_db_schema::{newtypes::CommentId, source::post::Post, traits::Crud};
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
@@ -89,15 +83,3 @@ impl Note {
     }
   }
 }
-
-// For Pleroma/Mastodon compat. Unimplemented because its only used for sending.
-#[async_trait::async_trait(?Send)]
-impl ActivityHandler for Note {
-  type DataType = LemmyContext;
-  async fn verify(&self, _: &Data<Self::DataType>, _: &mut i32) -> Result<(), LemmyError> {
-    Err(anyhow!("Announce/Page can only be sent, not received").into())
-  }
-  async fn receive(self, _: &Data<Self::DataType>, _: &mut i32) -> Result<(), LemmyError> {
-    unimplemented!()
-  }
-}