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

Add a server status page for notification server

Summary:
- Add a /notification/status/ page which shows server status.
- Remove various test controllers and routes.
- Make the "no notifications" message look better.
- Move port/URI configuration to config file.

Test Plan: Started server, hit /notification/status/, saw server status.

Reviewers: allenjohnashton, ddfisher, keebuhm, jungejason

Reviewed By: jungejason

CC: aran

Maniphest Tasks: T944

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

+169 -198
+12 -1
conf/default.conf.php
··· 186 186 // extend AphrontMySQLDatabaseConnectionBase. 187 187 'mysql.implementation' => 'AphrontMySQLDatabaseConnection', 188 188 189 - // -- Notifications ----// 189 + 190 + // -- Notifications --------------------------------------------------------- // 191 + 190 192 'notification.enabled' => false, 193 + 194 + // Client port for the realtime server to listen on, and for realtime clients 195 + // to connect to. Use "localhost" if you are running the notification server 196 + // on the same host as the web server. 197 + 'notification.client-uri' => 'http://localhost:22280/', 198 + 199 + // URI and port for the notification root server. 200 + 'notification.server-uri' => 'http://localhost:22281/', 201 + 191 202 192 203 // -- Email ----------------------------------------------------------------- // 193 204
+26 -26
src/__celerity_resource_map__.php
··· 2311 2311 ), 2312 2312 'phabricator-standard-page-view' => 2313 2313 array( 2314 - 'uri' => '/res/fe757493/rsrc/css/application/base/standard-page-view.css', 2314 + 'uri' => '/res/4e1958d0/rsrc/css/application/base/standard-page-view.css', 2315 2315 'type' => 'css', 2316 2316 'requires' => 2317 2317 array( ··· 2566 2566 ), array( 2567 2567 'packages' => 2568 2568 array( 2569 - '59b02d20' => 2569 + '0ba8269e' => 2570 2570 array( 2571 2571 'name' => 'core.pkg.css', 2572 2572 'symbols' => ··· 2595 2595 21 => 'phabricator-flag-css', 2596 2596 22 => 'aphront-error-view-css', 2597 2597 ), 2598 - 'uri' => '/res/pkg/59b02d20/core.pkg.css', 2598 + 'uri' => '/res/pkg/0ba8269e/core.pkg.css', 2599 2599 'type' => 'css', 2600 2600 ), 2601 2601 '0c96375e' => ··· 2762 2762 'reverse' => 2763 2763 array( 2764 2764 'aphront-attached-file-view-css' => '7839ae2d', 2765 - 'aphront-crumbs-view-css' => '59b02d20', 2766 - 'aphront-dialog-view-css' => '59b02d20', 2767 - 'aphront-error-view-css' => '59b02d20', 2768 - 'aphront-form-view-css' => '59b02d20', 2765 + 'aphront-crumbs-view-css' => '0ba8269e', 2766 + 'aphront-dialog-view-css' => '0ba8269e', 2767 + 'aphront-error-view-css' => '0ba8269e', 2768 + 'aphront-form-view-css' => '0ba8269e', 2769 2769 'aphront-headsup-action-list-view-css' => '32f461a4', 2770 - 'aphront-headsup-view-css' => '59b02d20', 2771 - 'aphront-list-filter-view-css' => '59b02d20', 2772 - 'aphront-pager-view-css' => '59b02d20', 2773 - 'aphront-panel-view-css' => '59b02d20', 2774 - 'aphront-side-nav-view-css' => '59b02d20', 2775 - 'aphront-table-view-css' => '59b02d20', 2776 - 'aphront-tokenizer-control-css' => '59b02d20', 2777 - 'aphront-tooltip-css' => '59b02d20', 2778 - 'aphront-typeahead-control-css' => '59b02d20', 2770 + 'aphront-headsup-view-css' => '0ba8269e', 2771 + 'aphront-list-filter-view-css' => '0ba8269e', 2772 + 'aphront-pager-view-css' => '0ba8269e', 2773 + 'aphront-panel-view-css' => '0ba8269e', 2774 + 'aphront-side-nav-view-css' => '0ba8269e', 2775 + 'aphront-table-view-css' => '0ba8269e', 2776 + 'aphront-tokenizer-control-css' => '0ba8269e', 2777 + 'aphront-tooltip-css' => '0ba8269e', 2778 + 'aphront-typeahead-control-css' => '0ba8269e', 2779 2779 'differential-changeset-view-css' => '32f461a4', 2780 2780 'differential-core-view-css' => '32f461a4', 2781 2781 'differential-inline-comment-editor' => '1662d764', ··· 2841 2841 'javelin-workflow' => '0c96375e', 2842 2842 'maniphest-task-summary-css' => '7839ae2d', 2843 2843 'maniphest-transaction-detail-css' => '7839ae2d', 2844 - 'phabricator-app-buttons-css' => '59b02d20', 2844 + 'phabricator-app-buttons-css' => '0ba8269e', 2845 2845 'phabricator-content-source-view-css' => '32f461a4', 2846 - 'phabricator-core-buttons-css' => '59b02d20', 2847 - 'phabricator-core-css' => '59b02d20', 2848 - 'phabricator-directory-css' => '59b02d20', 2846 + 'phabricator-core-buttons-css' => '0ba8269e', 2847 + 'phabricator-core-css' => '0ba8269e', 2848 + 'phabricator-directory-css' => '0ba8269e', 2849 2849 'phabricator-drag-and-drop-file-upload' => '1662d764', 2850 2850 'phabricator-dropdown-menu' => '0c96375e', 2851 - 'phabricator-flag-css' => '59b02d20', 2852 - 'phabricator-jump-nav' => '59b02d20', 2851 + 'phabricator-flag-css' => '0ba8269e', 2852 + 'phabricator-jump-nav' => '0ba8269e', 2853 2853 'phabricator-keyboard-shortcut' => '0c96375e', 2854 2854 'phabricator-keyboard-shortcut-manager' => '0c96375e', 2855 2855 'phabricator-menu-item' => '0c96375e', ··· 2857 2857 'phabricator-paste-file-upload' => '0c96375e', 2858 2858 'phabricator-prefab' => '0c96375e', 2859 2859 'phabricator-project-tag-css' => '7839ae2d', 2860 - 'phabricator-remarkup-css' => '59b02d20', 2860 + 'phabricator-remarkup-css' => '0ba8269e', 2861 2861 'phabricator-shaped-request' => '1662d764', 2862 - 'phabricator-standard-page-view' => '59b02d20', 2862 + 'phabricator-standard-page-view' => '0ba8269e', 2863 2863 'phabricator-tooltip' => '0c96375e', 2864 - 'phabricator-transaction-view-css' => '59b02d20', 2865 - 'syntax-highlighting-css' => '59b02d20', 2864 + 'phabricator-transaction-view-css' => '0ba8269e', 2865 + 'syntax-highlighting-css' => '0ba8269e', 2866 2866 ), 2867 2867 ));
+2 -6
src/__phutil_library_map__.php
··· 534 534 'PackageModifyMail' => 'applications/owners/mail/PackageModifyMail.php', 535 535 'Phabricator404Controller' => 'applications/base/controller/Phabricator404Controller.php', 536 536 'PhabricatorAccessLog' => 'infrastructure/PhabricatorAccessLog.php', 537 - 'PhabricatorAphlictTestPageController' => 'applications/notifications/controller/PhabricatorAphlictTestPageController.php', 538 537 'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php', 539 538 'PhabricatorAuditAddCommentController' => 'applications/audit/controller/PhabricatorAuditAddCommentController.php', 540 539 'PhabricatorAuditComment' => 'applications/audit/storage/PhabricatorAuditComment.php', ··· 747 746 'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php', 748 747 'PhabricatorNotificationPanelController' => 'applications/notification/controller/PhabricatorNotificationPanelController.php', 749 748 'PhabricatorNotificationQuery' => 'applications/notification/PhabricatorNotificationQuery.php', 749 + 'PhabricatorNotificationStatusController' => 'applications/notification/controller/PhabricatorNotificationStatusController.php', 750 750 'PhabricatorNotificationStoryView' => 'applications/notification/view/PhabricatorNotificationStoryView.php', 751 - 'PhabricatorNotificationTestController' => 'applications/notification/controller/PhabricatorNotificationTestController.php', 752 751 'PhabricatorNotificationView' => 'applications/notification/view/PhabricatorNotificationView.php', 753 - 'PhabricatorNotificationsController' => 'applications/notifications/controller/PhabricatorNotificationsController.php', 754 752 'PhabricatorOAuthClientAuthorization' => 'applications/oauthserver/storage/PhabricatorOAuthClientAuthorization.php', 755 753 'PhabricatorOAuthClientAuthorizationBaseController' => 'applications/oauthserver/controller/clientauthorization/PhabricatorOAuthClientAuthorizationBaseController.php', 756 754 'PhabricatorOAuthClientAuthorizationDeleteController' => 'applications/oauthserver/controller/clientauthorization/PhabricatorOAuthClientAuthorizationDeleteController.php', ··· 1538 1536 'PackageDeleteMail' => 'PackageMail', 1539 1537 'PackageModifyMail' => 'PackageMail', 1540 1538 'Phabricator404Controller' => 'PhabricatorController', 1541 - 'PhabricatorAphlictTestPageController' => 'PhabricatorNotificationsController', 1542 1539 'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController', 1543 1540 'PhabricatorAuditComment' => 'PhabricatorAuditDAO', 1544 1541 'PhabricatorAuditCommitListView' => 'AphrontView', ··· 1719 1716 'PhabricatorNotificationController' => 'PhabricatorController', 1720 1717 'PhabricatorNotificationIndividualController' => 'PhabricatorNotificationController', 1721 1718 'PhabricatorNotificationPanelController' => 'PhabricatorNotificationController', 1719 + 'PhabricatorNotificationStatusController' => 'PhabricatorNotificationController', 1722 1720 'PhabricatorNotificationStoryView' => 'PhabricatorNotificationView', 1723 - 'PhabricatorNotificationTestController' => 'PhabricatorNotificationController', 1724 1721 'PhabricatorNotificationView' => 'AphrontView', 1725 - 'PhabricatorNotificationsController' => 'PhabricatorController', 1726 1722 'PhabricatorOAuthClientAuthorization' => 'PhabricatorOAuthServerDAO', 1727 1723 'PhabricatorOAuthClientAuthorizationBaseController' => 'PhabricatorOAuthServerController', 1728 1724 'PhabricatorOAuthClientAuthorizationDeleteController' => 'PhabricatorOAuthClientAuthorizationBaseController',
+6 -4
src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
··· 426 426 'PhabricatorChatLogChannelLogController', 427 427 ), 428 428 429 - '/notification/test/' => 'PhabricatorNotificationTestController', 430 - '/notification/panel/' => 'PhabricatorNotificationPanelController', 431 - '/notification/individual/' 432 - => 'PhabricatorNotificationIndividualController', 429 + '/notification/' => array( 430 + 'panel/' => 'PhabricatorNotificationPanelController', 431 + 'individual/' => 'PhabricatorNotificationIndividualController', 432 + 'status/' => 'PhabricatorNotificationStatusController', 433 + ), 434 + 433 435 '/flag/' => array( 434 436 '' => 'PhabricatorFlagListController', 435 437 'view/(?P<view>[^/]+)/' => 'PhabricatorFlagListController',
+16 -10
src/applications/notification/controller/PhabricatorNotificationPanelController.php
··· 30 30 31 31 $stories = $query->execute(); 32 32 33 - $builder = new PhabricatorNotificationBuilder($stories); 34 - $notifications_view = $builder->buildView(); 33 + $num_unconsumed = 0; 34 + if ($stories) { 35 + $builder = new PhabricatorNotificationBuilder($stories); 36 + $notifications_view = $builder->buildView(); 35 37 36 - $num_unconsumed = 0; 37 - foreach ($stories as $story) { 38 - if (!$story->getHasViewed()) { 39 - $num_unconsumed++; 38 + foreach ($stories as $story) { 39 + if (!$story->getHasViewed()) { 40 + $num_unconsumed++; 41 + } 40 42 } 43 + $content = $notifications_view->render(); 44 + } else { 45 + $content = 46 + '<div class="phabricator-notification no-notifications">'. 47 + 'You have no notifications.'. 48 + '</div>'; 41 49 } 42 50 43 51 $json = array( 44 - "content" => $stories ? 45 - $notifications_view->render() : 46 - "<b>You currently have no notifications<b>", 47 - "number" => $num_unconsumed, 52 + 'content' => $content, 53 + 'number' => $num_unconsumed, 48 54 ); 49 55 50 56 return id(new AphrontAjaxResponse())->setContent($json);
+94
src/applications/notification/controller/PhabricatorNotificationStatusController.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class PhabricatorNotificationStatusController 20 + extends PhabricatorNotificationController { 21 + 22 + public function processRequest() { 23 + 24 + $uri = PhabricatorEnv::getEnvConfig('notification.server-uri'); 25 + $uri = new PhutilURI($uri); 26 + 27 + $uri->setPath('/status/'); 28 + 29 + $future = id(new HTTPSFuture($uri)) 30 + ->setTimeout(3); 31 + 32 + try { 33 + list($body) = $future->resolvex(); 34 + $body = json_decode($body, true); 35 + if (!is_array($body)) { 36 + throw new Exception("Expected JSON response from server!"); 37 + } 38 + 39 + $status = $this->renderServerStatus($body); 40 + } catch (Exception $ex) { 41 + $status = new AphrontErrorView(); 42 + $status->setTitle("Notification Server Issue"); 43 + $status->appendChild( 44 + 'Unable to determine server status. This probably means the server '. 45 + 'is not in great shape. The specific issue encountered was:'. 46 + '<br />'. 47 + '<br />'. 48 + '<strong>'.phutil_escape_html(get_class($ex)).'</strong> '. 49 + nl2br(phutil_escape_html($ex->getMessage()))); 50 + } 51 + 52 + return $this->buildStandardPageResponse( 53 + $status, 54 + array( 55 + 'title' => 'Aphlict Server Status', 56 + )); 57 + } 58 + 59 + private function renderServerStatus(array $status) { 60 + 61 + $rows = array(); 62 + foreach ($status as $key => $value) { 63 + $label = phutil_escape_html($key); 64 + 65 + switch ($key) { 66 + case 'uptime': 67 + $value /= 1000; 68 + $value = phabricator_format_relative_time_detailed($value); 69 + break; 70 + case 'log': 71 + $value = phutil_escape_html($value); 72 + break; 73 + default: 74 + $value = phutil_escape_html(number_format($value)); 75 + break; 76 + } 77 + 78 + $rows[] = array($label, $value); 79 + } 80 + 81 + $table = new AphrontTableView($rows); 82 + $table->setColumnClasses( 83 + array( 84 + 'header', 85 + 'wide', 86 + )); 87 + 88 + $panel = new AphrontPanelView(); 89 + $panel->setHeader('Server Status'); 90 + $panel->appendChild($table); 91 + 92 + return $panel; 93 + } 94 + }
-53
src/applications/notification/controller/PhabricatorNotificationTestController.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorNotificationTestController 20 - extends PhabricatorNotificationController { 21 - 22 - public function processRequest() { 23 - 24 - $request = $this->getRequest(); 25 - $user = $request->getUser(); 26 - 27 - $query = new PhabricatorNotificationQuery(); 28 - $query->setUserPHID($user->getPHID()); 29 - 30 - $stories = $query->execute(); 31 - 32 - $builder = new PhabricatorNotificationBuilder($stories); 33 - $notifications_view = $builder->buildView(); 34 - 35 - $num_unconsumed = 0; 36 - 37 - foreach ($stories as $story) { 38 - if (!$story->getHasViewed()) { 39 - $num_unconsumed++; 40 - } 41 - 42 - } 43 - 44 - $json = array( 45 - $notifications_view->render() 46 - ); 47 - 48 - 49 - return $this->buildStandardPageResponse( 50 - $json, 51 - array('title' => 'Notification Test Page')); 52 - } 53 - }
-56
src/applications/notifications/controller/PhabricatorAphlictTestPageController.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorAphlictTestPageController 20 - extends PhabricatorNotificationsController { 21 - 22 - public function processRequest() { 23 - 24 - $instructions = '<h1>Check Your Javascript Console!</h1>'; 25 - 26 - $object_id = 'aphlictswfobject'; 27 - 28 - $content = phutil_render_tag( 29 - 'object', 30 - array( 31 - 'classid' => 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000', 32 - ), 33 - '<param name="movie" value="/rsrc/swf/aphlict.swf" />'. 34 - '<param name="allowScriptAccess" value="always" />'. 35 - '<embed src="/rsrc/swf/aphlict.swf" id="'.$object_id.'"></embed>'); 36 - 37 - Javelin::initBehavior( 38 - 'aphlict-listen', 39 - array( 40 - 'id' => $object_id, 41 - 'server' => '127.0.0.1', 42 - 'port' => 22280, 43 - )); 44 - 45 - return $this->buildStandardPageResponse( 46 - array( 47 - $instructions, 48 - $content, 49 - ), 50 - array( 51 - 'title' => 'Aphlict Test Page', 52 - )); 53 - } 54 - 55 - 56 - }
-37
src/applications/notifications/controller/PhabricatorNotificationsController.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - abstract class PhabricatorNotificationsController 20 - extends PhabricatorController { 21 - 22 - public function buildStandardPageResponse($view, array $data) { 23 - 24 - $page = $this->buildStandardPageView(); 25 - 26 - $page->setApplicationName('Notifications'); 27 - $page->setBaseURI('/notifications/'); 28 - $page->setTitle(idx($data, 'title')); 29 - $page->setGlyph('!'); 30 - $page->appendChild($view); 31 - 32 - $response = new AphrontWebpageResponse(); 33 - return $response->setContent($page->render()); 34 - 35 - } 36 - 37 - }
+9 -5
src/view/page/PhabricatorStandardPageView.php
··· 391 391 392 392 $aphlict_object_id = 'aphlictswfobject'; 393 393 394 - $server_uri = new PhutilURI(PhabricatorEnv::getURI('')); 395 - $server_domain = $server_uri->getDomain(); 394 + $client_uri = PhabricatorEnv::getEnvConfig('notification.client-uri'); 395 + $client_uri = new PhutilURI($client_uri); 396 + if ($client_uri->getDomain() == 'localhost') { 397 + $this_host = new PhutilURI($this->getRequest()->getHost()); 398 + $client_uri->setDomain($this_host->getDomain()); 399 + } 396 400 397 401 Javelin::initBehavior( 398 402 'aphlict-listen', 399 403 array( 400 404 'id' => $aphlict_object_id, 401 - 'server' => $server_domain, 402 - 'port' => 22280, 403 - 'pageObjects' => $this->pageObjects, 405 + 'server' => $client_uri->getDomain(), 406 + 'port' => $client_uri->getPort(), 407 + 'pageObjects' => $this->pageObjects, 404 408 )); 405 409 406 410 Javelin::initBehavior('aphlict-dropdown', array());
+4
webroot/rsrc/css/application/base/standard-page-view.css
··· 303 303 padding: 6px 6px; 304 304 } 305 305 306 + .no-notifications { 307 + color: #999999; 308 + } 309 + 306 310 .phabricator-notification-unread { 307 311 background: #aacfef; 308 312 }