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

Hide "abraham landed Dxyz irresponsibly" stories from feed

Summary:
Ref T13099. Ref T12787. See PHI417. Differential has new "irresponsible" warnings in the timeline somewhat recently, but these publish feed stories that don't link to the revision or have other relevant details, so they're confusing on the balance.

These have a high strength so they render on top, but we actually just want to hide them from the feed and let "abraham closed Dxyz by committing rXzzz." be the primary story.

Modularize things more so that we can get this behavior. Also, respect `shouldHideForFeed()` at display time, not just publishing time.

Test Plan: Used `bin/differential attach-commit` on a non-accepted revision to "irresponsibly land" a revision. Verified that feed story now shows "closed by commit" instead of "closed irresponsibly".

Maniphest Tasks: T13099, T12787

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

+65 -31
+3 -2
src/applications/differential/xaction/DifferentialRevisionWrongStateTransaction.php
··· 35 35 $this->renderValue($status->getDisplayName())); 36 36 } 37 37 38 - public function getTitleForFeed() { 39 - return null; 38 + public function shouldHideForFeed() { 39 + return true; 40 40 } 41 + 41 42 }
-16
src/applications/maniphest/storage/ManiphestTransaction.php
··· 40 40 return parent::shouldGenerateOldValue(); 41 41 } 42 42 43 - public function shouldHideForFeed() { 44 - // NOTE: Modular transactions don't currently support this, and it has 45 - // very few callsites, and it's publish-time rather than display-time. 46 - // This should probably become a supported, display-time behavior. For 47 - // discussion, see T12787. 48 - 49 - // Hide "alice created X, a task blocking Y." from feed because it 50 - // will almost always appear adjacent to "alice created Y". 51 - $is_new = $this->getMetadataValue('blocker.new'); 52 - if ($is_new) { 53 - return true; 54 - } 55 - 56 - return parent::shouldHideForFeed(); 57 - } 58 - 59 43 public function getRequiredHandlePHIDs() { 60 44 $phids = parent::getRequiredHandlePHIDs(); 61 45
+10
src/applications/maniphest/xaction/ManiphestTaskUnblockTransaction.php
··· 112 112 return 'fa-shield'; 113 113 } 114 114 115 + public function shouldHideForFeed() { 116 + // Hide "alice created X, a task blocking Y." from feed because it 117 + // will almost always appear adjacent to "alice created Y". 118 + $is_new = $this->getMetadataValue('blocker.new'); 119 + if ($is_new) { 120 + return true; 121 + } 122 + 123 + return parent::shouldHideForFeed(); 124 + } 115 125 116 126 }
-12
src/applications/phriction/storage/PhrictionTransaction.php
··· 54 54 return parent::shouldHideForMail($xactions); 55 55 } 56 56 57 - public function shouldHideForFeed() { 58 - switch ($this->getTransactionType()) { 59 - case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: 60 - case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: 61 - return true; 62 - case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 63 - return $this->getMetadataValue('stub:create:phid', false); 64 - } 65 - return parent::shouldHideForFeed(); 66 - } 67 - 68 - 69 57 public function getMailTags() { 70 58 $tags = array(); 71 59 switch ($this->getTransactionType()) {
+4
src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php
··· 59 59 return 'fa-arrows'; 60 60 } 61 61 62 + public function shouldHideForFeed() { 63 + return true; 64 + } 65 + 62 66 }
+4
src/applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php
··· 102 102 return 'fa-arrows'; 103 103 } 104 104 105 + public function shouldHideForFeed() { 106 + return true; 107 + } 108 + 105 109 }
+32 -1
src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php
··· 6 6 class PhabricatorApplicationTransactionFeedStory 7 7 extends PhabricatorFeedStory { 8 8 9 + private $primaryTransactionPHID; 10 + 9 11 public function getPrimaryObjectPHID() { 10 12 return $this->getValue('objectPHID'); 11 13 } ··· 27 29 } 28 30 29 31 protected function getPrimaryTransactionPHID() { 30 - return head($this->getValue('transactionPHIDs')); 32 + if ($this->primaryTransactionPHID === null) { 33 + // Transactions are filtered and sorted before they're stored, but the 34 + // rendering logic can change between the time an edit occurs and when 35 + // we actually render the story. Recalculate the filtering at display 36 + // time because it's cheap and gets us better results when things change 37 + // by letting the changes apply retroactively. 38 + 39 + $xaction_phids = $this->getValue('transactionPHIDs'); 40 + 41 + $xactions = array(); 42 + foreach ($xaction_phids as $xaction_phid) { 43 + $xactions[] = $this->getObject($xaction_phid); 44 + } 45 + 46 + foreach ($xactions as $key => $xaction) { 47 + if ($xaction->shouldHideForFeed()) { 48 + unset($xactions[$key]); 49 + } 50 + } 51 + 52 + if ($xactions) { 53 + $primary_phid = head($xactions)->getPHID(); 54 + } else { 55 + $primary_phid = head($xaction_phids); 56 + } 57 + 58 + $this->primaryTransactionPHID = $primary_phid; 59 + } 60 + 61 + return $this->primaryTransactionPHID; 31 62 } 32 63 33 64 public function getPrimaryTransaction() {
+8
src/applications/transactions/storage/PhabricatorModularTransaction.php
··· 92 92 return parent::shouldHide(); 93 93 } 94 94 95 + final public function shouldHideForFeed() { 96 + if ($this->getTransactionImplementation()->shouldHideForFeed()) { 97 + return true; 98 + } 99 + 100 + return parent::shouldHideForFeed(); 101 + } 102 + 95 103 /* final */ public function getIcon() { 96 104 $icon = $this->getTransactionImplementation()->getIcon(); 97 105 if ($icon !== null) {
+4
src/applications/transactions/storage/PhabricatorModularTransactionType.php
··· 47 47 return false; 48 48 } 49 49 50 + public function shouldHideForFeed() { 51 + return false; 52 + } 53 + 50 54 public function getIcon() { 51 55 return null; 52 56 }