2013-06-26 01:29:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorFeedManagementRepublishWorkflow
|
|
|
|
extends PhabricatorFeedManagementWorkflow {
|
|
|
|
|
|
|
|
protected function didConstruct() {
|
|
|
|
$this
|
|
|
|
->setName('republish')
|
|
|
|
->setExamples('**republish** __story_key__')
|
|
|
|
->setSynopsis(
|
|
|
|
pht(
|
|
|
|
'Republish a feed event to all consumers.'))
|
|
|
|
->setArguments(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'name' => 'key',
|
|
|
|
'wildcard' => true,
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute(PhutilArgumentParser $args) {
|
|
|
|
$console = PhutilConsole::getConsole();
|
2013-12-27 22:15:40 +01:00
|
|
|
$viewer = $this->getViewer();
|
2013-06-26 01:29:47 +02:00
|
|
|
|
|
|
|
$key = $args->getArg('key');
|
|
|
|
if (count($key) < 1) {
|
|
|
|
throw new PhutilArgumentUsageException(
|
2014-06-09 20:36:49 +02:00
|
|
|
pht('Specify a story key to republish.'));
|
2013-06-26 01:29:47 +02:00
|
|
|
} else if (count($key) > 1) {
|
|
|
|
throw new PhutilArgumentUsageException(
|
2014-06-09 20:36:49 +02:00
|
|
|
pht('Specify exactly one story key to republish.'));
|
2013-06-26 01:29:47 +02:00
|
|
|
}
|
|
|
|
$key = head($key);
|
|
|
|
|
|
|
|
$story = id(new PhabricatorFeedQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withChronologicalKeys(array($key))
|
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$story) {
|
|
|
|
throw new PhutilArgumentUsageException(
|
|
|
|
pht('No story exists with key "%s"!', $key));
|
|
|
|
}
|
|
|
|
|
2014-06-09 20:36:49 +02:00
|
|
|
$console->writeOut("%s\n", pht('Republishing story...'));
|
2013-06-26 01:29:47 +02:00
|
|
|
|
|
|
|
PhabricatorWorker::setRunAllTasksInProcess(true);
|
|
|
|
|
|
|
|
PhabricatorWorker::scheduleTask(
|
|
|
|
'FeedPublisherWorker',
|
|
|
|
array(
|
|
|
|
'key' => $key,
|
|
|
|
));
|
|
|
|
|
2014-06-09 20:36:49 +02:00
|
|
|
$console->writeOut("%s\n", pht('Done.'));
|
2013-06-26 01:29:47 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|