diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index dbf149fd31..a3a0c48b8c 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -108,11 +108,12 @@ App::post('/v1/messaging/providers/mailgun') ->param('name', '', new Text(128), 'Provider name.') ->param('default', false, new Boolean(), 'Set as default provider.', true) ->param('enabled', true, new Boolean(), 'Set as enabled.', true) + ->param('isEuRegion', false, new Boolean(), 'Set as eu region.', true) ->param('apiKey', '', new Text(0), 'Mailgun API Key.') ->param('domain', '', new Text(0), 'Mailgun Domain.') ->inject('dbForProject') ->inject('response') - ->action(function (string $providerId, string $name, bool $default, bool $enabled, string $apiKey, string $domain, Database $dbForProject, Response $response) { + ->action(function (string $providerId, string $name, bool $default, bool $enabled, bool $isEuRegion, string $apiKey, string $domain, Database $dbForProject, Response $response) { $providerId = $providerId == 'unique()' ? ID::unique() : $providerId; $provider = new Document([ @@ -122,9 +123,11 @@ App::post('/v1/messaging/providers/mailgun') 'type' => 'email', 'default' => $default, 'enabled' => $enabled, + 'search' => $providerId . ' ' . $name . ' ' . 'mailgun' . ' ' . 'email', 'credentials' => [ 'apiKey' => $apiKey, 'domain' => $domain, + 'isEuRegion' => $isEuRegion, ], ]); @@ -164,11 +167,12 @@ App::patch('/v1/messaging/providers/:id/mailgun') ->param('id', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) ->param('enabled', true, new Boolean(), 'Set as enabled.', true) + ->param('isEuRegion', false, new Boolean(), 'Set as eu region.', true) ->param('apiKey', '', new Text(0), 'Mailgun API Key.', true) ->param('domain', '', new Text(0), 'Mailgun Domain.', true) ->inject('dbForProject') ->inject('response') - ->action(function (string $id, string $name, bool $enabled, string $apiKey, string $domain, Database $dbForProject, Response $response) { + ->action(function (string $id, string $name, bool $enabled, bool $isEuRegion, string $apiKey, string $domain, Database $dbForProject, Response $response) { $provider = $dbForProject->getDocument('providers', $id); if ($provider->isEmpty()) { @@ -182,9 +186,19 @@ App::patch('/v1/messaging/providers/:id/mailgun') if ($name) { $provider->setAttribute('name', $name); + $provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'mailgun' . ' ' . 'email'); } - if ($enabled === false) { + if ($isEuRegion === true || $isEuRegion === false) { + $credentials = $provider->getAttribute('credentials'); + $provider->setAttribute('credentials', [ + 'isEuRegion' => $isEuRegion, + 'apiKey' => $credentials['apiKey'], + 'domain' => $credentials['domain'], + ]); + } + + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -237,6 +251,7 @@ App::post('/v1/messaging/providers/sendgrid') 'type' => 'email', 'default' => $default, 'enabled' => $enabled, + 'search' => $providerId . ' ' . $name . ' ' . 'sendgrid' . ' ' . 'email', 'credentials' => [ 'apiKey' => $apiKey, ], @@ -295,9 +310,10 @@ App::patch('/v1/messaging/providers/:id/sendgrid') if ($name) { $provider->setAttribute('name', $name); + $provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'sendgrid' . ' ' . 'email'); } - if ($enabled === false) { + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -345,6 +361,7 @@ App::post('/v1/messaging/providers/msg91') 'name' => $name, 'provider' => 'msg91', 'type' => 'sms', + 'search' => $providerId . ' ' . $name . ' ' . 'msg91' . ' ' . 'sms', 'default' => $default, 'enabled' => $enabled, 'credentials' => [ @@ -407,9 +424,10 @@ App::patch('/v1/messaging/providers/:id/msg91') if ($name) { $provider->setAttribute('name', $name); + $provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'msg91' . ' ' . 'sms'); } - if ($enabled === false) { + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -461,6 +479,7 @@ App::post('/v1/messaging/providers/telesign') 'name' => $name, 'provider' => 'telesign', 'type' => 'sms', + 'search' => $providerId . ' ' . $name . ' ' . 'telesign' . ' ' . 'sms', 'default' => $default, 'enabled' => $enabled, 'credentials' => [ @@ -523,9 +542,10 @@ App::patch('/v1/messaging/providers/:id/telesign') if ($name) { $provider->setAttribute('name', $name); + $provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'telesign' . ' ' . 'sms'); } - if ($enabled === false) { + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -577,6 +597,7 @@ App::post('/v1/messaging/providers/textmagic') 'name' => $name, 'provider' => 'text-magic', 'type' => 'sms', + 'search' => $providerId . ' ' . $name . ' ' . 'text-magic' . ' ' . 'sms', 'default' => $default, 'enabled' => $enabled, 'credentials' => [ @@ -639,9 +660,10 @@ App::patch('/v1/messaging/providers/:id/textmagic') if ($name) { $provider->setAttribute('name', $name); + $provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'textmagic' . ' ' . 'sms'); } - if ($enabled === false) { + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -693,6 +715,7 @@ App::post('/v1/messaging/providers/twilio') 'name' => $name, 'provider' => 'twilio', 'type' => 'sms', + 'search' => $providerId . ' ' . $name . ' ' . 'twilio' . ' ' . 'sms', 'default' => $default, 'enabled' => $enabled, 'credentials' => [ @@ -755,9 +778,10 @@ App::patch('/v1/messaging/providers/:id/twilio') if ($name) { $provider->setAttribute('name', $name); + $provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'twilio' . ' ' . 'sms'); } - if ($enabled === false) { + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -809,6 +833,7 @@ App::post('/v1/messaging/providers/vonage') 'name' => $name, 'provider' => 'vonage', 'type' => 'sms', + 'search' => $providerId . ' ' . $name . ' ' . 'vonage' . ' ' . 'sms', 'default' => $default, 'enabled' => $enabled, 'credentials' => [ @@ -871,9 +896,10 @@ App::patch('/v1/messaging/providers/:id/vonage') if ($name) { $provider->setAttribute('name', $name); + $provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'vonage' . ' ' . 'sms'); } - if ($enabled === false) { + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -927,6 +953,7 @@ App::post('/v1/messaging/providers/fcm') 'name' => $name, 'provider' => 'fcm', 'type' => 'push', + 'search' => $providerId . ' ' . $name . ' ' . 'fcm' . ' ' . 'push', 'default' => $default, 'enabled' => $enabled, 'credentials' => [ @@ -987,9 +1014,10 @@ App::patch('/v1/messaging/providers/:id/fcm') if ($name) { $provider->setAttribute('name', $name); + $provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'fcm' . ' ' . 'push'); } - if ($enabled === false) { + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -1035,6 +1063,7 @@ App::post('/v1/messaging/providers/apns') 'name' => $name, 'provider' => 'apns', 'type' => 'push', + 'search' => $providerId . ' ' . $name . ' ' . 'apns' . ' ' . 'push', 'default' => $default, 'enabled' => $enabled, 'credentials' => [ @@ -1103,9 +1132,10 @@ App::patch('/v1/messaging/providers/:id/apns') if ($name) { $provider->setAttribute('name', $name); + $provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'apns' . ' ' . 'push'); } - if ($enabled === false) { + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -1219,7 +1249,7 @@ App::patch('/v1/messaging/providers/:id/general') $provider->setAttribute('name', $name); } - if ($enabled === false) { + if ($enabled === true || $enabled === false) { $provider->setAttribute('enabled', $enabled); } @@ -1280,9 +1310,8 @@ App::post('/v1/messaging/messages/email') ->param('to', [], new ArrayList(new Text(0)), 'Email Recepient.') ->param('subject', '', new Text(0), 'Email Subject.') ->param('content', '', new Text(0), 'Email Content.') - ->param('from', '', new Text(0), 'Email from.') + ->param('from', '', new Text(0), 'Email from.', true) ->param('html', false, new Boolean(false), 'Is content of type HTML', true) - ->param('deliveryTime', '', new DatetimeValidator(), 'Delivery time of the message', true) ->inject('dbForProject') ->inject('project') ->inject('messaging') @@ -1304,11 +1333,7 @@ App::post('/v1/messaging/messages/email') 'from' => $from, 'html' => $html ], - 'deliveryTime' => $deliveryTime, - 'deliveryErrors' => null, - 'deliveredTo' => null, - 'delivered' => false, - 'search' => null, + 'search' => $subject . ' ' . $from, ])); $messaging diff --git a/composer.lock b/composer.lock index 8eb26d06d7..279847dedc 100644 --- a/composer.lock +++ b/composer.lock @@ -65,16 +65,16 @@ }, { "name": "appwrite/appwrite", - "version": "8.0.0", + "version": "10.0.0", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-for-php.git", - "reference": "2b9e966edf35c4061179ed98ea364698ab30de8b" + "reference": "461eedf4efd502dc905c3055f36f0e3583f67390" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/2b9e966edf35c4061179ed98ea364698ab30de8b", - "reference": "2b9e966edf35c4061179ed98ea364698ab30de8b", + "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/461eedf4efd502dc905c3055f36f0e3583f67390", + "reference": "461eedf4efd502dc905c3055f36f0e3583f67390", "shasum": "" }, "require": { @@ -99,10 +99,10 @@ "support": { "email": "team@appwrite.io", "issues": "https://github.com/appwrite/sdk-for-php/issues", - "source": "https://github.com/appwrite/sdk-for-php/tree/8.0.0", + "source": "https://github.com/appwrite/sdk-for-php/tree/10.0.0", "url": "https://appwrite.io/support" }, - "time": "2023-04-12T10:16:28+00:00" + "time": "2023-09-07T23:28:31+00:00" }, { "name": "appwrite/php-clamav", @@ -2152,16 +2152,16 @@ }, { "name": "utopia-php/database", - "version": "0.43.1", + "version": "0.43.2", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "cc0247f4f0c402b39f663bf9f77b29d69b95f9d6" + "reference": "f2626acd42665a9987c94af1c93bf20c28d55c9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/cc0247f4f0c402b39f663bf9f77b29d69b95f9d6", - "reference": "cc0247f4f0c402b39f663bf9f77b29d69b95f9d6", + "url": "https://api.github.com/repos/utopia-php/database/zipball/f2626acd42665a9987c94af1c93bf20c28d55c9d", + "reference": "f2626acd42665a9987c94af1c93bf20c28d55c9d", "shasum": "" }, "require": { @@ -2202,9 +2202,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.43.1" + "source": "https://github.com/utopia-php/database/tree/0.43.2" }, - "time": "2023-09-01T20:38:36+00:00" + "time": "2023-09-07T19:04:33+00:00" }, { "name": "utopia-php/domains", @@ -2520,12 +2520,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/messaging.git", - "reference": "4ebebe97d80bb1de10d362c2464ba28717d333ac" + "reference": "2bb09220d0993a9f8f0afc63ff51382b13d93e18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/messaging/zipball/4ebebe97d80bb1de10d362c2464ba28717d333ac", - "reference": "4ebebe97d80bb1de10d362c2464ba28717d333ac", + "url": "https://api.github.com/repos/utopia-php/messaging/zipball/2bb09220d0993a9f8f0afc63ff51382b13d93e18", + "reference": "2bb09220d0993a9f8f0afc63ff51382b13d93e18", "shasum": "" }, "require": { @@ -2534,8 +2534,8 @@ }, "require-dev": { "laravel/pint": "^1.2", - "phpmailer/phpmailer": "^6.8", - "phpunit/phpunit": "^9.6" + "phpmailer/phpmailer": "6.8.*", + "phpunit/phpunit": "9.6.*" }, "type": "library", "autoload": { @@ -2560,31 +2560,31 @@ "issues": "https://github.com/utopia-php/messaging/issues", "source": "https://github.com/utopia-php/messaging/tree/feat-push" }, - "time": "2023-09-01T14:13:03+00:00" + "time": "2023-09-14T20:29:49+00:00" }, { "name": "utopia-php/migration", - "version": "0.3.2", + "version": "0.3.4", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "49a28adfbb781f0c08f1eaf459a8fbb8ab9fcc70" + "reference": "ade836d61b3e1547bc9f0dc300ee75b24ab49f7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/49a28adfbb781f0c08f1eaf459a8fbb8ab9fcc70", - "reference": "49a28adfbb781f0c08f1eaf459a8fbb8ab9fcc70", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/ade836d61b3e1547bc9f0dc300ee75b24ab49f7a", + "reference": "ade836d61b3e1547bc9f0dc300ee75b24ab49f7a", "shasum": "" }, "require": { - "appwrite/appwrite": "^8.0", - "php": ">=8.0", - "utopia-php/cli": "^0.15.0" + "appwrite/appwrite": "10.0.*", + "php": "8.*", + "utopia-php/cli": "0.*" }, "require-dev": { - "laravel/pint": "^1.10", - "phpunit/phpunit": "^9.3", - "vlucas/phpdotenv": "^5.5" + "laravel/pint": "1.*", + "phpunit/phpunit": "9.*", + "vlucas/phpdotenv": "5.*" }, "type": "library", "autoload": { @@ -2616,9 +2616,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.3.2" + "source": "https://github.com/utopia-php/migration/tree/0.3.4" }, - "time": "2023-08-31T04:11:35+00:00" + "time": "2023-09-14T17:17:55+00:00" }, { "name": "utopia-php/mongo", @@ -4145,16 +4145,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.23.1", + "version": "1.24.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26" + "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6", "shasum": "" }, "require": { @@ -4186,22 +4186,22 @@ "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.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0" }, - "time": "2023-08-03T16:32:59+00:00" + "time": "2023-09-07T20:46:32+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.27", + "version": "9.2.28", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" + "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", + "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", "shasum": "" }, "require": { @@ -4258,7 +4258,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.28" }, "funding": [ { @@ -4266,7 +4266,7 @@ "type": "github" } ], - "time": "2023-07-26T13:44:30+00:00" + "time": "2023-09-12T14:36:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -6036,5 +6036,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" }