2019-05-09 18:54:39 +12:00
|
|
|
<?php
|
|
|
|
|
2021-06-12 02:20:18 +12:00
|
|
|
use Appwrite\Resque\Worker;
|
2020-05-10 04:39:50 +12:00
|
|
|
use Utopia\Audit\Audit;
|
|
|
|
use Utopia\CLI\Console;
|
|
|
|
|
2021-08-13 20:39:46 +12:00
|
|
|
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');
|
2021-09-01 21:13:23 +12:00
|
|
|
Console::success(APP_NAME . ' audits worker v1 has started');
|
2019-12-29 22:47:55 +13:00
|
|
|
|
2021-06-12 02:20:18 +12:00
|
|
|
class AuditsV1 extends Worker
|
2019-05-09 18:54:39 +12:00
|
|
|
{
|
2021-06-12 02:20:18 +12:00
|
|
|
public function init(): void
|
2019-05-09 18:54:39 +12:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-12 02:20:18 +12:00
|
|
|
public function run(): void
|
2019-05-09 18:54:39 +12:00
|
|
|
{
|
2019-09-07 05:08:48 +12:00
|
|
|
$projectId = $this->args['projectId'];
|
|
|
|
$userId = $this->args['userId'];
|
2021-08-14 22:13:24 +12:00
|
|
|
$userName = $this->args['userName'];
|
|
|
|
$userEmail = $this->args['userEmail'];
|
|
|
|
$mode = $this->args['mode'];
|
2019-09-07 05:08:48 +12:00
|
|
|
$event = $this->args['event'];
|
|
|
|
$resource = $this->args['resource'];
|
|
|
|
$userAgent = $this->args['userAgent'];
|
|
|
|
$ip = $this->args['ip'];
|
|
|
|
$data = $this->args['data'];
|
2019-12-29 22:47:55 +13:00
|
|
|
|
2021-07-26 11:14:19 +12:00
|
|
|
$dbForInternal = $this->getInternalDB($projectId);
|
2021-06-07 17:17:29 +12:00
|
|
|
$audit = new Audit($dbForInternal);
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2021-08-14 22:13:24 +12:00
|
|
|
$audit->log($userId, $event, $resource, $userAgent, $ip, '', [
|
|
|
|
'userName' => $userName,
|
|
|
|
'userEmail' => $userEmail,
|
|
|
|
'mode' => $mode,
|
|
|
|
'data' => $data,
|
|
|
|
]);
|
2019-05-09 18:54:39 +12:00
|
|
|
}
|
|
|
|
|
2021-06-12 02:20:18 +12:00
|
|
|
public function shutdown(): void
|
2019-05-09 18:54:39 +12:00
|
|
|
{
|
|
|
|
// ... Remove environment for this job
|
|
|
|
}
|
2021-09-01 21:13:23 +12:00
|
|
|
}
|