1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

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:
epriestley 2013-07-22 12:21:01 -07:00
parent cf255cde3d
commit c66ea56743
2 changed files with 34 additions and 1 deletions

View file

@ -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,
)); ));
} }

View file

@ -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;
}
} }