chg: remove hardcode response, map shell/cmd names.

pull/7939/head
Luciano Righetti 2021-10-26 11:14:11 +02:00
parent 35cf34fab2
commit 9bb95db27e
3 changed files with 9 additions and 6 deletions

View File

@ -390,8 +390,7 @@ class EventShell extends AppShell
$user = $this->getUser($userId);
$job = $this->Job->read(null, $jobId);
$this->Event->Behaviors->unload('SysLogLogable.SysLogLogable');
// $result = $this->Event->publish($id, $passAlong);
$result = true;
$result = $this->Event->publish($id, $passAlong);
$job['Job']['progress'] = 100;
$job['Job']['status'] = Job::STATUS_COMPLETED;
$job['Job']['date_modified'] = date("Y-m-d H:i:s");

View File

@ -68,10 +68,14 @@ class BackgroundJobsTool
self::UPDATE_QUEUE,
];
public const CMD_EVENT_SHELL = 'event';
public const CMD_EVENT = 'event';
public const ALLOWED_COMMANDS = [
self::CMD_EVENT_SHELL
self::CMD_EVENT
];
public const CMD_TO_SHELL_DICT = [
self::CMD_EVENT => 'EventShell'
];
public const JOB_STATUS_PREFIX = 'job_status';
@ -130,7 +134,7 @@ class BackgroundJobsTool
): string {
if ($this->settings['use_resque']) {
$this->resqueEnqueue($queue, $command, $args, $trackStatus, $job);
$this->resqueEnqueue($queue, self::CMD_TO_SHELL_DICT[$command], $args, $trackStatus, $job);
}
$this->validateQueue($queue);

View File

@ -4553,7 +4553,7 @@ class Event extends AppModel
return $this->getBackgroundJobsTool()->enqueue(
BackgroundJobsTool::PRIO_QUEUE,
BackgroundJobsTool::CMD_EVENT_SHELL,
BackgroundJobsTool::CMD_EVENT,
[
'publish',
$id,