From d67df5feb13fc55ddf3ef9e35d1cb92c1fcd40d9 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 22 Apr 2024 22:45:55 +0200 Subject: [PATCH] Fixed formatting --- app/controllers/api/messaging.php | 8 ++++---- app/controllers/api/projects.php | 4 ++-- app/controllers/api/teams.php | 2 +- app/controllers/api/users.php | 2 +- app/controllers/general.php | 3 +-- app/controllers/shared/api.php | 2 +- app/http.php | 5 +++-- app/init2.php | 1 + app/realtime.php | 8 ++++---- src/Appwrite/Platform/Workers/Audits.php | 2 +- src/Appwrite/Platform/Workers/Deletes.php | 6 +++--- 11 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index d98f4ee283..8c72a9b62f 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -920,7 +920,7 @@ Http::get('/v1/messaging/providers/:providerId/logs') $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject, $authorization); + $audit = new Audit($dbForProject); $resource = 'provider/' . $providerId; $logs = $audit->getLogsByResource($resource, $limit, $offset); $output = []; @@ -2056,7 +2056,7 @@ Http::get('/v1/messaging/topics/:topicId/logs') $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject, $authorization); + $audit = new Audit($dbForProject); $resource = 'topic/' . $topicId; $logs = $audit->getLogsByResource($resource, $limit, $offset); @@ -2427,7 +2427,7 @@ Http::get('/v1/messaging/subscribers/:subscriberId/logs') $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject, $authorization); + $audit = new Audit($dbForProject); $resource = 'subscriber/' . $subscriberId; $logs = $audit->getLogsByResource($resource, $limit, $offset); @@ -3115,7 +3115,7 @@ Http::get('/v1/messaging/messages/:messageId/logs') $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject, $authorization); + $audit = new Audit($dbForProject); $resource = 'message/' . $messageId; $logs = $audit->getLogsByResource($resource, $limit, $offset); diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 6e4415117e..d6e9ca58ff 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -199,9 +199,9 @@ Http::post('/v1/projects') $dbForProject->setNamespace("_{$project->getInternalId()}"); $dbForProject->create(); - $audit = new Audit($dbForProject, $authorization); + $audit = new Audit($dbForProject); $audit->setup(); - $adapter = new TimeLimit('', 0, 1, $dbForProject, $authorization); + $adapter = new TimeLimit('', 0, 1, $dbForProject); $adapter->setup(); /** @var array $collections */ $collections = Config::getParam('collections', [])['projects'] ?? []; diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 0dd1922f05..f55b140815 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1156,7 +1156,7 @@ Http::get('/v1/teams/:teamId/logs') $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject, $authorization); + $audit = new Audit($dbForProject); $resource = 'team/' . $team->getId(); $logs = $audit->getLogsByResource($resource, $limit, $offset); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index fc870045b6..27f605e571 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -788,7 +788,7 @@ Http::get('/v1/users/:userId/logs') $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject, $authorization); + $audit = new Audit($dbForProject); $logs = $audit->getLogsByUser($user->getInternalId(), $limit, $offset); diff --git a/app/controllers/general.php b/app/controllers/general.php index d58efef3dc..cf727a2a05 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -15,7 +15,6 @@ use Appwrite\Utopia\Response\Filters\V17 as ResponseV17; use Appwrite\Utopia\View; use Executor\Executor; use MaxMind\Db\Reader; -use Swoole\Http\Request as SwooleRequest; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; @@ -597,7 +596,7 @@ Http::options() ->inject('queueForUsage') ->inject('geodb') ->inject('authorization') - ->action(function (Route $route, Request $request, Response $response, Database $dbForConsole, callable $getProjectDB, Event $queueForEvents, Usage $queueForUsage, Reader $geodb, Authorization $authorization) { + ->action(function (Route $route, Request $request, Response $response, Database $dbForConsole, callable $getProjectDB, Event $queueForEvents, Usage $queueForUsage, Reader $geodb, Authorization $authorization) { /* * Appwrite Router */ diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 66dc93f029..c46148cfb3 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -336,7 +336,7 @@ Http::init() foreach ($abuseKeyLabel as $abuseKey) { $start = $request->getContentRangeStart(); $end = $request->getContentRangeEnd(); - $timeLimit = new TimeLimit($abuseKey, $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600), $dbForProject, $authorization); + $timeLimit = new TimeLimit($abuseKey, $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600), $dbForProject); $timeLimit ->setParam('{projectId}', $project->getId()) ->setParam('{userId}', $user->getId()) diff --git a/app/http.php b/app/http.php index 0ba12219ee..307b9252fe 100644 --- a/app/http.php +++ b/app/http.php @@ -1,4 +1,5 @@ getCollection(Audit::COLLECTION)->isEmpty()) { - $audit = new Audit($dbForConsole, $authorization); + $audit = new Audit($dbForConsole); $audit->setup(); } if ($dbForConsole->getCollection(TimeLimit::COLLECTION)->isEmpty()) { - $abuse = new TimeLimit("", 0, 1, $dbForConsole, $authorization); + $abuse = new TimeLimit("", 0, 1, $dbForConsole); $abuse->setup(); } diff --git a/app/init2.php b/app/init2.php index 7561fa7cd3..25161d0c31 100644 --- a/app/init2.php +++ b/app/init2.php @@ -1,4 +1,5 @@ onOpen(function (int $connection, SwooleRequest $request) use ($server, * * Abuse limits are connecting 128 times per minute and ip address. */ - $timeLimit = new TimeLimit('url:{url},ip:{ip}', 128, 60, $dbForProject, $auth); + $timeLimit = new TimeLimit('url:{url},ip:{ip}', 128, 60, $dbForProject); $timeLimit ->setParam('{ip}', $request->getIP()) ->setParam('{url}', $request->getURI()); - $abuse = new Abuse($timeLimit, $auth); + $abuse = new Abuse($timeLimit); if (System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled' && $abuse->check()) { throw new Exception(Exception::REALTIME_TOO_MANY_MESSAGES, 'Too many requests'); @@ -540,13 +540,13 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re * * Abuse limits are sending 32 times per minute and connection. */ - $timeLimit = new TimeLimit('url:{url},connection:{connection}', 32, 60, $database, $auth); + $timeLimit = new TimeLimit('url:{url},connection:{connection}', 32, 60, $database); $timeLimit ->setParam('{connection}', $connection) ->setParam('{container}', $containerId); - $abuse = new Abuse($timeLimit, $auth); + $abuse = new Abuse($timeLimit); if ($abuse->check() && System::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled') { throw new Exception(Exception::REALTIME_TOO_MANY_MESSAGES, 'Too many messages.'); diff --git a/src/Appwrite/Platform/Workers/Audits.php b/src/Appwrite/Platform/Workers/Audits.php index 0650906538..4712e58cbe 100644 --- a/src/Appwrite/Platform/Workers/Audits.php +++ b/src/Appwrite/Platform/Workers/Audits.php @@ -63,7 +63,7 @@ class Audits extends Action $userName = $user->getAttribute('name', ''); $userEmail = $user->getAttribute('email', ''); - $audit = new Audit($dbForProject, $auth); + $audit = new Audit($dbForProject); $audit->log( userId: $user->getInternalId(), // Pass first, most verbose event pattern diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 2b474234f8..ec3f142d37 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -660,8 +660,8 @@ class Deletes extends Action { $projectId = $project->getId(); $dbForProject = $getProjectDB($project); - $timeLimit = new TimeLimit("", 0, 1, $dbForProject, $auth); - $abuse = new Abuse($timeLimit, $auth); + $timeLimit = new TimeLimit("", 0, 1, $dbForProject); + $abuse = new Abuse($timeLimit); $status = $abuse->cleanup($abuseRetention); if (!$status) { throw new Exception('Failed to delete Abuse logs for project ' . $projectId); @@ -679,7 +679,7 @@ class Deletes extends Action { $projectId = $project->getId(); $dbForProject = $getProjectDB($project); - $audit = new Audit($dbForProject, $auth); + $audit = new Audit($dbForProject); $status = $audit->cleanup($auditRetention); if (!$status) { throw new Exception('Failed to delete Audit logs for project' . $projectId);