From 68b72f316295bde61e9f0de4b242d823dffe8ffd Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 19 Oct 2025 21:44:22 +0100 Subject: [PATCH] feat: integrate Utopia Emails library for email validation - Added Utopia Emails library as a dependency in composer.json. - Updated email validation references across multiple API controllers to use the new Utopia Emails validator. - Removed the deprecated disposable emails configuration file. - Updated composer.lock to reflect the new library and version changes for existing dependencies. --- app/config/domains/disposable-emails.php | 4 - app/controllers/api/account.php | 2 +- app/controllers/api/messaging.php | 2 +- app/controllers/api/projects.php | 2 +- app/controllers/api/teams.php | 2 +- app/controllers/api/users.php | 2 +- app/init/database/formats.php | 2 +- composer.json | 1 + composer.lock | 86 ++++++++++++++++--- src/Appwrite/GraphQL/Types/Mapper.php | 2 +- src/Appwrite/Network/Validator/Email.php | 51 ++--------- .../Collections/Attributes/Email/Create.php | 2 +- .../Collections/Attributes/Email/Update.php | 2 +- .../TablesDB/Tables/Columns/Email/Create.php | 2 +- .../TablesDB/Tables/Columns/Email/Update.php | 2 +- .../SDK/Specification/Format/OpenAPI3.php | 2 +- .../SDK/Specification/Format/Swagger2.php | 2 +- 17 files changed, 93 insertions(+), 75 deletions(-) delete mode 100644 app/config/domains/disposable-emails.php diff --git a/app/config/domains/disposable-emails.php b/app/config/domains/disposable-emails.php deleted file mode 100644 index b62512838d..0000000000 --- a/app/config/domains/disposable-emails.php +++ /dev/null @@ -1,4 +0,0 @@ -=8.0", + "utopia-php/cli": "^0.15", + "utopia-php/domains": "^0.8", + "utopia-php/fetch": "^0.4", + "utopia-php/framework": "0.33.*" + }, + "require-dev": { + "laravel/pint": "1.25.*", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\Emails\\": "src/Emails" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eldad Fux", + "email": "eldad@appwrite.io" + } + ], + "description": "Utopia Emails library is simple and lite library for parsing and validating email addresses. This library is aiming to be as simple and easy to learn and use.", + "keywords": [ + "RFC5322", + "email", + "emails", + "framework", + "parsing", + "php", + "upf", + "utopia", + "validation" + ], + "support": { + "issues": "https://github.com/utopia-php/emails/issues", + "source": "https://github.com/utopia-php/emails/tree/0.4.0" + }, + "time": "2025-10-19T20:31:42+00:00" + }, { "name": "utopia-php/fetch", "version": "0.4.2", diff --git a/src/Appwrite/GraphQL/Types/Mapper.php b/src/Appwrite/GraphQL/Types/Mapper.php index b74e2a7549..fcf10ef208 100644 --- a/src/Appwrite/GraphQL/Types/Mapper.php +++ b/src/Appwrite/GraphQL/Types/Mapper.php @@ -273,7 +273,7 @@ class Mapper case 'Appwrite\Event\Validator\Event': case 'Appwrite\Event\Validator\FunctionEvent': case 'Appwrite\Network\Validator\CNAME': - case 'Appwrite\Network\Validator\Email': + case 'Utopia\Emails\Validator\Email': case 'Appwrite\Network\Validator\Redirect': case 'Appwrite\Network\Validator\DNS': case 'Appwrite\Network\Validator\Origin': diff --git a/src/Appwrite/Network/Validator/Email.php b/src/Appwrite/Network/Validator/Email.php index 3209a4aada..8052e2bdd0 100644 --- a/src/Appwrite/Network/Validator/Email.php +++ b/src/Appwrite/Network/Validator/Email.php @@ -2,16 +2,17 @@ namespace Appwrite\Network\Validator; -use Utopia\Validator; +use Utopia\Emails\Validator\Email as UtopiaEmailValidator; /** * Email * * Validate that an variable is a valid email address + * Extends the new Utopia Emails validator to maintain backward compatibility * - * @package Utopia\Validator + * @package Appwrite\Network\Validator */ -class Email extends Validator +class Email extends UtopiaEmailValidator { protected bool $allowEmpty; @@ -20,18 +21,6 @@ class Email extends Validator $this->allowEmpty = $allowEmpty; } - /** - * Get Description - * - * Returns validator description - * - * @return string - */ - public function getDescription(): string - { - return 'Value must be a valid email address'; - } - /** * Is valid * @@ -46,34 +35,6 @@ class Email extends Validator return true; } - if (!\filter_var($value, FILTER_VALIDATE_EMAIL)) { - return false; - } - - return true; + return parent::isValid($value); } - - /** - * Is array - * - * Function will return true if object is array. - * - * @return bool - */ - public function isArray(): bool - { - return false; - } - - /** - * Get Type - * - * Returns validator type. - * - * @return string - */ - public function getType(): string - { - return self::TYPE_STRING; - } -} +} \ No newline at end of file diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Create.php index cbfd66e4d9..0b597ae320 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Create.php @@ -4,7 +4,7 @@ namespace Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attribu use Appwrite\Event\Database as EventDatabase; use Appwrite\Event\Event; -use Appwrite\Network\Validator\Email; +use Utopia\Emails\Validator\Email; use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action; use Appwrite\SDK\AuthType; use Appwrite\SDK\Deprecated; diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Update.php index 2446722f7a..d4d9fd95d3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Update.php @@ -3,7 +3,7 @@ namespace Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Email; use Appwrite\Event\Event; -use Appwrite\Network\Validator\Email; +use Utopia\Emails\Validator\Email; use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Action; use Appwrite\SDK\AuthType; use Appwrite\SDK\ContentType; diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Create.php index 3a8d492e4e..5ffe02e9ee 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Create.php @@ -2,7 +2,7 @@ namespace Appwrite\Platform\Modules\Databases\Http\TablesDB\Tables\Columns\Email; -use Appwrite\Network\Validator\Email; +use Utopia\Emails\Validator\Email; use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Email\Create as EmailCreate; use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Update.php index 4d32489357..f67a97207a 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Update.php @@ -2,7 +2,7 @@ namespace Appwrite\Platform\Modules\Databases\Http\TablesDB\Tables\Columns\Email; -use Appwrite\Network\Validator\Email; +use Utopia\Emails\Validator\Email; use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Attributes\Email\Update as EmailUpdate; use Appwrite\SDK\AuthType; use Appwrite\SDK\ContentType; diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index 38613313db..4044df3e0b 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -464,7 +464,7 @@ class OpenAPI3 extends Format Database::VAR_POLYGON => '[[[1, 2], [3, 4], [5, 6], [1, 2]]]', }; break; - case 'Appwrite\Network\Validator\Email': + case 'Utopia\Emails\Validator\Email': $node['schema']['type'] = $validator->getType(); $node['schema']['format'] = 'email'; $node['schema']['x-example'] = 'email@example.com'; diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index d497369b9a..d73604a327 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -471,7 +471,7 @@ class Swagger2 extends Format Database::VAR_POLYGON => '[[[1, 2], [3, 4], [5, 6], [1, 2]]]', }; break; - case 'Appwrite\Network\Validator\Email': + case 'Utopia\Emails\Validator\Email': $node['type'] = $validator->getType(); $node['format'] = 'email'; $node['x-example'] = 'email@example.com';