mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Clean up miscellaneous bot issues
Summary: Fixes T6073. Fixes T7775. Ref T4377. This fixes a few easy things without any compatibility-breaking changes. - Stop matching things like `:D123` as a revision (particularly: IPv6 addresses). - Use "diffusion.querycommits". - Support "conduit.token". Test Plan: Used a token: ``` [07:52am] epriestley: -D22 :D22 #D22 /D22 [07:52am] epriestley: D22 [07:52am] phabot-local: D22: asdbb - http://local.phacility.com/D22 [07:54am] epriestley: rHGTESTX6518697472d6395f5d1cec557148957734aa76c2 [07:54am] phabot-local: http://local.phacility.com/rHGTESTX6518697472d6395f5d1cec557148957734aa76c2 ``` Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7775, T6073, T4377 Differential Revision: https://secure.phabricator.com/D12773
This commit is contained in:
parent
7beae445e9
commit
dd88a0e9e9
2 changed files with 26 additions and 21 deletions
|
@ -53,8 +53,7 @@ final class PhabricatorBot extends PhabricatorDaemon {
|
|||
|
||||
$conduit_uri = idx($config, 'conduit.uri');
|
||||
if ($conduit_uri) {
|
||||
$conduit_user = idx($config, 'conduit.user');
|
||||
$conduit_cert = idx($config, 'conduit.cert');
|
||||
$conduit_token = idx($config, 'conduit.token');
|
||||
|
||||
// Normalize the path component of the URI so users can enter the
|
||||
// domain without the "/api/" part.
|
||||
|
@ -64,16 +63,23 @@ final class PhabricatorBot extends PhabricatorDaemon {
|
|||
$conduit_uri = (string)$conduit_uri->setPath('/api/');
|
||||
|
||||
$conduit = new ConduitClient($conduit_uri);
|
||||
$response = $conduit->callMethodSynchronous(
|
||||
'conduit.connect',
|
||||
array(
|
||||
'client' => 'PhabricatorBot',
|
||||
'clientVersion' => '1.0',
|
||||
'clientDescription' => php_uname('n').':'.$nick,
|
||||
'host' => $conduit_host,
|
||||
'user' => $conduit_user,
|
||||
'certificate' => $conduit_cert,
|
||||
));
|
||||
if ($conduit_token) {
|
||||
$conduit->setConduitToken($conduit_token);
|
||||
} else {
|
||||
$conduit_user = idx($config, 'conduit.user');
|
||||
$conduit_cert = idx($config, 'conduit.cert');
|
||||
|
||||
$response = $conduit->callMethodSynchronous(
|
||||
'conduit.connect',
|
||||
array(
|
||||
'client' => 'PhabricatorBot',
|
||||
'clientVersion' => '1.0',
|
||||
'clientDescription' => php_uname('n').':'.$nick,
|
||||
'host' => $conduit_host,
|
||||
'user' => $conduit_user,
|
||||
'certificate' => $conduit_cert,
|
||||
));
|
||||
}
|
||||
|
||||
$this->conduit = $conduit;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ final class PhabricatorBotObjectNameHandler extends PhabricatorBotHandler {
|
|||
|
||||
$pattern =
|
||||
'@'.
|
||||
'(?<!/)(?:^|\b)'.
|
||||
'(?<![/:#-])(?:^|\b)'.
|
||||
'(R2D2)'.
|
||||
'(?:\b|$)'.
|
||||
'@';
|
||||
|
@ -41,9 +41,11 @@ final class PhabricatorBotObjectNameHandler extends PhabricatorBotHandler {
|
|||
}
|
||||
}
|
||||
|
||||
// Use a negative lookbehind to prevent matching "/D123", "#D123",
|
||||
// ":D123", etc.
|
||||
$pattern =
|
||||
'@'.
|
||||
'(?<!/)(?:^|\b)'. // Negative lookbehind prevent matching "/D123".
|
||||
'(?<![/:#-])(?:^|\b)'.
|
||||
'([A-Z])(\d+)'.
|
||||
'(?:\b|$)'.
|
||||
'@';
|
||||
|
@ -158,15 +160,12 @@ final class PhabricatorBotObjectNameHandler extends PhabricatorBotHandler {
|
|||
|
||||
if ($commit_names) {
|
||||
$commits = $this->getConduit()->callMethodSynchronous(
|
||||
'diffusion.getcommits',
|
||||
'diffusion.querycommits',
|
||||
array(
|
||||
'commits' => $commit_names,
|
||||
'names' => $commit_names,
|
||||
));
|
||||
foreach ($commits as $commit) {
|
||||
if (isset($commit['error'])) {
|
||||
continue;
|
||||
}
|
||||
$output[$commit['commitPHID']] = $commit['uri'];
|
||||
foreach ($commits['data'] as $commit) {
|
||||
$output[$commit['phid']] = $commit['uri'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue