Skip to content

Commit 7f13dbf

Browse files
author
Vasilij Dusko | CREATION
committed
* sender changed to from
1 parent e20ef1e commit 7f13dbf

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTransport.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
final class LightSmsTransport extends AbstractTransport
2828
{
29-
protected const HOST = 'www.lightsms.com';
29+
protected const HOST = 'lightsms.com';
3030

3131
private $login;
3232
private $password;
@@ -75,11 +75,11 @@ final class LightSmsTransport extends AbstractTransport
7575
'39' => 'Phone number does not exist in this database',
7676
];
7777

78-
public function __construct(string $login, string $password, string $phone, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
78+
public function __construct(string $login, string $password, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null)
7979
{
8080
$this->login = $login;
8181
$this->password = $password;
82-
$this->phone = $phone;
82+
$this->from = $from;
8383

8484
parent::__construct($client, $dispatcher);
8585
}
@@ -102,19 +102,16 @@ protected function doSend(MessageInterface $message): SentMessage
102102

103103
$timestamp = time();
104104

105-
$signature = $this->generateSignature([
106-
'message' => $message,
107-
'timestamp' => $timestamp,
108-
]);
105+
$signature = $this->generateSignature($message, $timestamp);
109106

110107
$endpoint = sprintf(
111-
'https://%s/external/get/send.php?login=%s&signature=%s&phone=%s&text=%s&sender=%s&timestamp=%s',
108+
'https://www.%s/external/get/send.php?login=%s&signature=%s&phone=%s&text=%s&sender=%s&timestamp=%s',
112109
$this->getEndpoint(),
113110
$this->login,
114111
$signature,
115112
$this->escapePhoneNumber($message->getPhone()),
116113
$this->escapeSubject($message->getSubject()),
117-
$this->phone,
114+
$this->from,
118115
$timestamp
119116
);
120117

@@ -143,14 +140,14 @@ protected function doSend(MessageInterface $message): SentMessage
143140
return $sentMessage;
144141
}
145142

146-
private function generateSignature(array $params): string
143+
private function generateSignature(SmsMessage $message, string $timestamp): string
147144
{
148145
$params = [
149-
'timestamp' => $params['timestamp'],
146+
'timestamp' => $timestamp,
150147
'login' => $this->login,
151-
'phone' => $this->escapePhoneNumber($params['message']->getPhone()),
152-
'sender' => $this->phone,
153-
'text' => $this->escapeSubject($params['message']->getSubject()),
148+
'phone' => $this->escapePhoneNumber($message->getPhone()),
149+
'sender' => $this->from,
150+
'text' => $this->escapeSubject($message->getSubject()),
154151
];
155152

156153
ksort($params);

src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTransportFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public function create(Dsn $dsn): TransportInterface
3434

3535
$login = $this->getUser($dsn);
3636
$token = $this->getPassword($dsn);
37-
$phone = $dsn->getRequiredOption('phone');
37+
$from = $dsn->getRequiredOption('from');
3838

3939
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
4040
$port = $dsn->getPort();
4141

42-
return (new LightSmsTransport($login, $token, $phone, $this->client, $this->dispatcher))->setHost($host)->setPort($port);
42+
return (new LightSmsTransport($login, $token, $from, $this->client, $this->dispatcher))->setHost($host)->setPort($port);
4343
}
4444

4545
protected function getSupportedSchemes(): array

src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function supportsProvider(): iterable
4141

4242
public function unsupportedSchemeProvider(): iterable
4343
{
44-
yield ['somethingElse://accountSid:authToken@default?phone=37061234567'];
45-
yield ['somethingElse://accountSid:authToken@default']; // missing "phone" option
44+
yield ['somethingElse://login:token@default?phone=37061234567'];
45+
yield ['somethingElse://login:token@default']; // missing "phone" option
4646
}
4747
}

0 commit comments

Comments
 (0)
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