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

Provide a Conduit method to get inline comments

Summary:
See D2855 for usage.

This has a drawback that inlines without a comment (synthetic comments) are not attached anywhere.
I don't like adding more and more methods so I've chosen this solution.
Plus comments and inline comments are often useful together.

Test Plan: Called the method on a revision with inline comments.

Reviewers: epriestley

Reviewed By: epriestley

CC: vii, aran, Korvin

Differential Revision: https://secure.phabricator.com/D2844

vrana 43121f68 382bafa2

+42 -4
+42 -4
src/applications/conduit/method/differential/ConduitAPI_differential_getrevisioncomments_Method.php
··· 29 29 public function defineParamTypes() { 30 30 return array( 31 31 'ids' => 'required list<int>', 32 + 'inlines' => 'optional bool', 32 33 ); 33 34 } 34 35 ··· 53 54 'revisionID IN (%Ld)', 54 55 $revision_ids); 55 56 57 + $with_inlines = $request->getValue('inlines'); 58 + if ($with_inlines) { 59 + $inlines = id(new DifferentialInlineComment())->loadAllWhere( 60 + 'revisionID IN (%Ld)', 61 + $revision_ids); 62 + $changesets = array(); 63 + if ($inlines) { 64 + $changesets = id(new DifferentialChangeset())->loadAllWhere( 65 + 'id IN (%Ld)', 66 + array_unique(mpull($inlines, 'getChangesetID'))); 67 + $inlines = mgroup($inlines, 'getCommentID'); 68 + } 69 + } 70 + 56 71 foreach ($comments as $comment) { 57 72 $revision_id = $comment->getRevisionID(); 58 - if (!array_key_exists($revision_id, $results)) { 59 - $results[$revision_id] = array(); 60 - } 61 - $results[$revision_id][] = array( 73 + $result = array( 62 74 'revisionID' => $revision_id, 63 75 'action' => $comment->getAction(), 64 76 'authorPHID' => $comment->getAuthorPHID(), 65 77 'dateCreated' => $comment->getDateCreated(), 66 78 'content' => $comment->getContent(), 67 79 ); 80 + 81 + if ($with_inlines) { 82 + $result['inlines'] = array(); 83 + foreach (idx($inlines, $comment->getID(), array()) as $inline) { 84 + $file_path = null; 85 + $diff_id = null; 86 + $changeset = idx($changesets, $inline->getChangesetID()); 87 + if ($changeset) { 88 + $file_path = ($inline->getIsNewFile() ? 89 + $changeset->getFilename() : 90 + $changeset->getOldFile()); 91 + $diff_id = $changeset->getDiffID(); 92 + } 93 + $result['inlines'][] = array( 94 + 'filePath' => $file_path, 95 + 'isNewFile' => $inline->getIsNewFile(), 96 + 'lineNumber' => $inline->getLineNumber(), 97 + 'lineLength' => $inline->getLineLength(), 98 + 'diffID' => $diff_id, 99 + 'content' => $inline->getContent(), 100 + ); 101 + } 102 + // TODO: Put synthetic inlines without an attached comment somewhere. 103 + } 104 + 105 + $results[$revision_id][] = $result; 68 106 } 69 107 70 108 return $results;