-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Description
Symfony version(s) affected: 5.2.1
Description
slack-notifier documentation tells that SLACK_DSN
must look like this:
SLACK_DSN=slack://xoxb-......@default?channel=my-channel-name
But this format generates this exception when we try to send notification:
Support for Slack webhook DSN has been dropped since 5.2 (maybe you haven't updated the DSN when upgrading from 5.1).
How to reproduce
- Create new symfony app:
symfony new slack-notifier-test
- Require slack-notifier:
composer req slack-notifier
- Edit file
config/packages/notifier.yaml
to enable chatter transport:
framework:
notifier:
chatter_transports:
slack: '%env(SLACK_DSN)%'
- Add your own SLACK_DSN to
.env
file:
SLACK_DSN=slack://xoxb-449280182032-1632617752622-xYSN4i3olopYlAijAW6PcMO8@default?channel=general
- Create file
src/Command/NotifyCommand.php
:
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Notifier\ChatterInterface;
use Symfony\Component\Notifier\Message\ChatMessage;
class NotifyCommand extends Command
{
protected static $defaultName = 'notify';
protected $chatter;
public function __construct(ChatterInterface $chatter)
{
$this->chatter = $chatter;
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$message = (new ChatMessage('Hello'))
->transport('slack');
$this->chatter->send($message);
return Command::SUCCESS;
}
}
- Run console command:
symfony console notify
. We'll get an error:
[error] Error thrown while running command "notify". Message: "Support for Slack webhook DSN has been dropped since 5.2 (maybe you haven't updated the DSN when upgrading from 5.1)."
Possible Solution
It seems to me that this bug was fixed in this commit: symfony/slack-notifier@da1642c
But why we don't see these changes in the current version of slack-notifier
, v.5.2.1?