From 1fec5fd727d1a29f9715affc7a5c98a112f742c3 Mon Sep 17 00:00:00 2001 From: jhester Date: Mon, 12 Dec 2011 11:55:55 -0800 Subject: [PATCH] Add author to differential.getrevisionfeedback Summary: Add the author PHID to the differential.getrevisionfeedback conduit api method Test Plan: issue differential.getrevisionfeedback query via conduit against a valid revision and verify author phid is included in results Reviewers: epriestley Reviewed By: epriestley CC: epriestley, aran, jungejason, tuomaspelkonen, jonathanhester Differential Revision: 1190 --- src/__phutil_library_map__.php | 2 + ...ifferential_getrevisioncomments_Method.php | 72 +++++++++++++++++++ .../getrevisioncomments/__init__.php | 15 ++++ 3 files changed, 89 insertions(+) create mode 100644 src/applications/conduit/method/differential/getrevisioncomments/ConduitAPI_differential_getrevisioncomments_Method.php create mode 100644 src/applications/conduit/method/differential/getrevisioncomments/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 5c8901836b..a534a3e965 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -104,6 +104,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_getcommitpaths_Method' => 'applications/conduit/method/differential/getcommitpaths', 'ConduitAPI_differential_getdiff_Method' => 'applications/conduit/method/differential/getdiff', 'ConduitAPI_differential_getrevision_Method' => 'applications/conduit/method/differential/getrevision', + 'ConduitAPI_differential_getrevisioncomments_Method' => 'applications/conduit/method/differential/getrevisioncomments', 'ConduitAPI_differential_getrevisionfeedback_Method' => 'applications/conduit/method/differential/getrevisionfeedback', 'ConduitAPI_differential_markcommitted_Method' => 'applications/conduit/method/differential/markcommitted', 'ConduitAPI_differential_parsecommitmessage_Method' => 'applications/conduit/method/differential/parsecommitmessage', @@ -830,6 +831,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getdiff_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getrevision_Method' => 'ConduitAPIMethod', + 'ConduitAPI_differential_getrevisioncomments_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getrevisionfeedback_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_markcommitted_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod', diff --git a/src/applications/conduit/method/differential/getrevisioncomments/ConduitAPI_differential_getrevisioncomments_Method.php b/src/applications/conduit/method/differential/getrevisioncomments/ConduitAPI_differential_getrevisioncomments_Method.php new file mode 100644 index 0000000000..86d64dc92b --- /dev/null +++ b/src/applications/conduit/method/differential/getrevisioncomments/ConduitAPI_differential_getrevisioncomments_Method.php @@ -0,0 +1,72 @@ + 'required list', + ); + } + + public function defineReturnType() { + return 'nonempty list>'; + } + + public function defineErrorTypes() { + return array( + ); + } + + protected function execute(ConduitAPIRequest $request) { + $results = array(); + $revision_ids = $request->getValue('ids'); + + if (!$revision_ids) { + return $results; + } + + $comments = id(new DifferentialComment())->loadAllWhere( + 'revisionID IN (%Ld)', + $revision_ids); + + foreach ($comments as $comment) { + $revision_id = $comment->getRevisionID(); + if (!array_key_exists($revision_id, $results)) { + $results[$revision_id] = array(); + } + $results[$revision_id][] = array( + 'revisionID' => $revision_id, + 'action' => $comment->getAction(), + 'authorPHID' => $comment->getAuthorPHID(), + 'dateCreated' => $comment->getDateCreated(), + 'content' => $comment->getContent(), + ); + } + + return $results; + } +} diff --git a/src/applications/conduit/method/differential/getrevisioncomments/__init__.php b/src/applications/conduit/method/differential/getrevisioncomments/__init__.php new file mode 100644 index 0000000000..dd846bae09 --- /dev/null +++ b/src/applications/conduit/method/differential/getrevisioncomments/__init__.php @@ -0,0 +1,15 @@ +