@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 querytransaction method

Summary: Ref T3166. Returned all the data I could think of, though notable "metadata" isn't used in conpherence (yet afaik) AND its somewhat silly to return the conpherence id / phid you specified, but seems handy.

Test Plan: played with conduit console.

Reviewers: epriestley

Reviewed By: epriestley

CC: chad, aran, Korvin

Maniphest Tasks: T3166

Differential Revision: https://secure.phabricator.com/D6098

+97
+2
src/__phutil_library_map__.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 123 'ConduitAPI_conpherence_querythread_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_querythread_Method.php', 124 + 'ConduitAPI_conpherence_querytransaction_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_querytransaction_Method.php', 124 125 'ConduitAPI_daemon_launched_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_launched_Method.php', 125 126 'ConduitAPI_daemon_log_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_log_Method.php', 126 127 'ConduitAPI_daemon_setstatus_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_setstatus_Method.php', ··· 1961 1962 'ConduitAPI_conpherence_Method' => 'ConduitAPIMethod', 1962 1963 'ConduitAPI_conpherence_createthread_Method' => 'ConduitAPI_conpherence_Method', 1963 1964 'ConduitAPI_conpherence_querythread_Method' => 'ConduitAPI_conpherence_Method', 1965 + 'ConduitAPI_conpherence_querytransaction_Method' => 'ConduitAPI_conpherence_Method', 1964 1966 'ConduitAPI_daemon_launched_Method' => 'ConduitAPIMethod', 1965 1967 'ConduitAPI_daemon_log_Method' => 'ConduitAPIMethod', 1966 1968 'ConduitAPI_daemon_setstatus_Method' => 'ConduitAPIMethod',
+95
src/applications/conpherence/conduit/ConduitAPI_conpherence_querytransaction_Method.php
··· 1 + <?php 2 + 3 + /** 4 + * @group conduit 5 + */ 6 + final class ConduitAPI_conpherence_querytransaction_Method 7 + extends ConduitAPI_conpherence_Method { 8 + 9 + 10 + public function getMethodDescription() { 11 + return pht( 12 + 'Query for transactions for the logged in user within a specific '. 13 + 'conpherence thread. You can specify the thread by id or phid. '. 14 + 'Otherwise, specify limit and offset to query the most recent '. 15 + 'transactions within the conpherence for the logged in user.'); 16 + } 17 + 18 + public function defineParamTypes() { 19 + return array( 20 + 'threadID' => 'optional int', 21 + 'threadPHID' => 'optional phid', 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 + 'ERR_USAGE_NO_THREAD_ID' => pht( 34 + 'You must specify a thread id or thread phid to query transactions '. 35 + 'from.') 36 + ); 37 + } 38 + 39 + protected function execute(ConduitAPIRequest $request) { 40 + $user = $request->getUser(); 41 + $thread_id = $request->getValue('threadID'); 42 + $thread_phid = $request->getValue('threadPHID'); 43 + $limit = $request->getValue('limit'); 44 + $offset = $request->getValue('offset'); 45 + 46 + $query = id(new ConpherenceThreadQuery()) 47 + ->setViewer($user); 48 + 49 + if ($thread_id) { 50 + $query->withIDs(array($thread_id)); 51 + } else if ($thread_phid) { 52 + $query->withPHIDs(array($thread_phid)); 53 + } else { 54 + throw new ConduitException('ERR_USAGE_NO_THREAD_ID'); 55 + } 56 + 57 + $conpherence = $query->executeOne(); 58 + 59 + $query = id(new ConpherenceTransactionQuery()) 60 + ->setViewer($user) 61 + ->withObjectPHIDs(array($conpherence->getPHID())) 62 + ->setLimit($limit) 63 + ->setOffset($offset); 64 + 65 + $transactions = $query->execute(); 66 + 67 + $data = array(); 68 + foreach ($transactions as $transaction) { 69 + $comment = null; 70 + $comment_obj = $transaction->getComment(); 71 + if ($comment_obj) { 72 + $comment = $comment_obj->getContent(); 73 + } 74 + $title = null; 75 + $title_obj = $transaction->getTitle(); 76 + if ($title_obj) { 77 + $title = $title_obj->getHTMLContent(); 78 + } 79 + $id = $transaction->getID(); 80 + $data[$id] = array( 81 + 'transactionID' => $id, 82 + 'transactionType' => $transaction->getTransactionType(), 83 + 'transactionTitle' => $title, 84 + 'transactionComment' => $comment, 85 + 'transactionOldValue' => $transaction->getOldValue(), 86 + 'transactionNewValue' => $transaction->getNewValue(), 87 + 'transactionMetadata' => $transaction->getMetadata(), 88 + 'authorPHID' => $transaction->getAuthorPHID(), 89 + 'dateCreated' => $transaction->getDateCreated(), 90 + 'conpherenceID' => $conpherence->getID(), 91 + 'conpherencePHID' => $conpherence->getPHID()); 92 + } 93 + return $data; 94 + } 95 + }