diff --git a/src/applications/conduit/method/differential/ConduitAPI_differential_Method.php b/src/applications/conduit/method/differential/ConduitAPI_differential_Method.php index 32d78cf88e..51c933ca81 100644 --- a/src/applications/conduit/method/differential/ConduitAPI_differential_Method.php +++ b/src/applications/conduit/method/differential/ConduitAPI_differential_Method.php @@ -32,4 +32,31 @@ abstract class ConduitAPI_differential_Method extends ConduitAPIMethod { } + protected function buildInlineInfoDictionary( + DifferentialInlineComment $inline, + DifferentialChangeset $changeset = null) { + + $file_path = null; + $diff_id = null; + if ($changeset) { + $file_path = $inline->getIsNewFile() + ? $changeset->getFilename() + : $changeset->getOldFile(); + + $diff_id = $changeset->getDiffID(); + } + + return array( + 'id' => $inline->getID(), + 'authorPHID' => $inline->getAuthorPHID(), + 'filePath' => $file_path, + 'isNewFile' => $inline->getIsNewFile(), + 'lineNumber' => $inline->getLineNumber(), + 'lineLength' => $inline->getLineLength(), + 'diffID' => $diff_id, + 'content' => $inline->getContent(), + ); + } + + } diff --git a/src/applications/conduit/method/differential/ConduitAPI_differential_createinline_Method.php b/src/applications/conduit/method/differential/ConduitAPI_differential_createinline_Method.php index 0ffa7fd30c..a9dfa7d743 100644 --- a/src/applications/conduit/method/differential/ConduitAPI_differential_createinline_Method.php +++ b/src/applications/conduit/method/differential/ConduitAPI_differential_createinline_Method.php @@ -20,7 +20,7 @@ * @group conduit */ final class ConduitAPI_differential_createinline_Method - extends ConduitAPIMethod { + extends ConduitAPI_differential_Method { public function getMethodDescription() { return "Add an inline comment to a Differential revision."; @@ -32,9 +32,9 @@ final class ConduitAPI_differential_createinline_Method 'diffID' => 'optional diffid', 'filePath' => 'required string', 'isNewFile' => 'required bool', - 'lineStart' => 'required int', - 'lineCount' => 'optional int', - 'message' => 'required string', + 'lineNumber' => 'required int', + 'lineLength' => 'optional int', + 'content' => 'required string', ); } @@ -106,25 +106,16 @@ final class ConduitAPI_differential_createinline_Method ->setRevisionID($rid) ->setChangesetID($cid) ->setAuthorPHID($request->getUser()->getPHID()) - ->setContent($request->getValue('message')) + ->setContent($request->getValue('content')) ->setIsNewFile($request->getValue('isNewFile')) - ->setLineNumber($request->getValue('lineStart')) - ->setLineLength($request->getValue('lineCount', 0)) + ->setLineNumber($request->getValue('lineNumber')) + ->setLineLength($request->getValue('lineLength', 0)) ->save(); // Load everything again, just to be safe. $changeset = id(new DifferentialChangeset()) ->load($inline->getChangesetID()); - return array( - 'filePath' => ($inline->getIsNewFile() ? - $changeset->getFilename() : - $changeset->getOldFile()), - 'isNewFile' => $inline->getIsNewFile(), - 'lineNumber' => $inline->getLineNumber(), - 'lineLength' => $inline->getLineLength(), - 'diffID' => $changeset->getDiffID(), - 'content' => $inline->getContent(), - ); + return $this->buildInlineInfoDictionary($inline, $changeset); } } diff --git a/src/applications/conduit/method/differential/ConduitAPI_differential_getrevisioncomments_Method.php b/src/applications/conduit/method/differential/ConduitAPI_differential_getrevisioncomments_Method.php index 5f09a73fb8..8d71da0149 100644 --- a/src/applications/conduit/method/differential/ConduitAPI_differential_getrevisioncomments_Method.php +++ b/src/applications/conduit/method/differential/ConduitAPI_differential_getrevisioncomments_Method.php @@ -20,7 +20,7 @@ * @group conduit */ final class ConduitAPI_differential_getrevisioncomments_Method - extends ConduitAPIMethod { + extends ConduitAPI_differential_Method { public function getMethodDescription() { return "Retrieve Differential Revision Comments."; @@ -81,23 +81,10 @@ final class ConduitAPI_differential_getrevisioncomments_Method if ($with_inlines) { $result['inlines'] = array(); foreach (idx($inlines, $comment->getID(), array()) as $inline) { - $file_path = null; - $diff_id = null; $changeset = idx($changesets, $inline->getChangesetID()); - if ($changeset) { - $file_path = ($inline->getIsNewFile() ? - $changeset->getFilename() : - $changeset->getOldFile()); - $diff_id = $changeset->getDiffID(); - } - $result['inlines'][] = array( - 'filePath' => $file_path, - 'isNewFile' => $inline->getIsNewFile(), - 'lineNumber' => $inline->getLineNumber(), - 'lineLength' => $inline->getLineLength(), - 'diffID' => $diff_id, - 'content' => $inline->getContent(), - ); + $result['inlines'][] = $this->buildInlineInfoDictionary( + $inline, + $changeset); } // TODO: Put synthetic inlines without an attached comment somewhere. }