Changeset View
Changeset View
Standalone View
Standalone View
src/applications/feed/worker/FeedPublisherHTTPWorker.php
<?php | <?php | ||||
final class FeedPublisherHTTPWorker extends FeedPushWorker { | final class FeedPublisherHTTPWorker extends FeedPushWorker { | ||||
protected function doWork() { | protected function doWork() { | ||||
$story = $this->loadFeedStory(); | $story = $this->loadFeedStory(); | ||||
$data = $story->getStoryData(); | $post_data = self::getHookDataForStory($story); | ||||
$uri = idx($this->getTaskData(), 'uri'); | $uri = idx($this->getTaskData(), 'uri'); | ||||
id(new HTTPSFuture($uri, $post_data)) | |||||
->setMethod('POST') | |||||
->setTimeout(30) | |||||
->resolvex(); | |||||
} | |||||
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) { | |||||
return max($task->getFailureCount(), 1) * 60; | |||||
} | |||||
public static function getHookDataForStory(PhabricatorFeedStory $story) { | |||||
$data = $story->getStoryData(); | |||||
$object_phid = $story->getPrimaryObjectPHID(); | |||||
$chronokey = $story->getChronologicalKey(); | |||||
$handle = id(new PhabricatorHandleQuery()) | |||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | |||||
->withPHIDs(array($object_phid)) | |||||
->executeOne(); | |||||
$object_uri = PhabricatorEnv::getProductionURI($handle->getURI()); | |||||
$story_uri = PhabricatorEnv::getProductionURI('/feed/'.$chronokey.'/'); | |||||
$post_data = array( | $post_data = array( | ||||
'storyID' => $data->getID(), | 'storyID' => $data->getID(), | ||||
'storyType' => $data->getStoryType(), | 'storyType' => $data->getStoryType(), | ||||
'storyData' => $data->getStoryData(), | 'storyData' => $data->getStoryData(), | ||||
'storyAuthorPHID' => $data->getAuthorPHID(), | 'storyAuthorPHID' => $data->getAuthorPHID(), | ||||
'storyText' => $story->renderText(), | 'storyText' => $story->renderText(), | ||||
'epoch' => $data->getEpoch(), | 'epoch' => $data->getEpoch(), | ||||
'objectPHID' => $object_phid, | |||||
'objectURI' => $object_uri, | |||||
'storyURI' => $story_uri, | |||||
); | ); | ||||
id(new HTTPSFuture($uri, $post_data)) | return $post_data; | ||||
->setMethod('POST') | |||||
->setTimeout(30) | |||||
->resolvex(); | |||||
} | } | ||||
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) { | |||||
return max($task->getFailureCount(), 1) * 60; | |||||
} | |||||
} | } |