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

Remove PhabricatorFeedStoryManiphest and ManiphestAction

Summary:
I'll hold this for a couple weeks.

These classes are now only used to render legacy feed stories. I don't plan to migrate the stories since I don't think they're particularly valuable, and migrating them would be complex and time consuming.

With these classes removed, legacy Maniphest feed stories simply vanish from feed.

Test Plan: `grep`, viewed feed, verified it worked but omitted old-style stories.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

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

-233
-4
src/__phutil_library_map__.php
··· 704 704 'LiskIsolationTestDAOException' => 'infrastructure/storage/lisk/__tests__/LiskIsolationTestDAOException.php', 705 705 'LiskMigrationIterator' => 'infrastructure/storage/lisk/LiskMigrationIterator.php', 706 706 'LiskRawMigrationIterator' => 'infrastructure/storage/lisk/LiskRawMigrationIterator.php', 707 - 'ManiphestAction' => 'applications/maniphest/constants/ManiphestAction.php', 708 707 'ManiphestBatchEditController' => 'applications/maniphest/controller/ManiphestBatchEditController.php', 709 708 'ManiphestCapabilityDefaultEdit' => 'applications/maniphest/capability/ManiphestCapabilityDefaultEdit.php', 710 709 'ManiphestCapabilityDefaultView' => 'applications/maniphest/capability/ManiphestCapabilityDefaultView.php', ··· 1197 1196 'PhabricatorFeedStoryData' => 'applications/feed/storage/PhabricatorFeedStoryData.php', 1198 1197 'PhabricatorFeedStoryDifferential' => 'applications/feed/story/PhabricatorFeedStoryDifferential.php', 1199 1198 'PhabricatorFeedStoryDifferentialAggregate' => 'applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php', 1200 - 'PhabricatorFeedStoryManiphest' => 'applications/feed/story/PhabricatorFeedStoryManiphest.php', 1201 1199 'PhabricatorFeedStoryManiphestAggregate' => 'applications/feed/story/PhabricatorFeedStoryManiphestAggregate.php', 1202 1200 'PhabricatorFeedStoryNotification' => 'applications/notification/storage/PhabricatorFeedStoryNotification.php', 1203 1201 'PhabricatorFeedStoryPhriction' => 'applications/feed/story/PhabricatorFeedStoryPhriction.php', ··· 2839 2837 'LiskIsolationTestDAOException' => 'Exception', 2840 2838 'LiskMigrationIterator' => 'PhutilBufferedIterator', 2841 2839 'LiskRawMigrationIterator' => 'PhutilBufferedIterator', 2842 - 'ManiphestAction' => 'ManiphestConstants', 2843 2840 'ManiphestBatchEditController' => 'ManiphestController', 2844 2841 'ManiphestCapabilityDefaultEdit' => 'PhabricatorPolicyCapability', 2845 2842 'ManiphestCapabilityDefaultView' => 'PhabricatorPolicyCapability', ··· 3381 3378 'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO', 3382 3379 'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory', 3383 3380 'PhabricatorFeedStoryDifferentialAggregate' => 'PhabricatorFeedStoryAggregate', 3384 - 'PhabricatorFeedStoryManiphest' => 'PhabricatorFeedStory', 3385 3381 'PhabricatorFeedStoryManiphestAggregate' => 'PhabricatorFeedStoryAggregate', 3386 3382 'PhabricatorFeedStoryNotification' => 'PhabricatorFeedDAO', 3387 3383 'PhabricatorFeedStoryPhriction' => 'PhabricatorFeedStory',
-143
src/applications/feed/story/PhabricatorFeedStoryManiphest.php
··· 1 - <?php 2 - 3 - final class PhabricatorFeedStoryManiphest 4 - extends PhabricatorFeedStory { 5 - 6 - public function getPrimaryObjectPHID() { 7 - return $this->getValue('taskPHID'); 8 - } 9 - 10 - public function getRequiredHandlePHIDs() { 11 - return array( 12 - $this->getValue('ownerPHID'), 13 - ); 14 - } 15 - 16 - public function renderView() { 17 - $data = $this->getStoryData(); 18 - 19 - $view = $this->newStoryView(); 20 - $view->setAppIcon('maniphest-dark'); 21 - 22 - $line = $this->getLineForData($data); 23 - $view->setTitle($line); 24 - 25 - $action = $data->getValue('action'); 26 - 27 - $view->setImage($this->getHandle($data->getAuthorPHID())->getImageURI()); 28 - 29 - switch ($action) { 30 - case ManiphestAction::ACTION_COMMENT: 31 - // I'm just fetching the comments here 32 - // Don't repeat this at home! 33 - $comments = $data->getValue('comments'); 34 - $content = $this->renderSummary($comments); 35 - $view->appendChild($content); 36 - break; 37 - case ManiphestAction::ACTION_CREATE: 38 - $content = $this->renderSummary($data->getValue('description')); 39 - $view->appendChild($content); 40 - break; 41 - } 42 - 43 - $href = $this->getHandle($data->getValue('taskPHID'))->getURI(); 44 - $view->setHref($href); 45 - 46 - return $view; 47 - } 48 - 49 - private function getLineForData($data) { 50 - $action = $data->getValue('action'); 51 - 52 - $actor_phid = $data->getAuthorPHID(); 53 - $actor_link = $this->linkTo($actor_phid); 54 - 55 - $task_phid = $data->getValue('taskPHID'); 56 - $task_link = $this->linkTo($task_phid); 57 - 58 - $owner_phid = $data->getValue('ownerPHID'); 59 - $owner_link = $this->linkTo($owner_phid); 60 - 61 - $verb = ManiphestAction::getActionPastTenseVerb($action); 62 - 63 - switch ($action) { 64 - case ManiphestAction::ACTION_ASSIGN: 65 - case ManiphestAction::ACTION_REASSIGN: 66 - if ($owner_phid) { 67 - if ($owner_phid == $actor_phid) { 68 - $one_line = hsprintf('%s claimed %s', $actor_link, $task_link); 69 - } else { 70 - $one_line = hsprintf('%s %s %s to %s', 71 - $actor_link, 72 - $verb, 73 - $owner_link, 74 - $task_link); 75 - } 76 - } else { 77 - $one_line = hsprintf( 78 - '%s placed %s up for grabs', 79 - $actor_link, 80 - $task_link); 81 - } 82 - break; 83 - default: 84 - $one_line = hsprintf('%s %s %s', $actor_link, $verb, $task_link); 85 - break; 86 - } 87 - 88 - return $one_line; 89 - } 90 - 91 - public function renderText() { 92 - $actor_phid = $this->getAuthorPHID(); 93 - $author_name = $this->getHandle($actor_phid)->getLinkName(); 94 - 95 - $owner_phid = $this->getValue('ownerPHID'); 96 - $owner_name = $this->getHandle($owner_phid)->getLinkName(); 97 - 98 - $task_phid = $this->getPrimaryObjectPHID(); 99 - $task_handle = $this->getHandle($task_phid); 100 - $task_title = $task_handle->getLinkName(); 101 - $task_uri = PhabricatorEnv::getURI($task_handle->getURI()); 102 - 103 - $action = $this->getValue('action'); 104 - $verb = ManiphestAction::getActionPastTenseVerb($action); 105 - 106 - switch ($action) { 107 - case ManiphestAction::ACTION_ASSIGN: 108 - case ManiphestAction::ACTION_REASSIGN: 109 - if ($owner_phid) { 110 - if ($owner_phid == $actor_phid) { 111 - $text = "{$author_name} claimed {$task_title}"; 112 - } else { 113 - $text = "{$author_name} {$verb} {$task_title} to {$owner_name}"; 114 - } 115 - } else { 116 - $text = "{$author_name} placed {$task_title} up for grabs"; 117 - } 118 - break; 119 - default: 120 - $text = "{$author_name} {$verb} {$task_title}"; 121 - break; 122 - } 123 - 124 - $text .= " {$task_uri}"; 125 - 126 - return $text; 127 - } 128 - 129 - public function getNotificationAggregations() { 130 - $class = get_class($this); 131 - $phid = $this->getStoryData()->getValue('taskPHID'); 132 - $read = (int)$this->getHasViewed(); 133 - 134 - // Don't aggregate updates separated by more than 2 hours. 135 - $block = (int)($this->getEpoch() / (60 * 60 * 2)); 136 - 137 - return array( 138 - "{$class}:{$phid}:{$read}:{$block}" 139 - => 'PhabricatorFeedStoryManiphestAggregate', 140 - ); 141 - } 142 - 143 - }
-86
src/applications/maniphest/constants/ManiphestAction.php
··· 1 - <?php 2 - 3 - /** 4 - * @group maniphest 5 - */ 6 - final class ManiphestAction extends ManiphestConstants { 7 - /* These actions must be determined when the story 8 - is generated and thus are new */ 9 - const ACTION_CREATE = 'create'; 10 - const ACTION_REOPEN = 'reopen'; 11 - const ACTION_CLOSE = 'close'; 12 - const ACTION_UPDATE = 'update'; 13 - const ACTION_ASSIGN = 'assign'; 14 - 15 - /* these actions are determined sufficiently by the transaction 16 - type and thus we use them here*/ 17 - const ACTION_COMMENT = PhabricatorTransactions::TYPE_COMMENT; 18 - const ACTION_CC = ManiphestTransaction::TYPE_CCS; 19 - const ACTION_PRIORITY = ManiphestTransaction::TYPE_PRIORITY; 20 - const ACTION_PROJECT = ManiphestTransaction::TYPE_PROJECTS; 21 - const ACTION_TITLE = ManiphestTransaction::TYPE_TITLE; 22 - const ACTION_DESCRIPTION = ManiphestTransaction::TYPE_DESCRIPTION; 23 - const ACTION_REASSIGN = ManiphestTransaction::TYPE_OWNER; 24 - const ACTION_ATTACH = ManiphestTransaction::TYPE_ATTACH; 25 - const ACTION_EDGE = ManiphestTransaction::TYPE_EDGE; 26 - const ACTION_AUXILIARY = PhabricatorTransactions::TYPE_CUSTOMFIELD; 27 - 28 - public static function getActionPastTenseVerb($action) { 29 - static $map = array( 30 - self::ACTION_CREATE => 'created', 31 - self::ACTION_CLOSE => 'closed', 32 - self::ACTION_UPDATE => 'updated', 33 - self::ACTION_ASSIGN => 'assigned', 34 - self::ACTION_REASSIGN => 'reassigned', 35 - self::ACTION_COMMENT => 'commented on', 36 - self::ACTION_CC => 'updated cc\'s of', 37 - self::ACTION_PRIORITY => 'changed the priority of', 38 - self::ACTION_PROJECT => 'modified projects of', 39 - self::ACTION_TITLE => 'updated title of', 40 - self::ACTION_DESCRIPTION => 'updated description of', 41 - self::ACTION_ATTACH => 'attached something to', 42 - self::ACTION_EDGE => 'changed related objects of', 43 - self::ACTION_REOPEN => 'reopened', 44 - self::ACTION_AUXILIARY => 'updated an auxiliary field of', 45 - ); 46 - 47 - return idx($map, $action, "brazenly {$action}'d"); 48 - } 49 - 50 - /** 51 - * If a group of transactions contain several actions, select the "strongest" 52 - * action. For instance, a close is stronger than an update, because we want 53 - * to render "User U closed task T" instead of "User U updated task T" when 54 - * a user closes a task. 55 - */ 56 - public static function selectStrongestAction(array $actions) { 57 - static $strengths = array( 58 - self::ACTION_AUXILIARY => -1, 59 - self::ACTION_UPDATE => 0, 60 - self::ACTION_CC => 1, 61 - self::ACTION_PROJECT => 2, 62 - self::ACTION_DESCRIPTION => 3, 63 - self::ACTION_TITLE => 4, 64 - self::ACTION_ATTACH => 5, 65 - self::ACTION_EDGE => 5, 66 - self::ACTION_COMMENT => 6, 67 - self::ACTION_PRIORITY => 7, 68 - self::ACTION_REASSIGN => 8, 69 - self::ACTION_ASSIGN => 9, 70 - self::ACTION_REOPEN => 10, 71 - self::ACTION_CREATE => 11, 72 - self::ACTION_CLOSE => 12, 73 - ); 74 - 75 - $strongest = null; 76 - $strength = -1; 77 - foreach ($actions as $action) { 78 - if ($strengths[$action] > $strength) { 79 - $strength = $strengths[$action]; 80 - $strongest = $action; 81 - } 82 - } 83 - return $strongest; 84 - } 85 - 86 - }