[Notifier] [Free Mobile] Could not use custom host in DSN
This commit is contained in:
parent
3a3b2498fd
commit
63350cc19b
@ -26,7 +26,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
*/
|
||||
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 @@ final class FreeMobileTransport extends AbstractTransport
|
||||
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,
|
||||
|
@ -43,7 +43,10 @@ final class FreeMobileTransportFactory extends AbstractTransportFactory
|
||||
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
|
||||
|
@ -23,9 +23,7 @@ final class FreeMobileTransportFactoryTest extends TestCase
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user