1
0
Fork 0
mirror of synced 2024-06-27 02:31:04 +12:00

decouple audits log from events

This commit is contained in:
shimon 2022-09-04 11:45:53 +03:00
parent 2c9b749f72
commit f63c740917
3 changed files with 28 additions and 3 deletions

View file

@ -342,6 +342,8 @@ App::shutdown()
$audits->setPayload($responsePayload);
}
var_dump($audits);
foreach ($events->getParams() as $key => $value) {
$audits->setParam($key, $value);
}

View file

@ -24,7 +24,7 @@ class AuditsV1 extends Worker
public function run(): void
{
$events = $this->args['events'];
$event = $this->args['event'];
$payload = $this->args['payload'];
$mode = $this->args['mode'];
$resource = $this->args['resource'];
@ -42,7 +42,7 @@ class AuditsV1 extends Worker
$audit->log(
userId: $user->getId(),
// Pass first, most verbose event pattern
event: $events[0],
event: $event,
resource: $resource,
userAgent: $userAgent,
ip: $ip,

View file

@ -108,6 +108,29 @@ class Audit extends Event
return $this->ip;
}
/**
* Set description for this audit event
*
* @param string $event
* @return self
*/
public function setEvent(string $event): self
{
$this->event = $event;
return $this;
}
/**
* Returns the audit event description.
*
* @return string
*/
public function getEvent(): string
{
return $this->event;
}
/**
* Executes the event and sends it to the audit worker.
*
@ -124,7 +147,7 @@ class Audit extends Event
'mode' => $this->mode,
'ip' => $this->ip,
'userAgent' => $this->userAgent,
'events' => Event::generateEvents($this->getEvent(), $this->getParams())
'event' => $this->event,
]);
}
}