Skip to content

Commit fe98aa6

Browse files
joshuaspenceepriestley
authored andcommitted
Publish additional context to the Aphlict server.
Summary: Ref T4324. As well as sending the key for the notification, also publish the notification type and a list of subscribers to the Aphlict server. The idea here is that the Aphlict server passes anything within the `data` key to the clients, whereas other keys (such as `subscribers`) will be used by the server to determine where the notifications should be routed. Note that these changes don't do anything useful, but are a prerequisite for further work on T4324. Test Plan: Sent myself test notifications at `/notification/status/`. Also inspected the Aphlict server debug output: ``` > sudo ./bin/aphlict --foreground Starting server in foreground, ignoring pidfile... Launching server: $ node '/usr/src/phabricator/support/aphlict/server/aphlict_server.js' --port='22280' --admin='22281' --host='localhost' --user='aphlict' --log='/var/log/aphlict.log' [Thu Jun 05 2014 18:38:14 GMT+0000 (UTC)] Started Server (PID 15437) [Thu Jun 05 2014 18:38:16 GMT+0000 (UTC)] <FlashPolicy> Policy Request From ::ffff:10.0.0.1 [Thu Jun 05 2014 18:38:16 GMT+0000 (UTC)] <Listener/1> Connected from ::ffff:10.0.0.1 [Thu Jun 05 2014 18:38:19 GMT+0000 (UTC)] notification: {"data":{"key":"6021516228036848559","type":"notification"},"subscribers":["PHID-USER-cb5af6p4oepy5tlgqypi"]} [Thu Jun 05 2014 18:38:19 GMT+0000 (UTC)] <Listener/1> Wrote Message ``` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T4324 Differential Revision: https://secure.phabricator.com/D9396
1 parent ac2b917 commit fe98aa6

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/applications/feed/PhabricatorFeedStoryPublisher.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,12 @@ private function insertNotifications($chrono_key) {
175175
}
176176

177177
private function sendNotification($chrono_key) {
178-
179178
$data = array(
180-
'key' => (string)$chrono_key,
179+
'data' => array(
180+
'key' => (string)$chrono_key,
181+
'type' => 'notification',
182+
),
183+
'subscribers' => $this->subscribedPHIDs,
181184
);
182185

183186
try {

src/applications/notification/client/PhabricatorNotificationClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
final class PhabricatorNotificationClient {
44

5-
const EXPECT_VERSION = 4;
5+
const EXPECT_VERSION = 5;
66

77
public static function getServerStatus() {
88
$uri = PhabricatorEnv::getEnvConfig('notification.server-uri');

support/aphlict/server/aphlict_server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ var receive_server = http.createServer(function(request, response) {
120120
request.on('end', function () {
121121
++messages_in;
122122

123-
var data = JSON.parse(body);
124-
debug.log('notification: ' + JSON.stringify(data));
125-
broadcast(data);
123+
var msg = JSON.parse(body);
124+
debug.log('notification: ' + JSON.stringify(msg));
125+
broadcast(msg.data);
126126
response.end();
127127
});
128128
} else if (request.url == '/status/') {
@@ -139,7 +139,7 @@ var receive_server = http.createServer(function(request, response) {
139139
'messages.in': messages_in,
140140
'messages.out': messages_out,
141141
'log': config.log,
142-
'version': 4
142+
'version': 5
143143
};
144144

145145
response.write(JSON.stringify(status));

0 commit comments

Comments
 (0)