From 6ed202b6756eb88c98b4046ce1802003a3d85486 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 20 Aug 2012 14:08:52 -0700 Subject: [PATCH] Add a 'silent' option to differential.createcomment Summary: See T1677. I think wanting bots to be able to post comments without sending email is a pretty reasonable use case. Eventually we should probably support this more broadly and maybe protect it with permissions (normal users maybe shouldn't be able to do this?) but we can wait for use cases. Test Plan: Made comments with and without "silent". Verified that the non-silent comment sent email, and the silent comment did not. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran Maniphest Tasks: T1677 Differential Revision: https://secure.phabricator.com/D3341 --- ...tAPI_differential_createcomment_Method.php | 2 + .../editor/DifferentialCommentEditor.php | 38 +++++++++++-------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/applications/conduit/method/differential/ConduitAPI_differential_createcomment_Method.php b/src/applications/conduit/method/differential/ConduitAPI_differential_createcomment_Method.php index b986e9834a..0eacd2efc2 100644 --- a/src/applications/conduit/method/differential/ConduitAPI_differential_createcomment_Method.php +++ b/src/applications/conduit/method/differential/ConduitAPI_differential_createcomment_Method.php @@ -31,6 +31,7 @@ final class ConduitAPI_differential_createcomment_Method 'revision_id' => 'required revisionid', 'message' => 'optional string', 'action' => 'optional string', + 'silent' => 'optional bool', ); } @@ -66,6 +67,7 @@ final class ConduitAPI_differential_createcomment_Method $action); $editor->setContentSource($content_source); $editor->setMessage($request->getValue('message')); + $editor->setNoEmail($request->getValue('silent')); $editor->save(); return array( diff --git a/src/applications/differential/editor/DifferentialCommentEditor.php b/src/applications/differential/editor/DifferentialCommentEditor.php index 9cfd4de8bf..0afd9c5a05 100644 --- a/src/applications/differential/editor/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/DifferentialCommentEditor.php @@ -31,6 +31,7 @@ final class DifferentialCommentEditor { private $parentMessageID; private $contentSource; + private $noEmail; private $isDaemonWorkflow; @@ -105,6 +106,11 @@ final class DifferentialCommentEditor { return $this; } + public function setNoEmail($no_email) { + $this->noEmail = $no_email; + return $this; + } + public function save() { $revision = $this->revision; $action = $this->action; @@ -553,21 +559,23 @@ final class DifferentialCommentEditor { $xherald_header = HeraldTranscript::loadXHeraldRulesHeader( $revision->getPHID()); - id(new DifferentialCommentMail( - $revision, - $actor_handle, - $comment, - $changesets, - $inline_comments)) - ->setToPHIDs( - array_merge( - $revision->getReviewers(), - array($revision->getAuthorPHID()))) - ->setCCPHIDs($revision->getCCPHIDs()) - ->setChangedByCommit($this->getChangedByCommit()) - ->setXHeraldRulesHeader($xherald_header) - ->setParentMessageID($this->parentMessageID) - ->send(); + if (!$this->noEmail) { + id(new DifferentialCommentMail( + $revision, + $actor_handle, + $comment, + $changesets, + $inline_comments)) + ->setToPHIDs( + array_merge( + $revision->getReviewers(), + array($revision->getAuthorPHID()))) + ->setCCPHIDs($revision->getCCPHIDs()) + ->setChangedByCommit($this->getChangedByCommit()) + ->setXHeraldRulesHeader($xherald_header) + ->setParentMessageID($this->parentMessageID) + ->send(); + } $event_data = array( 'revision_id' => $revision->getID(),