10BC0 * LightSmsTransport.php - move timestamp · symfony/symfony@8620e82 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8620e82

Browse files
author
Vasilij Dusko | CREATION
committed
* LightSmsTransport.php - move timestamp
1 parent 66c34ba commit 8620e82

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ protected function doSend(MessageInterface $message): SentMessage
9999
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
100100
}
101101

102-
$signature = $this->generateSignature($message);
102+
$signature = $this->generateSignature([
103+
'message' => $message,
104+
'timestamp' => time(),
105+
]);
103106

104107
$endpoint = sprintf(
105108
'https://%s/external/get/send.php?login=%s&signature=%s&phone=%s&text=%s&sender=%s&timestamp=%s',
@@ -121,7 +124,7 @@ protected function doSend(MessageInterface $message): SentMessage
121124
}
122125

123126
$phone = preg_replace("/[^\d]/", '', $message->getPhone());
124-
if (32 == $content[$phone]['error']) {
127+
if (32 === $content[$phone]['error']) {
125128
throw new TransportException('Unable to send the SMS: '.self::ERROR_CODES[$content['error']], $response);
126129
}
127130

@@ -133,14 +136,14 @@ protected function doSend(MessageInterface $message): SentMessage
133136
return $sentMessage;
134137
}
135138

136-
private function generateSignature(SmsMessage $message): string
139+
private function generateSignature(array $params): string
137140
{
138141
$params = [
139-
'timestamp' => time(),
142+
'timestamp' => $params['timestamp'],
140143
'login' => $this->login,
141-
'phone' => str_replace('+', '', $message->getPhone()),
144+
'phone' => str_replace('+', '', $params['message']->getPhone()),
142145
'sender' => $this->phone,
143-
'text' => $message->getSubject(),
146+
'text' => $params['message']->getSubject(),
144147
];
145148

146149
ksort($params);

0 commit comments

Comments
 (0)
0