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:
pepperoni-pi
2020-06-04 20:18:49 -07:00
committed by GitHub
parent cd362b7983
commit 28ae37c406
3 changed files with 145 additions and 19 deletions

View File

@@ -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' => [