From 7d4754ef04c58387dccd4c8348c3c3dde683cfb6 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:29:06 -0500 Subject: [PATCH 01/26] feat: add Pusher symfony notifier bridge --- .../Notifier/Bridge/Pusher/.gitattributes | 4 ++ .../Notifier/Bridge/Pusher/.gitignore | 8 +++ .../Notifier/Bridge/Pusher/CHANGELOG.md | 7 ++ .../Component/Notifier/Bridge/Pusher/LICENSE | 19 ++++++ .../Bridge/Pusher/PusherNotification.php | 18 +++++ .../Notifier/Bridge/Pusher/PusherOptions.php | 35 ++++++++++ .../Bridge/Pusher/PusherRecipient.php | 22 +++++++ .../Bridge/Pusher/PusherTransport.php | 66 +++++++++++++++++++ .../Bridge/Pusher/PusherTransportFactory.php | 44 +++++++++++++ .../Notifier/Bridge/Pusher/README.md | 32 +++++++++ .../Bridge/Pusher/Tests/PusherOptionsTest.php | 44 +++++++++++++ .../Tests/PusherTransportFactoryTest.php | 55 ++++++++++++++++ .../Pusher/Tests/PusherTransportTest.php | 62 +++++++++++++++++ .../Notifier/Bridge/Pusher/composer.json | 56 ++++++++++++++++ .../Notifier/Bridge/Pusher/phpunit.xml.dist | 31 +++++++++ 15 files changed, 503 insertions(+) create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/.gitattributes create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php create mode 100755 src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php create mode 100755 src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php create mode 100755 src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/README.md create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/composer.json create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/.gitattributes b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitattributes new file mode 100644 index 0000000000000..84c7add058fb5 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitattributes @@ -0,0 +1,4 @@ +/Tests export-ignore +/phpunit.xml.dist export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore new file mode 100644 index 0000000000000..ad99719aaed4c --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore @@ -0,0 +1,8 @@ +vendor/ +composer.lock +phpunit.xml +.phpunit.result.cache +.php-cs-fixer +.php-cs-fixer.cache +.phpcs-cache +phpcs.xml diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md new file mode 100644 index 0000000000000..f19f06f2721c4 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -0,0 +1,7 @@ +CHANGELOG +========= + +6.1.0 +----- + + * Added the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE new file mode 100644 index 0000000000000..7e53e00d06058 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2019-2022 Metises LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php new file mode 100644 index 0000000000000..ced209e51a6d9 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -0,0 +1,18 @@ +getSubject(), $this->getContent(), new PusherOptions($recipient->getChannels())); + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php new file mode 100755 index 0000000000000..571b6defcda95 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -0,0 +1,35 @@ + + */ +final class PusherOptions implements MessageOptionsInterface +{ + private array $channels; + + public function __construct(array $channels) + { + $this->channels = $channels; + } + + public function toArray(): array + { + return $this->channels; + } + + public function getRecipientId(): ?string + { + return null; + } + + public function getChannels(): array + { + return $this->channels; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php new file mode 100644 index 0000000000000..dcc2c6d069430 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -0,0 +1,22 @@ +channels = $channels; + } + + public function getChannels(): array + { + return $this->channels; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php new file mode 100755 index 0000000000000..2832da1916876 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -0,0 +1,66 @@ + + */ +final class PusherTransport extends AbstractTransport +{ + private $pusherClient; + + public function __construct(Pusher $pusherClient, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null) + { + $this->pusherClient = $pusherClient; + + parent::__construct($client, $dispatcher); + } + + public function __toString(): string + { + $settings = $this->pusherClient->getSettings(); + preg_match('/api-([\w]+)\.pusher\.com$/m', $settings['host'], $server); + + return sprintf('pusher://%s:%s@%s?server=%s', $settings['auth_key'], $settings['secret'], $settings['app_id'], $server[1]); + } + + public function supports(MessageInterface $message): bool + { + return $message instanceof PushMessage && (null === $message->getOptions() || $message->getOptions() instanceof PusherOptions); + } + + protected function doSend(MessageInterface $message): SentMessage + { + if (!$message instanceof PushMessage) { + throw new UnsupportedMessageTypeException(__CLASS__, PushMessage::class, $message); + } + + $options = $message->getOptions(); + + if (!$options instanceof PusherOptions) { + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, PusherOptions::class)); + } + + try { + $this->pusherClient->trigger($options->getChannels(), $message->getSubject(), $message->getContent(), [], true); + } catch (Throwable) { + throw new RuntimeException('An error occurred at Pusher Notifier Transport'); + } + + return new SentMessage($message, $this->__toString()); + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php new file mode 100755 index 0000000000000..e21e77535033d --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -0,0 +1,44 @@ + + */ +#[Autoconfigure(tags: ['texter.transport_factory'])] +final class PusherTransportFactory extends AbstractTransportFactory +{ + public function create(Dsn $dsn): TransportInterface + { + if ('pusher' !== $dsn->getScheme()) { + throw new UnsupportedSchemeException($dsn, 'pusher', $this->getSupportedSchemes()); + } + + if (null === $dsn->getUser() || null === $dsn->getPassword() || null === $dsn->getOption('server')) { + throw new MissingRequiredOptionException('Pusher needs a APP_KEY, APP_SECRET AND SERVER specified.'); + } + + $options = [ + 'cluster' => $dsn->getOption('server', 'mt1'), + ]; + + $pusherClient = new Pusher($dsn->getUser(), $dsn->getPassword(), $dsn->getHost(), $options); + + return new PusherTransport($pusherClient, $this->client, $this->dispatcher); + } + + protected function getSupportedSchemes(): array + { + return ['pusher']; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/README.md b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md new file mode 100644 index 0000000000000..c8f4fb1f0c2bc --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md @@ -0,0 +1,32 @@ +Pusher Notifier +============== + +Provides [Pusher](https://pusher.com) integration for Symfony Notifier. + +DSN example +----------- + +``` +PUSHER_DSN=pusher://APP_KEY:APP_SECRET@APP_ID?server=SERVER +``` + +where: + +- `APP_KEY` is your app unique key +- `APP_SECRET` is your app unique and secret password +- `APP_ID` is your app unique id +- `SERVER` is your app server + +valid DSN's are: + +``` +PUSHER_DSN=pusher://as8d09a0ds8:as8d09a8sd0a8sd0@123123123?server=mt1 +``` + +invalid DSN's are: + +``` +PUSHER_DSN=pusher://asdasdasd@asdasdasd?server=invalid-server +PUSHER_DSN=pusher://:asdasdasd@asdasdasd?server=invalid-server +PUSHER_DSN=pusher://asdadasdasd:asdasdasd@asdasdasd?server=invalid-server +``` diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php new file mode 100644 index 0000000000000..871fbdebf34b6 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php @@ -0,0 +1,44 @@ + + * + * @internal + * @coversNothing + */ +final class PusherOptionsTest extends TestCase +{ + /** + * @dataProvider toArrayProvider + * @dataProvider toArraySimpleOptionsProvider + */ + public function testToArray(array $options, array $expected = null): void + { + static::assertSame($expected ?? $options, (new PusherOptions($options))->toArray()); + } + + public function toArrayProvider(): iterable + { + yield 'empty is allowed' => [ + [], + [], + ]; + } + + public function toArraySimpleOptionsProvider(): iterable + { + yield [[]]; + } + + public function setProvider(): iterable + { + yield ['async', 'async', true]; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php new file mode 100644 index 0000000000000..fabe60bc0011f --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php @@ -0,0 +1,55 @@ + + * + * @internal + * @coversNothing + */ +final class PusherTransportFactoryTest extends TransportFactoryTestCase +{ + /** + * @return PusherTransportFactory + */ + public function createFactory(): TransportFactoryInterface + { + return new PusherTransportFactory(); + } + + public function createProvider(): iterable + { + yield [ + 'pusher://key:secret@id?server=mt1', + 'pusher://key:secret@id?server=mt1', + ]; + } + + public function supportsProvider(): iterable + { + yield [true, 'pusher://key:secret@id?server=mt1']; + yield [false, 'somethingElse://xoxb-TestToken@host?server=testChannel']; + } + + public function incompleteDsnProvider(): iterable + { + yield 'missing secret' => ['pusher://key@id?server=mt1']; + } + + public function unsupportedSchemeProvider(): iterable + { + yield ['somethingElse://something@else']; + } + + public function missingRequiredOptionProvider(): iterable + { + yield ['pusher://key:secret@id']; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php new file mode 100644 index 0000000000000..dfb3644f7d807 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -0,0 +1,62 @@ + + * + * @internal + * @coversNothing + */ +final class PusherTransportTest extends TransportTestCase +{ + public function toStringProvider(): iterable + { + yield ['pusher://key:secret@app?server=mt1', $this->createTransport()]; + } + + /** + * @return PusherTransport + */ + public function createTransport(HttpClientInterface $client = null): TransportInterface + { + return new PusherTransport(new Pusher('key', 'secret', 'app'), $client ?? $this->createMock(HttpClientInterface::class)); + } + + public function supportedMessagesProvider(): iterable + { + yield [new PushMessage('event', 'data')]; + } + + public function unsupportedMessagesProvider(): iterable + { + yield [new SmsMessage('0611223344', 'Hello!')]; + yield [$this->createMock(MessageInterface::class)]; + } + + public function testCanSetCustomHost(): void + { + static::markTestSkipped('Does not apply for this provider.'); + } + + public function testCanSetCustomPort(): void + { + static::markTestSkipped('Does not apply for this provider.'); + } + + public function testCanSetCustomHostAndPort(): void + { + static::markTestSkipped('Does not apply for this provider.'); + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json new file mode 100644 index 0000000000000..dce2a2a86a75d --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json @@ -0,0 +1,56 @@ +{ + "name": "metises/pusher-notifier", + "type": "symfony-notifier-bridge", + "description": "Symfony Pusher Notifier Bridge", + "keywords": [ + "pusher", + "notifier" + ], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Yasmany Cubela Medina", + "email": "yasmanycm@gmail.com" + } + ], + "require": { + "php": ">=8.0", + "pusher/pusher-php-server": "^7.0", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/http-client": "^4.3|^5.0|^6.0", + "symfony/notifier": "^5.3|^6.0", + "symfony/dependency-injection": "^5.3|^6.0" + }, + "require-dev": { + "roave/security-advisories": "dev-latest", + "symfony/event-dispatcher": "^4.3|^5.0|^6.0", + "phpunit/phpunit": "^9.5", + "friendsofphp/php-cs-fixer": "v3.4" + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Notifier\\Bridge\\Pusher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "scripts": { + "csf": "./vendor/bin/php-cs-fixer fix", + "post-install-cmd": [ + "@auto-scripts" + ], + "post-update-cmd": [ + "@auto-scripts" + ] + }, + "minimum-stability": "dev", + "config": { + "allow-plugins": { + "phpstan/extension-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "symfony/thanks": true + } + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist b/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist new file mode 100644 index 0000000000000..9d948b7dd3cd3 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + From b2d65b1c66c28415f33ac9d56f55c74b60ed7754 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:37:42 -0500 Subject: [PATCH 02/26] fix: composer.json package name --- .../Notifier/Bridge/Pusher/composer.json | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json index dce2a2a86a75d..e618f6a0d21a3 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json @@ -1,5 +1,5 @@ { - "name": "metises/pusher-notifier", + "name": "symfony/pusher-notifier", "type": "symfony-notifier-bridge", "description": "Symfony Pusher Notifier Bridge", "keywords": [ @@ -12,21 +12,17 @@ { "name": "Yasmany Cubela Medina", "email": "yasmanycm@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "require": { - "php": ">=8.0", + "php": ">=8.1", "pusher/pusher-php-server": "^7.0", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0", - "symfony/dependency-injection": "^5.3|^6.0" - }, - "require-dev": { - "roave/security-advisories": "dev-latest", - "symfony/event-dispatcher": "^4.3|^5.0|^6.0", - "phpunit/phpunit": "^9.5", - "friendsofphp/php-cs-fixer": "v3.4" + "symfony/http-client": "^5.4|^6.0", + "symfony/notifier": "^5.4|^6.0" }, "autoload": { "psr-4": { @@ -36,21 +32,5 @@ "/Tests/" ] }, - "scripts": { - "csf": "./vendor/bin/php-cs-fixer fix", - "post-install-cmd": [ - "@auto-scripts" - ], - "post-update-cmd": [ - "@auto-scripts" - ] - }, - "minimum-stability": "dev", - "config": { - "allow-plugins": { - "phpstan/extension-installer": true, - "dealerdirect/phpcodesniffer-composer-installer": true, - "symfony/thanks": true - } - } + "minimum-stability": "dev" } From aa58ad28bfd14c27e19eb09a56e12acc6fd5e195 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:39:42 -0500 Subject: [PATCH 03/26] fix: LICENSE and CHANGELOG.md --- src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md | 2 +- src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md index f19f06f2721c4..42bafa26795fb 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG ========= -6.1.0 +6.2.0 ----- * Added the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE index 7e53e00d06058..9c907a46a6218 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Metises LLC +Copyright (c) 2019-2022 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From caf622780df6f0b3c7648868e86e6c037acc3957 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:44:32 -0500 Subject: [PATCH 04/26] chore: apply fabbot --- .../Notifier/Bridge/Pusher/PusherNotification.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherOptions.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherRecipient.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherTransport.php | 11 ++++++++++- .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 9 +++++++++ .../Bridge/Pusher/Tests/PusherOptionsTest.php | 10 ++++++++++ .../Pusher/Tests/PusherTransportFactoryTest.php | 10 ++++++++++ .../Bridge/Pusher/Tests/PusherTransportTest.php | 10 ++++++++++ 8 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index ced209e51a6d9..cbc482f68a907 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Symfony\Component\Notifier\Message\PushMessage; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index 571b6defcda95..4ac5858cd5231 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Symfony\Component\Notifier\Message\MessageOptionsInterface; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php index dcc2c6d069430..1c94c3588807c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Symfony\Component\Notifier\Recipient\RecipientInterface; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 2832da1916876..b32a83ccd7ed6 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Pusher\Pusher; @@ -23,7 +32,7 @@ final class PusherTransport extends AbstractTransport { private $pusherClient; - public function __construct(Pusher $pusherClient, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null) + public function __construct(Pusher $pusherClient, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { $this->pusherClient = $pusherClient; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index e21e77535033d..e6c0344db07c7 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Pusher\Pusher; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php index 871fbdebf34b6..3e97e740fd571 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher\Tests; use PHPUnit\Framework\TestCase; @@ -11,6 +20,7 @@ * @author Yasmany Cubela Medina * * @internal + * * @coversNothing */ final class PusherOptionsTest extends TestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php index fabe60bc0011f..245ea1dae212d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher\Tests; use Symfony\Component\Notifier\Bridge\Pusher\PusherTransportFactory; @@ -12,6 +21,7 @@ * @author Yasmany Cubela Medina * * @internal + * * @coversNothing */ final class PusherTransportFactoryTest extends TransportFactoryTestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index dfb3644f7d807..fffa888748980 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher\Tests; use Pusher\Pusher; @@ -17,6 +26,7 @@ * @author Yasmany Cubela Medina * * @internal + * * @coversNothing */ final class PusherTransportTest extends TransportTestCase From 9459855b4c543ba47fe4c26ece7f2cc9af9b65f7 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:46:24 -0500 Subject: [PATCH 05/26] chore: apply fabbot --- .../Notifier/Bridge/Pusher/PusherNotification.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherOptions.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherRecipient.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherTransport.php | 11 ++++++++++- .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 9 +++++++++ .../Bridge/Pusher/Tests/PusherOptionsTest.php | 2 +- .../Bridge/Pusher/Tests/PusherTransportTest.php | 6 +++--- 7 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index cbc482f68a907..ae65eb79b1456 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index 4ac5858cd5231..f220294d7e71f 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php index 1c94c3588807c..e772e2083bf8e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index b32a83ccd7ed6..4683526f5eb8f 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* @@ -67,7 +76,7 @@ protected function doSend(MessageInterface $message): SentMessage try { $this->pusherClient->trigger($options->getChannels(), $message->getSubject(), $message->getContent(), [], true); } catch (Throwable) { - throw new RuntimeException('An error occurred at Pusher Notifier Transport'); + throw new RuntimeException('An error occurred at Pusher Notifier Transport.'); } return new SentMessage($message, $this->__toString()); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index e6c0344db07c7..c1eac38d48723 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php index 3e97e740fd571..208a222eaa91d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php @@ -29,7 +29,7 @@ final class PusherOptionsTest extends TestCase * @dataProvider toArrayProvider * @dataProvider toArraySimpleOptionsProvider */ - public function testToArray(array $options, array $expected = null): void + public function testToArray(array $options, array $expected = null) { static::assertSame($expected ?? $options, (new PusherOptions($options))->toArray()); } diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index fffa888748980..92514c8121c35 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -55,17 +55,17 @@ public function unsupportedMessagesProvider(): iterable yield [$this->createMock(MessageInterface::class)]; } - public function testCanSetCustomHost(): void + public function testCanSetCustomHost() { static::markTestSkipped('Does not apply for this provider.'); } - public function testCanSetCustomPort(): void + public function testCanSetCustomPort() { static::markTestSkipped('Does not apply for this provider.'); } - public function testCanSetCustomHostAndPort(): void + public function testCanSetCustomHostAndPort() { static::markTestSkipped('Does not apply for this provider.'); } From f0d3e633fa11ee8bdb6127e803e3ecf7577c32f3 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:47:15 -0500 Subject: [PATCH 06/26] chore: apply fabbot --- .../Notifier/Bridge/Pusher/PusherNotification.php | 8 -------- .../Component/Notifier/Bridge/Pusher/PusherOptions.php | 8 -------- .../Component/Notifier/Bridge/Pusher/PusherRecipient.php | 8 -------- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 8 -------- .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 8 -------- 5 files changed, 40 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index ae65eb79b1456..b49323850803e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index f220294d7e71f..5f18b140429eb 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php index e772e2083bf8e..73d28626f18f2 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 4683526f5eb8f..c410e9632bc28 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index c1eac38d48723..86185ac2e1a8c 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); From 6d733d9210bb70a54f3b07e5a33376085286bf02 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Mon, 14 Nov 2022 07:52:56 -0500 Subject: [PATCH 07/26] chore: work on PR comments --- src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore | 5 ----- src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md | 2 +- src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE | 2 +- .../Component/Notifier/Bridge/Pusher/PusherNotification.php | 4 +++- .../Component/Notifier/Bridge/Pusher/PusherOptions.php | 1 - .../Component/Notifier/Bridge/Pusher/PusherRecipient.php | 4 +++- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 1 - .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 1 - 8 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore index ad99719aaed4c..c49a5d8df5c65 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore @@ -1,8 +1,3 @@ vendor/ composer.lock phpunit.xml -.phpunit.result.cache -.php-cs-fixer -.php-cs-fixer.cache -.phpcs-cache -phpcs.xml diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md index 42bafa26795fb..db56b7a479885 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG ========= -6.2.0 +6.3 ----- * Added the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE index 9c907a46a6218..0ece8964f767d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2022 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index b49323850803e..27e9959bed7ef 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -1,6 +1,5 @@ + */ class PusherNotification extends Notification implements PushNotificationInterface { public function asPushMessage(RecipientInterface $recipient, string $transport = null): ?PushMessage diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index 5f18b140429eb..4ac5858cd5231 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -1,6 +1,5 @@ + */ class PusherRecipient implements RecipientInterface { private array $channels; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index c410e9632bc28..70dc25d046337 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -1,6 +1,5 @@ Date: Mon, 14 Nov 2022 08:12:31 -0500 Subject: [PATCH 08/26] chore: drop declare strict types --- .../Component/Notifier/Bridge/Pusher/PusherNotification.php | 2 -- src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php | 2 -- .../Component/Notifier/Bridge/Pusher/PusherRecipient.php | 2 -- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 2 -- .../Component/Notifier/Bridge/Pusher/PusherTransportFactory.php | 2 -- .../Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php | 2 -- .../Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php | 2 -- .../Notifier/Bridge/Pusher/Tests/PusherTransportTest.php | 2 -- 8 files changed, 16 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index 27e9959bed7ef..a9cccf0e21aa6 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -1,7 +1,5 @@ Date: Mon, 14 Nov 2022 10:35:15 -0500 Subject: [PATCH 09/26] chore: small format changes --- .../Component/Notifier/Bridge/Pusher/composer.json | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json index e618f6a0d21a3..1a27f2904cb74 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json @@ -2,10 +2,7 @@ "name": "symfony/pusher-notifier", "type": "symfony-notifier-bridge", "description": "Symfony Pusher Notifier Bridge", - "keywords": [ - "pusher", - "notifier" - ], + "keywords": ["pusher", "notifier"], "homepage": "https://symfony.com", "license": "MIT", "authors": [ @@ -22,12 +19,13 @@ "php": ">=8.1", "pusher/pusher-php-server": "^7.0", "symfony/http-client": "^5.4|^6.0", - "symfony/notifier": "^5.4|^6.0" + "symfony/notifier": "^6.2" + }, + "require-dev": { + "symfony/event-dispatcher": "^5.4|^6.0" }, "autoload": { - "psr-4": { - "Symfony\\Component\\Notifier\\Bridge\\Pusher\\": "" - }, + "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Pusher\\": "" }, "exclude-from-classmap": [ "/Tests/" ] From 389338fa5d856d2c5297982e16caa7720bb8dea2 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Mon, 14 Nov 2022 10:54:54 -0500 Subject: [PATCH 10/26] fix: add pusher package to main composer.json to fix tests --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 381c2fef9c772..7df0681cf222e 100644 --- a/composer.json +++ b/composer.json @@ -147,6 +147,7 @@ "predis/predis": "^1.1|^2.0", "psr/http-client": "^1.0", "psr/simple-cache": "^1.0|^2.0|^3.0", + "pusher/pusher-php-server": "^7.0", "seld/jsonlint": "^1.10", "symfony/mercure-bundle": "^0.3", "symfony/phpunit-bridge": "^6.4|^7.0", From 7e039d6a817a169eef2c10d0c3149ae9523b77d5 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Fri, 2 Dec 2022 10:55:29 -0500 Subject: [PATCH 11/26] chore: set PusherRecipientInterface as typehint of asPushMessage method chore: remove @internal annotation from tests chore: add footer to README.md chore: apply PR comments --- .../Notifier/Bridge/Pusher/CHANGELOG.md | 2 +- .../Bridge/Pusher/PusherNotification.php | 3 +-- .../Bridge/Pusher/PusherRecipient.php | 4 +--- .../Pusher/PusherRecipientInterface.php | 22 +++++++++++++++++++ .../Notifier/Bridge/Pusher/README.md | 8 +++++++ .../Bridge/Pusher/Tests/PusherOptionsTest.php | 2 -- .../Tests/PusherTransportFactoryTest.php | 2 -- .../Pusher/Tests/PusherTransportTest.php | 2 -- .../Notifier/Bridge/Pusher/phpunit.xml.dist | 20 ++++++++--------- 9 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipientInterface.php diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md index db56b7a479885..9dec118b3f6fe 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -4,4 +4,4 @@ CHANGELOG 6.3 ----- - * Added the bridge + * Add the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index a9cccf0e21aa6..516d86c0590e9 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -14,14 +14,13 @@ use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\Notification\PushNotificationInterface; -use Symfony\Component\Notifier\Recipient\RecipientInterface; /** * @author Yasmany Cubela Medina */ class PusherNotification extends Notification implements PushNotificationInterface { - public function asPushMessage(RecipientInterface $recipient, string $transport = null): ?PushMessage + public function asPushMessage(PusherRecipientInterface $recipient, string $transport = null): ?PushMessage { return new PushMessage($this->getSubject(), $this->getContent(), new PusherOptions($recipient->getChannels())); } diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php index 60b6e820cb866..5ce14e6a1799e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -11,12 +11,10 @@ namespace Symfony\Component\Notifier\Bridge\Pusher; -use Symfony\Component\Notifier\Recipient\RecipientInterface; - /** * @author Yasmany Cubela Medina */ -class PusherRecipient implements RecipientInterface +class PusherRecipient implements PusherRecipientInterface { private array $channels; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipientInterface.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipientInterface.php new file mode 100644 index 0000000000000..59e9c914cea4f --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipientInterface.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Pusher; + +use Symfony\Component\Notifier\Recipient\RecipientInterface; + +/** + * @author Yasmany Cubela Medina + */ +interface PusherRecipientInterface extends RecipientInterface +{ + public function getChannels(): array; +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/README.md b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md index c8f4fb1f0c2bc..79b4d760c194b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/README.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md @@ -30,3 +30,11 @@ PUSHER_DSN=pusher://asdasdasd@asdasdasd?server=invalid-server PUSHER_DSN=pusher://:asdasdasd@asdasdasd?server=invalid-server PUSHER_DSN=pusher://asdadasdasd:asdasdasd@asdasdasd?server=invalid-server ``` + +Resources +--------- + +* [Contributing](https://symfony.com/doc/current/contributing/index.html) +* [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php index 5e7ddd5e45df9..f93b58fb29630 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php @@ -17,8 +17,6 @@ /** * @author Yasmany Cubela Medina * - * @internal - * * @coversNothing */ final class PusherOptionsTest extends TestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php index 2695445e7d97d..1bd9a688fe8c9 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php @@ -18,8 +18,6 @@ /** * @author Yasmany Cubela Medina * - * @internal - * * @coversNothing */ final class PusherTransportFactoryTest extends TransportFactoryTestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index 6477c6434c21a..e8f4c1b3e6084 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -23,8 +23,6 @@ /** * @author Yasmany Cubela Medina * - * @internal - * * @coversNothing */ final class PusherTransportTest extends TransportTestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist b/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist index 9d948b7dd3cd3..27ba9f69b7dfd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist @@ -9,7 +9,7 @@ failOnWarning="true" > - + @@ -18,14 +18,14 @@ - - + + ./ - - ./Resources - ./Tests - ./vendor - - - + + + ./Resources + ./Tests + ./vendor + + From 0718f59d14b423e2d77765b6fb5054cc2b0d4826 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Fri, 2 Dec 2022 12:50:51 -0500 Subject: [PATCH 12/26] chore: set RecipientInterface as typehint of asPushMessage method --- .../Component/Notifier/Bridge/Pusher/PusherNotification.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index 516d86c0590e9..2bd8f67067d2b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -14,14 +14,15 @@ use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\Notification\PushNotificationInterface; +use Symfony\Component\Notifier\Recipient\RecipientInterface; /** * @author Yasmany Cubela Medina */ class PusherNotification extends Notification implements PushNotificationInterface { - public function asPushMessage(PusherRecipientInterface $recipient, string $transport = null): ?PushMessage + public function asPushMessage(RecipientInterface $recipient, string $transport = null): ?PushMessage { - return new PushMessage($this->getSubject(), $this->getContent(), new PusherOptions($recipient->getChannels())); + return new PushMessage($this->getSubject(), $this->getContent(), new PusherOptions($recipient instanceof PusherRecipientInterface ? $recipient->getChannels() : [])); } } From dc296b012e343c9f341ef2441ad4671ed8e060dd Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Mon, 9 Jan 2023 11:28:43 -0500 Subject: [PATCH 13/26] chore: fabbot --- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 10416271ebe63..6d019e07ef707 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Notifier\Bridge\Pusher; use Pusher\Pusher; -use RuntimeException; use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; @@ -65,7 +64,7 @@ protected function doSend(MessageInterface $message): SentMessage try { $this->pusherClient->trigger($options->getChannels(), $message->getSubject(), $message->getContent(), [], true); } catch (Throwable) { - throw new RuntimeException('An error occurred at Pusher Notifier Transport.'); + throw new \RuntimeException('An error occurred at Pusher Notifier Transport.'); } return new SentMessage($message, $this->__toString()); From 4111ae7b9e2e6a6b0efcbf9d8af71ef4b31b1d6c Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Mon, 9 Jan 2023 11:31:30 -0500 Subject: [PATCH 14/26] fix: LICENSE --- src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE index 0ece8964f767d..f961401699b27 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2022 Fabien Potencier +Copyright (c) 2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 5dcf3b570ff2108bea100e365fefdab80055efd1 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Wed, 15 Feb 2023 11:27:00 -0500 Subject: [PATCH 15/26] chore: rebase for #49385 --- .../Bridge/Pusher/Tests/PusherTransportTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index e8f4c1b3e6084..2a64c3365c16f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -13,10 +13,10 @@ use Pusher\Pusher; use Symfony\Component\Notifier\Bridge\Pusher\PusherTransport; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Fixtures\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -35,20 +35,20 @@ public function toStringProvider(): iterable /** * @return PusherTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new PusherTransport(new Pusher('key', 'secret', 'app'), $client ?? $this->createMock(HttpClientInterface::class)); + return new PusherTransport(new Pusher('key', 'secret', 'app'), $client); } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new PushMessage('event', 'data')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testCanSetCustomHost() From b7386b8f3f03b221a8e16a250727dab05669c540 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Wed, 15 Feb 2023 13:43:01 -0500 Subject: [PATCH 16/26] chore: apply comments from #49385 --- .../Notifier/Bridge/Pusher/Tests/PusherTransportTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index 2a64c3365c16f..897ba189ac74c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -16,6 +16,7 @@ use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Fixtures\DummyHttpClient; use Symfony\Component\Notifier\Tests\Fixtures\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -37,7 +38,7 @@ public function toStringProvider(): iterable */ public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new PusherTransport(new Pusher('key', 'secret', 'app'), $client); + return new PusherTransport(new Pusher('key', 'secret', 'app'), $client ?? new DummyHttpClient()); } public static function supportedMessagesProvider(): iterable From e427702fed7d404f07570b031d63809c1ccc40ee Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Wed, 15 Feb 2023 20:59:12 -0500 Subject: [PATCH 17/26] feat: drop autoconfigure tag from transport factory feat: configure pusher notifier on framework bundle --- .../FrameworkBundle/Resources/config/notifier_transports.php | 1 + .../Component/Notifier/Bridge/Pusher/PusherTransportFactory.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php index 39a44e2786d66..d6d371747da76 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php @@ -41,6 +41,7 @@ 'mercure' => Bridge\Mercure\MercureTransportFactory::class, 'microsoft-teams' => Bridge\MicrosoftTeams\MicrosoftTeamsTransportFactory::class, 'pager-duty' => Bridge\PagerDuty\PagerDutyTransportFactory::class, + 'pusher' => Bridge\Pusher\PusherTransportFactory::class, 'rocket-chat' => Bridge\RocketChat\RocketChatTransportFactory::class, 'slack' => Bridge\Slack\SlackTransportFactory::class, 'telegram' => Bridge\Telegram\TelegramTransportFactory::class, diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index f58979b4f9e72..dfbe4a7698ba6 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -22,7 +22,6 @@ /** * @author Yasmany Cubela Medina */ -#[Autoconfigure(tags: ['texter.transport_factory'])] final class PusherTransportFactory extends AbstractTransportFactory { public function create(Dsn $dsn): TransportInterface From 974c996029fd047dbc1e21643ee8bd6efca0259c Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Thu, 16 Feb 2023 06:30:04 -0500 Subject: [PATCH 18/26] chore: drop extra - on CHANGELOG.md fix: drop sensitive information from toString method on transport --- src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md | 2 +- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md index 9dec118b3f6fe..c7d6080bb1103 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -2,6 +2,6 @@ CHANGELOG ========= 6.3 ------ +---- * Add the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 6d019e07ef707..b99af8154339b 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -41,7 +41,7 @@ public function __toString(): string $settings = $this->pusherClient->getSettings(); preg_match('/api-([\w]+)\.pusher\.com$/m', $settings['host'], $server); - return sprintf('pusher://%s:%s@%s?server=%s', $settings['auth_key'], $settings['secret'], $settings['app_id'], $server[1]); + return sprintf('pusher://%s?server=%s', $settings['app_id'], $server[1]); } public function supports(MessageInterface $message): bool From 85e2bf43301db000f56d7e04fa43de10ae3983cb Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Dec 2023 22:54:26 +0100 Subject: [PATCH 19/26] - --- .../Notifier/Bridge/Pusher/README.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/README.md b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md index 79b4d760c194b..f6dd1a3d4f6d8 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/README.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md @@ -1,7 +1,7 @@ -Pusher Notifier -============== +Pusher.com Notifier +=================== -Provides [Pusher](https://pusher.com) integration for Symfony Notifier. +Provides [Pusher.com](https://pusher.com) integration for Symfony Notifier. DSN example ----------- @@ -12,10 +12,10 @@ PUSHER_DSN=pusher://APP_KEY:APP_SECRET@APP_ID?server=SERVER where: -- `APP_KEY` is your app unique key -- `APP_SECRET` is your app unique and secret password -- `APP_ID` is your app unique id -- `SERVER` is your app server + - `APP_KEY` is your app unique key + - `APP_SECRET` is your app unique and secret password + - `APP_ID` is your app unique id + - `SERVER` is your app server valid DSN's are: @@ -34,7 +34,7 @@ PUSHER_DSN=pusher://asdadasdasd:asdasdasd@asdasdasd?server=invalid-server Resources --------- -* [Contributing](https://symfony.com/doc/current/contributing/index.html) -* [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) From cf28c5084034b44c69362c446967f284f1657244 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Dec 2023 22:54:39 +0100 Subject: [PATCH 20/26] - --- src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md index c7d6080bb1103..5be39cbeeb951 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG ========= -6.3 ----- +7.1 +--- * Add the bridge From f999080437d660ef35246244afc944d0de87ad90 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Dec 2023 22:56:51 +0100 Subject: [PATCH 21/26] - --- .../Notifier/Bridge/Pusher/PusherOptions.php | 7 +- .../Notifier/Bridge/Pusher/composer.json | 66 ++++++++++--------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index e67e9003973b8..78362bfdaf84a 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -18,11 +18,10 @@ */ final class PusherOptions implements MessageOptionsInterface { - private array $channels; - - public function __construct(array $channels) + public function __construct( + private readonly array $channels, + ) { - $this->channels = $channels; } public function toArray(): array diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json index 1a27f2904cb74..00d64b208a8fe 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json @@ -1,34 +1,38 @@ { - "name": "symfony/pusher-notifier", - "type": "symfony-notifier-bridge", - "description": "Symfony Pusher Notifier Bridge", - "keywords": ["pusher", "notifier"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Yasmany Cubela Medina", - "email": "yasmanycm@gmail.com" + "name": "symfony/pusher-notifier", + "type": "symfony-notifier-bridge", + "description": "Symfony Pusher Notifier Bridge", + "keywords": ["pusher", "notifier"], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Yasmany Cubela Medina", + "email": "yasmanycm@gmail.com" + }, + { + "name": "Oskar Stark", + "email": "oskarstark@googlemail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": ">=8.2", + "pusher/pusher-php-server": "^7.0", + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/notifier": "^7.1" }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=8.1", - "pusher/pusher-php-server": "^7.0", - "symfony/http-client": "^5.4|^6.0", - "symfony/notifier": "^6.2" - }, - "require-dev": { - "symfony/event-dispatcher": "^5.4|^6.0" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Pusher\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev" + "require-dev": { + "symfony/event-dispatcher": "^5.4|^6.0|^7.0" + }, + "autoload": { + "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Pusher\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "minimum-stability": "dev" } From 25522aadda6e8f887835a273e198bba3b7154b18 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Dec 2023 22:58:04 +0100 Subject: [PATCH 22/26] - --- .../Notifier/Bridge/Pusher/PusherTransport.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index b99af8154339b..7e36effd01a2d 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -27,18 +27,18 @@ */ final class PusherTransport extends AbstractTransport { - private $pusherClient; - - public function __construct(Pusher $pusherClient, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) - { - $this->pusherClient = $pusherClient; + public function __construct( + private Pusher $pusher, + HttpClientInterface $client = null, + EventDispatcherInterface $dispatcher = null, + ) { parent::__construct($client, $dispatcher); } public function __toString(): string { - $settings = $this->pusherClient->getSettings(); + $settings = $this->pusher->getSettings(); preg_match('/api-([\w]+)\.pusher\.com$/m', $settings['host'], $server); return sprintf('pusher://%s?server=%s', $settings['app_id'], $server[1]); @@ -62,7 +62,7 @@ protected function doSend(MessageInterface $message): SentMessage } try { - $this->pusherClient->trigger($options->getChannels(), $message->getSubject(), $message->getContent(), [], true); + $this->pusher->trigger($options->getChannels(), $message->getSubject(), $message->getContent(), [], true); } catch (Throwable) { throw new \RuntimeException('An error occurred at Pusher Notifier Transport.'); } From bddf6ef927e0904574c3643b2ed9c74e69228d60 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Dec 2023 23:00:28 +0100 Subject: [PATCH 23/26] - --- .../Bridge/Pusher/PusherTransportFactory.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index dfbe4a7698ba6..7c5894ba82f21 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -30,17 +30,15 @@ public function create(Dsn $dsn): TransportInterface throw new UnsupportedSchemeException($dsn, 'pusher', $this->getSupportedSchemes()); } - if (null === $dsn->getUser() || null === $dsn->getPassword() || null === $dsn->getOption('server')) { - throw new MissingRequiredOptionException('Pusher needs a APP_KEY, APP_SECRET AND SERVER specified.'); + if (null === $dsn->getUser() || null === $dsn->getPassword()) { + throw new MissingRequiredOptionException('Pusher needs APP_KEY and APP_SECRET specified.'); } - $options = [ - 'cluster' => $dsn->getOption('server', 'mt1'), - ]; - - $pusherClient = new Pusher($dsn->getUser(), $dsn->getPassword(), $dsn->getHost(), $options); - - return new PusherTransport($pusherClient, $this->client, $this->dispatcher); + return new PusherTransport( + new Pusher($dsn->getUser(), $dsn->getPassword(), $dsn->getHost(), ['cluster' => $dsn->getRequiredOption('server'),]), + $this->client, + $this->dispatcher + ); } protected function getSupportedSchemes(): array From d69148accf8d2e5e7f4dd9acbca7bef5321e6cf4 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Dec 2023 23:01:06 +0100 Subject: [PATCH 24/26] - --- .../Component/Notifier/Bridge/Pusher/PusherRecipient.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php index 5ce14e6a1799e..03246e1b3afc0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -16,11 +16,9 @@ */ class PusherRecipient implements PusherRecipientInterface { - private array $channels; - - public function __construct(array $channels) - { - $this->channels = $channels; + public function __construct( + private readonly array $channels, + ) { } public function getChannels(): array From 52482a19939475513196d7409fa1b393d9aa3701 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Dec 2023 23:03:45 +0100 Subject: [PATCH 25/26] - --- .../Notifier/Bridge/Pusher/PusherTransport.php | 2 +- .../Bridge/Pusher/Tests/PusherOptionsTest.php | 2 -- .../Pusher/Tests/PusherTransportFactoryTest.php | 12 +++++------- .../Bridge/Pusher/Tests/PusherTransportTest.php | 16 ++++++++-------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 7e36effd01a2d..4a1272b22661a 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -28,7 +28,7 @@ final class PusherTransport extends AbstractTransport { public function __construct( - private Pusher $pusher, + private readonly Pusher $pusher, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, ) { diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php index f93b58fb29630..fdb2b395bba88 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php @@ -16,8 +16,6 @@ /** * @author Yasmany Cubela Medina - * - * @coversNothing */ final class PusherOptionsTest extends TestCase { diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php index 1bd9a688fe8c9..58b88cf905c00 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php @@ -17,8 +17,6 @@ /** * @author Yasmany Cubela Medina - * - * @coversNothing */ final class PusherTransportFactoryTest extends TransportFactoryTestCase { @@ -30,7 +28,7 @@ public function createFactory(): TransportFactoryInterface return new PusherTransportFactory(); } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ 'pusher://key:secret@id?server=mt1', @@ -38,23 +36,23 @@ public function createProvider(): iterable ]; } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [true, 'pusher://key:secret@id?server=mt1']; yield [false, 'somethingElse://xoxb-TestToken@host?server=testChannel']; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { yield 'missing secret' => ['pusher://key@id?server=mt1']; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield ['somethingElse://something@else']; } - public function missingRequiredOptionProvider(): iterable + public static function missingRequiredOptionProvider(): iterable { yield ['pusher://key:secret@id']; } diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index 897ba189ac74c..afa4fefd73faa 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -12,12 +12,12 @@ namespace Symfony\Component\Notifier\Bridge\Pusher\Tests; use Pusher\Pusher; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Pusher\PusherTransport; use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; -use Symfony\Component\Notifier\Tests\Fixtures\DummyHttpClient; -use Symfony\Component\Notifier\Tests\Fixtures\DummyMessage; +use Symfony\Component\Notifier\Tests\Transport\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -28,17 +28,17 @@ */ final class PusherTransportTest extends TransportTestCase { - public function toStringProvider(): iterable - { - yield ['pusher://key:secret@app?server=mt1', $this->createTransport()]; - } - /** * @return PusherTransport */ public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new PusherTransport(new Pusher('key', 'secret', 'app'), $client ?? new DummyHttpClient()); + return new PusherTransport(new Pusher('key', 'secret', 'app'), $client ?? new MockHttpClient()); + } + + public static function toStringProvider(): iterable + { + yield ['pusher://key:secret@app?server=mt1', self::createTransport()]; } public static function supportedMessagesProvider(): iterable From 69923a23e7a55fb67261525eb78c7613a323d3ac Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Dec 2023 23:10:51 +0100 Subject: [PATCH 26/26] - --- .../Component/Notifier/Bridge/Pusher/PusherOptions.php | 3 +-- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 4 +--- .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index 78362bfdaf84a..9ddd27dc74fd9 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -20,8 +20,7 @@ final class PusherOptions implements MessageOptionsInterface { public function __construct( private readonly array $channels, - ) - { + ) { } public function toArray(): array diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 4a1272b22661a..1c9dec34c3a16 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -20,7 +20,6 @@ use Symfony\Component\Notifier\Transport\AbstractTransport; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; -use Throwable; /** * @author Yasmany Cubela Medina @@ -32,7 +31,6 @@ public function __construct( HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, ) { - parent::__construct($client, $dispatcher); } @@ -63,7 +61,7 @@ protected function doSend(MessageInterface $message): SentMessage try { $this->pusher->trigger($options->getChannels(), $message->getSubject(), $message->getContent(), [], true); - } catch (Throwable) { + } catch (\Throwable) { throw new \RuntimeException('An error occurred at Pusher Notifier Transport.'); } diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index 7c5894ba82f21..8cc85d79b198d 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Notifier\Bridge\Pusher; use Pusher\Pusher; -use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; use Symfony\Component\Notifier\Exception\MissingRequiredOptionException; use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; use Symfony\Component\Notifier\Transport\AbstractTransportFactory;