1
0
Fork 0
mirror of synced 2024-06-03 03:14:50 +12:00
appwrite/app/workers/audits.php

47 lines
1 KiB
PHP
Raw Normal View History

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;
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');
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-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;
$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);
2020-07-06 07:19:14 +12:00
$adapter = new AuditAdapter($db);
$adapter->setNamespace('app_'.$projectId);
2019-05-09 18:54:39 +12:00
$audit = new Audit($adapter);
2019-05-09 18:54:39 +12: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
}
}