diff --git a/src/applications/differential/doorkeeper/DifferentialDoorkeeperRevisionFeedStoryPublisher.php b/src/applications/differential/doorkeeper/DifferentialDoorkeeperRevisionFeedStoryPublisher.php index d11e73dc78..1b9750a100 100644 --- a/src/applications/differential/doorkeeper/DifferentialDoorkeeperRevisionFeedStoryPublisher.php +++ b/src/applications/differential/doorkeeper/DifferentialDoorkeeperRevisionFeedStoryPublisher.php @@ -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) { diff --git a/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php b/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php index 77fc99a302..6ded4ad2f8 100644 --- a/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php +++ b/src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php @@ -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())) diff --git a/src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php b/src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php index 460c82fa8b..428a22be67 100644 --- a/src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php +++ b/src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php @@ -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); diff --git a/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php b/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php index d4f7486ae6..f23653a744 100644 --- a/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php +++ b/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php @@ -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) {