1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Publish create object stories into Asana sort of, but not really

Summary: Ref T2852. Current code works fine, but although we want to drop creation stories, we really only want to drop the story text, not the other effects of the creation story. Also generalize this mechanism so we don't have Asana-specific code in the publishers.

Test Plan: Used `bin/feed republish` to publish creation and non-creation stories. Verified creation story published no text.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2852

Differential Revision: https://secure.phabricator.com/D6639
This commit is contained in:
epriestley 2013-08-01 12:19:18 -07:00
parent 22d7b54378
commit 75e56cb25d
4 changed files with 30 additions and 22 deletions

View file

@ -4,23 +4,19 @@ final class DifferentialDoorkeeperRevisionFeedStoryPublisher
extends DoorkeeperFeedStoryPublisher {
public function canPublishStory(PhabricatorFeedStory $story, $object) {
if (!($object instanceof DifferentialRevision)) {
return false;
}
return ($object instanceof DifferentialRevision);
}
// Don't publish the "create" story, since pushing the object into Asana
// naturally generates a notification which effectively serves the same
// purpose as the "create" story.
public function isStoryAboutObjectCreation($object) {
$story = $this->getFeedStory();
$action = $story->getStoryData()->getValue('action');
switch ($action) {
case DifferentialAction::ACTION_CREATE:
return false;
return true;
default:
break;
return false;
}
return true;
}
public function willPublishStory($object) {

View file

@ -15,6 +15,13 @@ final class DiffusionDoorkeeperCommitFeedStoryPublisher
return ($object instanceof PhabricatorRepositoryCommit);
}
public function isStoryAboutObjectCreation($object) {
// TODO: Although creation stories exist, they currently don't have a
// primary object PHID set, so they'll never make it here because they
// won't pass `canPublishStory()`.
return false;
}
public function willPublishStory($commit) {
$requests = id(new PhabricatorAuditQuery())
->withCommitPHIDs(array($commit->getPHID()))

View file

@ -35,6 +35,7 @@ abstract class DoorkeeperFeedStoryPublisher {
return $object;
}
abstract public function isStoryAboutObjectCreation($object);
abstract public function getOwnerPHID($object);
abstract public function getActiveUserPHIDs($object);
abstract public function getPassiveUserPHIDs($object);

View file

@ -476,20 +476,24 @@ final class DoorkeeperFeedWorkerAsana extends FeedPushWorker {
$sub_editor->save();
// Don't publish the "create" story, since pushing the object into Asana
// naturally generates a notification which effectively serves the same
// purpose as the "create" story.
if (!$publisher->isStoryAboutObjectCreation($object)) {
// Post the feed story itself to the main Asana task. We do this last
// because everything else is idempotent, so this is the only effect we
// can't safely run more than once.
// Post the feed story itself to the main Asana task. We do this last
// because everything else is idempotent, so this is the only effect we
// can't safely run more than once.
$text = $publisher->getStoryText($object);
$text = $publisher->getStoryText($object);
$this->makeAsanaAPICall(
$oauth_token,
'tasks/'.$parent_ref->getObjectID().'/stories',
'POST',
array(
'text' => $text,
));
$this->makeAsanaAPICall(
$oauth_token,
'tasks/'.$parent_ref->getObjectID().'/stories',
'POST',
array(
'text' => $text,
));
}
}
private function lookupAsanaUserIDs($all_phids) {