@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Prepare TransactionEditor for silent transactions via bulk edit

Summary:
Ref T13042. This adds a "silent" edit mechanism which suppresses feed stories, email, and notifications.

The other behaviors here are:

- The transactions are marked as "silent" so we can render a hint in the UI in the future to make it clear to users that they aren't missing email.
- If the editor uses Herald, mail rules are suppressed so they don't fire incorrectly (this mostly affects "the first time this rule matches, send me an email" rules: without this, they'd match "the first time" on the bulk edit, not send email, then never match again since they already matched).
- If the edit queues additional edits, those are applied silently too.

This doesn't (or, at least, shouldn't) actually change any behavior since you can't apply silent edits yet.

Test Plan:
Somewhat theoretical, since this isn't reachable yet. Should get meaningful testing in an upcoming change.

Did a bit of var_dump() / debug poking to attempt to verify that nothing too crazy is happening.

Viewed and edited objects, no changes in behavior.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13042

Differential Revision: https://secure.phabricator.com/D18882

+90 -11
+2
src/__phutil_library_map__.php
··· 1356 1356 'HeraldConditionTranscript' => 'applications/herald/storage/transcript/HeraldConditionTranscript.php', 1357 1357 'HeraldContentSourceField' => 'applications/herald/field/HeraldContentSourceField.php', 1358 1358 'HeraldController' => 'applications/herald/controller/HeraldController.php', 1359 + 'HeraldCoreStateReasons' => 'applications/herald/state/HeraldCoreStateReasons.php', 1359 1360 'HeraldDAO' => 'applications/herald/storage/HeraldDAO.php', 1360 1361 'HeraldDifferentialAdapter' => 'applications/differential/herald/HeraldDifferentialAdapter.php', 1361 1362 'HeraldDifferentialDiffAdapter' => 'applications/differential/herald/HeraldDifferentialDiffAdapter.php', ··· 6529 6530 'HeraldConditionTranscript' => 'Phobject', 6530 6531 'HeraldContentSourceField' => 'HeraldField', 6531 6532 'HeraldController' => 'PhabricatorController', 6533 + 'HeraldCoreStateReasons' => 'HeraldStateReasons', 6532 6534 'HeraldDAO' => 'PhabricatorLiskDAO', 6533 6535 'HeraldDifferentialAdapter' => 'HeraldAdapter', 6534 6536 'HeraldDifferentialDiffAdapter' => 'HeraldDifferentialAdapter',
+18
src/applications/herald/state/HeraldCoreStateReasons.php
··· 1 + <?php 2 + 3 + final class HeraldCoreStateReasons 4 + extends HeraldStateReasons { 5 + 6 + const REASON_SILENT = 'core.silent'; 7 + 8 + public function explainReason($reason) { 9 + $reasons = array( 10 + self::REASON_SILENT => pht( 11 + 'This change applied silently, so mail and other notifications '. 12 + 'will not be sent.'), 13 + ); 14 + 15 + return idx($reasons, $reason); 16 + } 17 + 18 + }
+44 -10
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 68 68 private $feedNotifyPHIDs = array(); 69 69 private $feedRelatedPHIDs = array(); 70 70 private $feedShouldPublish = false; 71 + private $mailShouldSend = false; 71 72 private $modularTypes; 73 + private $silent; 72 74 73 75 private $transactionQueue = array(); 74 76 ··· 185 187 186 188 public function getIsPreview() { 187 189 return $this->isPreview; 190 + } 191 + 192 + public function setIsSilent($silent) { 193 + $this->silent = $silent; 194 + return $this; 195 + } 196 + 197 + public function getIsSilent() { 198 + return $this->silent; 188 199 } 189 200 190 201 public function setIsInverseEdgeEditor($is_inverse_edge_editor) { ··· 790 801 $xaction->setObjectPHID($object->getPHID()); 791 802 } 792 803 804 + if ($this->getIsSilent()) { 805 + $xaction->setIsSilentTransaction(true); 806 + } 807 + 793 808 return $xaction; 794 809 } 795 810 ··· 1136 1151 // Editors need to pass into workers. 1137 1152 $object = $this->willPublish($object, $xactions); 1138 1153 1139 - if ($this->shouldSendMail($object, $xactions)) { 1140 - $this->mailToPHIDs = $this->getMailTo($object); 1141 - $this->mailCCPHIDs = $this->getMailCC($object); 1142 - } 1154 + if (!$this->getIsSilent()) { 1155 + if ($this->shouldSendMail($object, $xactions)) { 1156 + $this->mailShouldSend = true; 1157 + $this->mailToPHIDs = $this->getMailTo($object); 1158 + $this->mailCCPHIDs = $this->getMailCC($object); 1159 + } 1143 1160 1144 - if ($this->shouldPublishFeedStory($object, $xactions)) { 1145 - $this->feedShouldPublish = true; 1146 - $this->feedRelatedPHIDs = $this->getFeedRelatedPHIDs($object, $xactions); 1147 - $this->feedNotifyPHIDs = $this->getFeedNotifyPHIDs($object, $xactions); 1161 + if ($this->shouldPublishFeedStory($object, $xactions)) { 1162 + $this->feedShouldPublish = true; 1163 + $this->feedRelatedPHIDs = $this->getFeedRelatedPHIDs( 1164 + $object, 1165 + $xactions); 1166 + $this->feedNotifyPHIDs = $this->getFeedNotifyPHIDs( 1167 + $object, 1168 + $xactions); 1169 + } 1148 1170 } 1149 1171 1150 1172 PhabricatorWorker::scheduleTask( ··· 1186 1208 $this->object = $object; 1187 1209 1188 1210 $messages = array(); 1189 - if ($this->shouldSendMail($object, $xactions)) { 1211 + if ($this->mailShouldSend) { 1190 1212 $messages = $this->buildMail($object, $xactions); 1191 1213 } 1192 1214 ··· 3138 3160 $adapter->setApplicationEmail($this->getApplicationEmail()); 3139 3161 } 3140 3162 3163 + // If this editor is operating in silent mode, tell Herald that we aren't 3164 + // going to send any mail. This allows it to skip "the first time this 3165 + // rule matches, send me an email" rules which would otherwise match even 3166 + // though we aren't going to send any mail. 3167 + if ($this->getIsSilent()) { 3168 + $adapter->setForbiddenAction( 3169 + HeraldMailableState::STATECONST, 3170 + HeraldCoreStateReasons::REASON_SILENT); 3171 + } 3172 + 3141 3173 $xscript = HeraldEngine::loadAndApplyRules($adapter); 3142 3174 3143 3175 $this->setHeraldAdapter($adapter); ··· 3493 3525 'feedNotifyPHIDs', 3494 3526 'feedRelatedPHIDs', 3495 3527 'feedShouldPublish', 3528 + 'mailShouldSend', 3496 3529 ); 3497 3530 } 3498 3531 ··· 3875 3908 ->setActor($this->getActor()) 3876 3909 ->setContentSource($this->getContentSource()) 3877 3910 ->setContinueOnNoEffect($this->getContinueOnNoEffect()) 3878 - ->setContinueOnMissingFields($this->getContinueOnMissingFields()); 3911 + ->setContinueOnMissingFields($this->getContinueOnMissingFields()) 3912 + ->setIsSilent($this->getIsSilent()); 3879 3913 3880 3914 if ($this->actingAsPHID !== null) { 3881 3915 $editor->setActingAsPHID($this->actingAsPHID);
+14
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 158 158 return (bool)$this->getMetadataValue('core.default', false); 159 159 } 160 160 161 + public function setIsSilentTransaction($silent) { 162 + return $this->setMetadataValue('core.silent', $silent); 163 + } 164 + 165 + public function getIsSilentTransaction() { 166 + return (bool)$this->getMetadataValue('core.silent', false); 167 + } 168 + 161 169 public function attachComment( 162 170 PhabricatorApplicationTransactionComment $comment) { 163 171 $this->comment = $comment; ··· 1513 1521 // Don't group transactions which happened more than 2 minutes apart. 1514 1522 $apart = abs($xaction->getDateCreated() - $this->getDateCreated()); 1515 1523 if ($apart > (60 * 2)) { 1524 + return false; 1525 + } 1526 + 1527 + // Don't group silent and nonsilent transactions together. 1528 + $is_silent = $this->getIsSilentTransaction(); 1529 + if ($is_silent != $xaction->getIsSilentTransaction()) { 1516 1530 return false; 1517 1531 } 1518 1532 }
+2 -1
src/applications/transactions/view/PhabricatorApplicationTransactionView.php
··· 423 423 ->setUserHandle($xaction->getHandle($xaction->getAuthorPHID())) 424 424 ->setIcon($xaction->getIcon()) 425 425 ->setColor($xaction->getColor()) 426 - ->setHideCommentOptions($this->getHideCommentOptions()); 426 + ->setHideCommentOptions($this->getHideCommentOptions()) 427 + ->setIsSilent($xaction->getIsSilentTransaction()); 427 428 428 429 list($token, $token_removed) = $xaction->getToken(); 429 430 if ($token) {
+10
src/view/phui/PHUITimelineEventView.php
··· 29 29 private $authorPHID; 30 30 private $badges = array(); 31 31 private $pinboardItems = array(); 32 + private $isSilent; 32 33 33 34 public function setAuthorPHID($author_phid) { 34 35 $this->authorPHID = $author_phid; ··· 175 176 public function setColor($color) { 176 177 $this->color = $color; 177 178 return $this; 179 + } 180 + 181 + public function setIsSilent($is_silent) { 182 + $this->isSilent = $is_silent; 183 + return $this; 184 + } 185 + 186 + public function getIsSilent() { 187 + return $this->isSilent; 178 188 } 179 189 180 190 public function setReallyMajorEvent($me) {