diff --git a/src/inc/notifications/NotificationTeams.class.php b/src/inc/notifications/NotificationTeams.class.php new file mode 100644 index 000000000..891397ac4 --- /dev/null +++ b/src/inc/notifications/NotificationTeams.class.php @@ -0,0 +1,59 @@ + array( + "content" => $message, + "subject" => $subject, + "attachments" => array() // Ensures Power Automate receives a valid array + ) + ); + + $make_json = json_encode($json_data); + + $ch = curl_init($this->receiver); + + // Proxy configuration if enabled + if (SConfig::getInstance()->getVal(DConfig::NOTIFICATIONS_PROXY_ENABLE) == 1) { + curl_setopt($ch, CURLOPT_PROXY, SConfig::getInstance()->getVal(DConfig::NOTIFICATIONS_PROXY_SERVER)); + curl_setopt($ch, CURLOPT_PROXYPORT, SConfig::getInstance()->getVal(DConfig::NOTIFICATIONS_PROXY_PORT)); + $type = CURLPROXY_HTTP; + switch (SConfig::getInstance()->getVal(DConfig::NOTIFICATIONS_PROXY_TYPE)) { + case DProxyTypes::HTTPS: + $type = CURLPROXY_HTTPS; + break; + case DProxyTypes::SOCKS4: + $type = CURLPROXY_SOCKS4; + break; + case DProxyTypes::SOCKS5: + $type = CURLPROXY_SOCKS5; + break; + } + curl_setopt($ch, CURLOPT_PROXYTYPE, $type); + curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true); + } + + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $make_json); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + return curl_exec($ch); + } +} + +HashtopolisNotification::add('Teams Webhook', new HashtopolisNotificationTeamsWebhook()); \ No newline at end of file diff --git a/src/templates/notifications/Teams.template.html b/src/templates/notifications/Teams.template.html new file mode 100644 index 000000000..a83a00d6f --- /dev/null +++ b/src/templates/notifications/Teams.template.html @@ -0,0 +1 @@ +[[message]] \ No newline at end of file