From 6639f93153dc4a1fbf24743ae352af7dff311526 Mon Sep 17 00:00:00 2001
From: John Watson <john@dctrwatson.com>
Date: Thu, 9 Jan 2014 05:22:18 -0800
Subject: [PATCH] Add a 'silent' option to diffusion.createcomment

Test Plan: Created comments with 'silent' both true and empty, received notifcation for only the latter.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D7916
---
 .../audit/editor/PhabricatorAuditCommentEditor.php    | 11 ++++++++++-
 .../ConduitAPI_diffusion_createcomment_Method.php     |  2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php
index 01b178c1e0..8eb6ce79fc 100644
--- a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php
+++ b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php
@@ -8,6 +8,8 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
   private $auditors = array();
   private $ccs = array();
 
+  private $noEmail;
+
   public function __construct(PhabricatorRepositoryCommit $commit) {
     $this->commit = $commit;
     return $this;
@@ -28,6 +30,11 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
     return $this;
   }
 
+  public function setNoEmail($no_email) {
+    $this->noEmail = $no_email;
+    return $this;
+  }
+
   public function addComment(PhabricatorAuditComment $comment) {
 
     $commit = $this->commit;
@@ -297,7 +304,9 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
     id(new PhabricatorSearchIndexer())
       ->indexDocumentByPHID($commit->getPHID());
 
-    $this->sendMail($comment, $other_comments, $inline_comments, $requests);
+    if (!$this->noEmail) {
+      $this->sendMail($comment, $other_comments, $inline_comments, $requests);
+    }
   }
 
 
diff --git a/src/applications/diffusion/conduit/ConduitAPI_diffusion_createcomment_Method.php b/src/applications/diffusion/conduit/ConduitAPI_diffusion_createcomment_Method.php
index 692246497f..e4020a0d06 100644
--- a/src/applications/diffusion/conduit/ConduitAPI_diffusion_createcomment_Method.php
+++ b/src/applications/diffusion/conduit/ConduitAPI_diffusion_createcomment_Method.php
@@ -21,6 +21,7 @@ final class ConduitAPI_diffusion_createcomment_Method
       'phid'    => 'required string',
       'action'  => 'optional string',
       'message' => 'required string',
+      'silent'  => 'optional bool',
     );
   }
 
@@ -73,6 +74,7 @@ final class ConduitAPI_diffusion_createcomment_Method
 
     id(new PhabricatorAuditCommentEditor($commit))
       ->setActor($request->getUser())
+      ->setNoEmail($request->getValue('silent'))
       ->addComment($comment);
 
     return true;