From 0cccb7527351e3bc48a0fd01ac9fe437c1bea4ce Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 23 May 2025 12:05:42 +0530 Subject: [PATCH] added encrypt property in the attribute string response model --- app/controllers/api/databases.php | 6 ++++-- src/Appwrite/Utopia/Response/Model/AttributeString.php | 7 +++++++ tests/e2e/Services/Databases/DatabasesBase.php | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index d495a1d924..786b498adf 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -1372,10 +1372,12 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/string 'array' => $array, 'filters' => $filters, ]), $response, $dbForProject, $queueForDatabase, $queueForEvents); - + $stringAttribute = $attribute->getArrayCopy(); + $stringAttribute['encrypt'] = $encrypt; + $stringAttribute = new Document($stringAttribute); $response ->setStatusCode(Response::STATUS_CODE_ACCEPTED) - ->dynamic($attribute, Response::MODEL_ATTRIBUTE_STRING); + ->dynamic($stringAttribute, Response::MODEL_ATTRIBUTE_STRING); }); App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/email') diff --git a/src/Appwrite/Utopia/Response/Model/AttributeString.php b/src/Appwrite/Utopia/Response/Model/AttributeString.php index 12bb42009d..f5559f2206 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeString.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeString.php @@ -24,6 +24,13 @@ class AttributeString extends Attribute 'required' => false, 'example' => 'default', ]) + ->addRule('encrypt', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Encryption status for the string attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried.', + 'default' => false, + 'required' => false, + 'example' => false, + ]) ; } diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 7c0060ecaa..9aed3684de 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -298,7 +298,7 @@ trait DatabasesBase $this->assertEquals($title['body']['type'], 'string'); $this->assertEquals($title['body']['size'], 256); $this->assertEquals($title['body']['required'], true); - + $this->assertFalse($title['body']['encrypt']); $this->assertEquals(202, $description['headers']['status-code']); $this->assertEquals($description['body']['key'], 'description'); $this->assertEquals($description['body']['type'], 'string');