mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI * Disable style check
This commit is contained in:
@@ -9,39 +9,41 @@
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Alert\Transport;
|
||||
|
||||
use LibreNMS\Enum\AlertState;
|
||||
use LibreNMS\Alert\Transport;
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Enum\AlertState;
|
||||
|
||||
class Kayako extends Transport
|
||||
{
|
||||
public function deliverAlert($host, $kayako)
|
||||
{
|
||||
if (!empty($this->config)) {
|
||||
if (! empty($this->config)) {
|
||||
$kayako['url'] = $this->config['kayako-url'];
|
||||
$kayako['key'] = $this->config['kayako-key'];
|
||||
$kayako['secret'] = $this->config['kayako-secret'];
|
||||
$kayako['department'] = $this->config['kayako-department'];
|
||||
}
|
||||
|
||||
return $this->contactKayako($host, $kayako);
|
||||
}
|
||||
|
||||
public function contactKayako($host, $kayako)
|
||||
{
|
||||
$url = $kayako['url']."/Tickets/Ticket";
|
||||
$url = $kayako['url'] . "/Tickets/Ticket";
|
||||
$key = $kayako['key'];
|
||||
$secret = $kayako['secret'];
|
||||
$user = Config::get('email_from');
|
||||
$department = $kayako['department'];
|
||||
$ticket_type= 1;
|
||||
$ticket_type = 1;
|
||||
$ticket_status = 1;
|
||||
$ticket_prio = 1;
|
||||
$salt = mt_rand();
|
||||
$signature = base64_encode(hash_hmac('sha256', $salt, $secret, true));
|
||||
|
||||
$protocol = array(
|
||||
$protocol = [
|
||||
'subject' => ($host['name'] ? $host['name'] . ' on ' . $host['hostname'] : $host['title']),
|
||||
'fullname' => 'LibreNMS Alert',
|
||||
'email' => $user,
|
||||
@@ -54,11 +56,11 @@ class Kayako extends Transport
|
||||
'ignoreautoresponder' => true,
|
||||
'apikey' => $key,
|
||||
'salt' => $salt,
|
||||
'signature' => $signature
|
||||
);
|
||||
'signature' => $signature,
|
||||
];
|
||||
$post_data = http_build_query($protocol, '', '&');
|
||||
|
||||
$curl = curl_init();
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
@@ -68,6 +70,7 @@ class Kayako extends Transport
|
||||
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
if ($code != 200) {
|
||||
var_dump("Kayako returned Error, retry later");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -82,33 +85,33 @@ class Kayako extends Transport
|
||||
'title' => 'Kayako URL',
|
||||
'name' => 'kayako-url',
|
||||
'descr' => 'ServiceDesk API URL',
|
||||
'type' => 'text'
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'title' => 'Kayako API Key',
|
||||
'name' => 'kayako-key',
|
||||
'descr' => 'ServiceDesk API Key',
|
||||
'type' => 'text'
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'title' => 'Kayako API Secret',
|
||||
'name' => 'kayako-secret',
|
||||
'descr' => 'ServiceDesk API Secret Key',
|
||||
'type' => 'text'
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'title' => 'Kayako Department',
|
||||
'name' => 'kayako-department',
|
||||
'descr' => 'Department to post a ticket',
|
||||
'type' => 'text'
|
||||
]
|
||||
'type' => 'text',
|
||||
],
|
||||
],
|
||||
'validation' => [
|
||||
'kayako-url' => 'required|url',
|
||||
'kayako-key' => 'required|string',
|
||||
'kayako-secret' => 'required|string',
|
||||
'kayako-department' => 'required|string'
|
||||
]
|
||||
'kayako-department' => 'required|string',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user