1
0
Fork 0
mirror of synced 2024-07-08 16:06:02 +12:00
appwrite/app/workers/audits.php

50 lines
1.3 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;
2021-06-07 17:17:29 +12:00
use Utopia\Cache\Adapter\Redis;
use Utopia\Cache\Cache;
2020-05-10 04:39:50 +12:00
use Utopia\CLI\Console;
2021-06-07 17:17:29 +12:00
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Database;
2020-05-10 04:39:50 +12:00
require_once __DIR__.'/../workers.php';
2019-05-09 18:54:39 +12:00
2021-01-15 19:02:48 +13:00
Console::title('Audits V1 Worker');
2020-05-10 04:39:50 +12:00
Console::success(APP_NAME.' audits worker v1 has started');
class AuditsV1 extends Worker
2019-05-09 18:54:39 +12:00
{
public $args = [];
public function init(): void
2019-05-09 18:54:39 +12:00
{
}
public function run(): void
2019-05-09 18:54:39 +12:00
{
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);
2021-06-07 17:17:29 +12:00
$cache = new Cache(new Redis($register->get('cache')));
$dbForInternal = new Database(new MariaDB($db), $cache);
$dbForInternal->setNamespace('project_'.$projectId.'_internal');
2019-05-09 18:54:39 +12:00
2021-06-07 17:17:29 +12:00
$audit = new Audit($dbForInternal);
2019-05-09 18:54:39 +12:00
$audit->log($userId, $event, $resource, $userAgent, $ip, '', $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
}
}