mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Publish inline comments in Asana notification stories
Summary: Ref T2852. Bleh, gross. Does what it says in the title. Test Plan: {F54024} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2852 Differential Revision: https://secure.phabricator.com/D6735
This commit is contained in:
parent
c7a84876c9
commit
796007a85e
3 changed files with 51 additions and 4 deletions
|
@ -612,6 +612,10 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
|
|||
'action' => $comment->getAction(),
|
||||
'feedback_content' => $comment->getContent(),
|
||||
'actor_phid' => $actor_phid,
|
||||
|
||||
// NOTE: Don't use this, it will be removed after ApplicationTransactions.
|
||||
// For now, it powers inline comment rendering over the Asana brdige.
|
||||
'temporaryCommentID' => $comment->getID(),
|
||||
);
|
||||
|
||||
id(new PhabricatorFeedStoryPublisher())
|
||||
|
|
|
@ -45,6 +45,11 @@ final class DifferentialInlineCommentQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withCommentIDs(array $comment_ids) {
|
||||
$this->commentIDs = $comment_ids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$table = new DifferentialInlineComment();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
@ -111,6 +116,13 @@ final class DifferentialInlineCommentQuery
|
|||
$this->draftsByAuthors);
|
||||
}
|
||||
|
||||
if ($this->commentIDs) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'commentID IN (%Ld)',
|
||||
$this->commentIDs);
|
||||
}
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,18 +98,49 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
|
|||
$action = $this->getValue('action');
|
||||
$verb = DifferentialAction::getActionPastTenseVerb($action);
|
||||
|
||||
$engine = PhabricatorMarkupEngine::newMarkupEngine(array())
|
||||
->setConfig('viewer', new PhabricatorUser())
|
||||
->setMode(PhutilRemarkupEngine::MODE_TEXT);
|
||||
|
||||
$title = "{$author_name} {$verb} this revision.";
|
||||
if (strlen($comment)) {
|
||||
$engine = PhabricatorMarkupEngine::newMarkupEngine(array())
|
||||
->setConfig('viewer', new PhabricatorUser())
|
||||
->setMode(PhutilRemarkupEngine::MODE_TEXT);
|
||||
|
||||
$comment = $engine->markupText($comment);
|
||||
|
||||
$title .= "\n\n";
|
||||
$title .= $comment;
|
||||
}
|
||||
|
||||
// Roughly render inlines into the comment.
|
||||
$comment_id = $data->getValue('temporaryCommentID');
|
||||
if ($comment_id) {
|
||||
$inlines = id(new DifferentialInlineCommentQuery())
|
||||
->withCommentIDs(array($comment_id))
|
||||
->execute();
|
||||
if ($inlines) {
|
||||
$title .= "\n\n";
|
||||
$title .= pht('Inline Comments');
|
||||
$title .= "\n";
|
||||
$changeset_ids = mpull($inlines, 'getChangesetID');
|
||||
$changesets = id(new DifferentialChangeset())->loadAllWhere(
|
||||
'id IN (%Ld)',
|
||||
$changeset_ids);
|
||||
foreach ($inlines as $inline) {
|
||||
$changeset = idx($changesets, $inline->getChangesetID());
|
||||
if (!$changeset) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = $changeset->getDisplayFilename();
|
||||
$linenumber = $inline->getLineNumber();
|
||||
$inline_text = $engine->markupText($inline->getContent());
|
||||
$inline_text = rtrim($inline_text);
|
||||
|
||||
$title .= "{$filename}:{$linenumber} {$inline_text}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue