From c67f45734dd15bf5a93cb7ed7c3f5d6689b3cbcb Mon Sep 17 00:00:00 2001 From: Keebuhm Park Date: Fri, 8 Jun 2012 18:45:26 -0700 Subject: [PATCH] Notification implementation for Differential Summary: The notification implementation has been extended to Differential. Appropriate changes have been made to the Differential editors and Differential feed story. Test Plan: Tested out various actions available for Differential and confirmed that the notifications get delivered correctly and feed is generated. Reviewers: epriestley, btrahan Reviewed By: epriestley CC: allenjohnashton, ddfisher, aran, Korvin Differential Revision: https://secure.phabricator.com/D2696 --- .../DifferentialRevisionViewController.php | 4 ++ .../editor/DifferentialCommentEditor.php | 6 +++ .../editor/DifferentialRevisionEditor.php | 6 +++ .../PhabricatorFeedStoryDifferential.php | 48 ++++++++++++++----- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php index 7cd27056c5..4bd0cb5655 100644 --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -363,6 +363,10 @@ final class DifferentialRevisionViewController extends DifferentialController { if ($comment_form) { $page_pane->appendChild($comment_form->render()); } + + PhabricatorFeedStoryNotification::updateObjectNotificationViews( + $user, $revision->getPHID()); + return $this->buildStandardPageResponse( array( $reviewer_warning, diff --git a/src/applications/differential/editor/DifferentialCommentEditor.php b/src/applications/differential/editor/DifferentialCommentEditor.php index b1f21c1262..44d078a93a 100644 --- a/src/applications/differential/editor/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/DifferentialCommentEditor.php @@ -575,6 +575,12 @@ final class DifferentialCommentEditor { $this->actorPHID, $revision->getAuthorPHID(), )) + ->setPrimaryObjectPHID($revision->getPHID()) + ->setSubscribedPHIDs( + array_merge( + array($revision->getAuthorPHID()), + $revision->getReviewers(), + $revision->getCCPHIDs())) ->publish(); // TODO: Move to a daemon? diff --git a/src/applications/differential/editor/DifferentialRevisionEditor.php b/src/applications/differential/editor/DifferentialRevisionEditor.php index 491854d850..eab033a6c4 100644 --- a/src/applications/differential/editor/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/DifferentialRevisionEditor.php @@ -437,6 +437,12 @@ final class DifferentialRevisionEditor { $revision->getPHID(), $revision->getAuthorPHID(), )) + ->setPrimaryObjectPHID($revision->getPHID()) + ->setSubscribedPHIDs( + array_merge( + array($revision->getAuthorPHID()), + $revision->getReviewers(), + $revision->getCCPHIDs())) ->publish(); // TODO: Move this into a worker task thing. diff --git a/src/applications/feed/story/PhabricatorFeedStoryDifferential.php b/src/applications/feed/story/PhabricatorFeedStoryDifferential.php index efa55e6766..ae1dc242f5 100644 --- a/src/applications/feed/story/PhabricatorFeedStoryDifferential.php +++ b/src/applications/feed/story/PhabricatorFeedStoryDifferential.php @@ -36,19 +36,10 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory { public function renderView() { $data = $this->getStoryData(); - $author_phid = $data->getAuthorPHID(); - $view = new PhabricatorFeedStoryView(); - $revision_phid = $data->getValue('revision_phid'); - - $action = $data->getValue('action'); - $verb = DifferentialAction::getActionPastTenseVerb($action); - - $view->setTitle( - $this->linkTo($author_phid). - " {$verb} revision ". - $this->linkTo($revision_phid).'.'); + $line = $this->getLineForData($data); + $view->setTitle($line); $view->setEpoch($data->getEpoch()); $action = $data->getValue('action'); @@ -63,7 +54,7 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory { } if ($full_size) { - $view->setImage($this->getHandle($author_phid)->getImageURI()); + $view->setImage($this->getHandle($data->getAuthorPHID())->getImageURI()); $content = $this->renderSummary($data->getValue('feedback_content')); $view->appendChild($content); } else { @@ -73,4 +64,37 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory { return $view; } + public function renderNotificationView() { + $data = $this->getStoryData(); + + $view = new PhabricatorNotificationStoryView(); + + $view->setTitle($this->getLineForData($data)); + $view->setEpoch($data->getEpoch()); + $view->setViewed($this->getHasViewed()); + + return $view; + } + + private function getLineForData($data) { + $actor_phid = $data->getAuthorPHID(); + $owner_phid = $data->getValue('revision_author_phid'); + $revision_phid = $data->getValue('revision_phid'); + $action = $data->getValue('action'); + $comments = $data->getValue('feedback_content'); + + $actor_link = $this->linkTo($actor_phid); + $revision_link = $this->linkTo($revision_phid); + $owner_link = $this->linkTo($owner_phid); + + $verb = DifferentialAction::getActionPastTenseVerb($action); + + $one_line = "{$actor_link} {$verb} revision {$revision_link}"; + + if ($comments) { + $one_line .= " \"{$comments}\""; + } + + return $one_line; + } }