32 lines
683 B
PHP
32 lines
683 B
PHP
<?php
|
|
|
|
namespace Slack\Channels;
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
class SlackBotChannel
|
|
{
|
|
private const LOGKEY = 'SBC';
|
|
|
|
public function send($notifiable,Notification $notification): void
|
|
{
|
|
if (! $co = $notifiable->routeNotificationFor('slackapp',$notification)) {
|
|
return;
|
|
}
|
|
|
|
$o = $notification->toSlack($notifiable);
|
|
$o->setChannel($co);
|
|
|
|
Log::debug(sprintf('%s:Sending Event to Channel [%s]',self::LOGKEY,$co->channel_id));
|
|
|
|
try {
|
|
$result = $o->post();
|
|
|
|
} catch (\Exception $e) {
|
|
Log::error(sprintf('Error posting to slack [%s]',$e->getMessage()));
|
|
return;
|
|
}
|
|
}
|
|
} |