added 1500ms curl timeout for the push_notifications. otherwise the findblock cron will run default 300s timeout if a service goes down. (notifymyandroid is down.) 300ms are not enough for pushover working fine with fine with 1000ms increased it to 1500ms for high ping connections.
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
class Notifications_NotifyMyAndroid implements IPushNotification {
|
|
|
|
private $apiKey;
|
|
public function __construct($apikey){
|
|
$this->apiKey = $apikey;
|
|
}
|
|
|
|
static $priorities = array(
|
|
0 => 'info',
|
|
2 => 'error',
|
|
);
|
|
|
|
public static function getName(){
|
|
return "notifymyandroid.com";
|
|
}
|
|
|
|
public static function getParameters(){
|
|
return array(
|
|
'apikey' => 'API key',
|
|
);
|
|
}
|
|
|
|
public function notify($message, $severity = 'info', $event = null){
|
|
global $setting;
|
|
curl_setopt_array($ch = curl_init(), array(
|
|
CURLOPT_TIMEOUT_MS => 1500,
|
|
CURLOPT_URL => "https://www.notifymyandroid.com/publicapi/notify",
|
|
CURLOPT_POST => true,
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_POSTFIELDS => http_build_query($data = array(
|
|
"apikey" => $this->apiKey,
|
|
"application" => $setting->getValue('website_title')?:"PHP-MPOS",
|
|
"description" => $message,
|
|
"content-type" => "text/html",
|
|
"event" => $event,
|
|
"priority" => array_search($severity, self::$priorities),
|
|
)),
|
|
));
|
|
curl_exec($ch);
|
|
curl_close($ch);
|
|
}
|
|
} |