3 final class ConpherenceUpdateThreadConduitAPIMethod
4 extends ConpherenceConduitAPIMethod
{
6 public function getAPIMethodName() {
7 return 'conpherence.updatethread';
10 public function getMethodDescription() {
11 return pht('Update an existing conpherence room.');
14 public function getMethodStatus() {
15 return self
::METHOD_STATUS_FROZEN
;
18 public function getMethodStatusDescription() {
20 'This method is frozen and will eventually be deprecated. New code '.
21 'should use "conpherence.edit" instead.');
24 protected function defineParamTypes() {
26 'id' => 'optional int',
27 'phid' => 'optional phid',
28 'title' => 'optional string',
29 'message' => 'optional string',
30 'addParticipantPHIDs' => 'optional list<phids>',
31 'removeParticipantPHID' => 'optional phid',
35 protected function defineReturnType() {
39 protected function defineErrorTypes() {
41 'ERR_USAGE_NO_ROOM_ID' => pht(
42 'You must specify a room ID or room PHID to query transactions from.'),
43 'ERR_USAGE_ROOM_NOT_FOUND' => pht(
44 'Room does not exist or logged in user can not see it.'),
45 'ERR_USAGE_ONLY_SELF_REMOVE' => pht(
46 'Only a user can remove themselves from a room.'),
47 'ERR_USAGE_NO_UPDATES' => pht(
48 'You must specify data that actually updates the Conpherence.'),
52 protected function execute(ConduitAPIRequest
$request) {
53 $user = $request->getUser();
54 $id = $request->getValue('id');
55 $phid = $request->getValue('phid');
56 $query = id(new ConpherenceThreadQuery())
59 $query->withIDs(array($id));
61 $query->withPHIDs(array($phid));
63 throw new ConduitException('ERR_USAGE_NO_ROOM_ID');
65 $conpherence = $query->executeOne();
67 throw new ConduitException('ERR_USAGE_ROOM_NOT_FOUND');
70 $source = $request->newContentSource();
71 $editor = id(new ConpherenceEditor())
72 ->setContentSource($source)
75 $add_participant_phids = $request->getValue('addParticipantPHIDs', array());
76 $remove_participant_phid = $request->getValue('removeParticipantPHID');
77 $message = $request->getValue('message');
78 $title = $request->getValue('title');
79 if ($add_participant_phids) {
80 $xactions[] = id(new ConpherenceTransaction())
82 ConpherenceThreadParticipantsTransaction
::TRANSACTIONTYPE
)
83 ->setNewValue(array('+' => $add_participant_phids));
85 if ($remove_participant_phid) {
86 if ($remove_participant_phid != $user->getPHID()) {
87 throw new ConduitException('ERR_USAGE_ONLY_SELF_REMOVE');
89 $xactions[] = id(new ConpherenceTransaction())
91 ConpherenceThreadParticipantsTransaction
::TRANSACTIONTYPE
)
92 ->setNewValue(array('-' => array($remove_participant_phid)));
95 $xactions[] = id(new ConpherenceTransaction())
97 ConpherenceThreadTitleTransaction
::TRANSACTIONTYPE
)
98 ->setNewValue($title);
101 $xactions = array_merge(
103 $editor->generateTransactionsFromText(
110 $xactions = $editor->applyTransactions($conpherence, $xactions);
111 } catch (PhabricatorApplicationTransactionNoEffectException
$ex) {
112 throw new ConduitException('ERR_USAGE_NO_UPDATES');