]> Untitled Git - lemmy.git/commitdiff
Dont send email notifications for edited comments (fixes #1925)
authorFelix Ableitner <me@nutomic.com>
Wed, 24 Nov 2021 21:26:23 +0000 (22:26 +0100)
committerFelix Ableitner <me@nutomic.com>
Wed, 24 Nov 2021 21:29:29 +0000 (22:29 +0100)
crates/apub/src/activities/comment/create_or_update.rs
crates/apub/src/activities/comment/mod.rs

index 14fc14014f974ee66b601cc70cc2c84590b11b82..649f566c27b67777bc029c1c994e202b01cf191b 100644 (file)
@@ -108,7 +108,15 @@ impl ActivityHandler for CreateOrUpdateComment {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     let comment = ApubComment::from_apub(self.object, context, request_counter).await?;
-    let recipients = get_notif_recipients(&self.actor, &comment, context, request_counter).await?;
+    let do_send_email = self.kind == CreateOrUpdateType::Create;
+    let recipients = get_notif_recipients(
+      &self.actor,
+      &comment,
+      do_send_email,
+      context,
+      request_counter,
+    )
+    .await?;
     let notif_type = match self.kind {
       CreateOrUpdateType::Create => UserOperationCrud::CreateComment,
       CreateOrUpdateType::Update => UserOperationCrud::EditComment,
index b425385877fcbe9808fc2623cb87b38b674b946c..17b4f50cf373ffd95950ca1d36db24cd9c1e0fe4 100644 (file)
@@ -14,6 +14,7 @@ pub mod create_or_update;
 async fn get_notif_recipients(
   actor: &ObjectId<ApubPerson>,
   comment: &Comment,
+  do_send_email: bool,
   context: &LemmyContext,
   request_counter: &mut i32,
 ) -> Result<Vec<LocalUserId>, LemmyError> {
@@ -27,5 +28,5 @@ async fn get_notif_recipients(
   // anyway.
   // TODO: for compatibility with other projects, it would be much better to read this from cc or tags
   let mentions = scrape_text_for_mentions(&comment.content);
-  send_local_notifs(mentions, comment, &*actor, &post, true, context).await
+  send_local_notifs(mentions, comment, &*actor, &post, do_send_email, context).await
 }