From 2e3e078358c1ba135f114aa5388ec06ebca13a6f Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 26 Jan 2017 10:23:22 -0800 Subject: [PATCH] Remove "diffusion.createcomment" Conduit API method Summary: Ref T10978. This was introduced in D6923 in 2013 as a deprecated method (before methods were extensible) and has only ever been deprecated. It no longer works after D17250 (despite my mistaken claim there that we never had an API for actions), and has been superceded by `diffusion.commit.edit` which is a modern, fully-power method. Test Plan: Viewed Conduit console, no longer saw method. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10978 Differential Revision: https://secure.phabricator.com/D17254 --- src/__phutil_library_map__.php | 2 - ...DiffusionCreateCommentConduitAPIMethod.php | 106 ------------------ 2 files changed, 108 deletions(-) delete mode 100644 src/applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a27cbdd3fc..f145dd88ec 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -678,7 +678,6 @@ phutil_register_library_map(array( 'DiffusionCompareController' => 'applications/diffusion/controller/DiffusionCompareController.php', 'DiffusionConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionConduitAPIMethod.php', 'DiffusionController' => 'applications/diffusion/controller/DiffusionController.php', - 'DiffusionCreateCommentConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php', 'DiffusionCreateRepositoriesCapability' => 'applications/diffusion/capability/DiffusionCreateRepositoriesCapability.php', 'DiffusionDaemonLockException' => 'applications/diffusion/exception/DiffusionDaemonLockException.php', 'DiffusionDefaultEditCapability' => 'applications/diffusion/capability/DiffusionDefaultEditCapability.php', @@ -5387,7 +5386,6 @@ phutil_register_library_map(array( 'DiffusionCompareController' => 'DiffusionController', 'DiffusionConduitAPIMethod' => 'ConduitAPIMethod', 'DiffusionController' => 'PhabricatorController', - 'DiffusionCreateCommentConduitAPIMethod' => 'DiffusionConduitAPIMethod', 'DiffusionCreateRepositoriesCapability' => 'PhabricatorPolicyCapability', 'DiffusionDaemonLockException' => 'Exception', 'DiffusionDefaultEditCapability' => 'PhabricatorPolicyCapability', diff --git a/src/applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php deleted file mode 100644 index 51a494425f..0000000000 --- a/src/applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php +++ /dev/null @@ -1,106 +0,0 @@ - 'required string', - 'action' => 'optional string', - 'message' => 'required string', - 'silent' => 'optional bool', - ); - } - - protected function defineReturnType() { - return 'bool'; - } - - protected function defineErrorTypes() { - return array( - 'ERR_BAD_COMMIT' => pht('No commit found with that PHID.'), - 'ERR_BAD_ACTION' => pht('Invalid action type.'), - 'ERR_MISSING_MESSAGE' => pht('Message is required.'), - ); - } - - protected function execute(ConduitAPIRequest $request) { - $commit_phid = $request->getValue('phid'); - $commit = id(new DiffusionCommitQuery()) - ->setViewer($request->getUser()) - ->withPHIDs(array($commit_phid)) - ->needAuditRequests(true) - ->executeOne(); - if (!$commit) { - throw new ConduitException('ERR_BAD_COMMIT'); - } - - $message = trim($request->getValue('message')); - if (!$message) { - throw new ConduitException('ERR_MISSING_MESSAGE'); - } - - $action = $request->getValue('action'); - if (!$action) { - $action = PhabricatorAuditActionConstants::COMMENT; - } - - // Disallow ADD_CCS, ADD_AUDITORS forever. - if (!in_array($action, array( - PhabricatorAuditActionConstants::CONCERN, - PhabricatorAuditActionConstants::ACCEPT, - PhabricatorAuditActionConstants::COMMENT, - PhabricatorAuditActionConstants::RESIGN, - PhabricatorAuditActionConstants::CLOSE, - ))) { - throw new ConduitException('ERR_BAD_ACTION'); - } - - $xactions = array(); - - if ($action != PhabricatorAuditActionConstants::COMMENT) { - $xactions[] = id(new PhabricatorAuditTransaction()) - ->setTransactionType(PhabricatorAuditActionConstants::ACTION) - ->setNewValue($action); - } - - if (strlen($message)) { - $xactions[] = id(new PhabricatorAuditTransaction()) - ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) - ->attachComment( - id(new PhabricatorAuditTransactionComment()) - ->setCommitPHID($commit->getPHID()) - ->setContent($message)); - } - - id(new PhabricatorAuditEditor()) - ->setActor($request->getUser()) - ->setContentSource($request->newContentSource()) - ->setDisableEmail($request->getValue('silent')) - ->setContinueOnMissingFields(true) - ->applyTransactions($commit, $xactions); - - return true; - } - -}