Hack up Asana story text so it's more useful
Summary: `FeedStory->renderText()` is garbage and I don't want to fix it in general until after T2222 / T2217. Provide an Asana-specific alternative for higher-quality feed stories (notably, including comment text).
Test Plan: {F51035}
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2852
Differential Revision: https://secure.phabricator.com/D6521
This commit is contained in:
@@ -493,12 +493,18 @@ final class DoorkeeperFeedWorkerAsana extends FeedPushWorker {
|
|||||||
// because everything else is idempotent, so this is the only effect we
|
// because everything else is idempotent, so this is the only effect we
|
||||||
// can't safely run more than once.
|
// can't safely run more than once.
|
||||||
|
|
||||||
|
if ($story instanceof PhabricatorFeedStoryDifferential) {
|
||||||
|
$text = $story->renderForAsanaBridge();
|
||||||
|
} else {
|
||||||
|
$text = $story->renderText();
|
||||||
|
}
|
||||||
|
|
||||||
$this->makeAsanaAPICall(
|
$this->makeAsanaAPICall(
|
||||||
$oauth_token,
|
$oauth_token,
|
||||||
'tasks/'.$parent_ref->getObjectID().'/stories',
|
'tasks/'.$parent_ref->getObjectID().'/stories',
|
||||||
'POST',
|
'POST',
|
||||||
array(
|
array(
|
||||||
'text' => $story->renderText(),
|
'text' => $text,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,4 +74,31 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
|
|||||||
=> 'PhabricatorFeedStoryDifferentialAggregate',
|
=> 'PhabricatorFeedStoryDifferentialAggregate',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: At some point, make feed rendering not terrible and remove this
|
||||||
|
// hacky mess.
|
||||||
|
public function renderForAsanaBridge() {
|
||||||
|
$data = $this->getStoryData();
|
||||||
|
$comment = $data->getValue('feedback_content');
|
||||||
|
|
||||||
|
$author_name = $this->getHandle($this->getAuthorPHID())->getName();
|
||||||
|
$action = $this->getValue('action');
|
||||||
|
$verb = DifferentialAction::getActionPastTenseVerb($action);
|
||||||
|
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user