From b55521e3de5c7470cb3793d2b603110a2655ce2a Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 8 May 2025 09:36:13 +0530 Subject: [PATCH] update: address minor comments by `coderabbitai`. --- .../Databases/Http/Attributes/Action.php | 4 ++-- .../Http/Attributes/Boolean/Create.php | 2 +- .../Http/Attributes/Email/Create.php | 22 +++++++++---------- .../Databases/Http/Collections/XList.php | 3 +-- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Action.php b/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Action.php index 66e8313d33..6d729b8cf3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Action.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Action.php @@ -451,11 +451,11 @@ abstract class Action extends UtopiaAction throw new Exception($this->getNotAvailableException()); } - if ($attribute->getAttribute(('type') !== $type)) { + if ($attribute->getAttribute('type') !== $type) { throw new Exception($this->getTypeInvalidException()); } - if ($attribute->getAttribute('type') === Database::VAR_STRING && $attribute->getAttribute(('filter') !== $filter)) { + if ($attribute->getAttribute('type') === Database::VAR_STRING && $attribute->getAttribute('filter') !== $filter) { throw new Exception($this->getTypeInvalidException()); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Boolean/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Boolean/Create.php index 583e42b4ed..1db55ba33d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Boolean/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Boolean/Create.php @@ -34,7 +34,7 @@ class Create extends Action ->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/boolean') ->desc('Create boolean attribute') ->groups(['api', 'database', 'schema']) - ->label('event', 'databases.[databaseId].collections.[collectionId].collections.[attributeId].create') + ->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create') ->label('scope', 'collections.write') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'attribute.create') diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Email/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Email/Create.php index 9b63f2198a..c33ce9daeb 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Email/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Attributes/Email/Create.php @@ -55,7 +55,7 @@ class Create extends Action ] )) ->param('databaseId', '', new UID(), 'Database ID.') - ->param('tableId', '', new UID(), 'Collection ID.') + ->param('collectionId', '', new UID(), 'Collection ID.') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Email(), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) @@ -68,20 +68,20 @@ class Create extends Action } public function action( - string $databaseId, - string $tableId, - string $key, - ?bool $required, - ?string $default, - bool $array, + string $databaseId, + string $collectionId, + string $key, + ?bool $required, + ?string $default, + bool $array, UtopiaResponse $response, - Database $dbForProject, - EventDatabase $queueForDatabase, - Event $queueForEvents + Database $dbForProject, + EventDatabase $queueForDatabase, + Event $queueForEvents ): void { $attribute = $this->createAttribute( $databaseId, - $tableId, + $collectionId, new Document([ 'key' => $key, 'type' => Database::VAR_STRING, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Collections/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Collections/XList.php index 98246defaa..b6d002a59b 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Collections/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Collections/XList.php @@ -97,8 +97,7 @@ class XList extends Action $cursorDocument = $dbForProject->getDocument('database_' . $database->getInternalId(), $collectionIdId); if ($cursorDocument->isEmpty()) { - $message = - throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, ucfirst($this->getContext()) . " '$collectionIdId' for the 'cursor' value not found."); + throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, ucfirst($this->getContext()) . " '$collectionIdId' for the 'cursor' value not found."); } $cursor->setValue($cursorDocument);