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

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

+26 -21
+18 -12
src/infrastructure/daemon/bot/PhabricatorBot.php
··· 53 53 54 54 $conduit_uri = idx($config, 'conduit.uri'); 55 55 if ($conduit_uri) { 56 - $conduit_user = idx($config, 'conduit.user'); 57 - $conduit_cert = idx($config, 'conduit.cert'); 56 + $conduit_token = idx($config, 'conduit.token'); 58 57 59 58 // Normalize the path component of the URI so users can enter the 60 59 // domain without the "/api/" part. ··· 64 63 $conduit_uri = (string)$conduit_uri->setPath('/api/'); 65 64 66 65 $conduit = new ConduitClient($conduit_uri); 67 - $response = $conduit->callMethodSynchronous( 68 - 'conduit.connect', 69 - array( 70 - 'client' => 'PhabricatorBot', 71 - 'clientVersion' => '1.0', 72 - 'clientDescription' => php_uname('n').':'.$nick, 73 - 'host' => $conduit_host, 74 - 'user' => $conduit_user, 75 - 'certificate' => $conduit_cert, 76 - )); 66 + if ($conduit_token) { 67 + $conduit->setConduitToken($conduit_token); 68 + } else { 69 + $conduit_user = idx($config, 'conduit.user'); 70 + $conduit_cert = idx($config, 'conduit.cert'); 71 + 72 + $response = $conduit->callMethodSynchronous( 73 + 'conduit.connect', 74 + array( 75 + 'client' => 'PhabricatorBot', 76 + 'clientVersion' => '1.0', 77 + 'clientDescription' => php_uname('n').':'.$nick, 78 + 'host' => $conduit_host, 79 + 'user' => $conduit_user, 80 + 'certificate' => $conduit_cert, 81 + )); 82 + } 77 83 78 84 $this->conduit = $conduit; 79 85 }
+8 -9
src/infrastructure/daemon/bot/handler/PhabricatorBotObjectNameHandler.php
··· 26 26 27 27 $pattern = 28 28 '@'. 29 - '(?<!/)(?:^|\b)'. 29 + '(?<![/:#-])(?:^|\b)'. 30 30 '(R2D2)'. 31 31 '(?:\b|$)'. 32 32 '@'; ··· 41 41 } 42 42 } 43 43 44 + // Use a negative lookbehind to prevent matching "/D123", "#D123", 45 + // ":D123", etc. 44 46 $pattern = 45 47 '@'. 46 - '(?<!/)(?:^|\b)'. // Negative lookbehind prevent matching "/D123". 48 + '(?<![/:#-])(?:^|\b)'. 47 49 '([A-Z])(\d+)'. 48 50 '(?:\b|$)'. 49 51 '@'; ··· 158 160 159 161 if ($commit_names) { 160 162 $commits = $this->getConduit()->callMethodSynchronous( 161 - 'diffusion.getcommits', 163 + 'diffusion.querycommits', 162 164 array( 163 - 'commits' => $commit_names, 165 + 'names' => $commit_names, 164 166 )); 165 - foreach ($commits as $commit) { 166 - if (isset($commit['error'])) { 167 - continue; 168 - } 169 - $output[$commit['commitPHID']] = $commit['uri']; 167 + foreach ($commits['data'] as $commit) { 168 + $output[$commit['phid']] = $commit['uri']; 170 169 } 171 170 } 172 171