mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added ability to use JSON directly in Msteams Transport (#11129)
* Added ability to use JSON directly in Msteams Transport * Update Transports.md * Update Msteams.php * Update Msteams.php Added boolean to fix test transport button * Update Templates.md Added JSON example and modified titles slightly. * Update Templates.md Moved MS Teams examples under "Examples" header since they are no longer formatted in HTML * Update Templates.md * Update Templates.md * Update Msteams.php changed condition to use $obj['id'] rather than $obj['msg'] * Update Msteams.php
This commit is contained in:
@@ -28,7 +28,6 @@ class Msteams extends Transport
|
||||
public function contactMsteams($obj, $opts)
|
||||
{
|
||||
$url = $opts['url'];
|
||||
|
||||
$data = array(
|
||||
'title' => $obj['title'],
|
||||
'themeColor' => self::getColorForState($obj['state']),
|
||||
@@ -43,9 +42,11 @@ class Msteams extends Transport
|
||||
'Expect:'
|
||||
));
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
if ($this->config['use-json'] === 'on' && $obj['uid'] !== '000') {
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $obj['msg']);
|
||||
}
|
||||
$ret = curl_exec($curl);
|
||||
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
if ($code != 200) {
|
||||
var_dump("Microsoft Teams returned Error, retry later");
|
||||
return false;
|
||||
@@ -62,6 +63,13 @@ class Msteams extends Transport
|
||||
'name' => 'msteam-url',
|
||||
'descr' => 'Microsoft Teams Webhook URL',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'title' => 'Use JSON?',
|
||||
'name' => 'use-json',
|
||||
'descr' => 'Compose MessageCard with JSON rather than Markdown',
|
||||
'type' => 'checkbox',
|
||||
'default' => false,
|
||||
]
|
||||
],
|
||||
'validation' => [
|
||||
|
Reference in New Issue
Block a user