diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index c0873d286d..5bf6aceb21 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -696,6 +696,7 @@ phutil_register_library_map(array( 'PhabricatorFeedStoryCommit' => 'applications/feed/story/PhabricatorFeedStoryCommit.php', 'PhabricatorFeedStoryData' => 'applications/feed/storage/PhabricatorFeedStoryData.php', 'PhabricatorFeedStoryDifferential' => 'applications/feed/story/PhabricatorFeedStoryDifferential.php', + 'PhabricatorFeedStoryDifferentialAggregate' => 'applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php', 'PhabricatorFeedStoryManiphest' => 'applications/feed/story/PhabricatorFeedStoryManiphest.php', 'PhabricatorFeedStoryManiphestAggregate' => 'applications/feed/story/PhabricatorFeedStoryManiphestAggregate.php', 'PhabricatorFeedStoryNotification' => 'applications/notification/storage/PhabricatorFeedStoryNotification.php', @@ -1820,6 +1821,7 @@ phutil_register_library_map(array( 'PhabricatorFeedStoryCommit' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory', + 'PhabricatorFeedStoryDifferentialAggregate' => 'PhabricatorFeedStoryAggregate', 'PhabricatorFeedStoryManiphest' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryManiphestAggregate' => 'PhabricatorFeedStoryAggregate', 'PhabricatorFeedStoryNotification' => 'PhabricatorFeedDAO', diff --git a/src/applications/feed/story/PhabricatorFeedStoryDifferential.php b/src/applications/feed/story/PhabricatorFeedStoryDifferential.php index 25174bf242..cde2122d93 100644 --- a/src/applications/feed/story/PhabricatorFeedStoryDifferential.php +++ b/src/applications/feed/story/PhabricatorFeedStoryDifferential.php @@ -92,4 +92,18 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory { 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', + ); + } } diff --git a/src/applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php b/src/applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php new file mode 100644 index 0000000000..51ade007b5 --- /dev/null +++ b/src/applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php @@ -0,0 +1,86 @@ +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 = new PhabricatorNotificationStoryView(); + $view->setEpoch($this->getEpoch()); + $view->setViewed($this->getHasViewed()); + $view->setTitle($title); + + return $view; + } + +}