Skip to content

Commit

Permalink
Merge pull request #4 from mhdev90/master
Browse files Browse the repository at this point in the history
Variables "image_url" and "title_link" should not be empty.
  • Loading branch information
martinusso authored Oct 19, 2020
2 parents 1d2aace + dc75534 commit 92313ba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/RocketChatHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ protected function write(array $record): void
"attachments" => [
[
"title" => $record['level_name'] ?? '',
"title_link" => $record['link'] ?? '',
"text" => $record['message'] ?? '',
"image_url" => $record['image_url'] ?? '',
"color" => $this->levelColors[$level],
],
],
];

foreach (['title_link', 'image_url'] as $field_name) {
if(!empty($record[$field_name])) {
$content['attachments'][$field_name] = $record[$field_name];
}
}

foreach ($this->webhooks as $webhook) {
$this->client->request('POST', $webhook, [
'json' => $content,
Expand Down

0 comments on commit 92313ba

Please sign in to comment.