1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

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
This commit is contained in:
epriestley 2018-03-06 17:36:14 -08:00
parent 573bf15124
commit e57dbcda33
9 changed files with 65 additions and 31 deletions

View file

@ -35,7 +35,8 @@ final class DifferentialRevisionWrongStateTransaction
$this->renderValue($status->getDisplayName()));
}
public function getTitleForFeed() {
return null;
public function shouldHideForFeed() {
return true;
}
}

View file

@ -40,22 +40,6 @@ final class ManiphestTransaction
return parent::shouldGenerateOldValue();
}
public function shouldHideForFeed() {
// NOTE: Modular transactions don't currently support this, and it has
// very few callsites, and it's publish-time rather than display-time.
// This should probably become a supported, display-time behavior. For
// discussion, see T12787.
// Hide "alice created X, a task blocking Y." from feed because it
// will almost always appear adjacent to "alice created Y".
$is_new = $this->getMetadataValue('blocker.new');
if ($is_new) {
return true;
}
return parent::shouldHideForFeed();
}
public function getRequiredHandlePHIDs() {
$phids = parent::getRequiredHandlePHIDs();

View file

@ -112,5 +112,15 @@ final class ManiphestTaskUnblockTransaction
return 'fa-shield';
}
public function shouldHideForFeed() {
// Hide "alice created X, a task blocking Y." from feed because it
// will almost always appear adjacent to "alice created Y".
$is_new = $this->getMetadataValue('blocker.new');
if ($is_new) {
return true;
}
return parent::shouldHideForFeed();
}
}

View file

@ -54,18 +54,6 @@ final class PhrictionTransaction
return parent::shouldHideForMail($xactions);
}
public function shouldHideForFeed() {
switch ($this->getTransactionType()) {
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE:
case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE:
return true;
case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE:
return $this->getMetadataValue('stub:create:phid', false);
}
return parent::shouldHideForFeed();
}
public function getMailTags() {
$tags = array();
switch ($this->getTransactionType()) {

View file

@ -59,4 +59,8 @@ final class PhrictionDocumentMoveAwayTransaction
return 'fa-arrows';
}
public function shouldHideForFeed() {
return true;
}
}

View file

@ -102,4 +102,8 @@ final class PhrictionDocumentMoveToTransaction
return 'fa-arrows';
}
public function shouldHideForFeed() {
return true;
}
}

View file

@ -6,6 +6,8 @@
class PhabricatorApplicationTransactionFeedStory
extends PhabricatorFeedStory {
private $primaryTransactionPHID;
public function getPrimaryObjectPHID() {
return $this->getValue('objectPHID');
}
@ -27,7 +29,36 @@ class PhabricatorApplicationTransactionFeedStory
}
protected function getPrimaryTransactionPHID() {
return head($this->getValue('transactionPHIDs'));
if ($this->primaryTransactionPHID === null) {
// Transactions are filtered and sorted before they're stored, but the
// rendering logic can change between the time an edit occurs and when
// we actually render the story. Recalculate the filtering at display
// time because it's cheap and gets us better results when things change
// by letting the changes apply retroactively.
$xaction_phids = $this->getValue('transactionPHIDs');
$xactions = array();
foreach ($xaction_phids as $xaction_phid) {
$xactions[] = $this->getObject($xaction_phid);
}
foreach ($xactions as $key => $xaction) {
if ($xaction->shouldHideForFeed()) {
unset($xactions[$key]);
}
}
if ($xactions) {
$primary_phid = head($xactions)->getPHID();
} else {
$primary_phid = head($xaction_phids);
}
$this->primaryTransactionPHID = $primary_phid;
}
return $this->primaryTransactionPHID;
}
public function getPrimaryTransaction() {

View file

@ -92,6 +92,14 @@ abstract class PhabricatorModularTransaction
return parent::shouldHide();
}
final public function shouldHideForFeed() {
if ($this->getTransactionImplementation()->shouldHideForFeed()) {
return true;
}
return parent::shouldHideForFeed();
}
/* final */ public function getIcon() {
$icon = $this->getTransactionImplementation()->getIcon();
if ($icon !== null) {

View file

@ -47,6 +47,10 @@ abstract class PhabricatorModularTransactionType
return false;
}
public function shouldHideForFeed() {
return false;
}
public function getIcon() {
return null;
}