2013-05-31 19:43:46 +02:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class ConpherenceQueryThreadConduitAPIMethod
|
|
|
|
extends ConpherenceConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'conpherence.querythread';
|
|
|
|
}
|
2013-05-31 19:43:46 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2014-07-10 00:12:48 +02:00
|
|
|
|
2013-05-31 19:43:46 +02:00
|
|
|
}
|