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

at recaptime-dev/main 64 lines 1.7 kB view raw
1<?php 2 3final class FlagDeleteConduitAPIMethod extends FlagConduitAPIMethod { 4 5 public function getAPIMethodName() { 6 return 'flag.delete'; 7 } 8 9 public function getMethodDescription() { 10 return pht('Clear a flag.'); 11 } 12 13 protected function defineParamTypes() { 14 return array( 15 'id' => 'optional id', 16 'objectPHID' => 'optional phid', 17 ); 18 } 19 20 protected function defineReturnType() { 21 return 'dict | null'; 22 } 23 24 protected function defineErrorTypes() { 25 return array( 26 'ERR_NOT_FOUND' => pht('Bad flag ID.'), 27 'ERR_WRONG_USER' => pht('You are not the creator of this flag.'), 28 'ERR_NEED_PARAM' => pht('Must pass an id or an objectPHID.'), 29 ); 30 } 31 32 /** 33 * @param ConduitAPIRequest $request 34 * @return array<string,mixed>|null 35 */ 36 protected function execute(ConduitAPIRequest $request) { 37 $id = $request->getValue('id'); 38 $object = $request->getValue('objectPHID'); 39 if ($id) { 40 $flag = id(new PhabricatorFlag())->load($id); 41 if (!$flag) { 42 throw new ConduitException('ERR_NOT_FOUND'); 43 } 44 if ($flag->getOwnerPHID() != $request->getUser()->getPHID()) { 45 throw new ConduitException('ERR_WRONG_USER'); 46 } 47 } else if ($object) { 48 $flag = id(new PhabricatorFlag())->loadOneWhere( 49 'objectPHID = %s AND ownerPHID = %s', 50 $object, 51 $request->getUser()->getPHID()); 52 if (!$flag) { 53 return null; 54 } 55 } else { 56 throw new ConduitException('ERR_NEED_PARAM'); 57 } 58 $this->attachHandleToFlag($flag, $request->getUser()); 59 $ret = $this->buildFlagInfoDictionary($flag); 60 $flag->delete(); 61 return $ret; 62 } 63 64}