1
0
Fork 0
mirror of synced 2024-05-19 20:22:33 +12:00
appwrite/app/workers/audits.php

47 lines
1.2 KiB
PHP
Raw Normal View History

2019-05-09 18:54:39 +12:00
<?php
use Appwrite\Resque\Worker;
2020-05-10 04:39:50 +12:00
use Utopia\Audit\Audit;
use Utopia\CLI\Console;
require_once __DIR__.'/../init.php';
2019-05-09 18:54:39 +12:00
2021-01-15 19:02:48 +13:00
Console::title('Audits V1 Worker');
2021-09-01 21:13:23 +12:00
Console::success(APP_NAME . ' audits worker v1 has started');
class AuditsV1 extends Worker
2019-05-09 18:54:39 +12:00
{
public function init(): void
2019-05-09 18:54:39 +12:00
{
}
public function run(): void
2019-05-09 18:54:39 +12:00
{
$projectId = $this->args['projectId'];
$userId = $this->args['userId'];
2021-08-14 22:13:24 +12:00
$userName = $this->args['userName'];
$userEmail = $this->args['userEmail'];
$mode = $this->args['mode'];
$event = $this->args['event'];
$resource = $this->args['resource'];
$userAgent = $this->args['userAgent'];
$ip = $this->args['ip'];
$data = $this->args['data'];
$dbForProject = $this->getProjectDB($projectId);
$audit = new Audit($dbForProject);
2019-05-09 18:54:39 +12:00
2021-08-14 22:13:24 +12:00
$audit->log($userId, $event, $resource, $userAgent, $ip, '', [
'userName' => $userName,
'userEmail' => $userEmail,
'mode' => $mode,
'data' => $data,
]);
2019-05-09 18:54:39 +12:00
}
public function shutdown(): void
2019-05-09 18:54:39 +12:00
{
// ... Remove environment for this job
}
2021-09-01 21:13:23 +12:00
}