diff --git a/composer.lock b/composer.lock index 803678ff49..3c195434b3 100644 --- a/composer.lock +++ b/composer.lock @@ -2906,16 +2906,16 @@ }, { "name": "utopia-php/vcs", - "version": "0.6.2", + "version": "0.6.3", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "f135291b87cb45335fc6608722e7f89894bc33ee" + "reference": "86c3f42a2624bcccb7a67b74dcd7bd3a31fc2e4b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/f135291b87cb45335fc6608722e7f89894bc33ee", - "reference": "f135291b87cb45335fc6608722e7f89894bc33ee", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/86c3f42a2624bcccb7a67b74dcd7bd3a31fc2e4b", + "reference": "86c3f42a2624bcccb7a67b74dcd7bd3a31fc2e4b", "shasum": "" }, "require": { @@ -2949,9 +2949,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.6.2" + "source": "https://github.com/utopia-php/vcs/tree/0.6.3" }, - "time": "2023-11-08T15:36:03+00:00" + "time": "2023-12-14T06:53:39+00:00" }, { "name": "utopia-php/websocket", @@ -3489,16 +3489,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.17.1", + "version": "v4.18.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", "shasum": "" }, "require": { @@ -3539,9 +3539,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" }, - "time": "2023-08-13T19:53:39+00:00" + "time": "2023-12-10T21:03:43+00:00" }, { "name": "phar-io/manifest", @@ -3893,16 +3893,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.4", + "version": "1.24.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496" + "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6bd0c26f3786cd9b7c359675cb789e35a8e07496", - "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fedf211ff14ec8381c9bf5714e33a7a552dd1acc", + "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc", "shasum": "" }, "require": { @@ -3934,9 +3934,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.24.4" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.5" }, - "time": "2023-11-26T18:29:22+00:00" + "time": "2023-12-16T09:33:33+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index e04bace4c1..b075de762b 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -123,7 +123,9 @@ class Messaging extends Action /** * @var Document[] $providers */ - $providers = []; + $providers = [ + $primaryProvider->getId() => $primaryProvider + ]; foreach ($recipients as $recipient) { $providerId = $recipient->getAttribute('providerId'); @@ -144,13 +146,16 @@ class Messaging extends Action */ $results = batch(\array_map(function ($providerId) use ($identifiersByProviderId, $providers, $primaryProvider, $message, $dbForProject) { return function () use ($providerId, $identifiersByProviderId, $providers, $primaryProvider, $message, $dbForProject) { - if ($primaryProvider->getId() === $providerId) { - $provider = $primaryProvider; - } else { + if (\array_key_exists($providerId, $providers)) { + $provider = $providers[$providerId]; + } + else { $provider = $dbForProject->getDocument('providers', $providerId, [Query::equal('enabled', [true])]); if ($provider->isEmpty()) { $provider = $primaryProvider; + } else { + $providers[$providerId] = $provider; } } @@ -183,7 +188,7 @@ class Messaging extends Action try { $response = new Response($provider->getAttribute('type')); - $response->fromArray(\json_decode($adapter->send($data))); + $response->fromArray($adapter->send($data)); $deliveredTotal += $response->getDeliveredTo(); $details[] = $response->getDetails(); @@ -193,7 +198,7 @@ class Messaging extends Action } // Deleting push targets when token has expired. - if ($detail['error'] === 'Expired token.') { + if ($detail['error'] === 'Expired device token.') { $target = $dbForProject->findOne('targets', [Query::equal('identifier', [$detail['recipient']])]); if ($target instanceof Document && !$target->isEmpty()) { $dbForProject->deleteDocument('targets', $target->getId()); diff --git a/tests/e2e/Services/Messaging/MessagingBase.php b/tests/e2e/Services/Messaging/MessagingBase.php index 84b16597cc..ca472591c7 100644 --- a/tests/e2e/Services/Messaging/MessagingBase.php +++ b/tests/e2e/Services/Messaging/MessagingBase.php @@ -231,7 +231,6 @@ trait MessagingBase ], [ 'topicId' => ID::unique(), 'name' => 'my-app', - 'description' => 'web app' ]); $this->assertEquals(201, $response['headers']['status-code']); $this->assertEquals('my-app', $response['body']['name']);