Closed
Description
Symfony version(s) affected
7.x, 6.x, 5.x
Description
unfurlLinks and unfurlMedia are boolean values that end up in the $options array. When setting the explicitly to false (to prevent unfurling), they are stripped in the SlackTransport class from the $options array by filter_array, as a boolean false is considdered empty. This results in the key/value not being present in the json that is sent to Slack.
How to reproduce
Send a message:
$slack = new Symfony\Component\Notifier\Bridge\Slack\SlackTransport('xoxb-some-token', 'some-channel');
$opts = new \Symfony\Component\Notifier\Bridge\Slack\SlackOptions(['unfurl_links' => false]);
$message = new \Symfony\Component\Notifier\Message\ChatMessage('Test message with a link to https://www.github.com/', $opts);
$slack->send($message);
var_dump($options, filter_array($options))
array(3) {
["unfurl_links"]=>
bool(false)
["channel"]=>
string(17) "some-channel"
["text"]=>
string(35) "Test message with a link to https://www.github.com/'"
}
array(3) {
["channel"]=>
string(17) "some-channel"
["text"]=>
string(35) "Test message with a link to https://www.github.com/'"
}
Possible Solution
Add custom callback to array_filter function that uses empty(), but explicitly keeps boolean false values
Additional Context
No response