1
0
Fork 0
mirror of synced 2024-07-05 14:40:42 +12:00
appwrite/app/workers/audits.php

44 lines
1 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
{
$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'];
$dbForInternal = getInternalDB($projectId);
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
}
}