diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e53237625c..d9884c49a4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -745,7 +745,6 @@ phutil_register_library_map(array( 'PhabricatorFeedStoryReference' => 'applications/feed/storage/PhabricatorFeedStoryReference.php', 'PhabricatorFeedStoryStatus' => 'applications/feed/story/PhabricatorFeedStoryStatus.php', 'PhabricatorFeedStoryTypeConstants' => 'applications/feed/constants/PhabricatorFeedStoryTypeConstants.php', - 'PhabricatorFeedStoryUnknown' => 'applications/feed/story/PhabricatorFeedStoryUnknown.php', 'PhabricatorFeedStoryView' => 'applications/feed/view/PhabricatorFeedStoryView.php', 'PhabricatorFeedView' => 'applications/feed/view/PhabricatorFeedView.php', 'PhabricatorFile' => 'applications/files/storage/PhabricatorFile.php', @@ -872,8 +871,6 @@ phutil_register_library_map(array( 'PhabricatorNotificationPanelController' => 'applications/notification/controller/PhabricatorNotificationPanelController.php', 'PhabricatorNotificationQuery' => 'applications/notification/PhabricatorNotificationQuery.php', 'PhabricatorNotificationStatusController' => 'applications/notification/controller/PhabricatorNotificationStatusController.php', - 'PhabricatorNotificationStoryView' => 'applications/notification/view/PhabricatorNotificationStoryView.php', - 'PhabricatorNotificationView' => 'applications/notification/view/PhabricatorNotificationView.php', 'PhabricatorOAuthClientAuthorization' => 'applications/oauthserver/storage/PhabricatorOAuthClientAuthorization.php', 'PhabricatorOAuthClientAuthorizationBaseController' => 'applications/oauthserver/controller/clientauthorization/PhabricatorOAuthClientAuthorizationBaseController.php', 'PhabricatorOAuthClientAuthorizationDeleteController' => 'applications/oauthserver/controller/clientauthorization/PhabricatorOAuthClientAuthorizationDeleteController.php', @@ -1986,7 +1983,6 @@ phutil_register_library_map(array( 'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants', - 'PhabricatorFeedStoryUnknown' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryView' => 'PhabricatorFeedView', 'PhabricatorFeedView' => 'AphrontView', 'PhabricatorFile' => @@ -2096,8 +2092,6 @@ phutil_register_library_map(array( 'PhabricatorNotificationPanelController' => 'PhabricatorNotificationController', 'PhabricatorNotificationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorNotificationStatusController' => 'PhabricatorNotificationController', - 'PhabricatorNotificationStoryView' => 'PhabricatorNotificationView', - 'PhabricatorNotificationView' => 'AphrontView', 'PhabricatorOAuthClientAuthorization' => 'PhabricatorOAuthServerDAO', 'PhabricatorOAuthClientAuthorizationBaseController' => 'PhabricatorOAuthServerController', 'PhabricatorOAuthClientAuthorizationDeleteController' => 'PhabricatorOAuthClientAuthorizationBaseController', diff --git a/src/applications/feed/story/PhabricatorFeedStory.php b/src/applications/feed/story/PhabricatorFeedStory.php index cfe0072b6e..5d9823aac4 100644 --- a/src/applications/feed/story/PhabricatorFeedStory.php +++ b/src/applications/feed/story/PhabricatorFeedStory.php @@ -149,12 +149,6 @@ abstract class PhabricatorFeedStory implements PhabricatorPolicyInterface { abstract public function renderView(); -// TODO: Make abstract once all subclasses implement it. - public function renderNotificationView() { - return id(new PhabricatorFeedStoryUnknown($this->data)) - ->renderNotificationView(); - } - public function getRequiredHandlePHIDs() { return array(); } diff --git a/src/applications/feed/story/PhabricatorFeedStoryDifferential.php b/src/applications/feed/story/PhabricatorFeedStoryDifferential.php index 25742a8e5f..614003efb5 100644 --- a/src/applications/feed/story/PhabricatorFeedStoryDifferential.php +++ b/src/applications/feed/story/PhabricatorFeedStoryDifferential.php @@ -10,6 +10,7 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory { $data = $this->getStoryData(); $view = new PhabricatorFeedStoryView(); + $view->setViewed($this->getHasViewed()); $line = $this->getLineForData($data); $view->setTitle($line); @@ -37,18 +38,6 @@ 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(); $revision_phid = $data->getValue('revision_phid'); diff --git a/src/applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php b/src/applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php index b84c1b7c60..3ebfb625d8 100644 --- a/src/applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php +++ b/src/applications/feed/story/PhabricatorFeedStoryDifferentialAggregate.php @@ -4,11 +4,6 @@ final class PhabricatorFeedStoryDifferentialAggregate extends PhabricatorFeedStoryAggregate { public function renderView() { - return null; - } - - - public function renderNotificationView() { $data = $this->getStoryData(); $task_link = $this->linkTo($data->getValue('revision_phid')); @@ -59,7 +54,7 @@ final class PhabricatorFeedStoryDifferentialAggregate break; } - $view = new PhabricatorNotificationStoryView(); + $view = new PhabricatorFeedStoryView(); $view->setEpoch($this->getEpoch()); $view->setViewed($this->getHasViewed()); $view->setTitle($title); diff --git a/src/applications/feed/story/PhabricatorFeedStoryManiphest.php b/src/applications/feed/story/PhabricatorFeedStoryManiphest.php index 4f701c552d..31f9af76ff 100644 --- a/src/applications/feed/story/PhabricatorFeedStoryManiphest.php +++ b/src/applications/feed/story/PhabricatorFeedStoryManiphest.php @@ -17,6 +17,7 @@ final class PhabricatorFeedStoryManiphest $data = $this->getStoryData(); $view = new PhabricatorFeedStoryView(); + $view->setViewed($this->getHasViewed()); $line = $this->getLineForData($data); $view->setTitle($line); @@ -43,18 +44,6 @@ final class PhabricatorFeedStoryManiphest 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) { $action = $data->getValue('action'); diff --git a/src/applications/feed/story/PhabricatorFeedStoryManiphestAggregate.php b/src/applications/feed/story/PhabricatorFeedStoryManiphestAggregate.php index d09ba54c16..5222a2e875 100644 --- a/src/applications/feed/story/PhabricatorFeedStoryManiphestAggregate.php +++ b/src/applications/feed/story/PhabricatorFeedStoryManiphestAggregate.php @@ -4,11 +4,6 @@ final class PhabricatorFeedStoryManiphestAggregate extends PhabricatorFeedStoryAggregate { public function renderView() { - return null; - } - - - public function renderNotificationView() { $data = $this->getStoryData(); $task_link = $this->linkTo($data->getValue('taskPHID')); @@ -59,7 +54,7 @@ final class PhabricatorFeedStoryManiphestAggregate break; } - $view = new PhabricatorNotificationStoryView(); + $view = new PhabricatorFeedStoryView(); $view->setEpoch($this->getEpoch()); $view->setViewed($this->getHasViewed()); $view->setTitle($title); diff --git a/src/applications/feed/story/PhabricatorFeedStoryUnknown.php b/src/applications/feed/story/PhabricatorFeedStoryUnknown.php deleted file mode 100644 index afad4d8d51..0000000000 --- a/src/applications/feed/story/PhabricatorFeedStoryUnknown.php +++ /dev/null @@ -1,38 +0,0 @@ -getStoryData(); - - $view = new PhabricatorFeedStoryView(); - - $view->setTitle('Unknown Story'); - $view->setEpoch($data->getEpoch()); - - $view->appendChild( - 'This is an unrenderable feed story of type '. - '"'.phutil_escape_html($data->getStoryType()).'".'); - - - return $view; - } - - public function renderNotificationView() { - $data = $this->getStoryData(); - - $view = new PhabricatorNotificationStoryView(); - - $view->setTitle('A wild notifcation appeared!'); - $view->setEpoch($data->getEpoch()); - - $view->appendChild( - 'This is an unrenderable feed story of type '. - '"'.phutil_escape_html($data->getStoryType()).'".'); - - - return $view; - - } - -} diff --git a/src/applications/feed/view/PhabricatorFeedStoryView.php b/src/applications/feed/view/PhabricatorFeedStoryView.php index 4e56e47852..6c6e0fe691 100644 --- a/src/applications/feed/view/PhabricatorFeedStoryView.php +++ b/src/applications/feed/view/PhabricatorFeedStoryView.php @@ -7,6 +7,7 @@ final class PhabricatorFeedStoryView extends PhabricatorFeedView { private $phid; private $epoch; private $viewer; + private $viewed; private $oneLine; @@ -35,6 +36,32 @@ final class PhabricatorFeedStoryView extends PhabricatorFeedView { return $this; } + public function setViewed($viewed) { + $this->viewed = $viewed; + return $this; + } + + public function getViewed() { + return $this->viewed; + } + + public function renderNotification() { + $classes = array( + 'phabricator-notification', + ); + + if (!$this->viewed) { + $classes[] = 'phabricator-notification-unread'; + } + + return phutil_render_tag( + 'div', + array( + 'class' => implode(' ', $classes), + ), + $this->title); + } + public function render() { $head = phutil_render_tag( diff --git a/src/applications/notification/builder/PhabricatorNotificationBuilder.php b/src/applications/notification/builder/PhabricatorNotificationBuilder.php index c8f48402e4..c0687799f8 100644 --- a/src/applications/notification/builder/PhabricatorNotificationBuilder.php +++ b/src/applications/notification/builder/PhabricatorNotificationBuilder.php @@ -123,8 +123,9 @@ final class PhabricatorNotificationBuilder { $null_view = new AphrontNullView(); foreach ($stories as $story) { - $view = $story->renderNotificationView(); - $null_view->appendChild($view); + $view = $story->renderView(); + + $null_view->appendChild($view->renderNotification()); } return $null_view; diff --git a/src/applications/notification/storage/PhabricatorFeedStoryNotification.php b/src/applications/notification/storage/PhabricatorFeedStoryNotification.php index fdb3e2ddd0..32de4a75a3 100644 --- a/src/applications/notification/storage/PhabricatorFeedStoryNotification.php +++ b/src/applications/notification/storage/PhabricatorFeedStoryNotification.php @@ -14,7 +14,8 @@ final class PhabricatorFeedStoryNotification extends PhabricatorFeedDAO { ) + parent::getConfiguration(); } - static public function updateObjectNotificationViews(PhabricatorUser $user, + static public function updateObjectNotificationViews( + PhabricatorUser $user, $object_phid) { if (PhabricatorEnv::getEnvConfig('notification.enabled')) { @@ -38,22 +39,18 @@ final class PhabricatorFeedStoryNotification extends PhabricatorFeedDAO { } } - /* should only be called when notifications are enabled */ - public function countUnread( - PhabricatorUser $user) { + public function countUnread(PhabricatorUser $user) { + $conn = $this->establishConnection('r'); - $conn = $this->establishConnection('r'); + $data = queryfx_one( + $conn, + 'SELECT COUNT(*) as count + FROM %T + WHERE userPHID = %s AND hasViewed = 0', + $this->getTableName(), + $user->getPHID()); - $data = queryfx_one( - $conn, - "SELECT COUNT(*) as count - FROM %T - WHERE userPHID = %s - AND hasViewed=0", - $this->getTableName(), - $user->getPHID()); - - return $data['count']; + return $data['count']; } } diff --git a/src/applications/notification/view/PhabricatorNotificationStoryView.php b/src/applications/notification/view/PhabricatorNotificationStoryView.php deleted file mode 100644 index f9673a1d0d..0000000000 --- a/src/applications/notification/view/PhabricatorNotificationStoryView.php +++ /dev/null @@ -1,43 +0,0 @@ -title = $title; - return $this; - } - - public function setEpoch($epoch) { - $this->epoch = $epoch; - return $this; - } - - public function setViewed($viewed) { - $this->viewed = $viewed; - } - - public function render() { - - $classes = array( - 'phabricator-notification', - ); - - if (!$this->viewed) { - $classes[] = 'phabricator-notification-unread'; - } - - return phutil_render_tag( - 'div', - array( - 'class' => implode(' ', $classes), - ), - $this->title); - } - -} diff --git a/src/applications/notification/view/PhabricatorNotificationView.php b/src/applications/notification/view/PhabricatorNotificationView.php deleted file mode 100644 index 389cca9367..0000000000 --- a/src/applications/notification/view/PhabricatorNotificationView.php +++ /dev/null @@ -1,5 +0,0 @@ -