1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-11 23:54:04 +02:00

Fix SlackHandler

Slack API requires to json_encode the attachment field.
This commit is contained in:
Anton Nizhegorodov
2016-11-16 01:31:40 +02:00
committed by Haralan Dobrev
parent dd238892cf
commit 5fa5e37305
2 changed files with 5 additions and 1 deletions

View File

@@ -110,6 +110,10 @@ class SlackHandler extends SocketHandler
$dataArray = $this->slackRecord->getSlackData($record); $dataArray = $this->slackRecord->getSlackData($record);
$dataArray['token'] = $this->token; $dataArray['token'] = $this->token;
if (!empty($dataArray['attachments'])) {
$dataArray['attachments'] = json_encode($dataArray['attachments']);
}
return $dataArray; return $dataArray;
} }

View File

@@ -99,7 +99,7 @@ class SlackHandlerTest extends TestCase
fseek($this->res, 0); fseek($this->res, 0);
$content = fread($this->res, 1024); $content = fread($this->res, 1024);
$this->assertRegexp('/%5Bcolor%5D='.$expectedColor.'/', $content); $this->assertRegexp('/%22color%22%3A%22'.$expectedColor.'/', $content);
} }
public function testWriteContentWithPlainTextMessage() public function testWriteContentWithPlainTextMessage()