]> Untitled Git - lemmy.git/commitdiff
Merge pull request #1937 from LemmyNet/disable-edit-email-notifications
authorDessalines <dessalines@users.noreply.github.com>
Thu, 25 Nov 2021 18:00:26 +0000 (13:00 -0500)
committerGitHub <noreply@github.com>
Thu, 25 Nov 2021 18:00:26 +0000 (13:00 -0500)
Dont send email notifications for edited comments (fixes #1925)

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
 }