Merge pull request #12504 from appwrite/feat/email-metadata-response-model

Feat: email metadata response model
This commit is contained in:
Harsh Mahajan authored and GitHub committed 2026-06-06 03:34:27 +05:30
commit b16e60a7f8
4 files changed
+90 -5

No files matched your search

@@ -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' => true,
])
->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.',
@@ -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' => true,
])
->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.',
+5 -5
View File
@@ -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->assertEquals($email, $response['body']['emailCanonical']);
$this->assertIsBool($response['body']['emailIsFree']);
$this->assertIsBool($response['body']['emailIsDisposable']);
$this->assertIsBool($response['body']['emailIsCorporate']);
$this->assertIsBool($response['body']['emailIsCanonical']);
/**
* Test for FAILURE
+15
View File
@@ -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->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
@@ -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',