1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00
appwrite/app/workers/audits.php
2020-07-05 22:19:14 +03:00

46 lines
1,011 B
PHP

<?php
require_once __DIR__.'/../init.php';
\cli_set_process_title('Audits V1 Worker');
echo APP_NAME.' audits worker v1 has started'."\n";
use Utopia\Audit\Audit;
use Utopia\Audit\Adapters\MySQL as AuditAdapter;
class AuditsV1
{
public $args = [];
public function setUp()
{
}
public function perform()
{
global $register;
$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'];
$db = $register->get('db', true);
$adapter = new AuditAdapter($db);
$adapter->setNamespace('app_'.$projectId);
$audit = new Audit($adapter);
$audit->log($userId, $event, $resource, $userAgent, $ip, '', $data);
}
public function tearDown()
{
// ... Remove environment for this job
}
}