Closed john-f-chamberlain closed 10 months ago
Documentation that states to disable link unfurling you must pass "false": https://api.slack.com/reference/messaging/link-unfurling#no_unfurling_please
Possible solution: Modify https://github.com/laravel/slack-notification-channel/blob/6ad5a0cbcefce89e917f13b7f7b866d882af6380/src/Slack/SlackMessage.php#L214-L219
To Be:
public function unfurlLinks(bool $unfurl = true): self
{
$this->unfurlLinks = $unfurl;
return $this;
}
To Be:
public function unfurlMedia(bool $unfurl = true): self
{
$this->unfurlMedia = $unfurl;
return $this;
}
This would allow you to set unfurl_media and unfurl_links to false and prevent link and media previews from being generated in Slack.
Think you're looking at the wrong place as the notification class has the appropriate messages to set the boolean for these: https://github.com/laravel/slack-notification-channel/blob/6ad5a0cbcefce89e917f13b7f7b866d882af6380/src/Messages/SlackMessage.php#L240-L245
This is also the class that's documented.
Thank you! My apologies, I didn't realize my IDE autocompleted the wrong class! That would also explain why other methods were missing 🤦♂️
@driesvints
Actually, this doesn't appear to be the class that's in the official documentation. The official documentation uses the class that I originally used: \Illuminate\Notifications\Slack\SlackMessage
, not \Illuminate\Notifications\Messages\SlackMessage
https://laravel.com/docs/10.x/notifications#formatting-slack-notifications
The full example provided in the documentation is:
use Illuminate\Notifications\Slack\BlockKit\Blocks\ContextBlock;
use Illuminate\Notifications\Slack\BlockKit\Blocks\SectionBlock;
use Illuminate\Notifications\Slack\BlockKit\Composites\ConfirmObject;
use Illuminate\Notifications\Slack\SlackMessage;
/**
* Get the Slack representation of the notification.
*/
public function toSlack(object $notifiable): SlackMessage
{
return (new SlackMessage)
->text('One of your invoices has been paid!')
->headerBlock('Invoice Paid')
->contextBlock(function (ContextBlock $block) {
$block->text('Customer #1234');
})
->sectionBlock(function (SectionBlock $block) {
$block->text('An invoice has been paid.');
$block->field("*Invoice No:*\n1000")->markdown();
$block->field("*Invoice Recipient:*\ntaylor@laravel.com")->markdown();
})
->dividerBlock()
->sectionBlock(function (SectionBlock $block) {
$block->text('Congratulations!');
});
}
Right, seems to be part of https://github.com/laravel/slack-notification-channel/pull/64 by @claudiodekker. This might just have been forgotten. We'd appreciate a PR 👍
Slack Notification Channel Version
3.0.1
Laravel Version
10.2.8
PHP Version
8.1
Database Driver & Version
No response
Description
There is currently no way to set unfurl_links or unfurl_media to false. The only options currently are null (default) or true (by executing the
unfurlLinks
orunfurlMedia
methods.Unless specifically set to false, Slack will enable unfurl for links and media.
Steps To Reproduce
unfurlLinks
method.