1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 02:42:40 +01:00

Remove unused PhabricatorFeedStory subclasses

Summary: Remove a bunch of unused `PhabricatorFeedStory` subclasses.

Test Plan: `grep`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: btrahan, Korvin, epriestley

Maniphest Tasks: T5655

Differential Revision: https://secure.phabricator.com/D11674
This commit is contained in:
Joshua Spence 2015-05-20 07:02:08 +10:00
parent 16a8ed72bd
commit b5bf8e998d
9 changed files with 0 additions and 734 deletions

View file

@ -1832,15 +1832,8 @@ phutil_register_library_map(array(
'PhabricatorFeedQuery' => 'applications/feed/query/PhabricatorFeedQuery.php', 'PhabricatorFeedQuery' => 'applications/feed/query/PhabricatorFeedQuery.php',
'PhabricatorFeedSearchEngine' => 'applications/feed/query/PhabricatorFeedSearchEngine.php', 'PhabricatorFeedSearchEngine' => 'applications/feed/query/PhabricatorFeedSearchEngine.php',
'PhabricatorFeedStory' => 'applications/feed/story/PhabricatorFeedStory.php', 'PhabricatorFeedStory' => 'applications/feed/story/PhabricatorFeedStory.php',
'PhabricatorFeedStoryAggregate' => 'applications/feed/story/PhabricatorFeedStoryAggregate.php',
'PhabricatorFeedStoryAudit' => 'applications/feed/story/PhabricatorFeedStoryAudit.php',
'PhabricatorFeedStoryCommit' => 'applications/feed/story/PhabricatorFeedStoryCommit.php',
'PhabricatorFeedStoryData' => 'applications/feed/storage/PhabricatorFeedStoryData.php', 'PhabricatorFeedStoryData' => 'applications/feed/storage/PhabricatorFeedStoryData.php',
'PhabricatorFeedStoryDifferential' => 'applications/feed/story/PhabricatorFeedStoryDifferential.php',
'PhabricatorFeedStoryDifferentialAggregate' => 'applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php',
'PhabricatorFeedStoryManiphestAggregate' => 'applications/feed/story/PhabricatorFeedStoryManiphestAggregate.php',
'PhabricatorFeedStoryNotification' => 'applications/notification/storage/PhabricatorFeedStoryNotification.php', 'PhabricatorFeedStoryNotification' => 'applications/notification/storage/PhabricatorFeedStoryNotification.php',
'PhabricatorFeedStoryPhriction' => 'applications/feed/story/PhabricatorFeedStoryPhriction.php',
'PhabricatorFeedStoryPublisher' => 'applications/feed/PhabricatorFeedStoryPublisher.php', 'PhabricatorFeedStoryPublisher' => 'applications/feed/PhabricatorFeedStoryPublisher.php',
'PhabricatorFeedStoryReference' => 'applications/feed/storage/PhabricatorFeedStoryReference.php', 'PhabricatorFeedStoryReference' => 'applications/feed/storage/PhabricatorFeedStoryReference.php',
'PhabricatorFile' => 'applications/files/storage/PhabricatorFile.php', 'PhabricatorFile' => 'applications/files/storage/PhabricatorFile.php',
@ -5225,15 +5218,8 @@ phutil_register_library_map(array(
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
'PhabricatorMarkupInterface', 'PhabricatorMarkupInterface',
), ),
'PhabricatorFeedStoryAggregate' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryAudit' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryCommit' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO',
'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryDifferentialAggregate' => 'PhabricatorFeedStoryAggregate',
'PhabricatorFeedStoryManiphestAggregate' => 'PhabricatorFeedStoryAggregate',
'PhabricatorFeedStoryNotification' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryNotification' => 'PhabricatorFeedDAO',
'PhabricatorFeedStoryPhriction' => 'PhabricatorFeedStory',
'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO',
'PhabricatorFile' => array( 'PhabricatorFile' => array(
'PhabricatorFileDAO', 'PhabricatorFileDAO',

View file

@ -1,74 +0,0 @@
<?php
abstract class PhabricatorFeedStoryAggregate extends PhabricatorFeedStory {
private $aggregateStories = array();
public function getHasViewed() {
return head($this->getAggregateStories())->getHasViewed();
}
public function getPrimaryObjectPHID() {
return head($this->getAggregateStories())->getPrimaryObjectPHID();
}
public function getRequiredHandlePHIDs() {
$phids = array();
foreach ($this->getAggregateStories() as $story) {
$phids[] = $story->getRequiredHandlePHIDs();
}
return array_mergev($phids);
}
public function getRequiredObjectPHIDs() {
$phids = array();
foreach ($this->getAggregateStories() as $story) {
$phids[] = $story->getRequiredObjectPHIDs();
}
return array_mergev($phids);
}
protected function getAuthorPHIDs() {
$authors = array();
foreach ($this->getAggregateStories() as $story) {
$authors[] = $story->getStoryData()->getAuthorPHID();
}
return array_unique(array_filter($authors));
}
protected function getDataValues($key, $default) {
$result = array();
foreach ($this->getAggregateStories() as $key => $story) {
$result[$key] = $story->getStoryData()->getValue($key, $default);
}
return $result;
}
final public function setAggregateStories(array $aggregate_stories) {
assert_instances_of($aggregate_stories, 'PhabricatorFeedStory');
$this->aggregateStories = $aggregate_stories;
$objects = array();
$handles = array();
foreach ($this->aggregateStories as $story) {
$objects += $story->getObjects();
$handles += $story->getHandles();
}
$this->setObjects($objects);
$this->setHandles($handles);
return $this;
}
final public function getAggregateStories() {
return $this->aggregateStories;
}
final public function getNotificationAggregations() {
throw new Exception(
'You can not get aggregations for an aggregate story.');
}
}

View file

@ -1,49 +0,0 @@
<?php
final class PhabricatorFeedStoryAudit extends PhabricatorFeedStory {
public function getPrimaryObjectPHID() {
return $this->getStoryData()->getValue('commitPHID');
}
public function renderView() {
$author_phid = $this->getAuthorPHID();
$commit_phid = $this->getPrimaryObjectPHID();
$view = $this->newStoryView();
$action = $this->getValue('action');
$verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($action);
$view->setTitle(hsprintf(
'%s %s commit %s.',
$this->linkTo($author_phid),
$verb,
$this->linkTo($commit_phid)));
$comments = $this->getValue('content');
$view->setImage($this->getHandle($author_phid)->getImageURI());
if ($comments) {
$content = $this->renderSummary($this->getValue('content'));
$view->appendChild($content);
}
return $view;
}
public function renderText() {
$author_name = $this->getHandle($this->getAuthorPHID())->getLinkName();
$commit_path = $this->getHandle($this->getPrimaryObjectPHID())->getURI();
$commit_uri = PhabricatorEnv::getURI($commit_path);
$action = $this->getValue('action');
$verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($action);
$text = "{$author_name} {$verb} commit {$commit_uri}";
return $text;
}
}

View file

@ -1,107 +0,0 @@
<?php
final class PhabricatorFeedStoryCommit extends PhabricatorFeedStory {
public function getPrimaryObjectPHID() {
return $this->getValue('commitPHID');
}
public function getRequiredHandlePHIDs() {
return array(
$this->getValue('committerPHID'),
);
}
public function renderView() {
$data = $this->getStoryData();
$author = null;
if ($data->getValue('authorPHID')) {
$author = $this->linkTo($data->getValue('authorPHID'));
} else {
$author = $data->getValue('authorName');
}
$committer = null;
if ($data->getValue('committerPHID')) {
$committer = $this->linkTo($data->getValue('committerPHID'));
} else if ($data->getValue('committerName')) {
$committer = $data->getValue('committerName');
}
$commit = $this->linkTo($data->getValue('commitPHID'));
if (!$committer) {
$committer = $author;
$author = null;
}
if ($author) {
$title = pht(
'%s committed %s (authored by %s)',
$committer,
$commit,
$author);
} else {
$title = pht(
'%s committed %s',
$committer,
$commit);
}
$view = $this->newStoryView();
$view->setTitle($title);
if ($data->getValue('authorPHID')) {
$view->setImage($this->getHandle($data->getAuthorPHID())->getImageURI());
}
$content = $this->renderSummary($data->getValue('summary'));
$view->appendChild($content);
return $view;
}
public function renderText() {
$author = null;
if ($this->getAuthorPHID()) {
$author = $this->getHandle($this->getAuthorPHID())->getLinkName();
} else {
$author = $this->getValue('authorName');
}
$committer = null;
if ($this->getValue('committerPHID')) {
$committer_handle = $this->getHandle($this->getValue('committerPHID'));
$committer = $committer_handle->getLinkName();
} else if ($this->getValue('committerName')) {
$committer = $this->getValue('committerName');
}
$commit_handle = $this->getHandle($this->getPrimaryObjectPHID());
$commit_uri = PhabricatorEnv::getURI($commit_handle->getURI());
$commit_name = $commit_handle->getLinkName();
if (!$committer) {
$committer = $author;
$author = null;
}
if ($author) {
$text = pht(
'%s committed %s (authored by %s).',
$committer,
$commit_name,
$author);
} else {
$text = pht(
'%s committed %s.',
$committer,
$commit_name);
}
return $text;
}
}

View file

@ -1,237 +0,0 @@
<?php
final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
public function getPrimaryObjectPHID() {
return $this->getValue('revision_phid');
}
public function renderView() {
$data = $this->getStoryData();
$view = $this->newStoryView();
$line = $this->getLineForData($data);
$view->setTitle($line);
$href = $this->getHandle($data->getValue('revision_phid'))->getURI();
$view->setHref($href);
$action = $data->getValue('action');
switch ($action) {
case DifferentialAction::ACTION_CREATE:
case DifferentialAction::ACTION_CLOSE:
case DifferentialAction::ACTION_COMMENT:
$full_size = true;
break;
default:
$full_size = false;
break;
}
$view->setImage($this->getHandle($data->getAuthorPHID())->getImageURI());
if ($full_size) {
$content = $this->renderSummary($data->getValue('feedback_content'));
$view->appendChild($content);
}
return $view;
}
private function getLineForData($data) {
$actor_phid = $data->getAuthorPHID();
$revision_phid = $data->getValue('revision_phid');
$action = $data->getValue('action');
$actor_link = $this->linkTo($actor_phid);
$revision_link = $this->linkTo($revision_phid);
switch ($action) {
case DifferentialAction::ACTION_COMMENT:
$one_line = pht('%s commented on revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_ACCEPT:
$one_line = pht('%s accepted revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_REJECT:
$one_line = pht('%s requested changes to revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_RETHINK:
$one_line = pht('%s planned changes to revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_ABANDON:
$one_line = pht('%s abandoned revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_CLOSE:
$one_line = pht('%s closed revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_REQUEST:
$one_line = pht('%s requested a review of revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_RECLAIM:
$one_line = pht('%s reclaimed revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_UPDATE:
$one_line = pht('%s updated revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_RESIGN:
$one_line = pht('%s resigned from revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_SUMMARIZE:
$one_line = pht('%s summarized revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_TESTPLAN:
$one_line = pht('%s explained the test plan for revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_CREATE:
$one_line = pht('%s created revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_ADDREVIEWERS:
$one_line = pht('%s added reviewers to revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_ADDCCS:
$one_line = pht('%s added CCs to revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_CLAIM:
$one_line = pht('%s commandeered revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_REOPEN:
$one_line = pht('%s reopened revision %s',
$actor_link, $revision_link);
break;
case DifferentialTransaction::TYPE_INLINE:
$one_line = pht('%s added inline comments to %s',
$actor_link, $revision_link);
break;
default:
$one_line = pht('%s edited %s',
$actor_link, $revision_link);
break;
}
return $one_line;
}
public function renderText() {
$author_name = $this->getHandle($this->getAuthorPHID())->getLinkName();
$revision_handle = $this->getHandle($this->getPrimaryObjectPHID());
$revision_title = $revision_handle->getLinkName();
$revision_uri = PhabricatorEnv::getURI($revision_handle->getURI());
$action = $this->getValue('action');
switch ($action) {
case DifferentialAction::ACTION_COMMENT:
$one_line = pht('%s commented on revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_ACCEPT:
$one_line = pht('%s accepted revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_REJECT:
$one_line = pht('%s requested changes to revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_RETHINK:
$one_line = pht('%s planned changes to revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_ABANDON:
$one_line = pht('%s abandoned revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_CLOSE:
$one_line = pht('%s closed revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_REQUEST:
$one_line = pht('%s requested a review of revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_RECLAIM:
$one_line = pht('%s reclaimed revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_UPDATE:
$one_line = pht('%s updated revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_RESIGN:
$one_line = pht('%s resigned from revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_SUMMARIZE:
$one_line = pht('%s summarized revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_TESTPLAN:
$one_line = pht('%s explained the test plan for revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_CREATE:
$one_line = pht('%s created revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_ADDREVIEWERS:
$one_line = pht('%s added reviewers to revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_ADDCCS:
$one_line = pht('%s added CCs to revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_CLAIM:
$one_line = pht('%s commandeered revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_REOPEN:
$one_line = pht('%s reopened revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialTransaction::TYPE_INLINE:
$one_line = pht('%s added inline comments to %s %s',
$author_name, $revision_title, $revision_uri);
break;
default:
$one_line = pht('%s edited %s %s',
$author_name, $revision_title, $revision_uri);
break;
}
return $one_line;
}
public function getNotificationAggregations() {
$class = get_class($this);
$phid = $this->getStoryData()->getValue('revision_phid');
$read = (int)$this->getHasViewed();
// Don't aggregate updates separated by more than 2 hours.
$block = (int)($this->getEpoch() / (60 * 60 * 2));
return array(
"{$class}:{$phid}:{$read}:{$block}"
=> 'PhabricatorFeedStoryDifferentialAggregate',
);
}
}

View file

@ -1,66 +0,0 @@
<?php
final class PhabricatorFeedStoryDifferentialAggregate
extends PhabricatorFeedStoryAggregate {
public function renderView() {
$data = $this->getStoryData();
$task_link = $this->linkTo($data->getValue('revision_phid'));
$authors = $this->getAuthorPHIDs();
// TODO: These aren't really translatable because linkTo() returns a
// string, not an object with a gender.
switch (count($authors)) {
case 1:
$author = $this->linkTo(array_shift($authors));
$title = pht(
'%s made multiple updates to %s',
$author,
$task_link);
break;
case 2:
$author1 = $this->linkTo(array_shift($authors));
$author2 = $this->linkTo(array_shift($authors));
$title = pht(
'%s and %s made multiple updates to %s',
$author1,
$author2,
$task_link);
break;
case 3:
$author1 = $this->linkTo(array_shift($authors));
$author2 = $this->linkTo(array_shift($authors));
$author3 = $this->linkTo(array_shift($authors));
$title = pht(
'%s, %s, and %s made multiple updates to %s',
$author1,
$author2,
$author3,
$task_link);
break;
default:
$author1 = $this->linkTo(array_shift($authors));
$author2 = $this->linkTo(array_shift($authors));
$others = count($authors);
$title = pht(
'%s, %s, and %d others made multiple updates to %s',
$author1,
$author2,
$others,
$task_link);
break;
}
$view = $this->newStoryView();
$view->setTitle($title);
$href = $this->getHandle($data->getValue('revision_phid'))->getURI();
$view->setHref($href);
return $view;
}
}

View file

@ -1,66 +0,0 @@
<?php
final class PhabricatorFeedStoryManiphestAggregate
extends PhabricatorFeedStoryAggregate {
public function renderView() {
$data = $this->getStoryData();
$task_link = $this->linkTo($data->getValue('taskPHID'));
$authors = $this->getAuthorPHIDs();
// TODO: These aren't really translatable because linkTo() returns a
// string, not an object with a gender.
switch (count($authors)) {
case 1:
$author = $this->linkTo(array_shift($authors));
$title = pht(
'%s made multiple updates to %s',
$author,
$task_link);
break;
case 2:
$author1 = $this->linkTo(array_shift($authors));
$author2 = $this->linkTo(array_shift($authors));
$title = pht(
'%s and %s made multiple updates to %s',
$author1,
$author2,
$task_link);
break;
case 3:
$author1 = $this->linkTo(array_shift($authors));
$author2 = $this->linkTo(array_shift($authors));
$author3 = $this->linkTo(array_shift($authors));
$title = pht(
'%s, %s, and %s made multiple updates to %s',
$author1,
$author2,
$author3,
$task_link);
break;
default:
$author1 = $this->linkTo(array_shift($authors));
$author2 = $this->linkTo(array_shift($authors));
$others = count($authors);
$title = pht(
'%s, %s, and %d others made multiple updates to %s',
$author1,
$author2,
$others,
$task_link);
break;
}
$view = $this->newStoryView();
$view->setTitle($title);
$href = $this->getHandle($data->getValue('taskPHID'))->getURI();
$view->setHref($href);
return $view;
}
}

View file

@ -1,95 +0,0 @@
<?php
final class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
public function getPrimaryObjectPHID() {
return $this->getValue('phid');
}
public function getRequiredHandlePHIDs() {
$required_phids = parent::getRequiredHandlePHIDs();
$from_phid = $this->getStoryData()->getValue('movedFromPHID');
if ($from_phid) {
$required_phids[] = $from_phid;
}
return $required_phids;
}
public function renderView() {
$data = $this->getStoryData();
$author_phid = $data->getAuthorPHID();
$author_link = $this->linkTo($author_phid);
$document_phid = $data->getValue('phid');
$view = $this->newStoryView();
$action = $data->getValue('action');
$verb = PhrictionActionConstants::getActionPastTenseVerb($action);
switch ($action) {
case PhrictionActionConstants::ACTION_MOVE_HERE:
$from_phid = $data->getValue('movedFromPHID');
// Older feed stories may not have 'moved_from_phid', in that case
// we fall back to the default behaviour (hence the fallthrough)
if ($from_phid) {
$document_handle = $this->getHandle($document_phid);
$from_handle = $this->getHandle($from_phid);
$view->setTitle(pht(
'%s moved the document %s from %s to %s.',
$author_link,
$document_handle->renderLink(),
phutil_tag(
'a',
array(
'href' => $from_handle->getURI(),
),
$from_handle->getURI()),
phutil_tag(
'a',
array(
'href' => $document_handle->getURI(),
),
$document_handle->getURI())));
break;
}
/* Fallthrough */
default:
$view->setTitle(pht(
'%s %s the document %s.',
$author_link,
$verb,
$this->linkTo($document_phid)));
break;
}
$view->setImage($this->getHandle($author_phid)->getImageURI());
switch ($action) {
case PhrictionActionConstants::ACTION_CREATE:
$content = $this->renderSummary($data->getValue('content'));
$view->appendChild($content);
break;
}
return $view;
}
public function renderText() {
$author_handle = $this->getHandle($this->getAuthorPHID());
$author_name = $author_handle->getName();
$document_handle = $this->getHandle($this->getPrimaryObjectPHID());
$document_title = $document_handle->getLinkName();
$document_uri = PhabricatorEnv::getURI($document_handle->getURI());
$action = $this->getValue('action');
$verb = PhrictionActionConstants::getActionPastTenseVerb($action);
$text = "{$author_name} {$verb} the document".
" {$document_title} {$document_uri}";
return $text;
}
}

View file

@ -26,32 +26,6 @@ final class PhabricatorNotificationBuilder {
// nowhere sensible for the notification to link to, and no reasonable way // nowhere sensible for the notification to link to, and no reasonable way
// to unambiguously clear it. // to unambiguously clear it.
// Each notification emits keys it can aggregate on. For instance, if this
// story is "a updated T123", it might emit a key like this:
//
// task:phid123:unread => PhabricatorFeedStoryManiphestAggregate
//
// All the unread notifications about the task with PHID "phid123" will
// emit the same key, telling us we can aggregate them into a single
// story of type "PhabricatorFeedStoryManiphestAggregate", which could
// read like "a and b updated T123".
//
// A story might be able to aggregate in multiple ways. Although this is
// unlikely for stories in a notification context, stories in a feed context
// can also aggregate by actor:
//
// task:phid123 => PhabricatorFeedStoryManiphestAggregate
// actor:user123 => PhabricatorFeedStoryActorAggregate
//
// This means the story can either become "a and b updated T123" or
// "a updated T123 and T456". When faced with multiple possibilities, it's
// our job to choose the best aggregation.
//
// For now, we use a simple greedy algorithm and repeatedly select the
// aggregate story which consumes the largest number of individual stories
// until no aggregate story exists that consumes more than one story.
// Build up a map of all the possible aggregations. // Build up a map of all the possible aggregations.
$chronokey_map = array(); $chronokey_map = array();