new: [workflow:trigger_event_after_save] New trigger Event.afterSave

pull/8530/head
Sami Mokaddem 2022-07-27 10:45:05 +02:00
parent 8f1b07d698
commit 7f5ce84288
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 33 additions and 0 deletions

View File

@ -459,6 +459,17 @@ class Event extends AppModel
if (empty($event['unpublishAction']) && empty($event['skip_kafka'])) {
$this->publishKafkaNotification('event', $this->quickFetchEvent($event['id']), $created ? 'add' : 'edit');
}
if ($this->isTriggerCallable('event-after-save')) {
$event = $this->quickFetchEvent($event['id']);
$workflowErrors = [];
$logging = [
'model' => 'Event',
'action' => $created ? 'add' : 'edit',
'id' => $event['Event']['id'],
];
$triggerData = $event;
$this->executeTrigger('event-after-save', $triggerData, $workflowErrors, $logging);
}
}
public function attachTagsToEvents(array $events)

View File

@ -0,0 +1,22 @@
<?php
include_once APP . 'Model/WorkflowModules/WorkflowBaseModule.php';
class Module_event_after_save extends WorkflowBaseTriggerModule
{
public $id = 'event-after-save';
public $scope = 'event';
public $name = 'Event After Save';
public $description = 'This trigger is called after an Event has been saved in the database';
public $icon = 'envelope';
public $inputs = 0;
public $outputs = 1;
public $blocking = false;
public $misp_core_format = true;
public $trigger_overhead = self::OVERHEAD_MEDIUM;
public function __construct()
{
parent::__construct();
$this->trigger_overhead_message = __('This trigger is called each time an Event has been saved. Generally, the performance impact of running the workflow is low but in some cases (e.g. Very active community or frequent synchronisations) it can introduce a slight slowdown of the instance.');
}
}