diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 7cc67725ec461..7e5f88fde6d25 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2779,7 +2779,6 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ NotifierBridge\FortySixElks\FortySixElksTransportFactory::class => 'notifier.transport_factory.forty-six-elks', NotifierBridge\FreeMobile\FreeMobileTransportFactory::class => 'notifier.transport_factory.free-mobile', NotifierBridge\GatewayApi\GatewayApiTransportFactory::class => 'notifier.transport_factory.gateway-api', - NotifierBridge\Gitter\GitterTransportFactory::class => 'notifier.transport_factory.gitter', NotifierBridge\GoIp\GoIpTransportFactory::class => 'notifier.transport_factory.go-ip', NotifierBridge\GoogleChat\GoogleChatTransportFactory::class => 'notifier.transport_factory.google-chat', NotifierBridge\Infobip\InfobipTransportFactory::class => 'notifier.transport_factory.infobip', diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php index 4acfcf783e710..e34781e9c45b4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php @@ -31,7 +31,6 @@ 'discord' => Bridge\Discord\DiscordTransportFactory::class, 'fake-chat' => Bridge\FakeChat\FakeChatTransportFactory::class, 'firebase' => Bridge\Firebase\FirebaseTransportFactory::class, - 'gitter' => Bridge\Gitter\GitterTransportFactory::class, 'google-chat' => Bridge\GoogleChat\GoogleChatTransportFactory::class, 'line-notify' => Bridge\LineNotify\LineNotifyTransportFactory::class, 'linked-in' => Bridge\LinkedIn\LinkedInTransportFactory::class, diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/.gitattributes b/src/Symfony/Component/Notifier/Bridge/Gitter/.gitattributes deleted file mode 100644 index 84c7add058fb5..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/.gitattributes +++ /dev/null @@ -1,4 +0,0 @@ -/Tests export-ignore -/phpunit.xml.dist export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/.gitignore b/src/Symfony/Component/Notifier/Bridge/Gitter/.gitignore deleted file mode 100644 index c49a5d8df5c65..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Gitter/CHANGELOG.md deleted file mode 100644 index 1f2b652ac20ea..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/CHANGELOG.md +++ /dev/null @@ -1,7 +0,0 @@ -CHANGELOG -========= - -5.3 ---- - - * Add the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/GitterTransport.php b/src/Symfony/Component/Notifier/Bridge/Gitter/GitterTransport.php deleted file mode 100644 index 275a000018dea..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/GitterTransport.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Notifier\Bridge\Gitter; - -use Symfony\Component\Notifier\Exception\TransportException; -use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; -use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; -use Symfony\Component\Notifier\Message\SentMessage; -use Symfony\Component\Notifier\Transport\AbstractTransport; -use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; -use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; -use Symfony\Contracts\HttpClient\HttpClientInterface; - -/** - * @author Christin Gruber - */ -final class GitterTransport extends AbstractTransport -{ - protected const HOST = 'api.gitter.im'; - - public function __construct( - #[\SensitiveParameter] private string $token, - private string $roomId, - ?HttpClientInterface $client = null, - ?EventDispatcherInterface $dispatcher = null, - ) { - parent::__construct($client, $dispatcher); - } - - public function __toString(): string - { - return \sprintf('gitter://%s?room_id=%s', $this->getEndpoint(), $this->roomId); - } - - public function supports(MessageInterface $message): bool - { - return $message instanceof ChatMessage; - } - - /** - * @see https://developer.gitter.im/docs/rest-api - */ - protected function doSend(MessageInterface $message): SentMessage - { - if (!$message instanceof ChatMessage) { - throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); - } - - $endpoint = \sprintf('https://%s/v1/rooms/%s/chatMessages', $this->getEndpoint(), $this->roomId); - - $response = $this->client->request('POST', $endpoint, [ - 'auth_bearer' => $this->token, - 'json' => [ - 'text' => $message->getSubject(), - ], - ]); - - try { - $result = $response->toArray(false); - } catch (TransportExceptionInterface $e) { - throw new TransportException('Could not reach the remote Gitter server.', $response, 0, $e); - } - - if (200 !== $response->getStatusCode()) { - throw new TransportException(\sprintf('Unable to post the Gitter message: "%s".', $result['error']), $response); - } - - $sentMessage = new SentMessage($message, (string) $this); - $sentMessage->setMessageId($result['id']); - - return $sentMessage; - } -} diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/GitterTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Gitter/GitterTransportFactory.php deleted file mode 100644 index ad82e8ebed523..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/GitterTransportFactory.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Notifier\Bridge\Gitter; - -use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; -use Symfony\Component\Notifier\Transport\AbstractTransportFactory; -use Symfony\Component\Notifier\Transport\Dsn; - -/** - * @author Christin Gruber - */ -final class GitterTransportFactory extends AbstractTransportFactory -{ - public function create(Dsn $dsn): GitterTransport - { - $scheme = $dsn->getScheme(); - - if ('gitter' !== $scheme) { - throw new UnsupportedSchemeException($dsn, 'gitter', $this->getSupportedSchemes()); - } - - $token = $this->getUser($dsn); - $roomId = $dsn->getRequiredOption('room_id'); - $host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); - $port = $dsn->getPort(); - - return (new GitterTransport($token, $roomId, $this->client, $this->dispatcher))->setHost($host)->setPort($port); - } - - protected function getSupportedSchemes(): array - { - return ['gitter']; - } -} diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/LICENSE b/src/Symfony/Component/Notifier/Bridge/Gitter/LICENSE deleted file mode 100644 index 99c6bdf356ee7..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2021-present 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 -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/Gitter/README.md b/src/Symfony/Component/Notifier/Bridge/Gitter/README.md deleted file mode 100644 index 1927a65d59809..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/README.md +++ /dev/null @@ -1,23 +0,0 @@ -Gitter Notifier -=============== - -Provides [Gitter](https://gitter.im) integration for Symfony Notifier. - -DSN example ------------ - -``` -GITTER_DSN=gitter://TOKEN@default?room_id=ROOM_ID -``` - -where: - - `TOKEN` is your Gitter token - - `ROOM_ID` is your Gitter room id - -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/Gitter/Tests/GitterTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportFactoryTest.php deleted file mode 100644 index 6047ecde71029..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportFactoryTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Notifier\Bridge\Gitter\Tests; - -use Symfony\Component\Notifier\Bridge\Gitter\GitterTransportFactory; -use Symfony\Component\Notifier\Test\TransportFactoryTestCase; - -/** - * @author Christin Gruber - */ -final class GitterTransportFactoryTest extends TransportFactoryTestCase -{ - public function createFactory(): GitterTransportFactory - { - return new GitterTransportFactory(); - } - - public static function createProvider(): iterable - { - yield [ - 'gitter://api.gitter.im?room_id=5539a3ee5etest0d3255bfef', - 'gitter://token@api.gitter.im?room_id=5539a3ee5etest0d3255bfef', - ]; - } - - public static function supportsProvider(): iterable - { - yield [true, 'gitter://token@host?room_id=5539a3ee5etest0d3255bfef']; - yield [false, 'somethingElse://token@host?room_id=5539a3ee5etest0d3255bfef']; - } - - public static function incompleteDsnProvider(): iterable - { - yield 'missing token' => ['gitter://api.gitter.im?room_id=5539a3ee5etest0d3255bfef']; - } - - public static function missingRequiredOptionProvider(): iterable - { - yield 'missing option: room_id' => ['gitter://token@host']; - } - - public static function unsupportedSchemeProvider(): iterable - { - yield ['somethingElse://token@host?room_id=5539a3ee5etest0d3255bfef']; - yield ['somethingElse://token@host']; - } -} diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportTest.php deleted file mode 100644 index daf8036a4e7a1..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/Tests/GitterTransportTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Notifier\Bridge\Gitter\Tests; - -use Symfony\Component\HttpClient\MockHttpClient; -use Symfony\Component\Notifier\Bridge\Gitter\GitterTransport; -use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\SmsMessage; -use Symfony\Component\Notifier\Test\TransportTestCase; -use Symfony\Component\Notifier\Tests\Transport\DummyMessage; -use Symfony\Contracts\HttpClient\HttpClientInterface; - -/** - * @author Christin Gruber - */ -final class GitterTransportTest extends TransportTestCase -{ - public static function createTransport(?HttpClientInterface $client = null): GitterTransport - { - return (new GitterTransport('token', '5539a3ee5etest0d3255bfef', $client ?? new MockHttpClient()))->setHost('api.gitter.im'); - } - - public static function toStringProvider(): iterable - { - yield ['gitter://api.gitter.im?room_id=5539a3ee5etest0d3255bfef', self::createTransport()]; - } - - public static function supportedMessagesProvider(): iterable - { - yield [new ChatMessage('Hello!')]; - } - - public static function unsupportedMessagesProvider(): iterable - { - yield [new SmsMessage('0611223344', 'Hello!')]; - yield [new DummyMessage()]; - } -} diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/composer.json b/src/Symfony/Component/Notifier/Bridge/Gitter/composer.json deleted file mode 100644 index 184da45fa5a9e..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/composer.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "symfony/gitter-notifier", - "type": "symfony-notifier-bridge", - "description": "Symfony Gitter Notifier Bridge", - "keywords": ["chat", "gitter", "notifier"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Christin Gruber", - "email": "c.gruber@touchdesign.de" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=8.2", - "symfony/http-client": "^6.4|^7.0", - "symfony/notifier": "^6.4|^7.0" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Gitter\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev" -} diff --git a/src/Symfony/Component/Notifier/Bridge/Gitter/phpunit.xml.dist b/src/Symfony/Component/Notifier/Bridge/Gitter/phpunit.xml.dist deleted file mode 100644 index 1908dbae6cc1a..0000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Gitter/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - ./Tests/ - - - - - - ./ - - - ./Resources - ./Tests - ./vendor - - - diff --git a/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php b/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php index a69db6ec06cdc..426333873c92e 100644 --- a/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php +++ b/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php @@ -92,10 +92,6 @@ class UnsupportedSchemeException extends LogicException 'class' => Bridge\GatewayApi\GatewayApiTransportFactory::class, 'package' => 'symfony/gateway-api-notifier', ], - 'gitter' => [ - 'class' => Bridge\Gitter\GitterTransportFactory::class, - 'package' => 'symfony/gitter-notifier', - ], 'goip' => [ 'class' => Bridge\GoIp\GoIpTransportFactory::class, 'package' => 'symfony/go-ip-notifier', diff --git a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php index 17a14d03c3f60..2cc515e07f5b2 100644 --- a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php +++ b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php @@ -45,7 +45,6 @@ public static function setUpBeforeClass(): void Bridge\FortySixElks\FortySixElksTransportFactory::class => false, Bridge\FreeMobile\FreeMobileTransportFactory::class => false, Bridge\GatewayApi\GatewayApiTransportFactory::class => false, - Bridge\Gitter\GitterTransportFactory::class => false, Bridge\GoIp\GoIpTransportFactory::class => false, Bridge\GoogleChat\GoogleChatTransportFactory::class => false, Bridge\Infobip\InfobipTransportFactory::class => false, @@ -137,7 +136,6 @@ public static function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \ yield ['firebase', 'symfony/firebase-notifier']; yield ['freemobile', 'symfony/free-mobile-notifier']; yield ['gatewayapi', 'symfony/gateway-api-notifier']; - yield ['gitter', 'symfony/gitter-notifier']; yield ['googlechat', 'symfony/google-chat-notifier']; yield ['infobip', 'symfony/infobip-notifier']; yield ['iqsms', 'symfony/iqsms-notifier']; diff --git a/src/Symfony/Component/Notifier/Transport.php b/src/Symfony/Component/Notifier/Transport.php index 010525058c042..3091e5bbafdd3 100644 --- a/src/Symfony/Component/Notifier/Transport.php +++ b/src/Symfony/Component/Notifier/Transport.php @@ -47,7 +47,6 @@ final class Transport Bridge\FortySixElks\FortySixElksTransportFactory::class, Bridge\FreeMobile\FreeMobileTransportFactory::class, Bridge\GatewayApi\GatewayApiTransportFactory::class, - Bridge\Gitter\GitterTransportFactory::class, Bridge\GoIp\GoIpTransportFactory::class, Bridge\GoogleChat\GoogleChatTransportFactory::class, Bridge\Infobip\InfobipTransportFactory::class,