Skip to content

Commit 6ed202b

Browse files
author
epriestley
committed
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
1 parent 21ebd1a commit 6ed202b

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

src/applications/conduit/method/differential/ConduitAPI_differential_createcomment_Method.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function defineParamTypes() {
3131
'revision_id' => 'required revisionid',
3232
'message' => 'optional string',
3333
'action' => 'optional string',
34+
'silent' => 'optional bool',
3435
);
3536
}
3637

@@ -66,6 +67,7 @@ protected function execute(ConduitAPIRequest $request) {
6667
$action);
6768
$editor->setContentSource($content_source);
6869
$editor->setMessage($request->getValue('message'));
70+
$editor->setNoEmail($request->getValue('silent'));
6971
$editor->save();
7072

7173
return array(

src/applications/differential/editor/DifferentialCommentEditor.php

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ final class DifferentialCommentEditor {
3131

3232
private $parentMessageID;
3333
private $contentSource;
34+
private $noEmail;
3435

3536
private $isDaemonWorkflow;
3637

@@ -105,6 +106,11 @@ public function setIsDaemonWorkflow($is_daemon) {
105106
return $this;
106107
}
107108

109+
public function setNoEmail($no_email) {
110+
$this->noEmail = $no_email;
111+
return $this;
112+
}
113+
108114
public function save() {
109115
$revision = $this->revision;
110116
$action = $this->action;
@@ -553,21 +559,23 @@ public function save() {
553559
$xherald_header = HeraldTranscript::loadXHeraldRulesHeader(
554560
$revision->getPHID());
555561

556-
id(new DifferentialCommentMail(
557-
$revision,
558-
$actor_handle,
559-
$comment,
560-
$changesets,
561-
$inline_comments))
562-
->setToPHIDs(
563-
array_merge(
564-
$revision->getReviewers(),
565-
array($revision->getAuthorPHID())))
566-
->setCCPHIDs($revision->getCCPHIDs())
567-
->setChangedByCommit($this->getChangedByCommit())
568-
->setXHeraldRulesHeader($xherald_header)
569-
->setParentMessageID($this->parentMessageID)
570-
->send();
562+
if (!$this->noEmail) {
563+
id(new DifferentialCommentMail(
564+
$revision,
565+
$actor_handle,
566+
$comment,
567+
$changesets,
568+
$inline_comments))
569+
->setToPHIDs(
570+
array_merge(
571+
$revision->getReviewers(),
572+
array($revision->getAuthorPHID())))
573+
->setCCPHIDs($revision->getCCPHIDs())
574+
->setChangedByCommit($this->getChangedByCommit())
575+
->setXHeraldRulesHeader($xherald_header)
576+
->setParentMessageID($this->parentMessageID)
577+
->send();
578+
}
571579

572580
$event_data = array(
573581
'revision_id' => $revision->getID(),

0 commit comments

Comments
 (0)