mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 07:11:04 +01:00
Conpherence - add querythead conduit method
Summary: nice title. also adds a description to the create thread method which I forgot to add... Ref T3166. Test Plan: queried threads by ids, by phids, and by offset / limit tweakage. Got the right stuff! Reviewers: epriestley Reviewed By: epriestley CC: chad, aran, Korvin Maniphest Tasks: T3166 Differential Revision: https://secure.phabricator.com/D6096
This commit is contained in:
parent
6219103f02
commit
7b00cea57d
4 changed files with 100 additions and 7 deletions
|
@ -120,6 +120,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_conduit_query_Method' => 'applications/conduit/method/ConduitAPI_conduit_query_Method.php',
|
'ConduitAPI_conduit_query_Method' => 'applications/conduit/method/ConduitAPI_conduit_query_Method.php',
|
||||||
'ConduitAPI_conpherence_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_Method.php',
|
'ConduitAPI_conpherence_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_Method.php',
|
||||||
'ConduitAPI_conpherence_createthread_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_createthread_Method.php',
|
'ConduitAPI_conpherence_createthread_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_createthread_Method.php',
|
||||||
|
'ConduitAPI_conpherence_querythread_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_querythread_Method.php',
|
||||||
'ConduitAPI_daemon_launched_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_launched_Method.php',
|
'ConduitAPI_daemon_launched_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_launched_Method.php',
|
||||||
'ConduitAPI_daemon_log_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_log_Method.php',
|
'ConduitAPI_daemon_log_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_log_Method.php',
|
||||||
'ConduitAPI_daemon_setstatus_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_setstatus_Method.php',
|
'ConduitAPI_daemon_setstatus_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_setstatus_Method.php',
|
||||||
|
@ -1952,6 +1953,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_conduit_query_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_conduit_query_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_conpherence_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_conpherence_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_conpherence_createthread_Method' => 'ConduitAPI_conpherence_Method',
|
'ConduitAPI_conpherence_createthread_Method' => 'ConduitAPI_conpherence_Method',
|
||||||
|
'ConduitAPI_conpherence_querythread_Method' => 'ConduitAPI_conpherence_Method',
|
||||||
'ConduitAPI_daemon_launched_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_daemon_launched_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_daemon_log_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_daemon_log_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_daemon_setstatus_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_daemon_setstatus_Method' => 'ConduitAPIMethod',
|
||||||
|
|
|
@ -11,4 +11,10 @@ abstract class ConduitAPI_conpherence_Method
|
||||||
'PhabricatorApplicationConpherence');
|
'PhabricatorApplicationConpherence');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final protected function getConpherenceURI(ConpherenceThread $conpherence) {
|
||||||
|
$id = $conpherence->getID();
|
||||||
|
return PhabricatorEnv::getProductionURI(
|
||||||
|
$this->getApplication()->getApplicationURI($id));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
final class ConduitAPI_conpherence_createthread_Method
|
final class ConduitAPI_conpherence_createthread_Method
|
||||||
extends ConduitAPI_conpherence_Method {
|
extends ConduitAPI_conpherence_Method {
|
||||||
|
|
||||||
|
|
||||||
public function getMethodDescription() {
|
public function getMethodDescription() {
|
||||||
|
return pht('Create a new conpherence thread.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function defineParamTypes() {
|
public function defineParamTypes() {
|
||||||
|
@ -24,8 +24,10 @@ final class ConduitAPI_conpherence_createthread_Method
|
||||||
|
|
||||||
public function defineErrorTypes() {
|
public function defineErrorTypes() {
|
||||||
return array(
|
return array(
|
||||||
'ERR_EMPTY_PARTICIPANT_PHIDS' => 'You must specify participant phids.',
|
'ERR_EMPTY_PARTICIPANT_PHIDS' => pht(
|
||||||
'ERR_EMPTY_MESSAGE' => 'You must specify a message.'
|
'You must specify participant phids.'),
|
||||||
|
'ERR_EMPTY_MESSAGE' => pht(
|
||||||
|
'You must specify a message.')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,11 +57,9 @@ final class ConduitAPI_conpherence_createthread_Method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $conpherence->getID();
|
|
||||||
$uri = $this->getApplication()->getApplicationURI($id);
|
|
||||||
return array(
|
return array(
|
||||||
'conpherenceID' => $id,
|
'conpherenceID' => $conpherence->getID(),
|
||||||
'conpherencePHID' => $conpherence->getPHID(),
|
'conpherencePHID' => $conpherence->getPHID(),
|
||||||
'conpherenceURI' => $uri);
|
'conpherenceURI' => $this->getConpherenceURI($conpherence));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group conduit
|
||||||
|
*/
|
||||||
|
final class ConduitAPI_conpherence_querythread_Method
|
||||||
|
extends ConduitAPI_conpherence_Method {
|
||||||
|
|
||||||
|
|
||||||
|
public function getMethodDescription() {
|
||||||
|
return pht(
|
||||||
|
'Query for conpherence threads for the logged in user. '.
|
||||||
|
'You can query by ids or phids for specific conpherence threads. '.
|
||||||
|
'Otherwise, specify limit and offset to query the most recently '.
|
||||||
|
'updated conpherences for the logged in user.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineParamTypes() {
|
||||||
|
return array(
|
||||||
|
'ids' => 'optional array<int>',
|
||||||
|
'phids' => 'optional array<phids>',
|
||||||
|
'limit' => 'optional int',
|
||||||
|
'offset' => 'optional int'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineReturnType() {
|
||||||
|
return 'nonempty dict';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineErrorTypes() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
|
$user = $request->getUser();
|
||||||
|
$ids = $request->getValue('ids', array());
|
||||||
|
$phids = $request->getValue('phids', array());
|
||||||
|
$limit = $request->getValue('limit');
|
||||||
|
$offset = $request->getValue('offset');
|
||||||
|
|
||||||
|
$query = id(new ConpherenceThreadQuery())
|
||||||
|
->setViewer($user)
|
||||||
|
->needParticipantCache(true)
|
||||||
|
->needFilePHIDs(true);
|
||||||
|
|
||||||
|
if ($ids) {
|
||||||
|
$conpherences = $query
|
||||||
|
->withIDs($ids)
|
||||||
|
->setLimit($limit)
|
||||||
|
->setOffset($offset)
|
||||||
|
->execute();
|
||||||
|
} else if ($phids) {
|
||||||
|
$conpherences = $query
|
||||||
|
->withPHIDs($phids)
|
||||||
|
->setLimit($limit)
|
||||||
|
->setOffset($offset)
|
||||||
|
->execute();
|
||||||
|
} else {
|
||||||
|
$participation = id(new ConpherenceParticipantQuery())
|
||||||
|
->withParticipantPHIDs(array($user->getPHID()))
|
||||||
|
->setLimit($limit)
|
||||||
|
->setOffset($offset)
|
||||||
|
->execute();
|
||||||
|
$conpherence_phids = array_keys($participation);
|
||||||
|
$query->withPHIDs($conpherence_phids);
|
||||||
|
$conpherences = $query->execute();
|
||||||
|
$conpherences = array_select_keys($conpherences, $conpherence_phids);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
foreach ($conpherences as $conpherence) {
|
||||||
|
$id = $conpherence->getID();
|
||||||
|
$data[$id] = array(
|
||||||
|
'conpherenceID' => $id,
|
||||||
|
'conpherencePHID' => $conpherence->getPHID(),
|
||||||
|
'conpherenceTitle' => $conpherence->getTitle(),
|
||||||
|
'messageCount' => $conpherence->getMessageCount(),
|
||||||
|
'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(),
|
||||||
|
'filePHIDs' => $conpherence->getFilePHIDs(),
|
||||||
|
'conpherenceURI' => $this->getConpherenceURI($conpherence));
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue