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

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

+100 -7
+2
src/__phutil_library_map__.php
··· 120 120 'ConduitAPI_conduit_query_Method' => 'applications/conduit/method/ConduitAPI_conduit_query_Method.php', 121 121 'ConduitAPI_conpherence_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_Method.php', 122 122 'ConduitAPI_conpherence_createthread_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_createthread_Method.php', 123 + 'ConduitAPI_conpherence_querythread_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_querythread_Method.php', 123 124 'ConduitAPI_daemon_launched_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_launched_Method.php', 124 125 'ConduitAPI_daemon_log_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_log_Method.php', 125 126 'ConduitAPI_daemon_setstatus_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_setstatus_Method.php', ··· 1952 1953 'ConduitAPI_conduit_query_Method' => 'ConduitAPIMethod', 1953 1954 'ConduitAPI_conpherence_Method' => 'ConduitAPIMethod', 1954 1955 'ConduitAPI_conpherence_createthread_Method' => 'ConduitAPI_conpherence_Method', 1956 + 'ConduitAPI_conpherence_querythread_Method' => 'ConduitAPI_conpherence_Method', 1955 1957 'ConduitAPI_daemon_launched_Method' => 'ConduitAPIMethod', 1956 1958 'ConduitAPI_daemon_log_Method' => 'ConduitAPIMethod', 1957 1959 'ConduitAPI_daemon_setstatus_Method' => 'ConduitAPIMethod',
+6
src/applications/conpherence/conduit/ConduitAPI_conpherence_Method.php
··· 11 11 'PhabricatorApplicationConpherence'); 12 12 } 13 13 14 + final protected function getConpherenceURI(ConpherenceThread $conpherence) { 15 + $id = $conpherence->getID(); 16 + return PhabricatorEnv::getProductionURI( 17 + $this->getApplication()->getApplicationURI($id)); 18 + } 19 + 14 20 }
+7 -7
src/applications/conpherence/conduit/ConduitAPI_conpherence_createthread_Method.php
··· 6 6 final class ConduitAPI_conpherence_createthread_Method 7 7 extends ConduitAPI_conpherence_Method { 8 8 9 - 10 9 public function getMethodDescription() { 10 + return pht('Create a new conpherence thread.'); 11 11 } 12 12 13 13 public function defineParamTypes() { ··· 24 24 25 25 public function defineErrorTypes() { 26 26 return array( 27 - 'ERR_EMPTY_PARTICIPANT_PHIDS' => 'You must specify participant phids.', 28 - 'ERR_EMPTY_MESSAGE' => 'You must specify a message.' 27 + 'ERR_EMPTY_PARTICIPANT_PHIDS' => pht( 28 + 'You must specify participant phids.'), 29 + 'ERR_EMPTY_MESSAGE' => pht( 30 + 'You must specify a message.') 29 31 ); 30 32 } 31 33 ··· 55 57 } 56 58 } 57 59 58 - $id = $conpherence->getID(); 59 - $uri = $this->getApplication()->getApplicationURI($id); 60 60 return array( 61 - 'conpherenceID' => $id, 61 + 'conpherenceID' => $conpherence->getID(), 62 62 'conpherencePHID' => $conpherence->getPHID(), 63 - 'conpherenceURI' => $uri); 63 + 'conpherenceURI' => $this->getConpherenceURI($conpherence)); 64 64 } 65 65 }
+85
src/applications/conpherence/conduit/ConduitAPI_conpherence_querythread_Method.php
··· 1 + <?php 2 + 3 + /** 4 + * @group conduit 5 + */ 6 + final class ConduitAPI_conpherence_querythread_Method 7 + extends ConduitAPI_conpherence_Method { 8 + 9 + 10 + public function getMethodDescription() { 11 + return pht( 12 + 'Query for conpherence threads for the logged in user. '. 13 + 'You can query by ids or phids for specific conpherence threads. '. 14 + 'Otherwise, specify limit and offset to query the most recently '. 15 + 'updated conpherences for the logged in user.'); 16 + } 17 + 18 + public function defineParamTypes() { 19 + return array( 20 + 'ids' => 'optional array<int>', 21 + 'phids' => 'optional array<phids>', 22 + 'limit' => 'optional int', 23 + 'offset' => 'optional int' 24 + ); 25 + } 26 + 27 + public function defineReturnType() { 28 + return 'nonempty dict'; 29 + } 30 + 31 + public function defineErrorTypes() { 32 + return array(); 33 + } 34 + 35 + protected function execute(ConduitAPIRequest $request) { 36 + $user = $request->getUser(); 37 + $ids = $request->getValue('ids', array()); 38 + $phids = $request->getValue('phids', array()); 39 + $limit = $request->getValue('limit'); 40 + $offset = $request->getValue('offset'); 41 + 42 + $query = id(new ConpherenceThreadQuery()) 43 + ->setViewer($user) 44 + ->needParticipantCache(true) 45 + ->needFilePHIDs(true); 46 + 47 + if ($ids) { 48 + $conpherences = $query 49 + ->withIDs($ids) 50 + ->setLimit($limit) 51 + ->setOffset($offset) 52 + ->execute(); 53 + } else if ($phids) { 54 + $conpherences = $query 55 + ->withPHIDs($phids) 56 + ->setLimit($limit) 57 + ->setOffset($offset) 58 + ->execute(); 59 + } else { 60 + $participation = id(new ConpherenceParticipantQuery()) 61 + ->withParticipantPHIDs(array($user->getPHID())) 62 + ->setLimit($limit) 63 + ->setOffset($offset) 64 + ->execute(); 65 + $conpherence_phids = array_keys($participation); 66 + $query->withPHIDs($conpherence_phids); 67 + $conpherences = $query->execute(); 68 + $conpherences = array_select_keys($conpherences, $conpherence_phids); 69 + } 70 + 71 + $data = array(); 72 + foreach ($conpherences as $conpherence) { 73 + $id = $conpherence->getID(); 74 + $data[$id] = array( 75 + 'conpherenceID' => $id, 76 + 'conpherencePHID' => $conpherence->getPHID(), 77 + 'conpherenceTitle' => $conpherence->getTitle(), 78 + 'messageCount' => $conpherence->getMessageCount(), 79 + 'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(), 80 + 'filePHIDs' => $conpherence->getFilePHIDs(), 81 + 'conpherenceURI' => $this->getConpherenceURI($conpherence)); 82 + } 83 + return $data; 84 + } 85 + }