2019-05-09 18:54:39 +12:00
|
|
|
<?php
|
|
|
|
|
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
|
|
|
|
2019-09-07 05:08:48 +12:00
|
|
|
echo APP_NAME.' audits worker v1 has started';
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2019-12-29 22:47:55 +13:00
|
|
|
use Utopia\Audit\Audit;
|
|
|
|
use Utopia\Audit\Adapters\MySQL as AuditAdapter;
|
|
|
|
|
2019-05-09 18:54:39 +12:00
|
|
|
class AuditsV1
|
|
|
|
{
|
|
|
|
public $args = [];
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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'];
|
|
|
|
$pdo = $register->get('db', true);
|
2019-12-29 22:47:55 +13:00
|
|
|
|
|
|
|
$adapter = new AuditAdapter($pdo);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
// ... Remove environment for this job
|
|
|
|
}
|
2019-09-07 05:08:48 +12:00
|
|
|
}
|