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

Make HTTP errors returned from the Aphlict server more specific

Summary: Ref T5651. Currently, the Aphlict server returns either `200 OKAY` or `400 Bad Request`. We could return more specific errors in some cases and this may assist with debugging.

Test Plan:
Sent myself a test notification at `/notification/status/` and saw the Aphlict server process the request (running in debug mode). Also poked around with `curl`:

```
> curl http://localhost:22281/
405 Method Not Allowed

> curl http://localhost:22281/ -d ""
400 Bad Request

> curl http://localhost:22281/foobar/
404 Not Found
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5651

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

+33 -25
+2
src/applications/notification/client/PhabricatorNotificationClient.php
··· 40 40 41 41 private static function postMessage(array $data) { 42 42 $server_uri = PhabricatorEnv::getEnvConfig('notification.server-uri'); 43 + $server_uri = id(new PhutilURI($server_uri)) 44 + ->setPath('/'); 43 45 44 46 id(new HTTPSFuture($server_uri, json_encode($data))) 45 47 ->setMethod('POST')
+31 -25
support/aphlict/server/aphlict_server.js
··· 163 163 164 164 var receive_server = http.createServer(function(request, response) { 165 165 // Publishing a notification. 166 - if (request.method == 'POST') { 167 - var body = ''; 166 + if (request.url == '/') { 167 + if (request.method == 'POST') { 168 + var body = ''; 168 169 169 - request.on('data', function(data) { 170 - body += data; 171 - }); 170 + request.on('data', function(data) { 171 + body += data; 172 + }); 172 173 173 - request.on('end', function() { 174 - try { 175 - var msg = JSON.parse(body); 174 + request.on('end', function() { 175 + try { 176 + var msg = JSON.parse(body); 176 177 177 - debug.log('notification: ' + JSON.stringify(msg)); 178 - ++messages_in; 179 - transmit(msg); 178 + debug.log('notification: ' + JSON.stringify(msg)); 179 + ++messages_in; 180 + transmit(msg); 180 181 181 - response.writeHead(200, {'Content-Type': 'text/plain'}); 182 - } catch (err) { 183 - debug.log( 184 - '<%s> Bad Request! %s', 185 - request.socket.remoteAddress, 186 - err); 187 - response.statusCode = 400; 188 - response.write('400 Bad Request'); 189 - } finally { 190 - response.end(); 191 - } 192 - }); 182 + response.writeHead(200, {'Content-Type': 'text/plain'}); 183 + } catch (err) { 184 + debug.log( 185 + '<%s> Bad Request! %s', 186 + request.socket.remoteAddress, 187 + err); 188 + response.statusCode = 400; 189 + response.write('400 Bad Request\n'); 190 + } finally { 191 + response.end(); 192 + } 193 + }); 194 + } else { 195 + response.statusCode = 405; 196 + response.write('405 Method Not Allowed\n'); 197 + response.end(); 198 + } 193 199 } else if (request.url == '/status/') { 194 200 request.on('data', function() { 195 201 // We just ignore the request data, but newer versions of Node don't ··· 212 218 response.end(); 213 219 }); 214 220 } else { 215 - response.statusCode = 400; 216 - response.write('400 Bad Request'); 221 + response.statusCode = 404; 222 + response.write('404 Not Found\n'); 217 223 response.end(); 218 224 } 219 225 }).listen(config.admin, config.host);