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

Appearance settings

Commit f4662b8

Browse filesBrowse files
committed
-
1 parent 2e9214f commit f4662b8
Copy full SHA for f4662b8

File tree

4 files changed

+14
-14
lines changed
Filter options

4 files changed

+14
-14
lines changed

‎src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ protected function doSend(MessageInterface $message): void
6262
throw new LogicException(sprintf('The "%s" transport only support instances of "%s" for options.', __CLASS__, SlackOptions::class));
6363
}
6464

65-
$options = ($opts = $message->getOptions()) ? $opts->toArray() : [];
65+
if (!($opts = $message->getOptions()) && $notification = $message->getNotification()) {
66+
$opts = SlackOptions::fromNotification($notification);
67+
}
68+
69+
$options = $opts ? $opts->toArray() : [];
6670
$options['token'] = $this->accessToken;
6771
if (!isset($options['channel'])) {
6872
$options['channel'] = $message->getRecipientId() ?: $this->chatChannel;

‎src/Symfony/Component/Notifier/Message/ChatMessage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Message/ChatMessage.php
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Notifier\Message;
1313

14-
use Symfony\Component\Notifier\Bridge\Slack\SlackOptions;
1514
use Symfony\Component\Notifier\Notification\Notification;
1615
use Symfony\Component\Notifier\Receiver\Receiver;
1716

@@ -23,6 +22,7 @@ final class ChatMessage implements MessageInterface
2322
private $transport;
2423
private $subject;
2524
private $options;
25+
private $notification;
2626

2727
public function __construct(string $subject, MessageOptionsInterface $options = null)
2828
{
@@ -33,13 +33,7 @@ public function __construct(string $subject, MessageOptionsInterface $options =
3333
public static function fromNotification(Notification $notification, Receiver $receiver, string $transport = null): self
3434
{
3535
$message = new self($notification->getSubject());
36-
37-
// FIXME: here, we need to call a method on the $transport to get the right options
38-
// SlackOptions::fromNotification($notification)
39-
// or if we have all the information in the message
40-
if ('slack' === $transport) {
41-
return $message->options(SlackOptions::fromNotification($notification));
42-
}
36+
$message->notification = $notification;
4337

4438
return $message;
4539
}
@@ -93,4 +87,9 @@ public function getTransport(): ?string
9387
{
9488
return $this->transport;
9589
}
90+
91+
public function getNotification(): ?Notification
92+
{
93+
return $this->notification;
94+
}
9695
}

‎src/Symfony/Component/Notifier/Message/SmsMessage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Message/SmsMessage.php
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Notifier\Exception\LogicException;
1515
use Symfony\Component\Notifier\Notification\Notification;
16+
use Symfony\Component\Notifier\Notification\SmsNotificationInterface;
1617
use Symfony\Component\Notifier\Receiver\Receiver;
1718
use Symfony\Component\Notifier\Receiver\SmsReceiverInterface;
1819

@@ -34,11 +35,9 @@ public function __construct(string $phone, string $subject)
3435
public static function fromNotification(Notification $notification, Receiver $receiver, string $transport = null): self
3536
{
3637
if (!$receiver instanceof SmsReceiverInterface) {
37-
// FIXME: message is wrong now
38-
throw new LogicException(sprintf('To send a SMS notification, "%s" should be overriden in "%s" or the receiver should implement SmsReceiverInterface.', __METHOD__, static::class));
38+
throw new LogicException(sprintf('To send a SMS message, "%s" should implement "%s" or the receiver should implement "%s".', get_class($notification), SmsNotificationInterface::class, SmsReceiverInterface::class));
3939
}
4040

41-
// FIXME: prepend the emoji?
4241
return new self($receiver->getPhone(), $notification->getSubject());
4342
}
4443

‎src/Symfony/Component/Notifier/Receiver/SmsReceiverInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Receiver/SmsReceiverInterface.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*/
1717
interface SmsReceiverInterface
1818
{
19-
// FIXME: do we need a ChatReceiverInterface as well? which would depend on the transport 100% of the time
20-
2119
/**
2220
* @return $this
2321
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.