From 867f3e8c0869083e9a59795c397f315683b00afa Mon Sep 17 00:00:00 2001 From: prateek banga Date: Fri, 4 Aug 2023 19:00:08 +0530 Subject: [PATCH 01/22] adds messaging providers rename providers.php to authProviders.php --- .../{providers.php => authProviders.php} | 0 app/config/messagingProviders.php | 299 ++++++++++++++++++ app/init.php | 3 +- 3 files changed, 301 insertions(+), 1 deletion(-) rename app/config/{providers.php => authProviders.php} (100%) create mode 100644 app/config/messagingProviders.php diff --git a/app/config/providers.php b/app/config/authProviders.php similarity index 100% rename from app/config/providers.php rename to app/config/authProviders.php diff --git a/app/config/messagingProviders.php b/app/config/messagingProviders.php new file mode 100644 index 0000000000..c60a80d7a0 --- /dev/null +++ b/app/config/messagingProviders.php @@ -0,0 +1,299 @@ + [ + 'mailchimp' => [ + 'name' => 'Mailchimp', + 'developers' => 'https://mailchimp.com/developer/marketing/api/', + 'icon' => 'icon-mailchimp', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'mailgun' => [ + 'name' => 'Mailgun', + 'developers' => 'https://documentation.mailgun.com/', + 'icon' => 'icon-mailgun', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'mailjet' => [ + 'name' => 'Mailjet', + 'developers' => 'https://dev.mailjet.com/', + 'icon' => 'icon-mailjet', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'postmark' => [ + 'name' => 'Postmark', + 'developers' => 'https://postmarkapp.com/developer', + 'icon' => 'icon-postmark', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'sendgrid' => [ + 'name' => 'Sendgrid', + 'developers' => 'https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/', + 'icon' => 'icon-sendgrid', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'sendinblue' => [ + 'name' => 'SendinBlue', + 'developers' => 'https://developers.sendinblue.com/', + 'icon' => 'icon-sendinblue', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'mailslurp' => [ + 'name' => 'MailSlurp', + 'developers' => 'https://www.mailslurp.com/docs/', + 'icon' => 'icon-mailslurp', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'elasticemail' => [ + 'name' => 'ElasticEmail', + 'developers' => 'https://api.elasticemail.com/public/help', + 'icon' => 'icon-elasticemail', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'ses' => [ + 'name' => 'SES', + 'developers' => 'https://docs.aws.amazon.com/ses/latest/APIReference/', + 'icon' => 'icon-ses', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + ], + 'sms' => [ + 'africastalking' => [ + 'name' => 'Africa\'s Talking', + 'developers' => 'https://developers.africastalking.com/', + 'icon' => 'icon-africastalking', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'clickatell' => [ + 'name' => 'Clickatell', + 'developers' => 'https://www.clickatell.com/developers/api-docs/', + 'icon' => 'icon-clickatell', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'infobip' => [ + 'name' => 'Infobip', + 'developers' => 'https://www.infobip.com/docs/', + 'icon' => 'icon-infobip', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'msg91' => [ + 'name' => 'Msg91', + 'developers' => 'https://docs.msg91.com/reference/overview', + 'icon' => 'icon-msg91', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'plivo' => [ + 'name' => 'Plivo', + 'developers' => 'https://developers.plivo.com/', + 'icon' => 'icon-plivo', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'sinch' => [ + 'name' => 'Sinch', + 'developers' => 'https://developers.sinch.com/', + 'icon' => 'icon-sinch', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'sms77' => [ + 'name' => 'Sms77', + 'developers' => 'https://sms77.io/docs/gateway/', + 'icon' => 'icon-sms77', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'telesign' => [ + 'name' => 'Telesign', + 'developers' => 'https://developer.telesign.com/enterprise/docs', + 'icon' => 'icon-telesign', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'textmagic' => [ + 'name' => 'TextMagic', + 'developers' => 'https://www.textmagic.com/docs/api/', + 'icon' => 'icon-twilio', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'twilio' => [ + 'name' => 'Twilio', + 'developers' => 'https://www.twilio.com/docs/sms', + 'icon' => 'icon-twilio', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'twilio-notify' => [ + 'name' => 'Twilio Notify', + 'developers' => 'https://www.twilio.com/docs/notify', + 'icon' => 'icon-twilio', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'vonage' => [ + 'name' => 'Vonage', + 'developers' => 'https://developer.nexmo.com/', + 'icon' => 'icon-vonage', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + ], + 'push' => [ + 'apns' => [ + 'name' => 'APNS', + 'developers' => 'https://developer.apple.com/documentation/usernotifications', + 'icon' => 'icon-apns', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'fcm' => [ + 'name' => 'FCM', + 'developers' => 'https://firebase.google.com/docs/cloud-messaging', + 'icon' => 'icon-fcm', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'one_signal' => [ + 'name' => 'OneSignal', + 'developers' => 'https://documentation.onesignal.com/docs', + 'icon' => 'icon-onesignal', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'pushbullet' => [ + 'name' => 'PushBullet', + 'developers' => 'https://docs.pushbullet.com/', + 'icon' => 'icon-pushbullet', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'pusher' => [ + 'name' => 'Pusher', + 'developers' => 'https://pusher.com/docs', + 'icon' => 'icon-pusher', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'pushwoosh' => [ + 'name' => 'Pushwoosh', + 'developers' => 'https://www.pushwoosh.com/docs/', + 'icon' => 'icon-pushwoosh', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'urban_airship' => [ + 'name' => 'Urban Airship', + 'developers' => 'https://docs.airship.com/api/', + 'icon' => 'icon-urbanairship', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + 'web_push' => [ + 'name' => 'WebPush', + 'developers' => 'https://developer.mozilla.org/en-US/docs/Web/API/Push_API', + 'icon' => 'icon-webpush', + 'enabled' => false, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], + ] +]; diff --git a/app/init.php b/app/init.php index 6fb707acb0..1464d20c3d 100644 --- a/app/init.php +++ b/app/init.php @@ -188,7 +188,7 @@ App::setMode(App::getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION)); Config::load('events', __DIR__ . '/config/events.php'); Config::load('auth', __DIR__ . '/config/auth.php'); Config::load('errors', __DIR__ . '/config/errors.php'); -Config::load('providers', __DIR__ . '/config/providers.php'); +Config::load('providers', __DIR__ . '/config/authProviders.php'); Config::load('platforms', __DIR__ . '/config/platforms.php'); Config::load('collections', __DIR__ . '/config/collections.php'); Config::load('runtimes', __DIR__ . '/config/runtimes.php'); @@ -212,6 +212,7 @@ Config::load('storage-logos', __DIR__ . '/config/storage/logos.php'); Config::load('storage-mimes', __DIR__ . '/config/storage/mimes.php'); Config::load('storage-inputs', __DIR__ . '/config/storage/inputs.php'); Config::load('storage-outputs', __DIR__ . '/config/storage/outputs.php'); +Config::load('messagingProviders', __DIR__ . '/config/messagingProviders.php'); $user = App::getEnv('_APP_REDIS_USER', ''); $pass = App::getEnv('_APP_REDIS_PASS', ''); From 4ca798f4d7bd5181504d43d828b475af00c34c15 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Fri, 4 Aug 2023 19:01:55 +0530 Subject: [PATCH 02/22] fix lint issues --- app/config/messagingProviders.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/config/messagingProviders.php b/app/config/messagingProviders.php index c60a80d7a0..a33665196b 100644 --- a/app/config/messagingProviders.php +++ b/app/config/messagingProviders.php @@ -1,4 +1,5 @@ [ 'mailchimp' => [ From 5baa0d674ae2d1af4a1622f65a4cd4fb7d8755ff Mon Sep 17 00:00:00 2001 From: prateek banga Date: Mon, 7 Aug 2023 14:17:02 +0530 Subject: [PATCH 03/22] rename providers.php to authProviders.php in docs and test --- docs/tutorials/add-oauth2-provider.md | 6 +++--- tests/e2e/Services/Projects/ProjectsConsoleClientTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/add-oauth2-provider.md b/docs/tutorials/add-oauth2-provider.md index 4aa20649ca..93698d7b64 100644 --- a/docs/tutorials/add-oauth2-provider.md +++ b/docs/tutorials/add-oauth2-provider.md @@ -37,7 +37,7 @@ Finally, you will need to create a `feat-XXX-YYY-oauth` branch based on the `mas The first step in adding a new OAuth2 provider is to add it to the list of providers located at: ``` -app/config/providers.php +app/config/authProviders.php ``` Make sure to fill in all data needed and that your provider array key name: @@ -45,7 +45,7 @@ Make sure to fill in all data needed and that your provider array key name: - is in [`camelCase`](https://en.wikipedia.org/wiki/Camel_case) format - has no spaces or special characters -> Please make sure to keep the list of providers in `providers.php` in the alphabetical order A-Z. +> Please make sure to keep the list of providers in `authProviders.php` in the alphabetical order A-Z. ### 2.2 Add Provider Logo @@ -199,7 +199,7 @@ If you need any help with the contribution, feel free to head over to [our Disco If your OAuth provider requires special configuration apart from `clientId` and `clientSecret` you can create a custom form. Currently this is being realized through putting all custom fields as JSON into the `clientSecret` field to keep the project API stable. You can implement your custom form following these steps: -1. Add your custom form in `app/views/console/users/oauth/[PROVIDER].phtml`. Below is a template you can use. Add the filename to `app/config/providers.php`. +1. Add your custom form in `app/views/console/users/oauth/[PROVIDER].phtml`. Below is a template you can use. Add the filename to `app/config/authProviders.php`. ```php Date: Mon, 7 Aug 2023 15:54:00 +0530 Subject: [PATCH 04/22] rename provider param in config --- app/config/collections.php | 2 +- app/controllers/api/account.php | 10 ++-- app/controllers/api/projects.php | 2 +- app/controllers/api/users.php | 2 +- app/init.php | 2 +- composer.lock | 58 +++++++++---------- src/Appwrite/Migration/Version/V15.php | 2 +- src/Appwrite/Migration/Version/V16.php | 2 +- .../Utopia/Response/Model/Project.php | 2 +- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 6a608fe5f5..0c7e6e0a12 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -5,7 +5,7 @@ use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Helpers\ID; -$providers = Config::getParam('providers', []); +$providers = Config::getParam('authProviders', []); $auth = Config::getParam('auth', []); /** diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index bb19e2222d..d525e09da4 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -280,7 +280,7 @@ App::get('/v1/account/sessions/oauth2/:provider') ->label('sdk.methodType', 'webAuth') ->label('abuse-limit', 50) ->label('abuse-key', 'ip:{ip}') - ->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 Provider. Currently, supported providers are: ' . \implode(', ', \array_keys(\array_filter(Config::getParam('providers'), fn($node) => (!$node['mock'])))) . '.') + ->param('provider', '', new WhiteList(\array_keys(Config::getParam('authProviders')), true), 'OAuth2 Provider. Currently, supported providers are: ' . \implode(', ', \array_keys(\array_filter(Config::getParam('authProviders'), fn($node) => (!$node['mock'])))) . '.') ->param('success', '', fn($clients) => new Host($clients), 'URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', true, ['clients']) ->param('failure', '', fn($clients) => new Host($clients), 'URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', true, ['clients']) ->param('scopes', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) @@ -338,7 +338,7 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->label('scope', 'public') ->label('docs', false) ->param('projectId', '', new Text(1024), 'Project ID.') - ->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 provider.') + ->param('provider', '', new WhiteList(\array_keys(Config::getParam('authProviders')), true), 'OAuth2 provider.') ->param('code', '', new Text(2048, 0), 'OAuth2 code.', true) ->param('state', '', new Text(2048), 'Login state params.', true) ->param('error', '', new Text(2048, 0), 'Error code returned from the OAuth2 provider.', true) @@ -371,7 +371,7 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->label('origin', '*') ->label('docs', false) ->param('projectId', '', new Text(1024), 'Project ID.') - ->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 provider.') + ->param('provider', '', new WhiteList(\array_keys(Config::getParam('authProviders')), true), 'OAuth2 provider.') ->param('code', '', new Text(2048, 0), 'OAuth2 code.', true) ->param('state', '', new Text(2048), 'Login state params.', true) ->param('error', '', new Text(2048, 0), 'Error code returned from the OAuth2 provider.', true) @@ -410,7 +410,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') ->label('docs', false) ->label('usage.metric', 'sessions.{scope}.requests.create') ->label('usage.params', ['provider:{request.provider}']) - ->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'OAuth2 provider.') + ->param('provider', '', new WhiteList(\array_keys(Config::getParam('authProviders')), true), 'OAuth2 provider.') ->param('code', '', new Text(2048, 0), 'OAuth2 code.', true) ->param('state', '', new Text(2048), 'OAuth2 state params.', true) ->param('error', '', new Text(2048, 0), 'Error code returned from the OAuth2 provider.', true) @@ -438,7 +438,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') throw new Exception(Exception::PROJECT_PROVIDER_UNSUPPORTED); } - $providers = Config::getParam('providers'); + $providers = Config::getParam('authProviders'); $providerName = $providers[$provider]['name'] ?? ''; /** @var Appwrite\Auth\OAuth2 $oauth2 */ diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 80cc111695..0c628fdd78 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -531,7 +531,7 @@ App::patch('/v1/projects/:projectId/oauth2') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_PROJECT) ->param('projectId', '', new UID(), 'Project unique ID.') - ->param('provider', '', new WhiteList(\array_keys(Config::getParam('providers')), true), 'Provider Name') + ->param('provider', '', new WhiteList(\array_keys(Config::getParam('authProviders')), true), 'Provider Name') ->param('appId', null, new Text(256), 'Provider app ID. Max length: 256 chars.', true) ->param('secret', null, new text(512), 'Provider secret key. Max length: 512 chars.', true) ->param('enabled', null, new Boolean(), 'Provider status. Set to \'false\' to disable new session creation.', true) diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 21c84e8a07..2803f33be6 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -1140,7 +1140,7 @@ App::get('/v1/users/usage') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_USAGE_USERS) ->param('range', '30d', new WhiteList(['24h', '7d', '30d', '90d'], true), 'Date range.', true) - ->param('provider', '', new WhiteList(\array_merge(['email', 'anonymous'], \array_map(fn ($value) => "oauth-" . $value, \array_keys(Config::getParam('providers', [])))), true), 'Provider Name.', true) + ->param('provider', '', new WhiteList(\array_merge(['email', 'anonymous'], \array_map(fn ($value) => "oauth-" . $value, \array_keys(Config::getParam('authProviders', [])))), true), 'Provider Name.', true) ->inject('response') ->inject('dbForProject') ->inject('register') diff --git a/app/init.php b/app/init.php index 1464d20c3d..8c799163b8 100644 --- a/app/init.php +++ b/app/init.php @@ -188,7 +188,7 @@ App::setMode(App::getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION)); Config::load('events', __DIR__ . '/config/events.php'); Config::load('auth', __DIR__ . '/config/auth.php'); Config::load('errors', __DIR__ . '/config/errors.php'); -Config::load('providers', __DIR__ . '/config/authProviders.php'); +Config::load('authProviders', __DIR__ . '/config/authProviders.php'); Config::load('platforms', __DIR__ . '/config/platforms.php'); Config::load('collections', __DIR__ . '/config/collections.php'); Config::load('runtimes', __DIR__ . '/config/runtimes.php'); diff --git a/composer.lock b/composer.lock index 7bd2b3a78a..5f02dacceb 100644 --- a/composer.lock +++ b/composer.lock @@ -607,16 +607,16 @@ }, { "name": "guzzlehttp/promises", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6" + "reference": "111166291a0f8130081195ac4556a5587d7f1b5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/3a494dc7dc1d7d12e511890177ae2d0e6c107da6", - "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6", + "url": "https://api.github.com/repos/guzzle/promises/zipball/111166291a0f8130081195ac4556a5587d7f1b5d", + "reference": "111166291a0f8130081195ac4556a5587d7f1b5d", "shasum": "" }, "require": { @@ -670,7 +670,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.0" + "source": "https://github.com/guzzle/promises/tree/2.0.1" }, "funding": [ { @@ -686,20 +686,20 @@ "type": "tidelift" } ], - "time": "2023-05-21T13:50:22+00:00" + "time": "2023-08-03T15:11:55+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.5.0", + "version": "2.6.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6" + "reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/8bd7c33a0734ae1c5d074360512beb716bef3f77", + "reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77", "shasum": "" }, "require": { @@ -786,7 +786,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.5.0" + "source": "https://github.com/guzzle/psr7/tree/2.6.0" }, "funding": [ { @@ -802,7 +802,7 @@ "type": "tidelift" } ], - "time": "2023-04-17T16:11:26+00:00" + "time": "2023-08-03T15:06:02+00:00" }, { "name": "influxdb/influxdb-php", @@ -994,16 +994,16 @@ }, { "name": "matomo/device-detector", - "version": "6.1.3", + "version": "6.1.4", "source": { "type": "git", "url": "https://github.com/matomo-org/device-detector.git", - "reference": "3e0fac7e77f3faadc3858fea9f5fa7efeb9cf239" + "reference": "74f6c4f6732b3ad6cdf25560746841d522969112" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/matomo-org/device-detector/zipball/3e0fac7e77f3faadc3858fea9f5fa7efeb9cf239", - "reference": "3e0fac7e77f3faadc3858fea9f5fa7efeb9cf239", + "url": "https://api.github.com/repos/matomo-org/device-detector/zipball/74f6c4f6732b3ad6cdf25560746841d522969112", + "reference": "74f6c4f6732b3ad6cdf25560746841d522969112", "shasum": "" }, "require": { @@ -1059,7 +1059,7 @@ "source": "https://github.com/matomo-org/matomo", "wiki": "https://dev.matomo.org/" }, - "time": "2023-06-06T11:58:07+00:00" + "time": "2023-08-02T08:48:53+00:00" }, { "name": "mongodb/mongodb", @@ -3785,16 +3785,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.23.0", + "version": "1.23.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "a2b24135c35852b348894320d47b3902a94bc494" + "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/a2b24135c35852b348894320d47b3902a94bc494", - "reference": "a2b24135c35852b348894320d47b3902a94bc494", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26", + "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26", "shasum": "" }, "require": { @@ -3826,9 +3826,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.1" }, - "time": "2023-07-23T22:17:56+00:00" + "time": "2023-08-03T16:32:59+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4758,16 +4758,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.5", + "version": "5.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { @@ -4810,7 +4810,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" }, "funding": [ { @@ -4818,7 +4818,7 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { "name": "sebastian/lines-of-code", diff --git a/src/Appwrite/Migration/Version/V15.php b/src/Appwrite/Migration/Version/V15.php index 60f5fa20ab..b6deb780da 100644 --- a/src/Appwrite/Migration/Version/V15.php +++ b/src/Appwrite/Migration/Version/V15.php @@ -34,7 +34,7 @@ class V15 extends Migration ['email', 'anonymous'], \array_map( fn ($value) => "oauth-" . $value, - \array_keys(Config::getParam('providers', [])) + \array_keys(Config::getParam('authProviders', [])) ) ); diff --git a/src/Appwrite/Migration/Version/V16.php b/src/Appwrite/Migration/Version/V16.php index 1d56b246d6..bee2236dfb 100644 --- a/src/Appwrite/Migration/Version/V16.php +++ b/src/Appwrite/Migration/Version/V16.php @@ -126,7 +126,7 @@ class V16 extends Migration */ $authProviders = $document->getAttribute('authProviders', []); - foreach (Config::getParam('providers') as $provider => $value) { + foreach (Config::getParam('authProviders') as $provider => $value) { if (!$value['enabled']) { continue; } diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index 7671d412fb..0fc334abc2 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -315,7 +315,7 @@ class Project extends Model } // Providers - $providers = Config::getParam('providers', []); + $providers = Config::getParam('authProviders', []); $providerValues = $document->getAttribute('authProviders', []); $projectProviders = []; From be1afc61b0a27739a9a6ba8c052271afac3ba03c Mon Sep 17 00:00:00 2001 From: prateek banga Date: Mon, 7 Aug 2023 16:19:55 +0530 Subject: [PATCH 05/22] rename provider model to AuthProvider --- src/Appwrite/Utopia/Response.php | 9 +++++---- .../Model/{Provider.php => AuthProvider.php} | 12 ++++++------ src/Appwrite/Utopia/Response/Model/Project.php | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) rename src/Appwrite/Utopia/Response/Model/{Provider.php => AuthProvider.php} (82%) diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index e65f65cd52..902d50b0c7 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -31,6 +31,7 @@ use Appwrite\Utopia\Response\Model\AttributeIP; use Appwrite\Utopia\Response\Model\AttributeURL; use Appwrite\Utopia\Response\Model\AttributeDatetime; use Appwrite\Utopia\Response\Model\AttributeRelationship; +use Appwrite\Utopia\Response\Model\AuthProvider; use Appwrite\Utopia\Response\Model\BaseList; use Appwrite\Utopia\Response\Model\Collection; use Appwrite\Utopia\Response\Model\Database; @@ -205,8 +206,8 @@ class Response extends SwooleResponse public const MODEL_WEBHOOK_LIST = 'webhookList'; public const MODEL_KEY = 'key'; public const MODEL_KEY_LIST = 'keyList'; - public const MODEL_PROVIDER = 'provider'; - public const MODEL_PROVIDER_LIST = 'providerList'; + public const MODEL_AUTH_PROVIDER = 'authProvider'; + public const MODEL_AUTH_PROVIDER_LIST = 'authProviderList'; public const MODEL_PLATFORM = 'platform'; public const MODEL_PLATFORM_LIST = 'platformList'; public const MODEL_DOMAIN = 'domain'; @@ -277,7 +278,7 @@ class Response extends SwooleResponse ->setModel(new BaseList('Projects List', self::MODEL_PROJECT_LIST, 'projects', self::MODEL_PROJECT, true, false)) ->setModel(new BaseList('Webhooks List', self::MODEL_WEBHOOK_LIST, 'webhooks', self::MODEL_WEBHOOK, true, false)) ->setModel(new BaseList('API Keys List', self::MODEL_KEY_LIST, 'keys', self::MODEL_KEY, true, false)) - ->setModel(new BaseList('Providers List', self::MODEL_PROVIDER_LIST, 'platforms', self::MODEL_PROVIDER, true, false)) + ->setModel(new BaseList('Providers List', self::MODEL_AUTH_PROVIDER_LIST, 'platforms', self::MODEL_AUTH_PROVIDER, true, false)) ->setModel(new BaseList('Platforms List', self::MODEL_PLATFORM_LIST, 'platforms', self::MODEL_PLATFORM, true, false)) ->setModel(new BaseList('Domains List', self::MODEL_DOMAIN_LIST, 'domains', self::MODEL_DOMAIN, true, false)) ->setModel(new BaseList('Countries List', self::MODEL_COUNTRY_LIST, 'countries', self::MODEL_COUNTRY)) @@ -334,7 +335,7 @@ class Response extends SwooleResponse ->setModel(new Webhook()) ->setModel(new Key()) ->setModel(new Domain()) - ->setModel(new Provider()) + ->setModel(new AuthProvider()) ->setModel(new Platform()) ->setModel(new Variable()) ->setModel(new Country()) diff --git a/src/Appwrite/Utopia/Response/Model/Provider.php b/src/Appwrite/Utopia/Response/Model/AuthProvider.php similarity index 82% rename from src/Appwrite/Utopia/Response/Model/Provider.php rename to src/Appwrite/Utopia/Response/Model/AuthProvider.php index c589011a46..0171a3c152 100644 --- a/src/Appwrite/Utopia/Response/Model/Provider.php +++ b/src/Appwrite/Utopia/Response/Model/AuthProvider.php @@ -5,7 +5,7 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Model; -class Provider extends Model +class AuthProvider extends Model { /** * @var bool @@ -17,13 +17,13 @@ class Provider extends Model $this ->addRule('key', [ 'type' => self::TYPE_STRING, - 'description' => 'Provider.', + 'description' => 'Auth Provider.', 'default' => '', 'example' => 'github', ]) ->addRule('name', [ 'type' => self::TYPE_STRING, - 'description' => 'Provider name.', + 'description' => 'Auth Provider name.', 'default' => '', 'example' => 'GitHub', ]) @@ -41,7 +41,7 @@ class Provider extends Model ]) ->addRule('enabled', [ 'type' => self::TYPE_BOOLEAN, - 'description' => 'Provider is active and can be used to create session.', + 'description' => 'Auth Provider is active and can be used to create session.', 'example' => '', ]) ; @@ -54,7 +54,7 @@ class Provider extends Model */ public function getName(): string { - return 'Provider'; + return 'AuthProvider'; } /** @@ -64,6 +64,6 @@ class Provider extends Model */ public function getType(): string { - return Response::MODEL_PROVIDER; + return Response::MODEL_AUTH_PROVIDER; } } diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index 0fc334abc2..cebf951596 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -133,8 +133,8 @@ class Project extends Model 'example' => true, ]) ->addRule('providers', [ - 'type' => Response::MODEL_PROVIDER, - 'description' => 'List of Providers.', + 'type' => Response::MODEL_AUTH_PROVIDER, + 'description' => 'List of Auth Providers.', 'default' => [], 'example' => [new \stdClass()], 'array' => true, From 3e70a19e4fd716b1818f2bd9940a975f199085e4 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Mon, 7 Aug 2023 20:56:03 +0530 Subject: [PATCH 06/22] add response models required for messaging service --- src/Appwrite/Utopia/Response.php | 26 +++++ .../Utopia/Response/Model/Message.php | 97 +++++++++++++++++++ .../Utopia/Response/Model/Provider.php | 63 ++++++++++++ .../Utopia/Response/Model/Subsciber.php | 63 ++++++++++++ src/Appwrite/Utopia/Response/Model/Target.php | 70 +++++++++++++ src/Appwrite/Utopia/Response/Model/Topic.php | 64 ++++++++++++ 6 files changed, 383 insertions(+) create mode 100644 src/Appwrite/Utopia/Response/Model/Message.php create mode 100644 src/Appwrite/Utopia/Response/Model/Provider.php create mode 100644 src/Appwrite/Utopia/Response/Model/Subsciber.php create mode 100644 src/Appwrite/Utopia/Response/Model/Target.php create mode 100644 src/Appwrite/Utopia/Response/Model/Topic.php diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 902d50b0c7..37e6d7682b 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -2,6 +2,9 @@ namespace Appwrite\Utopia; +use Appwrite\Utopia\Response\Model\Message; +use Appwrite\Utopia\Response\Model\Subscriber; +use Appwrite\Utopia\Response\Model\Topic; use Exception; use Swoole\Http\Request as SwooleRequest; use Utopia\Swoole\Response as SwooleResponse; @@ -78,6 +81,7 @@ use Appwrite\Utopia\Response\Model\LocaleCode; use Appwrite\Utopia\Response\Model\Mock; // Keep last use Appwrite\Utopia\Response\Model\Provider; use Appwrite\Utopia\Response\Model\Runtime; +use Appwrite\Utopia\Response\Model\Target; use Appwrite\Utopia\Response\Model\TemplateSMS; use Appwrite\Utopia\Response\Model\UsageBuckets; use Appwrite\Utopia\Response\Model\UsageCollection; @@ -180,6 +184,18 @@ class Response extends SwooleResponse public const MODEL_PHONE = 'phone'; public const MODEL_PHONE_LIST = 'phoneList'; + // Messaging + public const MODEL_PROVIDER = 'provider'; + public const MODEL_PROVIDER_LIST = 'providerList'; + public const MODEL_MESSAGE = 'message'; + public const MODEL_MESSAGE_LIST = 'messageList'; + public const MODEL_TOPIC = 'topic'; + public const MODEL_TOPIC_LIST = 'topicList'; + public const MODEL_SUBSCRIBER = 'subscriber'; + public const MODEL_SUBSCRIBER_LIST = 'subscriberList'; + public const MODEL_TARGET = 'target'; + public const MODEL_TARGET_LIST = 'targetList'; + // Teams public const MODEL_TEAM = 'team'; public const MODEL_TEAM_LIST = 'teamList'; @@ -289,6 +305,11 @@ class Response extends SwooleResponse ->setModel(new BaseList('Metric List', self::MODEL_METRIC_LIST, 'metrics', self::MODEL_METRIC, true, false)) ->setModel(new BaseList('Variables List', self::MODEL_VARIABLE_LIST, 'variables', self::MODEL_VARIABLE)) ->setModel(new BaseList('Locale codes list', self::MODEL_LOCALE_CODE_LIST, 'localeCodes', self::MODEL_LOCALE_CODE)) + ->setModel(new BaseList('Provider list', self::MODEL_PROVIDER_LIST, 'providers', self::MODEL_PROVIDER)) + ->setModel(new BaseList('Message list', self::MODEL_MESSAGE_LIST, 'messages', self::MODEL_MESSAGE)) + ->setModel(new BaseList('Topic list', self::MODEL_TOPIC_LIST, 'topics', self::MODEL_TOPIC)) + ->setModel(new BaseList('Subscriber list', self::MODEL_SUBSCRIBER_LIST, 'subscribers', self::MODEL_SUBSCRIBER)) + ->setModel(new BaseList('Target list', self::MODEL_TARGET_LIST, 'targets', self::MODEL_TARGET)) // Entities ->setModel(new Database()) ->setModel(new Collection()) @@ -361,6 +382,11 @@ class Response extends SwooleResponse ->setModel(new TemplateSMS()) ->setModel(new TemplateEmail()) ->setModel(new ConsoleVariables()) + ->setModel(new Provider()) + ->setModel(new Message()) + ->setModel(new Topic()) + ->setModel(new Subscriber()) + ->setModel(new Target()) // Verification // Recovery // Tests (keep last) diff --git a/src/Appwrite/Utopia/Response/Model/Message.php b/src/Appwrite/Utopia/Response/Model/Message.php new file mode 100644 index 0000000000..f8a7913ff6 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Message.php @@ -0,0 +1,97 @@ +addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Message ID.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('providerId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider Id for the message.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('data', [ + 'type' => self::TYPE_JSON, + 'description' => 'Message Data.', + 'default' => '', + 'required' => false, + 'example' => '', + ]) + ->addRule('to', [ + 'type' => self::TYPE_STRING, + 'description' => 'Recipient of message.', + 'default' => '', + 'example' => ['user-1'], + ]) + ->addRule('deliveryTime', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Recipient of message.', + 'required' => false, + 'default' => DateTime::now(), + 'example' => DateTime::now(), + ]) + ->addRule('deliveryError', [ + 'type' => self::TYPE_STRING, + 'description' => 'Delivery error if any.', + 'required' => false, + 'default' => '', + 'example' => 'Provider not valid.', + ]) + ->addRule('deliveredTo', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of recipients the message was delivered to.', + 'default' => '', + 'example' => 1, + ]) + ->addRule('delivered', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Status of delivery.', + 'default' => '', + 'example' => true, + ]) + ->addRule('search', [ + 'type' => self::TYPE_STRING, + 'description' => 'Field that can be used for searching message.', + 'default' => '', + 'example' => 'Hello everyone', + ]); + } + + /** + * Get Name + * + * @return string + */ + public function getName(): string + { + return 'Message'; + } + + /** + * Get Type + * + * @return string + */ + public function getType(): string + { + return Response::MODEL_MESSAGE; + } +} diff --git a/src/Appwrite/Utopia/Response/Model/Provider.php b/src/Appwrite/Utopia/Response/Model/Provider.php new file mode 100644 index 0000000000..6bd43261ad --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Provider.php @@ -0,0 +1,63 @@ +addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider ID.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => self::TYPE_STRING, + 'description' => 'The user-given name for the provider instance.', + 'default' => '', + 'example' => 'Mailgun', + ]) + ->addRule('provider', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider name setup in Utopia.', + 'default' => '', + 'example' => 'mailgun', + ]) + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Type of provider.', + 'default' => '', + 'example' => 'sms', + ]); + } + + /** + * Get Name + * + * @return string + */ + public function getName(): string + { + return 'Provider'; + } + + /** + * Get Type + * + * @return string + */ + public function getType(): string + { + return Response::MODEL_PROVIDER; + } +} diff --git a/src/Appwrite/Utopia/Response/Model/Subsciber.php b/src/Appwrite/Utopia/Response/Model/Subsciber.php new file mode 100644 index 0000000000..a72146ccf3 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Subsciber.php @@ -0,0 +1,63 @@ +addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Subscriber ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('userId', [ + 'type' => self::TYPE_STRING, + 'description' => 'User ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('targetId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Target ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('topicId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Topic ID.', + 'default' => '', + 'example' => '259125845563242502', + ]); + } + + /** + * Get Name + * + * @return string + */ + public function getName(): string + { + return 'Subscriber'; + } + + /** + * Get Type + * + * @return string + */ + public function getType(): string + { + return Response::MODEL_SUBSCRIBER; + } +} diff --git a/src/Appwrite/Utopia/Response/Model/Target.php b/src/Appwrite/Utopia/Response/Model/Target.php new file mode 100644 index 0000000000..1ecc0126cc --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Target.php @@ -0,0 +1,70 @@ +addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Target ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('userId', [ + 'type' => self::TYPE_STRING, + 'description' => 'User ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('providerId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider ID.', + 'required' => false, + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('providerType', [ + 'type' => self::TYPE_STRING, + 'description' => 'The type of provider supported by this target.', + 'default' => '', + 'example' => 'sms', + ]) + ->addRule('identifier', [ + 'type' => self::TYPE_STRING, + 'description' => 'The target identifier.', + 'default' => '', + 'example' => 'token', + ]); + } + + /** + * Get Name + * + * @return string + */ + public function getName(): string + { + return 'Target'; + } + + /** + * Get Type + * + * @return string + */ + public function getType(): string + { + return Response::MODEL_TARGET; + } +} diff --git a/src/Appwrite/Utopia/Response/Model/Topic.php b/src/Appwrite/Utopia/Response/Model/Topic.php new file mode 100644 index 0000000000..d22364f917 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Topic.php @@ -0,0 +1,64 @@ +addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Topic ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('providerId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('name', [ + 'type' => self::TYPE_STRING, + 'description' => 'The name of the topic.', + 'default' => '', + 'example' => 'events', + ]) + ->addRule('description', [ + 'type' => self::TYPE_STRING, + 'description' => 'Description of the topic.', + 'default' => '', + 'required' => false, + 'example' => 'All events related messages will be sent to this topic.', + ]); + } + + /** + * Get Name + * + * @return string + */ + public function getName(): string + { + return 'Topic'; + } + + /** + * Get Type + * + * @return string + */ + public function getType(): string + { + return Response::MODEL_TOPIC; + } +} From d7f806e67110cecce9c0e98e36b14ccb280cef4e Mon Sep 17 00:00:00 2001 From: prateek banga Date: Mon, 7 Aug 2023 21:01:25 +0530 Subject: [PATCH 07/22] fix lint issuesl --- src/Appwrite/Utopia/Response.php | 2 +- .../Utopia/Response/Model/Message.php | 62 +++++++++---------- .../Utopia/Response/Model/Provider.php | 42 ++++++------- .../Utopia/Response/Model/Subsciber.php | 42 ++++++------- src/Appwrite/Utopia/Response/Model/Target.php | 46 +++++++------- src/Appwrite/Utopia/Response/Model/Topic.php | 42 ++++++------- 6 files changed, 118 insertions(+), 118 deletions(-) diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 37e6d7682b..97b870bf61 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -309,7 +309,7 @@ class Response extends SwooleResponse ->setModel(new BaseList('Message list', self::MODEL_MESSAGE_LIST, 'messages', self::MODEL_MESSAGE)) ->setModel(new BaseList('Topic list', self::MODEL_TOPIC_LIST, 'topics', self::MODEL_TOPIC)) ->setModel(new BaseList('Subscriber list', self::MODEL_SUBSCRIBER_LIST, 'subscribers', self::MODEL_SUBSCRIBER)) - ->setModel(new BaseList('Target list', self::MODEL_TARGET_LIST, 'targets', self::MODEL_TARGET)) + ->setModel(new BaseList('Target list', self::MODEL_TARGET_LIST, 'targets', self::MODEL_TARGET)) // Entities ->setModel(new Database()) ->setModel(new Collection()) diff --git a/src/Appwrite/Utopia/Response/Model/Message.php b/src/Appwrite/Utopia/Response/Model/Message.php index f8a7913ff6..28536012ab 100644 --- a/src/Appwrite/Utopia/Response/Model/Message.php +++ b/src/Appwrite/Utopia/Response/Model/Message.php @@ -11,87 +11,87 @@ class Message extends Model /** * @var bool */ - protected bool $public = false; + protected bool $public = false; - public function __construct() - { - $this - ->addRule('$id', [ + public function __construct() + { + $this + ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Message ID.', 'default' => '', 'example' => '5e5ea5c16897e', - ]) - ->addRule('providerId', [ + ]) + ->addRule('providerId', [ 'type' => self::TYPE_STRING, 'description' => 'Provider Id for the message.', 'default' => '', 'example' => '5e5ea5c16897e', - ]) - ->addRule('data', [ + ]) + ->addRule('data', [ 'type' => self::TYPE_JSON, 'description' => 'Message Data.', 'default' => '', 'required' => false, 'example' => '', - ]) - ->addRule('to', [ + ]) + ->addRule('to', [ 'type' => self::TYPE_STRING, 'description' => 'Recipient of message.', 'default' => '', 'example' => ['user-1'], - ]) - ->addRule('deliveryTime', [ + ]) + ->addRule('deliveryTime', [ 'type' => self::TYPE_DATETIME, 'description' => 'Recipient of message.', 'required' => false, 'default' => DateTime::now(), 'example' => DateTime::now(), - ]) - ->addRule('deliveryError', [ + ]) + ->addRule('deliveryError', [ 'type' => self::TYPE_STRING, 'description' => 'Delivery error if any.', 'required' => false, 'default' => '', 'example' => 'Provider not valid.', - ]) - ->addRule('deliveredTo', [ + ]) + ->addRule('deliveredTo', [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of recipients the message was delivered to.', 'default' => '', 'example' => 1, - ]) - ->addRule('delivered', [ + ]) + ->addRule('delivered', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Status of delivery.', 'default' => '', 'example' => true, - ]) - ->addRule('search', [ + ]) + ->addRule('search', [ 'type' => self::TYPE_STRING, 'description' => 'Field that can be used for searching message.', 'default' => '', 'example' => 'Hello everyone', - ]); - } + ]); + } /** * Get Name * * @return string */ - public function getName(): string - { - return 'Message'; - } + public function getName(): string + { + return 'Message'; + } /** * Get Type * * @return string */ - public function getType(): string - { - return Response::MODEL_MESSAGE; - } + public function getType(): string + { + return Response::MODEL_MESSAGE; + } } diff --git a/src/Appwrite/Utopia/Response/Model/Provider.php b/src/Appwrite/Utopia/Response/Model/Provider.php index 6bd43261ad..fcaacd87c0 100644 --- a/src/Appwrite/Utopia/Response/Model/Provider.php +++ b/src/Appwrite/Utopia/Response/Model/Provider.php @@ -10,54 +10,54 @@ class Provider extends Model /** * @var bool */ - protected bool $public = false; + protected bool $public = false; - public function __construct() - { - $this - ->addRule('$id', [ + public function __construct() + { + $this + ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Provider ID.', 'default' => '', 'example' => '5e5ea5c16897e', - ]) - ->addRule('name', [ + ]) + ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'The user-given name for the provider instance.', 'default' => '', 'example' => 'Mailgun', - ]) - ->addRule('provider', [ + ]) + ->addRule('provider', [ 'type' => self::TYPE_STRING, 'description' => 'Provider name setup in Utopia.', 'default' => '', 'example' => 'mailgun', - ]) - ->addRule('type', [ + ]) + ->addRule('type', [ 'type' => self::TYPE_STRING, 'description' => 'Type of provider.', 'default' => '', 'example' => 'sms', - ]); - } + ]); + } /** * Get Name * * @return string */ - public function getName(): string - { - return 'Provider'; - } + public function getName(): string + { + return 'Provider'; + } /** * Get Type * * @return string */ - public function getType(): string - { - return Response::MODEL_PROVIDER; - } + public function getType(): string + { + return Response::MODEL_PROVIDER; + } } diff --git a/src/Appwrite/Utopia/Response/Model/Subsciber.php b/src/Appwrite/Utopia/Response/Model/Subsciber.php index a72146ccf3..11905180e3 100644 --- a/src/Appwrite/Utopia/Response/Model/Subsciber.php +++ b/src/Appwrite/Utopia/Response/Model/Subsciber.php @@ -10,54 +10,54 @@ class Subscriber extends Model /** * @var bool */ - protected bool $public = false; + protected bool $public = false; - public function __construct() - { - $this - ->addRule('$id', [ + public function __construct() + { + $this + ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Subscriber ID.', 'default' => '', 'example' => '259125845563242502', - ]) - ->addRule('userId', [ + ]) + ->addRule('userId', [ 'type' => self::TYPE_STRING, 'description' => 'User ID.', 'default' => '', 'example' => '259125845563242502', - ]) - ->addRule('targetId', [ + ]) + ->addRule('targetId', [ 'type' => self::TYPE_STRING, 'description' => 'Target ID.', 'default' => '', 'example' => '259125845563242502', - ]) - ->addRule('topicId', [ + ]) + ->addRule('topicId', [ 'type' => self::TYPE_STRING, 'description' => 'Topic ID.', 'default' => '', 'example' => '259125845563242502', - ]); - } + ]); + } /** * Get Name * * @return string */ - public function getName(): string - { - return 'Subscriber'; - } + public function getName(): string + { + return 'Subscriber'; + } /** * Get Type * * @return string */ - public function getType(): string - { - return Response::MODEL_SUBSCRIBER; - } + public function getType(): string + { + return Response::MODEL_SUBSCRIBER; + } } diff --git a/src/Appwrite/Utopia/Response/Model/Target.php b/src/Appwrite/Utopia/Response/Model/Target.php index 1ecc0126cc..8bc90731ba 100644 --- a/src/Appwrite/Utopia/Response/Model/Target.php +++ b/src/Appwrite/Utopia/Response/Model/Target.php @@ -10,61 +10,61 @@ class Target extends Model /** * @var bool */ - protected bool $public = false; + protected bool $public = false; - public function __construct() - { - $this - ->addRule('$id', [ + public function __construct() + { + $this + ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Target ID.', 'default' => '', 'example' => '259125845563242502', - ]) - ->addRule('userId', [ + ]) + ->addRule('userId', [ 'type' => self::TYPE_STRING, 'description' => 'User ID.', 'default' => '', 'example' => '259125845563242502', - ]) - ->addRule('providerId', [ + ]) + ->addRule('providerId', [ 'type' => self::TYPE_STRING, 'description' => 'Provider ID.', 'required' => false, 'default' => '', 'example' => '259125845563242502', - ]) - ->addRule('providerType', [ + ]) + ->addRule('providerType', [ 'type' => self::TYPE_STRING, 'description' => 'The type of provider supported by this target.', 'default' => '', 'example' => 'sms', - ]) - ->addRule('identifier', [ + ]) + ->addRule('identifier', [ 'type' => self::TYPE_STRING, 'description' => 'The target identifier.', 'default' => '', 'example' => 'token', - ]); - } + ]); + } /** * Get Name * * @return string */ - public function getName(): string - { - return 'Target'; - } + public function getName(): string + { + return 'Target'; + } /** * Get Type * * @return string */ - public function getType(): string - { - return Response::MODEL_TARGET; - } + public function getType(): string + { + return Response::MODEL_TARGET; + } } diff --git a/src/Appwrite/Utopia/Response/Model/Topic.php b/src/Appwrite/Utopia/Response/Model/Topic.php index d22364f917..42ecd583af 100644 --- a/src/Appwrite/Utopia/Response/Model/Topic.php +++ b/src/Appwrite/Utopia/Response/Model/Topic.php @@ -10,55 +10,55 @@ class Topic extends Model /** * @var bool */ - protected bool $public = false; + protected bool $public = false; - public function __construct() - { - $this - ->addRule('$id', [ + public function __construct() + { + $this + ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Topic ID.', 'default' => '', 'example' => '259125845563242502', - ]) - ->addRule('providerId', [ + ]) + ->addRule('providerId', [ 'type' => self::TYPE_STRING, 'description' => 'Provider ID.', 'default' => '', 'example' => '259125845563242502', - ]) - ->addRule('name', [ + ]) + ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'The name of the topic.', 'default' => '', 'example' => 'events', - ]) - ->addRule('description', [ + ]) + ->addRule('description', [ 'type' => self::TYPE_STRING, 'description' => 'Description of the topic.', 'default' => '', 'required' => false, 'example' => 'All events related messages will be sent to this topic.', - ]); - } + ]); + } /** * Get Name * * @return string */ - public function getName(): string - { - return 'Topic'; - } + public function getName(): string + { + return 'Topic'; + } /** * Get Type * * @return string */ - public function getType(): string - { - return Response::MODEL_TOPIC; - } + public function getType(): string + { + return Response::MODEL_TOPIC; + } } From a174aca2c8018b01ffee0fb7cdda4b429b64a350 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Fri, 18 Aug 2023 23:30:42 +0530 Subject: [PATCH 08/22] lint fix and rename subscriber model file correctly --- .../Utopia/Response/Model/Message.php | 140 +++++++++--------- .../Utopia/Response/Model/Provider.php | 74 ++++----- .../Utopia/Response/Model/Subsciber.php | 63 -------- .../Utopia/Response/Model/Subscriber.php | 63 ++++++++ src/Appwrite/Utopia/Response/Model/Target.php | 88 +++++------ src/Appwrite/Utopia/Response/Model/Topic.php | 76 +++++----- 6 files changed, 252 insertions(+), 252 deletions(-) delete mode 100644 src/Appwrite/Utopia/Response/Model/Subsciber.php create mode 100644 src/Appwrite/Utopia/Response/Model/Subscriber.php diff --git a/src/Appwrite/Utopia/Response/Model/Message.php b/src/Appwrite/Utopia/Response/Model/Message.php index 28536012ab..177058be9b 100644 --- a/src/Appwrite/Utopia/Response/Model/Message.php +++ b/src/Appwrite/Utopia/Response/Model/Message.php @@ -8,88 +8,88 @@ use Utopia\Database\DateTime; class Message extends Model { - /** - * @var bool - */ + /** + * @var bool + */ protected bool $public = false; public function __construct() { $this - ->addRule('$id', [ - 'type' => self::TYPE_STRING, - 'description' => 'Message ID.', - 'default' => '', - 'example' => '5e5ea5c16897e', - ]) - ->addRule('providerId', [ - 'type' => self::TYPE_STRING, - 'description' => 'Provider Id for the message.', - 'default' => '', - 'example' => '5e5ea5c16897e', - ]) - ->addRule('data', [ - 'type' => self::TYPE_JSON, - 'description' => 'Message Data.', - 'default' => '', - 'required' => false, - 'example' => '', - ]) - ->addRule('to', [ - 'type' => self::TYPE_STRING, - 'description' => 'Recipient of message.', - 'default' => '', - 'example' => ['user-1'], - ]) - ->addRule('deliveryTime', [ - 'type' => self::TYPE_DATETIME, - 'description' => 'Recipient of message.', - 'required' => false, - 'default' => DateTime::now(), - 'example' => DateTime::now(), - ]) - ->addRule('deliveryError', [ - 'type' => self::TYPE_STRING, - 'description' => 'Delivery error if any.', - 'required' => false, - 'default' => '', - 'example' => 'Provider not valid.', - ]) - ->addRule('deliveredTo', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Number of recipients the message was delivered to.', - 'default' => '', - 'example' => 1, - ]) - ->addRule('delivered', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Status of delivery.', - 'default' => '', - 'example' => true, - ]) - ->addRule('search', [ - 'type' => self::TYPE_STRING, - 'description' => 'Field that can be used for searching message.', - 'default' => '', - 'example' => 'Hello everyone', - ]); + ->addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Message ID.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('providerId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider Id for the message.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('data', [ + 'type' => self::TYPE_JSON, + 'description' => 'Message Data.', + 'default' => '', + 'required' => false, + 'example' => '', + ]) + ->addRule('to', [ + 'type' => self::TYPE_STRING, + 'description' => 'Recipient of message.', + 'default' => '', + 'example' => ['user-1'], + ]) + ->addRule('deliveryTime', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Recipient of message.', + 'required' => false, + 'default' => DateTime::now(), + 'example' => DateTime::now(), + ]) + ->addRule('deliveryError', [ + 'type' => self::TYPE_STRING, + 'description' => 'Delivery error if any.', + 'required' => false, + 'default' => '', + 'example' => 'Provider not valid.', + ]) + ->addRule('deliveredTo', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of recipients the message was delivered to.', + 'default' => '', + 'example' => 1, + ]) + ->addRule('delivered', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Status of delivery.', + 'default' => '', + 'example' => true, + ]) + ->addRule('search', [ + 'type' => self::TYPE_STRING, + 'description' => 'Field that can be used for searching message.', + 'default' => '', + 'example' => 'Hello everyone', + ]); } - /** - * Get Name - * - * @return string - */ + /** + * Get Name + * + * @return string + */ public function getName(): string { return 'Message'; } - /** - * Get Type - * - * @return string - */ + /** + * Get Type + * + * @return string + */ public function getType(): string { return Response::MODEL_MESSAGE; diff --git a/src/Appwrite/Utopia/Response/Model/Provider.php b/src/Appwrite/Utopia/Response/Model/Provider.php index fcaacd87c0..6dd12a4d7a 100644 --- a/src/Appwrite/Utopia/Response/Model/Provider.php +++ b/src/Appwrite/Utopia/Response/Model/Provider.php @@ -7,55 +7,55 @@ use Appwrite\Utopia\Response\Model; class Provider extends Model { - /** - * @var bool - */ + /** + * @var bool + */ protected bool $public = false; public function __construct() { $this - ->addRule('$id', [ - 'type' => self::TYPE_STRING, - 'description' => 'Provider ID.', - 'default' => '', - 'example' => '5e5ea5c16897e', - ]) - ->addRule('name', [ - 'type' => self::TYPE_STRING, - 'description' => 'The user-given name for the provider instance.', - 'default' => '', - 'example' => 'Mailgun', - ]) - ->addRule('provider', [ - 'type' => self::TYPE_STRING, - 'description' => 'Provider name setup in Utopia.', - 'default' => '', - 'example' => 'mailgun', - ]) - ->addRule('type', [ - 'type' => self::TYPE_STRING, - 'description' => 'Type of provider.', - 'default' => '', - 'example' => 'sms', - ]); + ->addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider ID.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => self::TYPE_STRING, + 'description' => 'The user-given name for the provider instance.', + 'default' => '', + 'example' => 'Mailgun', + ]) + ->addRule('provider', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider name setup in Utopia.', + 'default' => '', + 'example' => 'mailgun', + ]) + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Type of provider.', + 'default' => '', + 'example' => 'sms', + ]); } - /** - * Get Name - * - * @return string - */ + /** + * Get Name + * + * @return string + */ public function getName(): string { return 'Provider'; } - /** - * Get Type - * - * @return string - */ + /** + * Get Type + * + * @return string + */ public function getType(): string { return Response::MODEL_PROVIDER; diff --git a/src/Appwrite/Utopia/Response/Model/Subsciber.php b/src/Appwrite/Utopia/Response/Model/Subsciber.php deleted file mode 100644 index 11905180e3..0000000000 --- a/src/Appwrite/Utopia/Response/Model/Subsciber.php +++ /dev/null @@ -1,63 +0,0 @@ -addRule('$id', [ - 'type' => self::TYPE_STRING, - 'description' => 'Subscriber ID.', - 'default' => '', - 'example' => '259125845563242502', - ]) - ->addRule('userId', [ - 'type' => self::TYPE_STRING, - 'description' => 'User ID.', - 'default' => '', - 'example' => '259125845563242502', - ]) - ->addRule('targetId', [ - 'type' => self::TYPE_STRING, - 'description' => 'Target ID.', - 'default' => '', - 'example' => '259125845563242502', - ]) - ->addRule('topicId', [ - 'type' => self::TYPE_STRING, - 'description' => 'Topic ID.', - 'default' => '', - 'example' => '259125845563242502', - ]); - } - - /** - * Get Name - * - * @return string - */ - public function getName(): string - { - return 'Subscriber'; - } - - /** - * Get Type - * - * @return string - */ - public function getType(): string - { - return Response::MODEL_SUBSCRIBER; - } -} diff --git a/src/Appwrite/Utopia/Response/Model/Subscriber.php b/src/Appwrite/Utopia/Response/Model/Subscriber.php new file mode 100644 index 0000000000..a9682cf0a6 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Subscriber.php @@ -0,0 +1,63 @@ +addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Subscriber ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('userId', [ + 'type' => self::TYPE_STRING, + 'description' => 'User ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('targetId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Target ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('topicId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Topic ID.', + 'default' => '', + 'example' => '259125845563242502', + ]); + } + + /** + * Get Name + * + * @return string + */ + public function getName(): string + { + return 'Subscriber'; + } + + /** + * Get Type + * + * @return string + */ + public function getType(): string + { + return Response::MODEL_SUBSCRIBER; + } +} diff --git a/src/Appwrite/Utopia/Response/Model/Target.php b/src/Appwrite/Utopia/Response/Model/Target.php index 8bc90731ba..272c929e11 100644 --- a/src/Appwrite/Utopia/Response/Model/Target.php +++ b/src/Appwrite/Utopia/Response/Model/Target.php @@ -7,62 +7,62 @@ use Appwrite\Utopia\Response\Model; class Target extends Model { - /** - * @var bool - */ + /** + * @var bool + */ protected bool $public = false; public function __construct() { $this - ->addRule('$id', [ - 'type' => self::TYPE_STRING, - 'description' => 'Target ID.', - 'default' => '', - 'example' => '259125845563242502', - ]) - ->addRule('userId', [ - 'type' => self::TYPE_STRING, - 'description' => 'User ID.', - 'default' => '', - 'example' => '259125845563242502', - ]) - ->addRule('providerId', [ - 'type' => self::TYPE_STRING, - 'description' => 'Provider ID.', - 'required' => false, - 'default' => '', - 'example' => '259125845563242502', - ]) - ->addRule('providerType', [ - 'type' => self::TYPE_STRING, - 'description' => 'The type of provider supported by this target.', - 'default' => '', - 'example' => 'sms', - ]) - ->addRule('identifier', [ - 'type' => self::TYPE_STRING, - 'description' => 'The target identifier.', - 'default' => '', - 'example' => 'token', - ]); + ->addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Target ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('userId', [ + 'type' => self::TYPE_STRING, + 'description' => 'User ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('providerId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider ID.', + 'required' => false, + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('providerType', [ + 'type' => self::TYPE_STRING, + 'description' => 'The type of provider supported by this target.', + 'default' => '', + 'example' => 'sms', + ]) + ->addRule('identifier', [ + 'type' => self::TYPE_STRING, + 'description' => 'The target identifier.', + 'default' => '', + 'example' => 'token', + ]); } - /** - * Get Name - * - * @return string - */ + /** + * Get Name + * + * @return string + */ public function getName(): string { return 'Target'; } - /** - * Get Type - * - * @return string - */ + /** + * Get Type + * + * @return string + */ public function getType(): string { return Response::MODEL_TARGET; diff --git a/src/Appwrite/Utopia/Response/Model/Topic.php b/src/Appwrite/Utopia/Response/Model/Topic.php index 42ecd583af..c0996fcf55 100644 --- a/src/Appwrite/Utopia/Response/Model/Topic.php +++ b/src/Appwrite/Utopia/Response/Model/Topic.php @@ -7,56 +7,56 @@ use Appwrite\Utopia\Response\Model; class Topic extends Model { - /** - * @var bool - */ + /** + * @var bool + */ protected bool $public = false; public function __construct() { $this - ->addRule('$id', [ - 'type' => self::TYPE_STRING, - 'description' => 'Topic ID.', - 'default' => '', - 'example' => '259125845563242502', - ]) - ->addRule('providerId', [ - 'type' => self::TYPE_STRING, - 'description' => 'Provider ID.', - 'default' => '', - 'example' => '259125845563242502', - ]) - ->addRule('name', [ - 'type' => self::TYPE_STRING, - 'description' => 'The name of the topic.', - 'default' => '', - 'example' => 'events', - ]) - ->addRule('description', [ - 'type' => self::TYPE_STRING, - 'description' => 'Description of the topic.', - 'default' => '', - 'required' => false, - 'example' => 'All events related messages will be sent to this topic.', - ]); + ->addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Topic ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('providerId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Provider ID.', + 'default' => '', + 'example' => '259125845563242502', + ]) + ->addRule('name', [ + 'type' => self::TYPE_STRING, + 'description' => 'The name of the topic.', + 'default' => '', + 'example' => 'events', + ]) + ->addRule('description', [ + 'type' => self::TYPE_STRING, + 'description' => 'Description of the topic.', + 'default' => '', + 'required' => false, + 'example' => 'All events related messages will be sent to this topic.', + ]); } - /** - * Get Name - * - * @return string - */ + /** + * Get Name + * + * @return string + */ public function getName(): string { return 'Topic'; } - /** - * Get Type - * - * @return string - */ + /** + * Get Type + * + * @return string + */ public function getType(): string { return Response::MODEL_TOPIC; From 32b48a3c7c088faf42bacb70ba7e43101e561244 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Thu, 31 Aug 2023 18:22:36 +0530 Subject: [PATCH 09/22] removes user id from subscriber model --- src/Appwrite/Utopia/Response/Model/Subscriber.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Appwrite/Utopia/Response/Model/Subscriber.php b/src/Appwrite/Utopia/Response/Model/Subscriber.php index a9682cf0a6..8e4ef74d74 100644 --- a/src/Appwrite/Utopia/Response/Model/Subscriber.php +++ b/src/Appwrite/Utopia/Response/Model/Subscriber.php @@ -21,12 +21,6 @@ class Subscriber extends Model 'default' => '', 'example' => '259125845563242502', ]) - ->addRule('userId', [ - 'type' => self::TYPE_STRING, - 'description' => 'User ID.', - 'default' => '', - 'example' => '259125845563242502', - ]) ->addRule('targetId', [ 'type' => self::TYPE_STRING, 'description' => 'Target ID.', From ea324262e76efa150997096dd2889b65cadb76f5 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Tue, 5 Sep 2023 01:33:50 +0530 Subject: [PATCH 10/22] updated messaging collectin --- app/config/collections.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 15effbf5ae..0a51a2c1bb 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1335,24 +1335,13 @@ $commonCollections = [ 'array' => false, 'filters' => [], ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], [ '$id' => ID::custom('data'), 'type' => Database::VAR_STRING, 'format' => '', 'size' => 16384, 'signed' => true, - 'required' => false, + 'required' => true, 'default' => null, 'array' => false, 'filters' => ['json'], @@ -1396,7 +1385,7 @@ $commonCollections = [ 'format' => '', 'size' => 0, 'signed' => true, - 'required' => true, + 'required' => false, 'default' => null, 'array' => false, 'filters' => [], @@ -1407,7 +1396,7 @@ $commonCollections = [ 'format' => '', 'size' => 0, 'signed' => true, - 'required' => true, + 'required' => false, 'default' => false, 'array' => false, 'filters' => [], From 1a791f46e6dab3dbaee1a836b82ca82f44420022 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Tue, 5 Sep 2023 13:33:22 +0530 Subject: [PATCH 11/22] adds default in provider response model --- src/Appwrite/Utopia/Response/Model/Provider.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/Provider.php b/src/Appwrite/Utopia/Response/Model/Provider.php index 6dd12a4d7a..0cbc233fc3 100644 --- a/src/Appwrite/Utopia/Response/Model/Provider.php +++ b/src/Appwrite/Utopia/Response/Model/Provider.php @@ -33,6 +33,12 @@ class Provider extends Model 'default' => '', 'example' => 'mailgun', ]) + ->addRule('default', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Default provider or not.', + 'default' => '', + 'example' => true, + ]) ->addRule('type', [ 'type' => self::TYPE_STRING, 'description' => 'Type of provider.', From ee0f789e372e94992c9d239edbd42f8d2de86b97 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Sat, 9 Sep 2023 01:18:26 +0530 Subject: [PATCH 12/22] udpates deliveryError to be an array type --- app/config/collections.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index f0acc33345..a316b02290 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1521,11 +1521,11 @@ $commonCollections = [ '$id' => ID::custom('deliveryError'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 2048, + 'size' => 16834, 'signed' => true, 'required' => false, 'default' => null, - 'array' => false, + 'array' => true, 'filters' => [], ], [ From f4f1aa4b5b09bd37a767662c9915b34ac8783f52 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Mon, 11 Sep 2023 19:27:45 +0530 Subject: [PATCH 13/22] review changes and adds missing subqueries --- app/config/collections.php | 88 ++++++++++++++++++++++++++++++-------- app/init.php | 41 ++++++++++++++++++ 2 files changed, 110 insertions(+), 19 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index a316b02290..398db4929f 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1437,22 +1437,61 @@ $commonCollections = [ 'default' => null, 'array' => false, 'filters' => ['json', 'encrypt'], - ] + ], + [ + '$id' => ID::custom('search'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 65535, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], ], 'indexes' => [ [ '$id' => ID::custom('_key_provider'), 'type' => Database::INDEX_KEY, 'attributes' => ['provider'], - 'lengths' => [128], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], [ '$id' => ID::custom('_key_name'), 'type' => Database::INDEX_FULLTEXT, 'attributes' => ['name'], - 'lengths' => [128], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_type'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['type'], + 'lengths' => [], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_default'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['default'], + 'lengths' => [], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_default_type'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['default, type'], + 'lengths' => [], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_search'), + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [], + 'orders' => [], ] ], ], @@ -1488,7 +1527,7 @@ $commonCollections = [ '$id' => ID::custom('data'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 16384, + 'size' => 65535, 'signed' => true, 'required' => true, 'default' => null, @@ -1499,7 +1538,7 @@ $commonCollections = [ '$id' => ID::custom('to'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 16834, + 'size' => 65535, 'signed' => true, 'required' => true, 'default' => null, @@ -1518,10 +1557,10 @@ $commonCollections = [ 'filters' => ['datetime'], ], [ - '$id' => ID::custom('deliveryError'), + '$id' => ID::custom('deliveryErrors'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 16834, + 'size' => 65535, 'signed' => true, 'required' => false, 'default' => null, @@ -1567,14 +1606,14 @@ $commonCollections = [ '$id' => ID::custom('_key_providerId'), 'type' => Database::INDEX_KEY, 'attributes' => ['providerId'], - 'lengths' => [128], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], [ '$id' => ID::custom('_key_providerInternalId'), 'type' => Database::INDEX_KEY, 'attributes' => ['providerInternalId'], - 'lengths' => [128], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], [ @@ -1646,21 +1685,32 @@ $commonCollections = [ 'default' => null, 'array' => false, 'filters' => ['subQueryTopicTargets'], - ] + ], + [ + '$id' => ID::custom('search'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], ], 'indexes' => [ [ '$id' => ID::custom('_key_providerId'), 'type' => Database::INDEX_KEY, 'attributes' => ['providerId'], - 'lengths' => [128], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], [ '$id' => ID::custom('_key_providerInternalId'), 'type' => Database::INDEX_KEY, 'attributes' => ['providerInternalId'], - 'lengths' => [128], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], [ @@ -1671,12 +1721,12 @@ $commonCollections = [ 'orders' => [], ], [ - '$id' => ID::custom('_key_description'), + '$id' => ID::custom('_key_search'), 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['description'], + 'attributes' => ['name'], 'lengths' => [], - 'orders' => [], - ], + 'orders' => [Database::ORDER_ASC], + ] ], ], @@ -1826,7 +1876,7 @@ $commonCollections = [ '$id' => ID::custom('identifier'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => Database::LENGTH_KEY, + 'size' => 2048, 'signed' => true, 'required' => true, 'default' => null, @@ -1839,14 +1889,14 @@ $commonCollections = [ '$id' => ID::custom('_key_userId'), 'type' => Database::INDEX_KEY, 'attributes' => ['userId'], - 'lengths' => [128], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], [ '$id' => ID::custom('_key_userInternalId'), 'type' => Database::INDEX_KEY, 'attributes' => ['userInternalId'], - 'lengths' => [128], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], [ diff --git a/app/init.php b/app/init.php index f2d7bc7db4..0df1280051 100644 --- a/app/init.php +++ b/app/init.php @@ -543,6 +543,47 @@ Database::addFilter( ])); } ); + +Database::addFilter( + 'subQueryProviderType', + function (mixed $value) { + return null; + }, + function (mixed $value, Document $document, Database $database) { + $provider = Authorization::skip(fn () => $database + ->getDocument( + 'providers', + $document->getAttribute('providerId'), + [Query::select(['type'])] + )); + if ($provider) { + return $provider->getAttribute('type'); + } + return null; + } +); + + +Database::addFilter( + 'subQueryTopicTargets', + function (mixed $value) { + return null; + }, + function (mixed $value, Document $document, Database $database) { + $targetIds = Authorization::skip(fn () => \array_map( + fn ($document) => $document->getAttribute('targetId'), + $database + ->find('subscribers', [ + Query::equal('topicInternalId', [$document->getInternalId()]), + Query::limit(APP_LIMIT_SUBQUERY), + ]) + )); + if (\count($targetIds) > 0) { + return $database->find('targets', [Query::equal('$id', $targetIds)]); + } + return []; + } +); /** * DB Formats */ From a59cfb64614e730bc8f62e48e25124b7450a1149 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Mon, 11 Sep 2023 20:30:21 +0530 Subject: [PATCH 14/22] review changes --- app/config/messagingProviders.php | 300 ------------------ src/Appwrite/Utopia/Response.php | 6 +- .../Utopia/Response/Model/Message.php | 15 +- .../Utopia/Response/Model/Project.php | 2 +- .../Utopia/Response/Model/Provider.php | 6 +- 5 files changed, 8 insertions(+), 321 deletions(-) delete mode 100644 app/config/messagingProviders.php diff --git a/app/config/messagingProviders.php b/app/config/messagingProviders.php deleted file mode 100644 index a33665196b..0000000000 --- a/app/config/messagingProviders.php +++ /dev/null @@ -1,300 +0,0 @@ - [ - 'mailchimp' => [ - 'name' => 'Mailchimp', - 'developers' => 'https://mailchimp.com/developer/marketing/api/', - 'icon' => 'icon-mailchimp', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'mailgun' => [ - 'name' => 'Mailgun', - 'developers' => 'https://documentation.mailgun.com/', - 'icon' => 'icon-mailgun', - 'enabled' => true, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'mailjet' => [ - 'name' => 'Mailjet', - 'developers' => 'https://dev.mailjet.com/', - 'icon' => 'icon-mailjet', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'postmark' => [ - 'name' => 'Postmark', - 'developers' => 'https://postmarkapp.com/developer', - 'icon' => 'icon-postmark', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'sendgrid' => [ - 'name' => 'Sendgrid', - 'developers' => 'https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/', - 'icon' => 'icon-sendgrid', - 'enabled' => true, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'sendinblue' => [ - 'name' => 'SendinBlue', - 'developers' => 'https://developers.sendinblue.com/', - 'icon' => 'icon-sendinblue', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'mailslurp' => [ - 'name' => 'MailSlurp', - 'developers' => 'https://www.mailslurp.com/docs/', - 'icon' => 'icon-mailslurp', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'elasticemail' => [ - 'name' => 'ElasticEmail', - 'developers' => 'https://api.elasticemail.com/public/help', - 'icon' => 'icon-elasticemail', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'ses' => [ - 'name' => 'SES', - 'developers' => 'https://docs.aws.amazon.com/ses/latest/APIReference/', - 'icon' => 'icon-ses', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - ], - 'sms' => [ - 'africastalking' => [ - 'name' => 'Africa\'s Talking', - 'developers' => 'https://developers.africastalking.com/', - 'icon' => 'icon-africastalking', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'clickatell' => [ - 'name' => 'Clickatell', - 'developers' => 'https://www.clickatell.com/developers/api-docs/', - 'icon' => 'icon-clickatell', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'infobip' => [ - 'name' => 'Infobip', - 'developers' => 'https://www.infobip.com/docs/', - 'icon' => 'icon-infobip', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'msg91' => [ - 'name' => 'Msg91', - 'developers' => 'https://docs.msg91.com/reference/overview', - 'icon' => 'icon-msg91', - 'enabled' => true, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'plivo' => [ - 'name' => 'Plivo', - 'developers' => 'https://developers.plivo.com/', - 'icon' => 'icon-plivo', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'sinch' => [ - 'name' => 'Sinch', - 'developers' => 'https://developers.sinch.com/', - 'icon' => 'icon-sinch', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'sms77' => [ - 'name' => 'Sms77', - 'developers' => 'https://sms77.io/docs/gateway/', - 'icon' => 'icon-sms77', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'telesign' => [ - 'name' => 'Telesign', - 'developers' => 'https://developer.telesign.com/enterprise/docs', - 'icon' => 'icon-telesign', - 'enabled' => true, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'textmagic' => [ - 'name' => 'TextMagic', - 'developers' => 'https://www.textmagic.com/docs/api/', - 'icon' => 'icon-twilio', - 'enabled' => true, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'twilio' => [ - 'name' => 'Twilio', - 'developers' => 'https://www.twilio.com/docs/sms', - 'icon' => 'icon-twilio', - 'enabled' => true, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'twilio-notify' => [ - 'name' => 'Twilio Notify', - 'developers' => 'https://www.twilio.com/docs/notify', - 'icon' => 'icon-twilio', - 'enabled' => true, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'vonage' => [ - 'name' => 'Vonage', - 'developers' => 'https://developer.nexmo.com/', - 'icon' => 'icon-vonage', - 'enabled' => true, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - ], - 'push' => [ - 'apns' => [ - 'name' => 'APNS', - 'developers' => 'https://developer.apple.com/documentation/usernotifications', - 'icon' => 'icon-apns', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'fcm' => [ - 'name' => 'FCM', - 'developers' => 'https://firebase.google.com/docs/cloud-messaging', - 'icon' => 'icon-fcm', - 'enabled' => true, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'one_signal' => [ - 'name' => 'OneSignal', - 'developers' => 'https://documentation.onesignal.com/docs', - 'icon' => 'icon-onesignal', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'pushbullet' => [ - 'name' => 'PushBullet', - 'developers' => 'https://docs.pushbullet.com/', - 'icon' => 'icon-pushbullet', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'pusher' => [ - 'name' => 'Pusher', - 'developers' => 'https://pusher.com/docs', - 'icon' => 'icon-pusher', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'pushwoosh' => [ - 'name' => 'Pushwoosh', - 'developers' => 'https://www.pushwoosh.com/docs/', - 'icon' => 'icon-pushwoosh', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'urban_airship' => [ - 'name' => 'Urban Airship', - 'developers' => 'https://docs.airship.com/api/', - 'icon' => 'icon-urbanairship', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - 'web_push' => [ - 'name' => 'WebPush', - 'developers' => 'https://developer.mozilla.org/en-US/docs/Web/API/Push_API', - 'icon' => 'icon-webpush', - 'enabled' => false, - 'sandbox' => false, - 'form' => false, - 'beta' => false, - 'mock' => false, - ], - ] -]; diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 90a5546548..7a2a040d94 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -2,9 +2,6 @@ namespace Appwrite\Utopia; -use Appwrite\Utopia\Response\Model\Message; -use Appwrite\Utopia\Response\Model\Subscriber; -use Appwrite\Utopia\Response\Model\Topic; use Exception; use Swoole\Http\Request as SwooleRequest; use Utopia\Swoole\Response as SwooleResponse; @@ -84,6 +81,9 @@ use Appwrite\Utopia\Response\Model\HealthVersion; use Appwrite\Utopia\Response\Model\Installation; use Appwrite\Utopia\Response\Model\LocaleCode; use Appwrite\Utopia\Response\Model\Provider; +use Appwrite\Utopia\Response\Model\Message; +use Appwrite\Utopia\Response\Model\Subscriber; +use Appwrite\Utopia\Response\Model\Topic; use Appwrite\Utopia\Response\Model\ProviderRepository; use Appwrite\Utopia\Response\Model\Runtime; use Appwrite\Utopia\Response\Model\Target; diff --git a/src/Appwrite/Utopia/Response/Model/Message.php b/src/Appwrite/Utopia/Response/Model/Message.php index 177058be9b..14940050fe 100644 --- a/src/Appwrite/Utopia/Response/Model/Message.php +++ b/src/Appwrite/Utopia/Response/Model/Message.php @@ -6,7 +6,7 @@ use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Model; use Utopia\Database\DateTime; -class Message extends Model +class Message extends Any { /** * @var bool @@ -28,13 +28,6 @@ class Message extends Model 'default' => '', 'example' => '5e5ea5c16897e', ]) - ->addRule('data', [ - 'type' => self::TYPE_JSON, - 'description' => 'Message Data.', - 'default' => '', - 'required' => false, - 'example' => '', - ]) ->addRule('to', [ 'type' => self::TYPE_STRING, 'description' => 'Recipient of message.', @@ -66,12 +59,6 @@ class Message extends Model 'description' => 'Status of delivery.', 'default' => '', 'example' => true, - ]) - ->addRule('search', [ - 'type' => self::TYPE_STRING, - 'description' => 'Field that can be used for searching message.', - 'default' => '', - 'example' => 'Hello everyone', ]); } diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index 885e7e9af6..5f78ff82cc 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -138,7 +138,7 @@ class Project extends Model 'default' => false, 'example' => true, ]) - ->addRule('providers', [ + ->addRule('authProviders', [ 'type' => Response::MODEL_AUTH_PROVIDER, 'description' => 'List of Auth Providers.', 'default' => [], diff --git a/src/Appwrite/Utopia/Response/Model/Provider.php b/src/Appwrite/Utopia/Response/Model/Provider.php index 0cbc233fc3..668db553fc 100644 --- a/src/Appwrite/Utopia/Response/Model/Provider.php +++ b/src/Appwrite/Utopia/Response/Model/Provider.php @@ -23,19 +23,19 @@ class Provider extends Model ]) ->addRule('name', [ 'type' => self::TYPE_STRING, - 'description' => 'The user-given name for the provider instance.', + 'description' => 'The name for the provider instance.', 'default' => '', 'example' => 'Mailgun', ]) ->addRule('provider', [ 'type' => self::TYPE_STRING, - 'description' => 'Provider name setup in Utopia.', + 'description' => 'The name of the provider service.', 'default' => '', 'example' => 'mailgun', ]) ->addRule('default', [ 'type' => self::TYPE_BOOLEAN, - 'description' => 'Default provider or not.', + 'description' => 'Is this a pre-configured provider instance?', 'default' => '', 'example' => true, ]) From 78a2f6f2467e9d45e1a46f5938d05d83d3b7e987 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Mon, 11 Sep 2023 20:36:43 +0530 Subject: [PATCH 15/22] review changes --- src/Appwrite/Utopia/Response/Model/Message.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/Message.php b/src/Appwrite/Utopia/Response/Model/Message.php index 14940050fe..150e837853 100644 --- a/src/Appwrite/Utopia/Response/Model/Message.php +++ b/src/Appwrite/Utopia/Response/Model/Message.php @@ -32,6 +32,7 @@ class Message extends Any 'type' => self::TYPE_STRING, 'description' => 'Recipient of message.', 'default' => '', + 'array' => true, 'example' => ['user-1'], ]) ->addRule('deliveryTime', [ @@ -46,6 +47,7 @@ class Message extends Any 'description' => 'Delivery error if any.', 'required' => false, 'default' => '', + 'array' => true, 'example' => 'Provider not valid.', ]) ->addRule('deliveredTo', [ From 497586378f15c4ce20602aeeee9fb914ad1c44ad Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Tue, 12 Sep 2023 22:05:14 +0530 Subject: [PATCH 16/22] removes unnecessary config load --- app/init.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/init.php b/app/init.php index ea1442d2d7..6d746fbe0b 100644 --- a/app/init.php +++ b/app/init.php @@ -257,7 +257,6 @@ Config::load('storage-logos', __DIR__ . '/config/storage/logos.php'); Config::load('storage-mimes', __DIR__ . '/config/storage/mimes.php'); Config::load('storage-inputs', __DIR__ . '/config/storage/inputs.php'); Config::load('storage-outputs', __DIR__ . '/config/storage/outputs.php'); -Config::load('messagingProviders', __DIR__ . '/config/messagingProviders.php'); $user = App::getEnv('_APP_REDIS_USER', ''); $pass = App::getEnv('_APP_REDIS_PASS', ''); From 7dd25f60f30ceb4b52db9b8814ea2812eb6a5445 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Tue, 12 Sep 2023 23:30:04 +0530 Subject: [PATCH 17/22] update console submodule changes --- app/console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/console b/app/console index 9174d8f8cb..88b6d59051 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit 9174d8f8cb584744dd7a53f69d324f490ee82ee3 +Subproject commit 88b6d59051992ed86183ee83d77bf678d1cb73bf From 11a458f1df30327b88295285f0b0b102c61fe895 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Wed, 13 Sep 2023 00:06:18 +0530 Subject: [PATCH 18/22] change providers to authProviders in remaining places --- app/controllers/api/users.php | 2 +- src/Appwrite/Utopia/Response.php | 2 +- src/Appwrite/Utopia/Response/Filters/V16.php | 6 +++--- src/Appwrite/Utopia/Response/Model/Project.php | 2 +- tests/e2e/Services/Projects/ProjectsConsoleClientTest.php | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index c6d9b2d4e3..5dd1ab44d8 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -1255,7 +1255,7 @@ App::get('/v1/users/usage') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_USAGE_USERS) ->param('range', '30d', new WhiteList(['24h', '7d', '30d', '90d'], true), 'Date range.', true) - ->param('provider', '', new WhiteList(\array_merge(['email', 'anonymous'], \array_map(fn ($value) => "oauth-" . $value, \array_keys(Config::getParam('providers', [])))), true), 'Provider Name.', true) + ->param('provider', '', new WhiteList(\array_merge(['email', 'anonymous'], \array_map(fn ($value) => "oauth-" . $value, \array_keys(Config::getParam('authProviders', [])))), true), 'Provider Name.', true) ->inject('response') ->inject('dbForProject') ->inject('register') diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 7a2a040d94..85db23b385 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -333,7 +333,7 @@ class Response extends SwooleResponse ->setModel(new BaseList('Projects List', self::MODEL_PROJECT_LIST, 'projects', self::MODEL_PROJECT, true, false)) ->setModel(new BaseList('Webhooks List', self::MODEL_WEBHOOK_LIST, 'webhooks', self::MODEL_WEBHOOK, true, false)) ->setModel(new BaseList('API Keys List', self::MODEL_KEY_LIST, 'keys', self::MODEL_KEY, true, false)) - ->setModel(new BaseList('Providers List', self::MODEL_AUTH_PROVIDER_LIST, 'platforms', self::MODEL_AUTH_PROVIDER, true, false)) + ->setModel(new BaseList('Auth Providers List', self::MODEL_AUTH_PROVIDER_LIST, 'platforms', self::MODEL_AUTH_PROVIDER, true, false)) ->setModel(new BaseList('Platforms List', self::MODEL_PLATFORM_LIST, 'platforms', self::MODEL_PLATFORM, true, false)) ->setModel(new BaseList('Countries List', self::MODEL_COUNTRY_LIST, 'countries', self::MODEL_COUNTRY)) ->setModel(new BaseList('Continents List', self::MODEL_CONTINENT_LIST, 'continents', self::MODEL_CONTINENT)) diff --git a/src/Appwrite/Utopia/Response/Filters/V16.php b/src/Appwrite/Utopia/Response/Filters/V16.php index 6943bd8f4d..66cf650a78 100644 --- a/src/Appwrite/Utopia/Response/Filters/V16.php +++ b/src/Appwrite/Utopia/Response/Filters/V16.php @@ -88,9 +88,9 @@ class V16 extends Filter protected function parseProject(array $content) { - foreach ($content['providers'] ?? [] as $i => $provider) { - $content['providers'][$i]['name'] = \ucfirst($provider['key']); - unset($content['providers'][$i]['key']); + foreach ($content['authProviders'] ?? [] as $i => $provider) { + $content['authProviders'][$i]['name'] = \ucfirst($provider['key']); + unset($content['authProviders'][$i]['key']); } $content['domains'] = []; diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index 5f78ff82cc..ae199d77f7 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -348,7 +348,7 @@ class Project extends Model ]); } - $document->setAttribute("providers", $projectProviders); + $document->setAttribute("authProviders", $projectProviders); return $document; } diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index d26d226dd3..eefc766b94 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -825,7 +825,7 @@ class ProjectsConsoleClientTest extends Scope foreach ($providers as $key => $provider) { $asserted = false; - foreach ($response['body']['providers'] as $responseProvider) { + foreach ($response['body']['authProviders'] as $responseProvider) { if ($responseProvider['key'] === $key) { $this->assertEquals('AppId-' . ucfirst($key), $responseProvider['appId']); $this->assertEquals('Secret-' . ucfirst($key), $responseProvider['secret']); @@ -867,7 +867,7 @@ class ProjectsConsoleClientTest extends Scope $i = 0; foreach ($providers as $key => $provider) { $asserted = false; - foreach ($response['body']['providers'] as $responseProvider) { + foreach ($response['body']['authProviders'] as $responseProvider) { if ($responseProvider['key'] === $key) { // On first provider, test enabled=false $this->assertEquals($i !== 0, $responseProvider['enabled']); From 851afae29a2d2054cf701d311b270aa2b6271e04 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Wed, 13 Sep 2023 00:50:16 +0530 Subject: [PATCH 19/22] change test provider to authProviders --- tests/unit/Utopia/Response/Filters/V16Test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/Utopia/Response/Filters/V16Test.php b/tests/unit/Utopia/Response/Filters/V16Test.php index fba3b69535..96c615f452 100644 --- a/tests/unit/Utopia/Response/Filters/V16Test.php +++ b/tests/unit/Utopia/Response/Filters/V16Test.php @@ -154,9 +154,9 @@ class V16Test extends TestCase public function projectProvider(): array { return [ - 'providers' => [ + 'authProviders' => [ [ - 'providers' => [ + 'authProviders' => [ [ 'key' => 'github', 'name' => 'GitHub', @@ -167,7 +167,7 @@ class V16Test extends TestCase ], ], [ - 'providers' => [ + 'authProviders' => [ [ 'name' => 'Github', 'appId' => 'client_id', From 9b6fc440d944016d7102b10cfc485eafce07ffa4 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Wed, 13 Sep 2023 16:57:59 +0530 Subject: [PATCH 20/22] Review changes and adds enabled in providers collection --- app/config/collections.php | 11 +++++++++++ src/Appwrite/Utopia/Response/Model/Message.php | 14 +++++++------- src/Appwrite/Utopia/Response/Model/Project.php | 2 +- src/Appwrite/Utopia/Response/Model/Provider.php | 11 +++++++---- src/Appwrite/Utopia/Response/Model/Subscriber.php | 5 ----- src/Appwrite/Utopia/Response/Model/Target.php | 11 ----------- src/Appwrite/Utopia/Response/Model/Topic.php | 5 ----- 7 files changed, 26 insertions(+), 33 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 6050afd95f..ed73c222a7 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1427,6 +1427,17 @@ $commonCollections = [ 'default' => false, 'array' => false, ], + [ + '$id' => ID::custom('enabled'), + 'type' => Database::VAR_BOOLEAN, + 'signed' => true, + 'size' => 0, + 'format' => '', + 'filters' => [], + 'required' => true, + 'default' => true, + 'array' => false, + ], [ '$id' => ID::custom('credentials'), 'type' => Database::VAR_STRING, diff --git a/src/Appwrite/Utopia/Response/Model/Message.php b/src/Appwrite/Utopia/Response/Model/Message.php index 150e837853..08d8af55ff 100644 --- a/src/Appwrite/Utopia/Response/Model/Message.php +++ b/src/Appwrite/Utopia/Response/Model/Message.php @@ -24,7 +24,7 @@ class Message extends Any ]) ->addRule('providerId', [ 'type' => self::TYPE_STRING, - 'description' => 'Provider Id for the message.', + 'description' => 'Provider ID for the message.', 'default' => '', 'example' => '5e5ea5c16897e', ]) @@ -40,26 +40,26 @@ class Message extends Any 'description' => 'Recipient of message.', 'required' => false, 'default' => DateTime::now(), - 'example' => DateTime::now(), + 'example' => self::TYPE_DATETIME_EXAMPLE, ]) - ->addRule('deliveryError', [ + ->addRule('deliveryErrors', [ 'type' => self::TYPE_STRING, - 'description' => 'Delivery error if any.', + 'description' => 'Delivery errors if any.', 'required' => false, 'default' => '', 'array' => true, - 'example' => 'Provider not valid.', + 'example' => 'Credentials not valid.', ]) ->addRule('deliveredTo', [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of recipients the message was delivered to.', - 'default' => '', + 'default' => 0, 'example' => 1, ]) ->addRule('delivered', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Status of delivery.', - 'default' => '', + 'default' => false, 'example' => true, ]); } diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index ae199d77f7..807c1fb574 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -348,7 +348,7 @@ class Project extends Model ]); } - $document->setAttribute("authProviders", $projectProviders); + $document->setAttribute('authProviders', $projectProviders); return $document; } diff --git a/src/Appwrite/Utopia/Response/Model/Provider.php b/src/Appwrite/Utopia/Response/Model/Provider.php index 668db553fc..7921786394 100644 --- a/src/Appwrite/Utopia/Response/Model/Provider.php +++ b/src/Appwrite/Utopia/Response/Model/Provider.php @@ -7,9 +7,6 @@ use Appwrite\Utopia\Response\Model; class Provider extends Model { - /** - * @var bool - */ protected bool $public = false; public function __construct() @@ -36,7 +33,13 @@ class Provider extends Model ->addRule('default', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Is this a pre-configured provider instance?', - 'default' => '', + 'default' => false, + 'example' => true, + ]) + ->addRule('enabled', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Is provider enabled?', + 'default' => true, 'example' => true, ]) ->addRule('type', [ diff --git a/src/Appwrite/Utopia/Response/Model/Subscriber.php b/src/Appwrite/Utopia/Response/Model/Subscriber.php index 8e4ef74d74..2f34619cb4 100644 --- a/src/Appwrite/Utopia/Response/Model/Subscriber.php +++ b/src/Appwrite/Utopia/Response/Model/Subscriber.php @@ -7,11 +7,6 @@ use Appwrite\Utopia\Response\Model; class Subscriber extends Model { - /** - * @var bool - */ - protected bool $public = false; - public function __construct() { $this diff --git a/src/Appwrite/Utopia/Response/Model/Target.php b/src/Appwrite/Utopia/Response/Model/Target.php index 272c929e11..5750f57eba 100644 --- a/src/Appwrite/Utopia/Response/Model/Target.php +++ b/src/Appwrite/Utopia/Response/Model/Target.php @@ -7,11 +7,6 @@ use Appwrite\Utopia\Response\Model; class Target extends Model { - /** - * @var bool - */ - protected bool $public = false; - public function __construct() { $this @@ -34,12 +29,6 @@ class Target extends Model 'default' => '', 'example' => '259125845563242502', ]) - ->addRule('providerType', [ - 'type' => self::TYPE_STRING, - 'description' => 'The type of provider supported by this target.', - 'default' => '', - 'example' => 'sms', - ]) ->addRule('identifier', [ 'type' => self::TYPE_STRING, 'description' => 'The target identifier.', diff --git a/src/Appwrite/Utopia/Response/Model/Topic.php b/src/Appwrite/Utopia/Response/Model/Topic.php index c0996fcf55..3a6e832f5c 100644 --- a/src/Appwrite/Utopia/Response/Model/Topic.php +++ b/src/Appwrite/Utopia/Response/Model/Topic.php @@ -7,11 +7,6 @@ use Appwrite\Utopia\Response\Model; class Topic extends Model { - /** - * @var bool - */ - protected bool $public = false; - public function __construct() { $this From 2fe94be4c183570a84aa2a62c782f0b94e8883fb Mon Sep 17 00:00:00 2001 From: prateek banga Date: Thu, 14 Sep 2023 16:34:53 +0530 Subject: [PATCH 21/22] review changes --- src/Appwrite/Utopia/Response/Model/Message.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Utopia/Response/Model/Message.php b/src/Appwrite/Utopia/Response/Model/Message.php index 08d8af55ff..971f148f7e 100644 --- a/src/Appwrite/Utopia/Response/Model/Message.php +++ b/src/Appwrite/Utopia/Response/Model/Message.php @@ -8,11 +8,6 @@ use Utopia\Database\DateTime; class Message extends Any { - /** - * @var bool - */ - protected bool $public = false; - public function __construct() { $this @@ -30,14 +25,14 @@ class Message extends Any ]) ->addRule('to', [ 'type' => self::TYPE_STRING, - 'description' => 'Recipient of message.', + 'description' => 'Message recipients.', 'default' => '', 'array' => true, 'example' => ['user-1'], ]) ->addRule('deliveryTime', [ 'type' => self::TYPE_DATETIME, - 'description' => 'Recipient of message.', + 'description' => 'Time the message is delivered at.', 'required' => false, 'default' => DateTime::now(), 'example' => self::TYPE_DATETIME_EXAMPLE, From 7d51da2e69e0e8b0d4751076457b1a23f64b43e4 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Thu, 14 Sep 2023 16:43:38 +0530 Subject: [PATCH 22/22] review changes --- src/Appwrite/Utopia/Response/Model/Message.php | 2 +- src/Appwrite/Utopia/Response/Model/Provider.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Appwrite/Utopia/Response/Model/Message.php b/src/Appwrite/Utopia/Response/Model/Message.php index 971f148f7e..6eebbcd793 100644 --- a/src/Appwrite/Utopia/Response/Model/Message.php +++ b/src/Appwrite/Utopia/Response/Model/Message.php @@ -43,7 +43,7 @@ class Message extends Any 'required' => false, 'default' => '', 'array' => true, - 'example' => 'Credentials not valid.', + 'example' => ['Failed to send message to target 5e5ea5c16897e: Credentials not valid.'], ]) ->addRule('deliveredTo', [ 'type' => self::TYPE_INTEGER, diff --git a/src/Appwrite/Utopia/Response/Model/Provider.php b/src/Appwrite/Utopia/Response/Model/Provider.php index 7921786394..e33e5a253d 100644 --- a/src/Appwrite/Utopia/Response/Model/Provider.php +++ b/src/Appwrite/Utopia/Response/Model/Provider.php @@ -7,8 +7,6 @@ use Appwrite\Utopia\Response\Model; class Provider extends Model { - protected bool $public = false; - public function __construct() { $this