Page MenuHomePhabricator

D18882.id45293.diff
No OneTemporary

D18882.id45293.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1356,6 +1356,7 @@
'HeraldConditionTranscript' => 'applications/herald/storage/transcript/HeraldConditionTranscript.php',
'HeraldContentSourceField' => 'applications/herald/field/HeraldContentSourceField.php',
'HeraldController' => 'applications/herald/controller/HeraldController.php',
+ 'HeraldCoreStateReasons' => 'applications/herald/state/HeraldCoreStateReasons.php',
'HeraldDAO' => 'applications/herald/storage/HeraldDAO.php',
'HeraldDifferentialAdapter' => 'applications/differential/herald/HeraldDifferentialAdapter.php',
'HeraldDifferentialDiffAdapter' => 'applications/differential/herald/HeraldDifferentialDiffAdapter.php',
@@ -6529,6 +6530,7 @@
'HeraldConditionTranscript' => 'Phobject',
'HeraldContentSourceField' => 'HeraldField',
'HeraldController' => 'PhabricatorController',
+ 'HeraldCoreStateReasons' => 'HeraldStateReasons',
'HeraldDAO' => 'PhabricatorLiskDAO',
'HeraldDifferentialAdapter' => 'HeraldAdapter',
'HeraldDifferentialDiffAdapter' => 'HeraldDifferentialAdapter',
diff --git a/src/applications/herald/state/HeraldCoreStateReasons.php b/src/applications/herald/state/HeraldCoreStateReasons.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/state/HeraldCoreStateReasons.php
@@ -0,0 +1,18 @@
+<?php
+
+final class HeraldCoreStateReasons
+ extends HeraldStateReasons {
+
+ const REASON_SILENT = 'core.silent';
+
+ public function explainReason($reason) {
+ $reasons = array(
+ self::REASON_SILENT => pht(
+ 'This change applied silently, so mail and other notifications '.
+ 'will not be sent.'),
+ );
+
+ return idx($reasons, $reason);
+ }
+
+}
diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
--- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
+++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
@@ -68,7 +68,9 @@
private $feedNotifyPHIDs = array();
private $feedRelatedPHIDs = array();
private $feedShouldPublish = false;
+ private $mailShouldSend = false;
private $modularTypes;
+ private $silent;
private $transactionQueue = array();
@@ -187,6 +189,15 @@
return $this->isPreview;
}
+ public function setIsSilent($silent) {
+ $this->silent = $silent;
+ return $this;
+ }
+
+ public function getIsSilent() {
+ return $this->silent;
+ }
+
public function setIsInverseEdgeEditor($is_inverse_edge_editor) {
$this->isInverseEdgeEditor = $is_inverse_edge_editor;
return $this;
@@ -790,6 +801,10 @@
$xaction->setObjectPHID($object->getPHID());
}
+ if ($this->getIsSilent()) {
+ $xaction->setIsSilentTransaction(true);
+ }
+
return $xaction;
}
@@ -1136,15 +1151,22 @@
// Editors need to pass into workers.
$object = $this->willPublish($object, $xactions);
- if ($this->shouldSendMail($object, $xactions)) {
- $this->mailToPHIDs = $this->getMailTo($object);
- $this->mailCCPHIDs = $this->getMailCC($object);
- }
+ if (!$this->getIsSilent()) {
+ if ($this->shouldSendMail($object, $xactions)) {
+ $this->mailShouldSend = true;
+ $this->mailToPHIDs = $this->getMailTo($object);
+ $this->mailCCPHIDs = $this->getMailCC($object);
+ }
- if ($this->shouldPublishFeedStory($object, $xactions)) {
- $this->feedShouldPublish = true;
- $this->feedRelatedPHIDs = $this->getFeedRelatedPHIDs($object, $xactions);
- $this->feedNotifyPHIDs = $this->getFeedNotifyPHIDs($object, $xactions);
+ if ($this->shouldPublishFeedStory($object, $xactions)) {
+ $this->feedShouldPublish = true;
+ $this->feedRelatedPHIDs = $this->getFeedRelatedPHIDs(
+ $object,
+ $xactions);
+ $this->feedNotifyPHIDs = $this->getFeedNotifyPHIDs(
+ $object,
+ $xactions);
+ }
}
PhabricatorWorker::scheduleTask(
@@ -1186,7 +1208,7 @@
$this->object = $object;
$messages = array();
- if ($this->shouldSendMail($object, $xactions)) {
+ if ($this->mailShouldSend) {
$messages = $this->buildMail($object, $xactions);
}
@@ -3138,6 +3160,16 @@
$adapter->setApplicationEmail($this->getApplicationEmail());
}
+ // If this editor is operating in silent mode, tell Herald that we aren't
+ // going to send any mail. This allows it to skip "the first time this
+ // rule matches, send me an email" rules which would otherwise match even
+ // though we aren't going to send any mail.
+ if ($this->getIsSilent()) {
+ $adapter->setForbiddenAction(
+ HeraldMailableState::STATECONST,
+ HeraldCoreStateReasons::REASON_SILENT);
+ }
+
$xscript = HeraldEngine::loadAndApplyRules($adapter);
$this->setHeraldAdapter($adapter);
@@ -3493,6 +3525,7 @@
'feedNotifyPHIDs',
'feedRelatedPHIDs',
'feedShouldPublish',
+ 'mailShouldSend',
);
}
@@ -3875,7 +3908,8 @@
->setActor($this->getActor())
->setContentSource($this->getContentSource())
->setContinueOnNoEffect($this->getContinueOnNoEffect())
- ->setContinueOnMissingFields($this->getContinueOnMissingFields());
+ ->setContinueOnMissingFields($this->getContinueOnMissingFields())
+ ->setIsSilent($this->getIsSilent());
if ($this->actingAsPHID !== null) {
$editor->setActingAsPHID($this->actingAsPHID);
diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
--- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
+++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
@@ -158,6 +158,14 @@
return (bool)$this->getMetadataValue('core.default', false);
}
+ public function setIsSilentTransaction($silent) {
+ return $this->setMetadataValue('core.silent', $silent);
+ }
+
+ public function getIsSilentTransaction() {
+ return (bool)$this->getMetadataValue('core.silent', false);
+ }
+
public function attachComment(
PhabricatorApplicationTransactionComment $comment) {
$this->comment = $comment;
@@ -1515,6 +1523,12 @@
if ($apart > (60 * 2)) {
return false;
}
+
+ // Don't group silent and nonsilent transactions together.
+ $is_silent = $this->getIsSilentTransaction();
+ if ($is_silent != $xaction->getIsSilentTransaction()) {
+ return false;
+ }
}
return true;
diff --git a/src/applications/transactions/view/PhabricatorApplicationTransactionView.php b/src/applications/transactions/view/PhabricatorApplicationTransactionView.php
--- a/src/applications/transactions/view/PhabricatorApplicationTransactionView.php
+++ b/src/applications/transactions/view/PhabricatorApplicationTransactionView.php
@@ -423,7 +423,8 @@
->setUserHandle($xaction->getHandle($xaction->getAuthorPHID()))
->setIcon($xaction->getIcon())
->setColor($xaction->getColor())
- ->setHideCommentOptions($this->getHideCommentOptions());
+ ->setHideCommentOptions($this->getHideCommentOptions())
+ ->setIsSilent($xaction->getIsSilentTransaction());
list($token, $token_removed) = $xaction->getToken();
if ($token) {
diff --git a/src/view/phui/PHUITimelineEventView.php b/src/view/phui/PHUITimelineEventView.php
--- a/src/view/phui/PHUITimelineEventView.php
+++ b/src/view/phui/PHUITimelineEventView.php
@@ -29,6 +29,7 @@
private $authorPHID;
private $badges = array();
private $pinboardItems = array();
+ private $isSilent;
public function setAuthorPHID($author_phid) {
$this->authorPHID = $author_phid;
@@ -177,6 +178,15 @@
return $this;
}
+ public function setIsSilent($is_silent) {
+ $this->isSilent = $is_silent;
+ return $this;
+ }
+
+ public function getIsSilent() {
+ return $this->isSilent;
+ }
+
public function setReallyMajorEvent($me) {
$this->reallyMajorEvent = $me;
return $this;

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 29, 7:14 AM (6 h, 30 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6941764
Default Alt Text
D18882.id45293.diff (8 KB)

Event Timeline