Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,17 @@ protected function execute(ConduitAPIRequest $request) {
->setContent($content));
}

// NOTE: The legacy "attach_inlines" flag is now ignored and has no
// effect. See T13513.
if ($request->getValue('attach_inlines')) {
$type_inline = DifferentialTransaction::TYPE_INLINE;
$inlines = $this->loadUnsubmittedInlineComments(
$viewer,
$revision);
foreach ($inlines as $inline) {
$xactions[] = id(new DifferentialTransaction())
->setTransactionType($type_inline)
->attachComment($inline);
}
}

// NOTE: The legacy "silent" flag is now ignored and has no effect. See
// T13042.
Expand All @@ -114,4 +123,49 @@ protected function execute(ConduitAPIRequest $request) {
);
}

public static function loadUnsubmittedInlineComments(
PhabricatorUser $viewer,
DifferentialRevision $revision) {

$inlines = id(new DifferentialDiffInlineCommentQuery())
->setViewer($viewer)
->withRevisionPHIDs(array($revision->getPHID()))
->withAuthorPHIDs(array($viewer->getPHID()))
->withHasTransaction(false)
->withIsDeleted(false)
->needReplyToComments(true)
->execute();

foreach ($inlines as $key => $inline) {
$inlines[$key] = DifferentialInlineComment::newFromModernComment(
$inline);
}

PhabricatorInlineComment::loadAndAttachVersionedDrafts(
$viewer,
$inlines);

// Don't count void inlines when considering draft state.
foreach ($inlines as $key => $inline) {
if ($inline->isVoidComment($viewer)) {
unset($inlines[$key]);
continue;
}

// For other inlines: if they have a nonempty draft state, set their
// content to the draft state content. We want to submit the comment
// as it is currently shown to the user, not as it was stored the last
// time they clicked "Save".

// $draft_content = $inline->getContentForEdit($viewer);
// if (strlen($draft_content)) {
// $inline->setContent($draft_content);
// }
}

$inlines = mpull($inlines, 'getStorageObject');

return $inlines;
}

}