From 63350cc19b4d44d7eee7f1a5de465d91f5dc279f Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 15 Dec 2020 11:26:26 +0100 Subject: [PATCH] =?UTF-8?q?[Notifier]=C2=A0[Free=20Mobile]=20Could=20not?= =?UTF-8?q?=20use=20custom=20host=20in=20DSN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Notifier/Bridge/FreeMobile/FreeMobileTransport.php | 6 ++++-- .../Bridge/FreeMobile/FreeMobileTransportFactory.php | 5 ++++- .../FreeMobile/Tests/FreeMobileTransportFactoryTest.php | 4 +--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php b/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php index 936e6b3a16ca3..bbb98dbab92d2 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php @@ -26,7 +26,7 @@ */ final class FreeMobileTransport extends AbstractTransport { - protected const HOST = 'https://smsapi.free-mobile.fr/sendmsg'; + protected const HOST = 'smsapi.free-mobile.fr/sendmsg'; private $login; private $password; @@ -57,7 +57,9 @@ protected function doSend(MessageInterface $message): void throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given) and configured with your phone number.', __CLASS__, SmsMessage::class, \get_class($message))); } - $response = $this->client->request('POST', $this->getEndpoint(), [ + $endpoint = sprintf('https://%s', $this->getEndpoint()); + + $response = $this->client->request('POST', $endpoint, [ 'json' => [ 'user' => $this->login, 'pass' => $this->password, diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransportFactory.php index aab7925d3967a..2a85414887eb1 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransportFactory.php @@ -43,7 +43,10 @@ public function create(Dsn $dsn): TransportInterface throw new IncompleteDsnException('Missing phone.', $dsn->getOriginalDsn()); } - return new FreeMobileTransport($login, $password, $phone, $this->client, $this->dispatcher); + $host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); + $port = $dsn->getPort(); + + return (new FreeMobileTransport($login, $password, $phone, $this->client, $this->dispatcher))->setHost($host)->setPort($port); } protected function getSupportedSchemes(): array diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportFactoryTest.php index 082994b3744a3..9f12505de103e 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportFactoryTest.php @@ -23,9 +23,7 @@ public function testCreateWithDsn() { $factory = $this->createFactory(); - $dsn = 'freemobile://login:pass@default?phone=0611223344'; - $transport = $factory->create(Dsn::fromString($dsn)); - $transport->setHost('host.test'); + $transport = $factory->create(Dsn::fromString('freemobile://login:pass@host.test?phone=0611223344')); $this->assertSame('freemobile://host.test?phone=0611223344', (string) $transport); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy