����JFIF��x�x����'
Server IP : 78.140.185.180 / Your IP : 13.59.111.209 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/www/vendor/laravel/slack-notification-channel/src/Channels/ |
Upload File : |
<?php namespace Illuminate\Notifications\Channels; use GuzzleHttp\Client as HttpClient; use Illuminate\Notifications\Messages\SlackAttachment; use Illuminate\Notifications\Messages\SlackAttachmentField; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; class SlackWebhookChannel { /** * The HTTP client instance. * * @var \GuzzleHttp\Client */ protected $http; /** * Create a new Slack channel instance. * * @param \GuzzleHttp\Client $http * @return void */ public function __construct(HttpClient $http) { $this->http = $http; } /** * Send the given notification. * * @param mixed $notifiable * @param \Illuminate\Notifications\Notification $notification * @return \Psr\Http\Message\ResponseInterface|null */ public function send($notifiable, Notification $notification) { if (! $url = $notifiable->routeNotificationFor('slack', $notification)) { return; } return $this->http->post($url, $this->buildJsonPayload( $notification->toSlack($notifiable) )); } /** * Build up a JSON payload for the Slack webhook. * * @param \Illuminate\Notifications\Messages\SlackMessage $message * @return array */ protected function buildJsonPayload(SlackMessage $message) { $optionalFields = array_filter([ 'channel' => data_get($message, 'channel'), 'icon_emoji' => data_get($message, 'icon'), 'icon_url' => data_get($message, 'image'), 'link_names' => data_get($message, 'linkNames'), 'unfurl_links' => data_get($message, 'unfurlLinks'), 'unfurl_media' => data_get($message, 'unfurlMedia'), 'username' => data_get($message, 'username'), ]); return array_merge([ 'json' => array_merge([ 'text' => $message->content, 'attachments' => $this->attachments($message), ], $optionalFields), ], $message->http); } /** * Format the message's attachments. * * @param \Illuminate\Notifications\Messages\SlackMessage $message * @return array */ protected function attachments(SlackMessage $message) { return collect($message->attachments)->map(function ($attachment) use ($message) { return array_filter([ 'actions' => $attachment->actions, 'author_icon' => $attachment->authorIcon, 'author_link' => $attachment->authorLink, 'author_name' => $attachment->authorName, 'callback_id' => $attachment->callbackId, 'color' => $attachment->color ?: $message->color(), 'fallback' => $attachment->fallback, 'fields' => $this->fields($attachment), 'footer' => $attachment->footer, 'footer_icon' => $attachment->footerIcon, 'image_url' => $attachment->imageUrl, 'mrkdwn_in' => $attachment->markdown, 'pretext' => $attachment->pretext, 'text' => $attachment->content, 'thumb_url' => $attachment->thumbUrl, 'title' => $attachment->title, 'title_link' => $attachment->url, 'ts' => $attachment->timestamp, ]); })->all(); } /** * Format the attachment's fields. * * @param \Illuminate\Notifications\Messages\SlackAttachment $attachment * @return array */ protected function fields(SlackAttachment $attachment) { return collect($attachment->fields)->map(function ($value, $key) { if ($value instanceof SlackAttachmentField) { return $value->toArray(); } return ['title' => $key, 'value' => $value, 'short' => true]; })->values()->all(); } }