1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 17:52:43 +01:00
phorge-phorge/src/applications/diffusion/conduit/DiffusionLookSoonConduitAPIMethod.php
epriestley 9febfb26a0 Convert diffusion.looksoon to use repository identifiers instead of callsigns
Summary:
Ref T4245. Like everything else, accept more identifiers.

This needs a change in `arc`, which I've made a note about elsewhere.

Test Plan: Used "Update Now" from web UI, saw update get scheduled.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14932
2016-01-04 06:54:20 -08:00

61 lines
1.5 KiB
PHP

<?php
final class DiffusionLookSoonConduitAPIMethod
extends DiffusionConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.looksoon';
}
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
public function getMethodDescription() {
return pht(
'Advises Phabricator to look for new commits in a repository as soon '.
'as possible. This advice is most useful if you have just pushed new '.
'commits to that repository.');
}
protected function defineReturnType() {
return 'void';
}
protected function defineParamTypes() {
return array(
'callsigns' => 'optional list<string> (deprecated)',
'repositories' => 'optional list<string>',
'urgency' => 'optional string',
);
}
protected function execute(ConduitAPIRequest $request) {
// NOTE: The "urgency" parameter does nothing, it is just a hilarious joke
// which exemplifies the boundless clever wit of this project.
$identifiers = $request->getValue('repositories');
if (!$identifiers) {
$identifiers = $request->getValue('callsigns');
}
if (!$identifiers) {
return null;
}
$repositories = id(new PhabricatorRepositoryQuery())
->setViewer($request->getUser())
->withIdentifiers($identifiers)
->execute();
foreach ($repositories as $repository) {
$repository->writeStatusMessage(
PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE,
PhabricatorRepositoryStatusMessage::CODE_OKAY);
}
return null;
}
}