8000 * LightSmsTransport.php - not ok throw exception · symfony/symfony@b0e64b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit b0e64b9

Browse files
author
Vasilij Dusko | CREATION
committed
* LightSmsTransport.php - not ok throw exception
1 parent fc13bb2 commit b0e64b9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Copy file name to clipboard
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\LightSms;
1313

14+
use Symfony\Component\HttpFoundation\Response;
1415
use Symfony\Component\Notifier\Exception\TransportException;
1516
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1617
use Symfony\Component\Notifier\Message\MessageInterface;
@@ -99,9 +100,11 @@ protected function doSend(MessageInterface $message): SentMessage
99100
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
100101
}
101102

103+
$timestamp = time();
104+
102105
$signature = $this->generateSignature([
103106
'message' => $message,
104-
'timestamp' => time(),
107+
'timestamp' => $timestamp,
105108
]);
106109

107110
$endpoint = sprintf(
@@ -112,11 +115,15 @@ protected function doSend(MessageInterface $message): SentMessage
112115
$this->escapePhoneNumber($message->getPhone()),
113116
$this->escapeSubject($message->getSubject()),
114117
$this->phone,
115-
time()
118+
$timestamp
116119
);
117120

118121
$response = $this->client->request('GET', $endpoint);
119122

123+
if (Response::HTTP_OK !== $response->getStatusCode()) {
124+
throw new TransportException('Unable to send the SMS: ', $response);
125+
}
126+
120127
$content = $response->toArray(false);
121128

122129
if (isset($content['error'])) {

0 commit comments

Comments
 (0)
0