Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Notifier] supportSmsMessage with 'from' set#58539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
petski wants to merge1 commit intosymfony:6.4
base:6.4
Choose a base branch
Loading
frompetski:fix-for-58535
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,14 +60,14 @@ public function supports(MessageInterface $message): bool
*/
protected function doSend(MessageInterface $message): SentMessage
{
if (!$this->supports($message)) {
if (!$message instanceof SmsMessage) {
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
}

$email = (new Email())
->from($message->getFrom() ?: $this->from)
->from($this->from)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

can you explain this change? it looks suspicious to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@petski Any insight?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The change looks valid to me. At least, there is nothing indicating that the$from property of theSmsMessage class has to be a valid e-mail address and thus we IMO must not use it as such in theFakeSmsEmailTransport.

->to($this->to)
->subject(sprintf('New SMSon phone number: %s',$message->getPhone()))
->subject('New SMSto phone number ' .$message->getPhone() . ($message->getFrom() ? ' from ' . $message->getFrom() : ''))
->html($message->getSubject())
->text($message->getSubject());

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,11 +51,11 @@ public function supports(MessageInterface $message): bool
*/
protected function doSend(MessageInterface $message): SentMessage
{
if (!$this->supports($message)) {
if (!$message instanceof SmsMessage) {
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
}

$this->logger->info(sprintf('New SMSon phone number: %s',$message->getPhone()));
$this->logger->info('New SMSto phone number ' .$message->getPhone() . ($message->getFrom() ? ' from ' . $message->getFrom() : ''));

return new SentMessage($message, (string) $this);
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,30 @@ public function testSendWithDefaultTransport()
$this->assertInstanceOf(Email::class, $sentEmail);
$this->assertSame($to, $sentEmail->getTo()[0]->getEncodedAddress());
$this->assertSame($from, $sentEmail->getFrom()[0]->getEncodedAddress());
$this->assertSame(sprintf('New SMS on phone number: %s', $phone), $sentEmail->getSubject());
$this->assertSame(\sprintf('New SMS to phone number %s', $phone), $sentEmail->getSubject());
$this->assertSame($subject, $sentEmail->getTextBody());
$this->assertFalse($sentEmail->getHeaders()->has('X-Transport'));
}

public function testSendWithFrom()
{
$transportName = null;

$message = new SmsMessage($phone = '0611223344', $subject = 'Hello!', $fromPhone = '0655667788');

$mailer = new DummyMailer();

$transport = (new FakeSmsEmailTransport($mailer, $to = 'recipient@email.net', $from = 'sender@email.net'));
$transport->setHost($transportName);

$transport->send($message);

/** @var Email $sentEmail */
$sentEmail = $mailer->getSentEmail();
$this->assertInstanceOf(Email::class, $sentEmail);
$this->assertSame($to, $sentEmail->getTo()[0]->getEncodedAddress());
$this->assertSame($from, $sentEmail->getFrom()[0]->getEncodedAddress());
$this->assertSame(\sprintf('New SMS to phone number %s from %s', $phone, $fromPhone), $sentEmail->getSubject());
$this->assertSame($subject, $sentEmail->getTextBody());
$this->assertFalse($sentEmail->getHeaders()->has('X-Transport'));
}
Expand All@@ -93,7 +116,7 @@ public function testSendWithCustomTransport()
$this->assertInstanceOf(Email::class, $sentEmail);
$this->assertSame($to, $sentEmail->getTo()[0]->getEncodedAddress());
$this->assertSame($from, $sentEmail->getFrom()[0]->getEncodedAddress());
$this->assertSame(sprintf('New SMSon phone number: %s', $phone), $sentEmail->getSubject());
$this->assertSame(\sprintf('New SMSto phone number %s', $phone), $sentEmail->getSubject());
$this->assertSame($subject, $sentEmail->getTextBody());
$this->assertTrue($sentEmail->getHeaders()->has('X-Transport'));
$this->assertSame($transportName, $sentEmail->getHeaders()->get('X-Transport')->getBody());
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,7 +61,7 @@ public function testSendWithDefaultTransport()
$this->assertNotEmpty($logs);

$log = $logs[0];
$this->assertSame(sprintf('New SMSon phone number: %s', $phone), $log['message']);
$this->assertSame(\sprintf('New SMSto phone number %s', $phone), $log['message']);
$this->assertSame('info', $log['level']);
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp