1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

Add a "slowvote.poll.search" API method

Summary: Ref T13350. Add a modern "*.search" API method for Slowvote so "slowvote.info" can be deprecated with a reasonable replacement.

Test Plan: Used Conduit test console to call method, saw reasonable results.

Maniphest Tasks: T13350

Differential Revision: https://secure.phabricator.com/D20685
This commit is contained in:
epriestley 2019-07-31 10:06:34 -07:00
parent d81d0c3ea0
commit 0b0ab1bd7c
4 changed files with 60 additions and 6 deletions

View file

@ -5614,6 +5614,7 @@ phutil_register_library_map(array(
'SlowvoteEmbedView' => 'applications/slowvote/view/SlowvoteEmbedView.php', 'SlowvoteEmbedView' => 'applications/slowvote/view/SlowvoteEmbedView.php',
'SlowvoteInfoConduitAPIMethod' => 'applications/slowvote/conduit/SlowvoteInfoConduitAPIMethod.php', 'SlowvoteInfoConduitAPIMethod' => 'applications/slowvote/conduit/SlowvoteInfoConduitAPIMethod.php',
'SlowvoteRemarkupRule' => 'applications/slowvote/remarkup/SlowvoteRemarkupRule.php', 'SlowvoteRemarkupRule' => 'applications/slowvote/remarkup/SlowvoteRemarkupRule.php',
'SlowvoteSearchConduitAPIMethod' => 'applications/slowvote/conduit/SlowvoteSearchConduitAPIMethod.php',
'SubscriptionListDialogBuilder' => 'applications/subscriptions/view/SubscriptionListDialogBuilder.php', 'SubscriptionListDialogBuilder' => 'applications/subscriptions/view/SubscriptionListDialogBuilder.php',
'SubscriptionListStringBuilder' => 'applications/subscriptions/view/SubscriptionListStringBuilder.php', 'SubscriptionListStringBuilder' => 'applications/subscriptions/view/SubscriptionListStringBuilder.php',
'TokenConduitAPIMethod' => 'applications/tokens/conduit/TokenConduitAPIMethod.php', 'TokenConduitAPIMethod' => 'applications/tokens/conduit/TokenConduitAPIMethod.php',
@ -11075,6 +11076,7 @@ phutil_register_library_map(array(
'PhabricatorProjectInterface', 'PhabricatorProjectInterface',
'PhabricatorDestructibleInterface', 'PhabricatorDestructibleInterface',
'PhabricatorSpacesInterface', 'PhabricatorSpacesInterface',
'PhabricatorConduitResultInterface',
), ),
'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController', 'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController',
'PhabricatorSlowvotePollPHIDType' => 'PhabricatorPHIDType', 'PhabricatorSlowvotePollPHIDType' => 'PhabricatorPHIDType',
@ -12221,6 +12223,7 @@ phutil_register_library_map(array(
'SlowvoteEmbedView' => 'AphrontView', 'SlowvoteEmbedView' => 'AphrontView',
'SlowvoteInfoConduitAPIMethod' => 'SlowvoteConduitAPIMethod', 'SlowvoteInfoConduitAPIMethod' => 'SlowvoteConduitAPIMethod',
'SlowvoteRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'SlowvoteRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'SlowvoteSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'SubscriptionListDialogBuilder' => 'Phobject', 'SubscriptionListDialogBuilder' => 'Phobject',
'SubscriptionListStringBuilder' => 'Phobject', 'SubscriptionListStringBuilder' => 'Phobject',
'TokenConduitAPIMethod' => 'ConduitAPIMethod', 'TokenConduitAPIMethod' => 'ConduitAPIMethod',

View file

@ -0,0 +1,18 @@
<?php
final class SlowvoteSearchConduitAPIMethod
extends PhabricatorSearchEngineAPIMethod {
public function getAPIMethodName() {
return 'slowvote.poll.search';
}
public function newSearchEngine() {
return new PhabricatorSlowvoteSearchEngine();
}
public function getMethodSummary() {
return pht('Read information about polls.');
}
}

View file

@ -46,17 +46,23 @@ final class PhabricatorSlowvoteSearchEngine
->setKey('authorPHIDs') ->setKey('authorPHIDs')
->setAliases(array('authors')) ->setAliases(array('authors'))
->setLabel(pht('Authors')), ->setLabel(pht('Authors')),
id(new PhabricatorSearchCheckboxesField()) id(new PhabricatorSearchCheckboxesField())
->setKey('voted') ->setKey('voted')
->setLabel(pht('Voted'))
// TODO: This should probably become a list of "voterPHIDs", so hide
// the field from Conduit to avoid a backward compatibility break when
// this changes.
->setEnableForConduit(false)
->setOptions(array( ->setOptions(array(
'voted' => pht("Show only polls I've voted in."), 'voted' => pht("Show only polls I've voted in."),
)), )),
id(new PhabricatorSearchCheckboxesField()) id(new PhabricatorSearchCheckboxesField())
->setKey('statuses') ->setKey('statuses')
->setLabel(pht('Statuses')) ->setLabel(pht('Statuses'))
->setOptions(array( ->setOptions(
array(
'open' => pht('Open'), 'open' => pht('Open'),
'closed' => pht('Closed'), 'closed' => pht('Closed'),
)), )),

View file

@ -9,7 +9,8 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
PhabricatorTokenReceiverInterface, PhabricatorTokenReceiverInterface,
PhabricatorProjectInterface, PhabricatorProjectInterface,
PhabricatorDestructibleInterface, PhabricatorDestructibleInterface,
PhabricatorSpacesInterface { PhabricatorSpacesInterface,
PhabricatorConduitResultInterface {
const RESPONSES_VISIBLE = 0; const RESPONSES_VISIBLE = 0;
const RESPONSES_VOTERS = 1; const RESPONSES_VOTERS = 1;
@ -202,10 +203,36 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
$this->saveTransaction(); $this->saveTransaction();
} }
/* -( PhabricatorSpacesInterface )--------------------------------------- */ /* -( PhabricatorSpacesInterface )----------------------------------------- */
public function getSpacePHID() { public function getSpacePHID() {
return $this->spacePHID; return $this->spacePHID;
} }
/* -( PhabricatorConduitResultInterface )---------------------------------- */
public function getFieldSpecificationsForConduit() {
return array(
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('name')
->setType('string')
->setDescription(pht('The name of the poll.')),
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('authorPHID')
->setType('string')
->setDescription(pht('The author of the poll.')),
);
}
public function getFieldValuesForConduit() {
return array(
'name' => $this->getQuestion(),
'authorPHID' => $this->getAuthorPHID(),
);
}
public function getConduitSearchAttachments() {
return array();
}
} }