mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-07 15:54:26 +02:00
Add event for proc_run hook
This commit is contained in:
parent
10e4f4bf36
commit
2a722b16aa
5 changed files with 14 additions and 5 deletions
|
@ -67,6 +67,7 @@ final class HookEventBridge
|
||||||
ArrayFilterEvent::REVOKE_FOLLOW_CONTACT => 'revoke_follow',
|
ArrayFilterEvent::REVOKE_FOLLOW_CONTACT => 'revoke_follow',
|
||||||
ArrayFilterEvent::BLOCK_CONTACT => 'block',
|
ArrayFilterEvent::BLOCK_CONTACT => 'block',
|
||||||
ArrayFilterEvent::UNBLOCK_CONTACT => 'unblock',
|
ArrayFilterEvent::UNBLOCK_CONTACT => 'unblock',
|
||||||
|
ArrayFilterEvent::ADD_WORKER_TASK => 'proc_run',
|
||||||
HtmlFilterEvent::HEAD => 'head',
|
HtmlFilterEvent::HEAD => 'head',
|
||||||
HtmlFilterEvent::FOOTER => 'footer',
|
HtmlFilterEvent::FOOTER => 'footer',
|
||||||
HtmlFilterEvent::PAGE_HEADER => 'page_header',
|
HtmlFilterEvent::PAGE_HEADER => 'page_header',
|
||||||
|
@ -114,6 +115,7 @@ final class HookEventBridge
|
||||||
ArrayFilterEvent::REVOKE_FOLLOW_CONTACT => 'onArrayFilterEvent',
|
ArrayFilterEvent::REVOKE_FOLLOW_CONTACT => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::BLOCK_CONTACT => 'onArrayFilterEvent',
|
ArrayFilterEvent::BLOCK_CONTACT => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::UNBLOCK_CONTACT => 'onArrayFilterEvent',
|
ArrayFilterEvent::UNBLOCK_CONTACT => 'onArrayFilterEvent',
|
||||||
|
ArrayFilterEvent::ADD_WORKER_TASK => 'onArrayFilterEvent',
|
||||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Core\Logger\Type\WorkerLogger;
|
||||||
use Friendica\Core\Worker\Entity\Process;
|
use Friendica\Core\Worker\Entity\Process;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Event\ArrayFilterEvent;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1237,10 +1238,6 @@ class Worker
|
||||||
* @return int '0' if worker queue entry already existed or there had been an error, otherwise the ID of the worker task
|
* @return int '0' if worker queue entry already existed or there had been an error, otherwise the ID of the worker task
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @note $cmd and string args are surrounded with ''
|
* @note $cmd and string args are surrounded with ''
|
||||||
*
|
|
||||||
* @hooks 'proc_run'
|
|
||||||
* array $arr
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static function add(...$args)
|
public static function add(...$args)
|
||||||
{
|
{
|
||||||
|
@ -1250,7 +1247,12 @@ class Worker
|
||||||
|
|
||||||
$arr = ['args' => $args, 'run_cmd' => true];
|
$arr = ['args' => $args, 'run_cmd' => true];
|
||||||
|
|
||||||
Hook::callAll('proc_run', $arr);
|
$eventDispatcher = DI::eventDispatcher();
|
||||||
|
|
||||||
|
$arr = $eventDispatcher->dispatch(
|
||||||
|
new ArrayFilterEvent(ArrayFilterEvent::ADD_WORKER_TASK, $arr),
|
||||||
|
)->getArray();
|
||||||
|
|
||||||
if (!$arr['run_cmd'] || !count($args)) {
|
if (!$arr['run_cmd'] || !count($args)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,8 @@ final class ArrayFilterEvent extends Event
|
||||||
|
|
||||||
public const UNBLOCK_CONTACT = 'friendica.data.unblock_contact';
|
public const UNBLOCK_CONTACT = 'friendica.data.unblock_contact';
|
||||||
|
|
||||||
|
public const ADD_WORKER_TASK = 'friendica.data.add_worker_task';
|
||||||
|
|
||||||
private array $array;
|
private array $array;
|
||||||
|
|
||||||
public function __construct(string $name, array $array)
|
public function __construct(string $name, array $array)
|
||||||
|
|
|
@ -56,6 +56,7 @@ class HookEventBridgeTest extends TestCase
|
||||||
ArrayFilterEvent::REVOKE_FOLLOW_CONTACT => 'onArrayFilterEvent',
|
ArrayFilterEvent::REVOKE_FOLLOW_CONTACT => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::BLOCK_CONTACT => 'onArrayFilterEvent',
|
ArrayFilterEvent::BLOCK_CONTACT => 'onArrayFilterEvent',
|
||||||
ArrayFilterEvent::UNBLOCK_CONTACT => 'onArrayFilterEvent',
|
ArrayFilterEvent::UNBLOCK_CONTACT => 'onArrayFilterEvent',
|
||||||
|
ArrayFilterEvent::ADD_WORKER_TASK => 'onArrayFilterEvent',
|
||||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||||
|
@ -288,6 +289,7 @@ class HookEventBridgeTest extends TestCase
|
||||||
[ArrayFilterEvent::REVOKE_FOLLOW_CONTACT, 'revoke_follow'],
|
[ArrayFilterEvent::REVOKE_FOLLOW_CONTACT, 'revoke_follow'],
|
||||||
[ArrayFilterEvent::BLOCK_CONTACT, 'block'],
|
[ArrayFilterEvent::BLOCK_CONTACT, 'block'],
|
||||||
[ArrayFilterEvent::UNBLOCK_CONTACT, 'unblock'],
|
[ArrayFilterEvent::UNBLOCK_CONTACT, 'unblock'],
|
||||||
|
[ArrayFilterEvent::ADD_WORKER_TASK, 'proc_run'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ class ArrayFilterEventTest extends TestCase
|
||||||
[ArrayFilterEvent::REVOKE_FOLLOW_CONTACT, 'friendica.data.revoke_follow_contact'],
|
[ArrayFilterEvent::REVOKE_FOLLOW_CONTACT, 'friendica.data.revoke_follow_contact'],
|
||||||
[ArrayFilterEvent::BLOCK_CONTACT, 'friendica.data.block_contact'],
|
[ArrayFilterEvent::BLOCK_CONTACT, 'friendica.data.block_contact'],
|
||||||
[ArrayFilterEvent::UNBLOCK_CONTACT, 'friendica.data.unblock_contact'],
|
[ArrayFilterEvent::UNBLOCK_CONTACT, 'friendica.data.unblock_contact'],
|
||||||
|
[ArrayFilterEvent::ADD_WORKER_TASK, 'friendica.data.add_worker_task'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue