decouple audits log from events
This commit is contained in:
parent
2c9b749f72
commit
f63c740917
3 changed files with 28 additions and 3 deletions
|
@ -342,6 +342,8 @@ App::shutdown()
|
|||
$audits->setPayload($responsePayload);
|
||||
}
|
||||
|
||||
var_dump($audits);
|
||||
|
||||
foreach ($events->getParams() as $key => $value) {
|
||||
$audits->setParam($key, $value);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue