mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
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
This commit is contained in:
parent
66161feb13
commit
767afd1780
1 changed files with 42 additions and 17 deletions
|
@ -73,24 +73,8 @@ final class TransactionSearchConduitAPIMethod
|
|||
->setViewer($viewer);
|
||||
|
||||
$constraints = $request->getValue('constraints', array());
|
||||
PhutilTypeSpec::checkMap(
|
||||
$constraints,
|
||||
array(
|
||||
'phids' => 'optional list<string>',
|
||||
));
|
||||
|
||||
$with_phids = idx($constraints, 'phids');
|
||||
|
||||
if ($with_phids === array()) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Constraint "phids" to "transaction.search" requires nonempty list, '.
|
||||
'empty list provided.'));
|
||||
}
|
||||
|
||||
if ($with_phids) {
|
||||
$xaction_query->withPHIDs($with_phids);
|
||||
}
|
||||
$xaction_query = $this->applyConstraints($constraints, $xaction_query);
|
||||
|
||||
$xactions = $xaction_query->executeWithCursorPager($pager);
|
||||
|
||||
|
@ -240,4 +224,45 @@ final class TransactionSearchConduitAPIMethod
|
|||
|
||||
return $this->addPagerResults($results, $pager);
|
||||
}
|
||||
|
||||
private function applyConstraints(
|
||||
array $constraints,
|
||||
PhabricatorApplicationTransactionQuery $query) {
|
||||
|
||||
PhutilTypeSpec::checkMap(
|
||||
$constraints,
|
||||
array(
|
||||
'phids' => 'optional list<string>',
|
||||
'authorPHIDs' => 'optional list<string>',
|
||||
));
|
||||
|
||||
$with_phids = idx($constraints, 'phids');
|
||||
|
||||
if ($with_phids === array()) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Constraint "phids" to "transaction.search" requires nonempty list, '.
|
||||
'empty list provided.'));
|
||||
}
|
||||
|
||||
if ($with_phids) {
|
||||
$query->withPHIDs($with_phids);
|
||||
}
|
||||
|
||||
$with_authors = idx($constraints, 'authorPHIDs');
|
||||
if ($with_authors === array()) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Constraint "authorPHIDs" to "transaction.search" requires '.
|
||||
'nonempty list, empty list provided.'));
|
||||
}
|
||||
|
||||
if ($with_authors) {
|
||||
$query->withAuthorPHIDs($with_authors);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue