From 37451ffb259f43e492050d9f599a6c5aedeeef6d Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 5 Mar 2012 09:57:21 -0800 Subject: [PATCH] Automatically select the right Conduit URI path for the irc bot Summary: The docs say "http://www.domain.com/" but if you don't put "/api/" it fails. GOTCHA! Test Plan: Removed "/api/", launched bot, it worked. Reviewers: btrahan Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T935 Differential Revision: https://secure.phabricator.com/D1763 --- src/infrastructure/daemon/irc/bot/PhabricatorIRCBot.php | 6 ++++++ src/infrastructure/daemon/irc/bot/__init__.php | 1 + 2 files changed, 7 insertions(+) diff --git a/src/infrastructure/daemon/irc/bot/PhabricatorIRCBot.php b/src/infrastructure/daemon/irc/bot/PhabricatorIRCBot.php index 9bffa665dd..1bd9f6e1b8 100644 --- a/src/infrastructure/daemon/irc/bot/PhabricatorIRCBot.php +++ b/src/infrastructure/daemon/irc/bot/PhabricatorIRCBot.php @@ -76,6 +76,12 @@ final class PhabricatorIRCBot extends PhabricatorDaemon { $conduit_user = idx($config, 'conduit.user'); $conduit_cert = idx($config, 'conduit.cert'); + // Normalize the path component of the URI so users can enter the + // domain without the "/api/" part. + $conduit_uri = new PhutilURI($conduit_uri); + $conduit_uri->setPath('/api/'); + $conduit_uri = (string)$conduit_uri; + $conduit = new ConduitClient($conduit_uri); $response = $conduit->callMethodSynchronous( 'conduit.connect', diff --git a/src/infrastructure/daemon/irc/bot/__init__.php b/src/infrastructure/daemon/irc/bot/__init__.php index 33c26ab4d6..d160b058c3 100644 --- a/src/infrastructure/daemon/irc/bot/__init__.php +++ b/src/infrastructure/daemon/irc/bot/__init__.php @@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'infrastructure/daemon/irc/message'); phutil_require_module('phutil', 'conduit/client'); phutil_require_module('phutil', 'error'); phutil_require_module('phutil', 'filesystem'); +phutil_require_module('phutil', 'parser/uri'); phutil_require_module('phutil', 'utils');