From 1b8e129145d1b2155ca1125d61e6a6658f0357a5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 17 Feb 2014 15:59:51 -0800 Subject: [PATCH] Move message posting to PhabricatorNotificationClient Summary: Ref T4324. Centralize communication with the notification server. This will probably get less messy eventually. Test Plan: Posted some messages. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4324 Differential Revision: https://secure.phabricator.com/D8252 --- .../feed/PhabricatorFeedStoryPublisher.php | 10 +++++----- .../client/PhabricatorNotificationClient.php | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/applications/feed/PhabricatorFeedStoryPublisher.php b/src/applications/feed/PhabricatorFeedStoryPublisher.php index ee0950f36a..9448a4f616 100644 --- a/src/applications/feed/PhabricatorFeedStoryPublisher.php +++ b/src/applications/feed/PhabricatorFeedStoryPublisher.php @@ -161,16 +161,16 @@ final class PhabricatorFeedStoryPublisher { } private function sendNotification($chrono_key) { - $server_uri = PhabricatorEnv::getEnvConfig('notification.server-uri'); $data = array( 'key' => (string)$chrono_key, ); - id(new HTTPSFuture($server_uri, $data)) - ->setMethod('POST') - ->setTimeout(1) - ->resolve(); + try { + PhabricatorNotificationClient::postMessage($data); + } catch (Exception $ex) { + // Ignore, these are not critical. + } } /** diff --git a/src/applications/notification/client/PhabricatorNotificationClient.php b/src/applications/notification/client/PhabricatorNotificationClient.php index beb1a7cffe..f9f78274c2 100644 --- a/src/applications/notification/client/PhabricatorNotificationClient.php +++ b/src/applications/notification/client/PhabricatorNotificationClient.php @@ -25,4 +25,13 @@ final class PhabricatorNotificationClient { return $status; } + public static function postMessage(array $data) { + $server_uri = PhabricatorEnv::getEnvConfig('notification.server-uri'); + + id(new HTTPSFuture($server_uri, $data)) + ->setMethod('POST') + ->setTimeout(1) + ->resolvex(); + } + }