Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / conpherence / conduit / ConpherenceCreateThreadConduitAPIMethod.php
blobe751318c169f17079b702b6cba38a496928b6aa9
1 <?php
3 final class ConpherenceCreateThreadConduitAPIMethod
4 extends ConpherenceConduitAPIMethod {
6 public function getAPIMethodName() {
7 return 'conpherence.createthread';
10 public function getMethodDescription() {
11 return pht('Create a new conpherence thread.');
14 public function getMethodStatus() {
15 return self::METHOD_STATUS_FROZEN;
18 public function getMethodStatusDescription() {
19 return pht(
20 'This method is frozen and will eventually be deprecated. New code '.
21 'should use "conpherence.edit" instead.');
24 protected function defineParamTypes() {
25 return array(
26 'title' => 'required string',
27 'topic' => 'optional string',
28 'message' => 'optional string',
29 'participantPHIDs' => 'required list<phids>',
33 protected function defineReturnType() {
34 return 'nonempty dict';
37 protected function defineErrorTypes() {
38 return array(
39 'ERR_EMPTY_PARTICIPANT_PHIDS' => pht(
40 'You must specify participant phids.'),
41 'ERR_EMPTY_TITLE' => pht(
42 'You must specify a title.'),
46 protected function execute(ConduitAPIRequest $request) {
47 $participant_phids = $request->getValue('participantPHIDs', array());
48 $message = $request->getValue('message');
49 $title = $request->getValue('title');
50 $topic = $request->getValue('topic');
52 list($errors, $conpherence) = ConpherenceEditor::createThread(
53 $request->getUser(),
54 $participant_phids,
55 $title,
56 $message,
57 $request->newContentSource(),
58 $topic);
60 if ($errors) {
61 foreach ($errors as $error_code) {
62 switch ($error_code) {
63 case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS:
64 throw new ConduitException('ERR_EMPTY_PARTICIPANT_PHIDS');
65 break;
70 return array(
71 'conpherenceID' => $conpherence->getID(),
72 'conpherencePHID' => $conpherence->getPHID(),
73 'conpherenceURI' => $this->getConpherenceURI($conpherence),