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

Support an "authorPHIDs" constraint for "transaction.search"

Summary: Ref T13255. The "transaction.search" API method currently does not support author constraints, but this is a reasonable thing to support.

Test Plan: Queried transactions by author, hit the error cases.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13255

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

+42 -17
+42 -17
src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php
··· 73 73 ->setViewer($viewer); 74 74 75 75 $constraints = $request->getValue('constraints', array()); 76 - PhutilTypeSpec::checkMap( 77 - $constraints, 78 - array( 79 - 'phids' => 'optional list<string>', 80 - )); 81 76 82 - $with_phids = idx($constraints, 'phids'); 83 - 84 - if ($with_phids === array()) { 85 - throw new Exception( 86 - pht( 87 - 'Constraint "phids" to "transaction.search" requires nonempty list, '. 88 - 'empty list provided.')); 89 - } 90 - 91 - if ($with_phids) { 92 - $xaction_query->withPHIDs($with_phids); 93 - } 77 + $xaction_query = $this->applyConstraints($constraints, $xaction_query); 94 78 95 79 $xactions = $xaction_query->executeWithCursorPager($pager); 96 80 ··· 240 224 241 225 return $this->addPagerResults($results, $pager); 242 226 } 227 + 228 + private function applyConstraints( 229 + array $constraints, 230 + PhabricatorApplicationTransactionQuery $query) { 231 + 232 + PhutilTypeSpec::checkMap( 233 + $constraints, 234 + array( 235 + 'phids' => 'optional list<string>', 236 + 'authorPHIDs' => 'optional list<string>', 237 + )); 238 + 239 + $with_phids = idx($constraints, 'phids'); 240 + 241 + if ($with_phids === array()) { 242 + throw new Exception( 243 + pht( 244 + 'Constraint "phids" to "transaction.search" requires nonempty list, '. 245 + 'empty list provided.')); 246 + } 247 + 248 + if ($with_phids) { 249 + $query->withPHIDs($with_phids); 250 + } 251 + 252 + $with_authors = idx($constraints, 'authorPHIDs'); 253 + if ($with_authors === array()) { 254 + throw new Exception( 255 + pht( 256 + 'Constraint "authorPHIDs" to "transaction.search" requires '. 257 + 'nonempty list, empty list provided.')); 258 + } 259 + 260 + if ($with_authors) { 261 + $query->withAuthorPHIDs($with_authors); 262 + } 263 + 264 + return $query; 265 + } 266 + 267 + 243 268 }