@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 an updatethread conduit method

Summary: Last of the methods. Fixes T3166.

Test Plan: updated a thread in all the various ways except remove and it worked. removed myself and it worked! tried to remove someone else and it yelled at me.

Reviewers: epriestley

Reviewed By: epriestley

CC: chad, aran, Korvin

Maniphest Tasks: T3166

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

+106
+2
src/__phutil_library_map__.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 124 'ConduitAPI_conpherence_querytransaction_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_querytransaction_Method.php', 125 + 'ConduitAPI_conpherence_updatethread_Method' => 'applications/conpherence/conduit/ConduitAPI_conpherence_updatethread_Method.php', 125 126 'ConduitAPI_daemon_launched_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_launched_Method.php', 126 127 'ConduitAPI_daemon_log_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_log_Method.php', 127 128 'ConduitAPI_daemon_setstatus_Method' => 'applications/daemon/conduit/ConduitAPI_daemon_setstatus_Method.php', ··· 1963 1964 'ConduitAPI_conpherence_createthread_Method' => 'ConduitAPI_conpherence_Method', 1964 1965 'ConduitAPI_conpherence_querythread_Method' => 'ConduitAPI_conpherence_Method', 1965 1966 'ConduitAPI_conpherence_querytransaction_Method' => 'ConduitAPI_conpherence_Method', 1967 + 'ConduitAPI_conpherence_updatethread_Method' => 'ConduitAPI_conpherence_Method', 1966 1968 'ConduitAPI_daemon_launched_Method' => 'ConduitAPIMethod', 1967 1969 'ConduitAPI_daemon_log_Method' => 'ConduitAPIMethod', 1968 1970 'ConduitAPI_daemon_setstatus_Method' => 'ConduitAPIMethod',
+104
src/applications/conpherence/conduit/ConduitAPI_conpherence_updatethread_Method.php
··· 1 + <?php 2 + 3 + /** 4 + * @group conduit 5 + */ 6 + final class ConduitAPI_conpherence_updatethread_Method 7 + extends ConduitAPI_conpherence_Method { 8 + 9 + public function getMethodDescription() { 10 + return pht('Update an existing conpherence thread.'); 11 + } 12 + 13 + public function defineParamTypes() { 14 + return array( 15 + 'id' => 'optional int', 16 + 'phid' => 'optional phid', 17 + 'title' => 'optional string', 18 + 'message' => 'optional string', 19 + 'addParticipantPHIDs' => 'optional list<phids>', 20 + 'removeParticipantPHID' => 'optional phid' 21 + ); 22 + } 23 + 24 + public function defineReturnType() { 25 + return 'bool'; 26 + } 27 + 28 + public function defineErrorTypes() { 29 + return array( 30 + 'ERR_USAGE_NO_THREAD_ID' => pht( 31 + 'You must specify a thread id or thread phid to query transactions '. 32 + 'from.'), 33 + 'ERR_USAGE_THREAD_NOT_FOUND' => pht( 34 + 'Thread does not exist or logged in user can not see it.'), 35 + 'ERR_USAGE_ONLY_SELF_REMOVE' => pht( 36 + 'Only a user can remove themselves from a thread.'), 37 + 'ERR_USAGE_NO_UPDATES' => pht( 38 + 'You must specify data that actually updates the conpherence.') 39 + ); 40 + } 41 + 42 + protected function execute(ConduitAPIRequest $request) { 43 + $user = $request->getUser(); 44 + $id = $request->getValue('id'); 45 + $phid = $request->getValue('phid'); 46 + $query = id(new ConpherenceThreadQuery()) 47 + ->setViewer($user) 48 + ->needFilePHIDs(true); 49 + if ($id) { 50 + $query->withIDs(array($id)); 51 + } else if ($phid) { 52 + $query->withPHIDs(array($phid)); 53 + } else { 54 + throw new ConduitException('ERR_USAGE_NO_THREAD_ID'); 55 + } 56 + $conpherence = $query->executeOne(); 57 + if (!$conpherence) { 58 + throw new ConduitException('ERR_USAGE_THREAD_NOT_FOUND'); 59 + } 60 + 61 + $source = PhabricatorContentSource::newFromConduitRequest($request); 62 + $editor = id(new ConpherenceEditor()) 63 + ->setContentSource($source) 64 + ->setActor($user); 65 + $xactions = array(); 66 + $add_participant_phids = $request->getValue('addParticipantPHIDs', array()); 67 + $remove_participant_phid = $request->getValue('removeParticipantPHID'); 68 + $message = $request->getValue('message'); 69 + $title = $request->getValue('title'); 70 + if ($add_participant_phids) { 71 + $xactions[] = id(new ConpherenceTransaction()) 72 + ->setTransactionType( 73 + ConpherenceTransactionType::TYPE_PARTICIPANTS) 74 + ->setNewValue(array('+' => $add_participant_phids)); 75 + } 76 + if ($remove_participant_phid) { 77 + if ($remove_participant_phid != $user->getPHID()) { 78 + throw new ConduitException('ERR_USAGE_ONLY_SELF_REMOVE'); 79 + } 80 + $xactions[] = id(new ConpherenceTransaction()) 81 + ->setTransactionType( 82 + ConpherenceTransactionType::TYPE_PARTICIPANTS) 83 + ->setNewValue(array('-' => array($remove_participant_phid))); 84 + } 85 + if ($title) { 86 + $xactions[] = id(new ConpherenceTransaction()) 87 + ->setTransactionType(ConpherenceTransactionType::TYPE_TITLE) 88 + ->setNewValue($title); 89 + } 90 + if ($message) { 91 + $xactions = array_merge( 92 + $xactions, 93 + $editor->generateTransactionsFromText($conpherence, $message)); 94 + } 95 + 96 + try { 97 + $xactions = $editor->applyTransactions($conpherence, $xactions); 98 + } catch (PhabricatorApplicationTransactionNoEffectException $ex) { 99 + throw new ConduitException('ERR_USAGE_NO_UPDATES'); 100 + } 101 + 102 + return true; 103 + } 104 + }