@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 an Aphlict CLI client

Summary: Depends on D2926. Adds a simple CLI client for Aphlict to make it easier to debug stuff.

Test Plan: Ran client, saw debug messages.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

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

+76
+4
src/docs/userguide/notifications.diviner
··· 76 76 77 77 phabricator/ $ ./bin/aphlict --foreground 78 78 79 + You can run `support/aphlict/client/aphlict_test_client.php` to connect to the 80 + Aphlict server from the command line. Messages the client receives will be 81 + printed to stdout. 82 + 79 83 You can set `notification.debug` in your configuration to get additional 80 84 output in your browser. 81 85
+72
support/aphlict/client/aphlict_test_client.php
··· 1 + #!/usr/bin/env php 2 + <?php 3 + 4 + /* 5 + * Copyright 2012 Facebook, Inc. 6 + * 7 + * Licensed under the Apache License, Version 2.0 (the "License"); 8 + * you may not use this file except in compliance with the License. 9 + * You may obtain a copy of the License at 10 + * 11 + * http://www.apache.org/licenses/LICENSE-2.0 12 + * 13 + * Unless required by applicable law or agreed to in writing, software 14 + * distributed under the License is distributed on an "AS IS" BASIS, 15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 + * See the License for the specific language governing permissions and 17 + * limitations under the License. 18 + */ 19 + 20 + $root = dirname(dirname(dirname(dirname(__FILE__)))); 21 + require_once $root.'/scripts/__init_script__.php'; 22 + 23 + $args = new PhutilArgumentParser($argv); 24 + $args->setTagline('test client for Aphlict server'); 25 + $args->setSynopsis(<<<EOHELP 26 + **aphlict_test_client.php** [__options__] 27 + Connect to the Aphlict server configured in the Phabricator config. 28 + 29 + EOHELP 30 + ); 31 + $args->parseStandardArguments(); 32 + $args->parse( 33 + array( 34 + array( 35 + 'name' => 'server', 36 + 'param' => 'uri', 37 + 'default' => PhabricatorEnv::getEnvConfig('notification.client-uri'), 38 + 'help' => 'Connect to __uri__ instead of the default server.', 39 + ), 40 + )); 41 + $console = PhutilConsole::getConsole(); 42 + 43 + $errno = null; 44 + $errstr = null; 45 + 46 + $uri = $args->getArg('server'); 47 + $uri = new PhutilURI($uri); 48 + $uri->setProtocol('tcp'); 49 + 50 + $console->writeErr("Connecting...\n"); 51 + $socket = stream_socket_client( 52 + $uri, 53 + $errno, 54 + $errstr); 55 + 56 + if (!$socket) { 57 + $console->writeErr( 58 + "Unable to connect to Aphlict (at '$uri'). Error #{$errno}: {$errstr}"); 59 + exit(1); 60 + } else { 61 + $console->writeErr("Connected.\n"); 62 + } 63 + 64 + $io_channel = new PhutilSocketChannel($socket); 65 + $proto_channel = new PhutilJSONProtocolChannel($io_channel); 66 + 67 + $json = new PhutilJSON(); 68 + while (true) { 69 + $message = $proto_channel->waitForMessage(); 70 + $console->writeOut($json->encodeFormatted($message)); 71 + } 72 +