1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

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
This commit is contained in:
epriestley 2012-08-20 14:08:52 -07:00
parent 21ebd1a609
commit 6ed202b675
2 changed files with 25 additions and 15 deletions

View file

@ -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(

View file

@ -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(),