Skip to content

Commit

Permalink
fixes #47 support workflows, thanks for Microsoft the old webhook is …
Browse files Browse the repository at this point in the history
…going to be abolished
  • Loading branch information
kevincobain2000 committed Jul 21, 2024
1 parent e59839f commit cd0be71
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 46 deletions.
3 changes: 3 additions & 0 deletions src/Dispatcher/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public static function send(string $url, array $body, $proxy, string $method = '
{
$client = new Client();
$result = $client->request($method, $url, [
'headers' => [
'Content-Type' => 'application/json',
],
'proxy' => $proxy,
'connect_timeout' => 5.0,
'timeout' => 5.0,
Expand Down
106 changes: 60 additions & 46 deletions src/MicrosoftTeams/ExceptionOccurredCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,54 +18,68 @@ public function __construct($exception, array $exceptionContext = [])
public function getCard()
{
return [
'@type' => 'MessageCard',
'@context' => 'http://schema.org/extensions',
'summary' => config('laravel_alert_notifications.microsoft_teams.cardSubject'),
'themeColor' => config('laravel_alert_notifications.themeColor'),
'title' => config('laravel_alert_notifications.cardSubject'),
'sections' => [
'type' => 'message',
'attachments' => [
[
'activityTitle' => config('laravel_alert_notifications.microsoft_teams.cardSubject'),
'activitySubtitle' => 'Error has occurred on '.config('app.name').' - '.config('app.name'),
'activityImage' => '',
'facts' => [
[
'name' => 'Environment:',
'value' => config('app.env'),
'contentType' => 'application/vnd.microsoft.card.adaptive',
'contentUrl' => null,
'content' => [
'\$schema' => 'http://adaptivecards.io/schemas/adaptive-card.json',
'type' => 'AdaptiveCard',
'version' => '1.4',
'accentColor' => 'bf0000',
'body' => [
[
'type' => 'TextBlock',
'text' => config('laravel_alert_notifications.microsoft_teams.cardSubject'),
'id' => 'title',
'size' => 'large',
'weight' => 'bolder',
'color' => 'accent',
],
[
'type' => 'FactSet',
'facts' => [
[
'title' => 'Environment:',
'value' => config('app.env'),
],
[
'title' => 'Server:',
'value' => Request::server('SERVER_NAME'),
],
[
'title' => 'Request Url:',
'value' => Request::fullUrl(),
],
[
'title' => 'Exception:',
'value' => get_class($this->exception),
],
[
'title' => 'Message:',
'value' => $this->exception->getMessage(),
],
[
'title' => 'Exception Code:',
'value' => $this->exception->getCode(),
],
[
'title' => 'In File:',
'value' => $this->exception->getFile() .' on line '.$this->exception->getLine(),
],
],
'id' => 'acFactSet',
],
[
'type' => 'CodeBlock',
'codeSnippet' => $this->exception->getTraceAsString(),
'fontType' => 'monospace',
'wrap' => true,
],
],
[
'name' => 'Server:',
'value' => Request::server('SERVER_NAME'),
],
[
'name' => 'Request Url:',
'value' => Request::fullUrl(),
],
[
'name' => 'Exception:',
'value' => get_class($this->exception),
],
[
'name' => 'Message:',
'value' => $this->exception->getMessage(),
],
[
'name' => 'Exception Code:',
'value' => $this->exception->getCode(),
],
[
'name' => 'In File:',
'value' => '<b style="color:red;">'
.$this->exception->getFile()
.' on line '.$this->exception->getLine().'</b>',
],
[
'name' => 'Stack Trace:',
'value' => '<pre>'.$this->exception->getTraceAsString().'</pre>',
],
[
'name' => 'Context:',
'value' => '<pre>$context = '.var_export($this->exceptionContext, true).';</pre>',
'msteams' => [
'width' => 'Full',
],
],
],
Expand Down

0 comments on commit cd0be71

Please sign in to comment.