2019-05-09 18:54:39 +12:00
|
|
|
<?php
|
|
|
|
|
2020-05-10 04:39:50 +12:00
|
|
|
use Utopia\Audit\Audit;
|
|
|
|
use Utopia\Audit\Adapters\MySQL as AuditAdapter;
|
|
|
|
use Utopia\CLI\Console;
|
|
|
|
|
2019-09-07 05:08:48 +12:00
|
|
|
require_once __DIR__.'/../init.php';
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-20 23:20:49 +12:00
|
|
|
\cli_set_process_title('Audits V1 Worker');
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-05-10 04:39:50 +12:00
|
|
|
Console::success(APP_NAME.' audits worker v1 has started');
|
2019-12-29 22:47:55 +13:00
|
|
|
|
2019-05-09 18:54:39 +12:00
|
|
|
class AuditsV1
|
|
|
|
{
|
|
|
|
public $args = [];
|
|
|
|
|
2020-10-01 10:58:30 +13:00
|
|
|
public function setUp(): void
|
2019-05-09 18:54:39 +12:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function perform()
|
|
|
|
{
|
|
|
|
global $register;
|
|
|
|
|
2019-09-07 05:08:48 +12:00
|
|
|
$projectId = $this->args['projectId'];
|
|
|
|
$userId = $this->args['userId'];
|
|
|
|
$event = $this->args['event'];
|
|
|
|
$resource = $this->args['resource'];
|
|
|
|
$userAgent = $this->args['userAgent'];
|
|
|
|
$ip = $this->args['ip'];
|
|
|
|
$data = $this->args['data'];
|
2020-07-06 07:19:14 +12:00
|
|
|
$db = $register->get('db', true);
|
2019-12-29 22:47:55 +13:00
|
|
|
|
2020-07-06 07:19:14 +12:00
|
|
|
$adapter = new AuditAdapter($db);
|
2019-09-07 05:08:48 +12:00
|
|
|
$adapter->setNamespace('app_'.$projectId);
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2019-12-29 22:47:55 +13:00
|
|
|
$audit = new Audit($adapter);
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2019-12-29 22:47:55 +13:00
|
|
|
$audit->log($userId, $event, $resource, $userAgent, $ip, '', $data);
|
2019-05-09 18:54:39 +12:00
|
|
|
}
|
|
|
|
|
2020-10-01 10:58:30 +13:00
|
|
|
public function tearDown(): void
|
2019-05-09 18:54:39 +12:00
|
|
|
{
|
|
|
|
// ... Remove environment for this job
|
|
|
|
}
|
2019-09-07 05:08:48 +12:00
|
|
|
}
|