From 77c50c591075e91f4b469083e1759f6c033d99ce Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 3 Jun 2026 16:40:05 +0530 Subject: [PATCH 1/4] feat: expose email metadata fields in user response model --- src/Appwrite/Utopia/Response/Model/User.php | 35 +++++++++++++++++++++ tests/e2e/Services/Account/AccountBase.php | 10 +++--- tests/e2e/Services/Users/UsersBase.php | 15 +++++++++ 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Utopia/Response/Model/User.php b/src/Appwrite/Utopia/Response/Model/User.php index 01447ccfc2..b15baa98fb 100644 --- a/src/Appwrite/Utopia/Response/Model/User.php +++ b/src/Appwrite/Utopia/Response/Model/User.php @@ -108,6 +108,41 @@ class User extends Model 'default' => false, 'example' => true, ]) + ->addRule('emailCanonical', [ + 'type' => self::TYPE_STRING, + 'description' => 'Canonical form of the user email address.', + 'required' => false, + 'default' => '', + 'example' => 'john@appwrite.io', + ]) + ->addRule('emailIsFree', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the user email is from a free email provider.', + 'required' => false, + 'default' => null, + 'example' => true, + ]) + ->addRule('emailIsDisposable', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the user email is from a disposable email provider.', + 'required' => false, + 'default' => null, + 'example' => false, + ]) + ->addRule('emailIsCorporate', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the user email is from a corporate domain.', + 'required' => false, + 'default' => null, + 'example' => false, + ]) + ->addRule('emailIsCanonical', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the user email is in its canonical form.', + 'required' => false, + 'default' => null, + 'example' => true, + ]) ->addRule('phoneVerification', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Phone verification status.', diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index 8b4dfd4e3e..c752a3bd5a 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -43,11 +43,11 @@ trait AccountBase $this->assertNotEmpty($response['body']['accessedAt']); $this->assertArrayHasKey('targets', $response['body']); $this->assertEquals($email, $response['body']['targets'][0]['identifier']); - $this->assertArrayNotHasKey('emailCanonical', $response['body']); - $this->assertArrayNotHasKey('emailIsFree', $response['body']); - $this->assertArrayNotHasKey('emailIsDisposable', $response['body']); - $this->assertArrayNotHasKey('emailIsCorporate', $response['body']); - $this->assertArrayNotHasKey('emailIsCanonical', $response['body']); + $this->assertArrayHasKey('emailCanonical', $response['body']); + $this->assertArrayHasKey('emailIsFree', $response['body']); + $this->assertArrayHasKey('emailIsDisposable', $response['body']); + $this->assertArrayHasKey('emailIsCorporate', $response['body']); + $this->assertArrayHasKey('emailIsCanonical', $response['body']); /** * Test for FAILURE diff --git a/tests/e2e/Services/Users/UsersBase.php b/tests/e2e/Services/Users/UsersBase.php index b06e2d88e1..828476ac07 100644 --- a/tests/e2e/Services/Users/UsersBase.php +++ b/tests/e2e/Services/Users/UsersBase.php @@ -337,6 +337,11 @@ trait UsersBase $this->assertEquals($body['status'], true); $this->assertGreaterThan('2000-01-01 00:00:00', $body['registration']); $this->assertEquals($body['labels'], []); + $this->assertArrayHasKey('emailCanonical', $body); + $this->assertArrayHasKey('emailIsFree', $body); + $this->assertArrayHasKey('emailIsDisposable', $body); + $this->assertArrayHasKey('emailIsCorporate', $body); + $this->assertArrayHasKey('emailIsCanonical', $body); /** * Test Create with Custom ID for SUCCESS @@ -751,6 +756,11 @@ trait UsersBase } } $this->assertNotNull($user1, 'user1 should exist in user list'); + $this->assertArrayHasKey('emailCanonical', $user1); + $this->assertArrayHasKey('emailIsFree', $user1); + $this->assertArrayHasKey('emailIsDisposable', $user1); + $this->assertArrayHasKey('emailIsCorporate', $user1); + $this->assertArrayHasKey('emailIsCanonical', $user1); // This test ensures that by default, endpoints dont support select queries // If we add select query to this endpoint, you will need to remove this test @@ -1092,6 +1102,11 @@ trait UsersBase $this->assertNotEmpty($user['body']['email']); $this->assertEquals($user['body']['status'], true); $this->assertGreaterThan('2000-01-01 00:00:00', $user['body']['registration']); + $this->assertArrayHasKey('emailCanonical', $user['body']); + $this->assertArrayHasKey('emailIsFree', $user['body']); + $this->assertArrayHasKey('emailIsDisposable', $user['body']); + $this->assertArrayHasKey('emailIsCorporate', $user['body']); + $this->assertArrayHasKey('emailIsCanonical', $user['body']); $sessions = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/sessions', array_merge([ 'content-type' => 'application/json', From 62c52efdbcc55b64f335dca819cac8cd3451fe53 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 3 Jun 2026 17:03:11 +0530 Subject: [PATCH 2/4] fix: add email metadata fields to Account response model --- .../Utopia/Response/Model/Account.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/Account.php b/src/Appwrite/Utopia/Response/Model/Account.php index aaaf501a88..befa88a181 100644 --- a/src/Appwrite/Utopia/Response/Model/Account.php +++ b/src/Appwrite/Utopia/Response/Model/Account.php @@ -78,6 +78,41 @@ class Account extends Model 'default' => false, 'example' => true, ]) + ->addRule('emailCanonical', [ + 'type' => self::TYPE_STRING, + 'description' => 'Canonical form of the user email address.', + 'required' => false, + 'default' => '', + 'example' => 'john@appwrite.io', + ]) + ->addRule('emailIsFree', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the user email is from a free email provider.', + 'required' => false, + 'default' => null, + 'example' => true, + ]) + ->addRule('emailIsDisposable', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the user email is from a disposable email provider.', + 'required' => false, + 'default' => null, + 'example' => false, + ]) + ->addRule('emailIsCorporate', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the user email is from a corporate domain.', + 'required' => false, + 'default' => null, + 'example' => false, + ]) + ->addRule('emailIsCanonical', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the user email is in its canonical form.', + 'required' => false, + 'default' => null, + 'example' => true, + ]) ->addRule('phoneVerification', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Phone verification status.', From 99ae69bdc3a4122d2f21665c6cdeac88ae4eae31 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Fri, 5 Jun 2026 19:44:00 +0530 Subject: [PATCH 3/4] test: assert exact values for email metadata fields in account and user tests --- tests/e2e/Services/Account/AccountBase.php | 10 +++++----- tests/e2e/Services/Users/UsersBase.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index c752a3bd5a..0f55f9dc0d 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -43,11 +43,11 @@ trait AccountBase $this->assertNotEmpty($response['body']['accessedAt']); $this->assertArrayHasKey('targets', $response['body']); $this->assertEquals($email, $response['body']['targets'][0]['identifier']); - $this->assertArrayHasKey('emailCanonical', $response['body']); - $this->assertArrayHasKey('emailIsFree', $response['body']); - $this->assertArrayHasKey('emailIsDisposable', $response['body']); - $this->assertArrayHasKey('emailIsCorporate', $response['body']); - $this->assertArrayHasKey('emailIsCanonical', $response['body']); + $this->assertEquals($email, $response['body']['emailCanonical']); + $this->assertEquals(false, $response['body']['emailIsFree']); + $this->assertEquals(false, $response['body']['emailIsDisposable']); + $this->assertEquals(true, $response['body']['emailIsCorporate']); + $this->assertEquals(true, $response['body']['emailIsCanonical']); /** * Test for FAILURE diff --git a/tests/e2e/Services/Users/UsersBase.php b/tests/e2e/Services/Users/UsersBase.php index 828476ac07..eeadbfa925 100644 --- a/tests/e2e/Services/Users/UsersBase.php +++ b/tests/e2e/Services/Users/UsersBase.php @@ -337,11 +337,11 @@ trait UsersBase $this->assertEquals($body['status'], true); $this->assertGreaterThan('2000-01-01 00:00:00', $body['registration']); $this->assertEquals($body['labels'], []); - $this->assertArrayHasKey('emailCanonical', $body); - $this->assertArrayHasKey('emailIsFree', $body); - $this->assertArrayHasKey('emailIsDisposable', $body); - $this->assertArrayHasKey('emailIsCorporate', $body); - $this->assertArrayHasKey('emailIsCanonical', $body); + $this->assertEquals('cristiano.ronaldo@manchester-united.co.uk', $body['emailCanonical']); + $this->assertEquals(false, $body['emailIsFree']); + $this->assertEquals(false, $body['emailIsDisposable']); + $this->assertEquals(true, $body['emailIsCorporate']); + $this->assertEquals(true, $body['emailIsCanonical']); /** * Test Create with Custom ID for SUCCESS From 6aa9b80e366e05a0ba2dbedfcfad734500b60f47 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Fri, 5 Jun 2026 20:34:37 +0530 Subject: [PATCH 4/4] fix: correct emailIsCorporate example value and relax localhost.test domain assertions --- src/Appwrite/Utopia/Response/Model/Account.php | 2 +- src/Appwrite/Utopia/Response/Model/User.php | 2 +- tests/e2e/Services/Account/AccountBase.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Appwrite/Utopia/Response/Model/Account.php b/src/Appwrite/Utopia/Response/Model/Account.php index befa88a181..fb03bdb155 100644 --- a/src/Appwrite/Utopia/Response/Model/Account.php +++ b/src/Appwrite/Utopia/Response/Model/Account.php @@ -104,7 +104,7 @@ class Account extends Model 'description' => 'Whether the user email is from a corporate domain.', 'required' => false, 'default' => null, - 'example' => false, + 'example' => true, ]) ->addRule('emailIsCanonical', [ 'type' => self::TYPE_BOOLEAN, diff --git a/src/Appwrite/Utopia/Response/Model/User.php b/src/Appwrite/Utopia/Response/Model/User.php index b15baa98fb..f255519bfd 100644 --- a/src/Appwrite/Utopia/Response/Model/User.php +++ b/src/Appwrite/Utopia/Response/Model/User.php @@ -134,7 +134,7 @@ class User extends Model 'description' => 'Whether the user email is from a corporate domain.', 'required' => false, 'default' => null, - 'example' => false, + 'example' => true, ]) ->addRule('emailIsCanonical', [ 'type' => self::TYPE_BOOLEAN, diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index 0f55f9dc0d..1804e621de 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -44,10 +44,10 @@ trait AccountBase $this->assertArrayHasKey('targets', $response['body']); $this->assertEquals($email, $response['body']['targets'][0]['identifier']); $this->assertEquals($email, $response['body']['emailCanonical']); - $this->assertEquals(false, $response['body']['emailIsFree']); - $this->assertEquals(false, $response['body']['emailIsDisposable']); - $this->assertEquals(true, $response['body']['emailIsCorporate']); - $this->assertEquals(true, $response['body']['emailIsCanonical']); + $this->assertIsBool($response['body']['emailIsFree']); + $this->assertIsBool($response['body']['emailIsDisposable']); + $this->assertIsBool($response['body']['emailIsCorporate']); + $this->assertIsBool($response['body']['emailIsCanonical']); /** * Test for FAILURE