Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15456292
D8251.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D8251.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1698,6 +1698,7 @@
'PhabricatorNoteExample' => 'applications/uiexample/examples/PhabricatorNoteExample.php',
'PhabricatorNotificationBuilder' => 'applications/notification/builder/PhabricatorNotificationBuilder.php',
'PhabricatorNotificationClearController' => 'applications/notification/controller/PhabricatorNotificationClearController.php',
+ 'PhabricatorNotificationClient' => 'applications/notification/client/PhabricatorNotificationClient.php',
'PhabricatorNotificationConfigOptions' => 'applications/config/option/PhabricatorNotificationConfigOptions.php',
'PhabricatorNotificationController' => 'applications/notification/controller/PhabricatorNotificationController.php',
'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php',
@@ -2016,6 +2017,7 @@
'PhabricatorSettingsPanelSessions' => 'applications/settings/panel/PhabricatorSettingsPanelSessions.php',
'PhabricatorSetupCheck' => 'applications/config/check/PhabricatorSetupCheck.php',
'PhabricatorSetupCheckAPC' => 'applications/config/check/PhabricatorSetupCheckAPC.php',
+ 'PhabricatorSetupCheckAphlict' => 'applications/notification/setup/PhabricatorSetupCheckAphlict.php',
'PhabricatorSetupCheckAuth' => 'applications/config/check/PhabricatorSetupCheckAuth.php',
'PhabricatorSetupCheckBaseURI' => 'applications/config/check/PhabricatorSetupCheckBaseURI.php',
'PhabricatorSetupCheckBinaries' => 'applications/config/check/PhabricatorSetupCheckBinaries.php',
@@ -4798,6 +4800,7 @@
'PhabricatorSettingsPanelSearchPreferences' => 'PhabricatorSettingsPanel',
'PhabricatorSettingsPanelSessions' => 'PhabricatorSettingsPanel',
'PhabricatorSetupCheckAPC' => 'PhabricatorSetupCheck',
+ 'PhabricatorSetupCheckAphlict' => 'PhabricatorSetupCheck',
'PhabricatorSetupCheckAuth' => 'PhabricatorSetupCheck',
'PhabricatorSetupCheckBaseURI' => 'PhabricatorSetupCheck',
'PhabricatorSetupCheckBinaries' => 'PhabricatorSetupCheck',
Index: src/applications/notification/client/PhabricatorNotificationClient.php
===================================================================
--- /dev/null
+++ src/applications/notification/client/PhabricatorNotificationClient.php
@@ -0,0 +1,28 @@
+<?php
+
+final class PhabricatorNotificationClient {
+
+ const EXPECT_VERSION = 2;
+
+ public static function getServerStatus() {
+ $uri = PhabricatorEnv::getEnvConfig('notification.server-uri');
+ $uri = new PhutilURI($uri);
+
+ $uri->setPath('/status/');
+
+ list($body) = id(new HTTPSFuture($uri))
+ ->setTimeout(3)
+ ->resolvex();
+
+ $status = json_decode($body, true);
+ if (!is_array($status)) {
+ throw new Exception(
+ pht(
+ 'Expected JSON response from notification server, received: %s',
+ $body));
+ }
+
+ return $status;
+ }
+
+}
Index: src/applications/notification/controller/PhabricatorNotificationStatusController.php
===================================================================
--- src/applications/notification/controller/PhabricatorNotificationStatusController.php
+++ src/applications/notification/controller/PhabricatorNotificationStatusController.php
@@ -4,23 +4,9 @@
extends PhabricatorNotificationController {
public function processRequest() {
-
- $uri = PhabricatorEnv::getEnvConfig('notification.server-uri');
- $uri = new PhutilURI($uri);
-
- $uri->setPath('/status/');
-
- $future = id(new HTTPSFuture($uri))
- ->setTimeout(3);
-
try {
- list($body) = $future->resolvex();
- $body = json_decode($body, true);
- if (!is_array($body)) {
- throw new Exception("Expected JSON response from server!");
- }
-
- $status = $this->renderServerStatus($body);
+ $status = PhabricatorNotificationClient::getServerStatus();
+ $status = $this->renderServerStatus($status);
} catch (Exception $ex) {
$status = new AphrontErrorView();
$status->setTitle("Notification Server Issue");
Index: src/applications/notification/setup/PhabricatorSetupCheckAphlict.php
===================================================================
--- /dev/null
+++ src/applications/notification/setup/PhabricatorSetupCheckAphlict.php
@@ -0,0 +1,64 @@
+<?php
+
+final class PhabricatorSetupCheckAphlict extends PhabricatorSetupCheck {
+
+ protected function executeChecks() {
+ $enabled = PhabricatorEnv::getEnvConfig('notification.enabled');
+ if (!$enabled) {
+ // Notifications aren't set up, so just ignore all of these checks.
+ return;
+ }
+
+ try {
+ $status = PhabricatorNotificationClient::getServerStatus();
+ } catch (Exception $ex) {
+ $message = pht(
+ 'Phabricator is configured to use a notification server, but '.
+ 'is unable to connect to it. You should resolve this issue or '.
+ 'disable the notification server. It may be helpful to double check '.
+ 'your configuration or restart the server using the command below.'.
+ "\n\n".
+ "%s",
+ phutil_tag(
+ 'pre',
+ array(),
+ array(
+ get_class($ex),
+ "\n",
+ $ex->getMessage(),
+ )));
+
+
+ $this->newIssue('aphlict.connect')
+ ->setShortName(pht('Notification Server Down'))
+ ->setName(pht('Unable to Connect to Notification Server'))
+ ->setMessage($message)
+ ->addRelatedPhabricatorConfig('notification.enabled')
+ ->addRelatedPhabricatorConfig('notification.server-uri')
+ ->addCommand(
+ pht(
+ "(To start or restart the server, run this command.)\n".
+ "phabricator/ $ sudo ./bin/aphlict"));
+
+ return;
+ }
+
+ $expect_version = PhabricatorNotificationClient::EXPECT_VERSION;
+ $have_version = idx($status, 'version', 1);
+ if ($have_version != $expect_version) {
+ $message = pht(
+ 'The notification server is out of date. You are running server '.
+ 'version %d, but Phabricator expects version %d. Restart the server '.
+ 'to update it, using the command below:',
+ $have_version,
+ $expect_version);
+
+ $this->newIssue('aphlict.version')
+ ->setShortName(pht('Notification Server Version'))
+ ->setName(pht('Notification Server Out of Date'))
+ ->setMessage($message)
+ ->addCommand('phabricator/ $ sudo ./bin/aphlict');
+ }
+
+ }
+}
Index: support/aphlict/server/aphlict_server.js
===================================================================
--- support/aphlict/server/aphlict_server.js
+++ support/aphlict/server/aphlict_server.js
@@ -192,7 +192,8 @@
'clients.total': generate_id.current_id || 0,
'messages.in': messages_in,
'messages.out': messages_out,
- 'log': config.log
+ 'log': config.log,
+ 'version': 2
};
response.write(JSON.stringify(status));
Index: webroot/rsrc/css/application/config/setup-issue.css
===================================================================
--- webroot/rsrc/css/application/config/setup-issue.css
+++ webroot/rsrc/css/application/config/setup-issue.css
@@ -94,6 +94,7 @@
text-align: center;
font-size: 15px;
color: #2980b9;
+ margin-top: 12px;
}
.setup-issue-config {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 31, 8:28 AM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7720601
Default Alt Text
D8251.diff (7 KB)
Attached To
Mode
D8251: Version the Aphlict notification server and prompt users to upgrade if they're out of date
Attached
Detach File
Event Timeline
Log In to Comment