mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +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:
parent
22d7b54378
commit
75e56cb25d
4 changed files with 30 additions and 22 deletions
|
@ -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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function willPublishStory($object) {
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -476,7 +476,10 @@ 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.
|
||||
|
@ -491,6 +494,7 @@ final class DoorkeeperFeedWorkerAsana extends FeedPushWorker {
|
|||
'text' => $text,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private function lookupAsanaUserIDs($all_phids) {
|
||||
$phid_map = array();
|
||||
|
|
Loading…
Reference in a new issue