mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
2b10956f0b
I've gone over all the Transporters adn changed all 'text' fields for token, keys and passwords to 'password' so the no longer show up as clear text in the GUI
74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?php
|
|
/* Copyright (C) 2015 Daniel Preussker <f0o@librenms.org>
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
/**
|
|
* Clickatell REST-API Transport
|
|
*
|
|
* @author f0o <f0o@librenms.org>
|
|
* @copyright 2015 f0o, LibreNMS
|
|
* @license GPL
|
|
*/
|
|
|
|
namespace LibreNMS\Alert\Transport;
|
|
|
|
use LibreNMS\Alert\Transport;
|
|
use LibreNMS\Exceptions\AlertTransportDeliveryException;
|
|
use LibreNMS\Util\Http;
|
|
|
|
class Clickatell extends Transport
|
|
{
|
|
public function deliverAlert(array $alert_data): bool
|
|
{
|
|
$url = 'https://platform.clickatell.com/messages/http/send';
|
|
$params = [
|
|
'apiKey' => $this->config['clickatell-token'],
|
|
'to' => implode(',', preg_split('/([,\r\n]+)/', $this->config['clickatell-numbers'])),
|
|
'content' => $alert_data['title'],
|
|
];
|
|
|
|
$res = Http::client()->get($url, $params);
|
|
|
|
if ($res->successful()) {
|
|
return true;
|
|
}
|
|
|
|
throw new AlertTransportDeliveryException($alert_data, $res->status(), $res->body(), $alert_data['title'], $params);
|
|
}
|
|
|
|
public static function configTemplate(): array
|
|
{
|
|
return [
|
|
'config' => [
|
|
[
|
|
'title' => 'Token',
|
|
'name' => 'clickatell-token',
|
|
'descr' => 'Clickatell Token',
|
|
'type' => 'password',
|
|
],
|
|
[
|
|
'title' => 'Mobile Numbers',
|
|
'name' => 'clickatell-numbers',
|
|
'descr' => 'Enter mobile numbers, can be new line or comma separated',
|
|
'type' => 'textarea',
|
|
],
|
|
],
|
|
'validation' => [
|
|
'clickatell-token' => 'required|string',
|
|
'clickatell-numbers' => 'required|string',
|
|
],
|
|
];
|
|
}
|
|
}
|