From e53af019da46c367546ed6bc789f28143a9ff7f2 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Tue, 29 Aug 2023 21:43:21 +0530 Subject: [PATCH] Revert "Working on messaging tests with worker" This reverts commit c2c70d68e9b624e22adc79ff960dd1a36962fd92. --- app/workers/messaging.php | 46 ++++++--------- composer.lock | 56 +++++++++---------- docker-compose.yml | 14 ++--- phpunit.xml | 2 +- .../Account/AccountCustomClientTest.php | 11 ---- 5 files changed, 54 insertions(+), 75 deletions(-) diff --git a/app/workers/messaging.php b/app/workers/messaging.php index 1a58029c07..84af6fa802 100644 --- a/app/workers/messaging.php +++ b/app/workers/messaging.php @@ -79,25 +79,11 @@ class MessagingV1 extends Worker public function run(): void { - $messageId = $this->args['messageId']; - $messageRecord = - $this - ->getConsoleDB() - ->getDocument('messages', $messageId); - - $providerId = $messageRecord['providerId']; - - $providerRecord = - $this - ->getConsoleDB() - ->getDocument('providers', $providerId); - - $message = match ($providerRecord->getAttribute('type')) { - 'sms' => $this->buildSMSMessage($messageRecord->getArrayCopy()), - 'push' => $this->buildPushMessage($messageRecord->getArrayCopy()), - 'email' => $this->buildEmailMessage($messageRecord->getArrayCopy()), - default => null - }; + $providerId = $this->args['providerId']; + $providerRecord = + $this + ->getConsoleDB() + ->getDocument('providers', $providerId); $provider = match ($providerRecord->getAttribute('type')) {//stubbbbbbed. 'sms' => $this->sms($providerRecord), @@ -106,21 +92,25 @@ class MessagingV1 extends Worker default => null }; - var_dump($provider); - die; - // Query for the provider // switch on provider name // call function passing needed credentials returns required provider. + $messageId = $this->args['messageId']; + $messageRecord = + $this + ->getConsoleDB() + ->getDocument('messages', $messageId); + + $message = match ($providerRecord->getAttribute('type')) { + 'sms' => $this->buildSMSMessage($messageRecord->getArrayCopy()), + 'push' => $this->buildPushMessage($messageRecord->getArrayCopy()), + 'email' => $this->buildEmailMessage($messageRecord->getArrayCopy()), + default => null + }; - try { - $provider->send($message); - } catch (\Exception $error) { - throw new Exception('Error sending message: ' . $error->getMessage(), 500); - } - + $provider->send($message); } public function shutdown(): void diff --git a/composer.lock b/composer.lock index ca4eff1d7d..f2b39d8414 100644 --- a/composer.lock +++ b/composer.lock @@ -1183,16 +1183,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.28.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", "shasum": "" }, "require": { @@ -1201,7 +1201,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.28-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1246,7 +1246,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" }, "funding": [ { @@ -1262,7 +1262,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "utopia-php/abuse", @@ -5024,16 +5024,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.28.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", "shasum": "" }, "require": { @@ -5048,7 +5048,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.28-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -5086,7 +5086,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" }, "funding": [ { @@ -5102,20 +5102,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", "shasum": "" }, "require": { @@ -5130,7 +5130,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.28-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -5169,7 +5169,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" }, "funding": [ { @@ -5185,7 +5185,7 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "textalk/websocket", @@ -5288,16 +5288,16 @@ }, { "name": "twig/twig", - "version": "v3.7.1", + "version": "v3.7.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554" + "reference": "5cf942bbab3df42afa918caeba947f1b690af64b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", - "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/5cf942bbab3df42afa918caeba947f1b690af64b", + "reference": "5cf942bbab3df42afa918caeba947f1b690af64b", "shasum": "" }, "require": { @@ -5307,7 +5307,7 @@ }, "require-dev": { "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.3" + "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0" }, "type": "library", "autoload": { @@ -5343,7 +5343,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.7.1" + "source": "https://github.com/twigphp/Twig/tree/v3.7.0" }, "funding": [ { @@ -5355,7 +5355,7 @@ "type": "tidelift" } ], - "time": "2023-08-28T11:09:02+00:00" + "time": "2023-07-26T07:16:09+00:00" } ], "aliases": [ diff --git a/docker-compose.yml b/docker-compose.yml index 79c7abd7fa..16b5937704 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -732,13 +732,13 @@ services: - _APP_CONNECTIONS_QUEUE - _APP_REGION - # appwrite-assistant: - # container_name: appwrite-assistant - # image: appwrite/assistant:0.1.0 - # networks: - # - appwrite - # environment: - # - OPENAI_API_KEY + appwrite-assistant: + container_name: appwrite-assistant + image: appwrite/assistant:0.1.0 + networks: + - appwrite + environment: + - OPENAI_API_KEY openruntimes-executor: container_name: openruntimes-executor diff --git a/phpunit.xml b/phpunit.xml index cca546e9ad..cffe166336 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,7 +6,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="true" + stopOnFailure="false" > diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index 796c723ee6..d225496a65 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -12,7 +12,6 @@ use Tests\E2E\Scopes\SideClient; use Utopia\Database\DateTime; use Utopia\Database\Helpers\ID; use Utopia\Database\Validator\Datetime as DatetimeValidator; -use Utopia\Messaging\Adapters\SMS\Mock as MockProvider; use function sleep; @@ -768,16 +767,6 @@ class AccountCustomClientTest extends Scope } - public function testCreateMockSMS(): MockProvider - { - - $smsMockProvider = new MockProvider('blah', 'blah'); - - $this->assertNotEquals(null, $smsMockProvider); - - return $smsMockProvider; - } - public function testCreatePhone(): array { $number = '+123456789';