mirror of
https://github.com/WhatCD/Gazelle.git
synced 2025-01-31 02:21:36 +00:00
Implement Pushjet notifications
This commit is contained in:
parent
efbb7586c6
commit
b0b2750a0b
@ -751,6 +751,9 @@ public static function send_push($UserIDs, $Title, $Body, $URL = '', $Type = sel
|
||||
case '6':
|
||||
$Service = "PushBullet";
|
||||
break;
|
||||
case '7':
|
||||
$Service = "Pushjet";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ private static function render_push_settings() {
|
||||
<option value="4"<? if ($PushService == 4) { ?> selected="selected"<? } ?>>Super Toasty</option>
|
||||
<option value="5"<? if ($PushService == 5) { ?> selected="selected"<? } ?>>Pushover</option>
|
||||
<option value="6"<? if ($PushService == 6) { ?> selected="selected"<? } ?>>PushBullet</option>
|
||||
<option value="7"<? if ($PushService == 7) { ?> selected="selected"<? } ?>>Pushjet</option>
|
||||
</select>
|
||||
<div id="pushsettings" style="display: none;">
|
||||
<label id="pushservice_title" for="pushkey">API key</label>
|
||||
|
@ -60,11 +60,40 @@ private function parse_data($Data) {
|
||||
$JSON['message']['body'],
|
||||
$JSON['message']['url']
|
||||
);
|
||||
case 'pushjet':
|
||||
$this->push_pushjet($JSON['user']['key'], $JSON['message']['title'], $JSON['message']['body'], $JSON['message']['url']);
|
||||
break
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function push_pushjet($Key, $Title, $Message, $URL) {
|
||||
$API = "https://api.pushjet.io/message";
|
||||
$Fields = array(
|
||||
'secret' => urlencode($Key),
|
||||
'title' => urlencode($Title),
|
||||
'description' => urlencode($Message)
|
||||
);
|
||||
if (!empty($URL)) {
|
||||
$Fields['link'] = $URL;
|
||||
}
|
||||
|
||||
$FieldsString = "";
|
||||
foreach ($Fields as $key => $value) {
|
||||
$FieldsString .= $key . '=' . $value . '&';
|
||||
}
|
||||
rtrim($FieldsString, '&');
|
||||
|
||||
$Curl = curl_init();
|
||||
curl_setopt($Curl, CURLOPT_URL, $API);
|
||||
curl_setopt($Curl, CURLOPT_POST, count($Fields));
|
||||
curl_setopt($Curl, CURLOPT_POSTFIELDS, $FieldsString);
|
||||
curl_exec($Curl);
|
||||
curl_close($Curl);
|
||||
echo "Push sent to Pushjet";
|
||||
}
|
||||
|
||||
private function push_prowl($Key, $Title, $Message, $URL) {
|
||||
$API = "https://api.prowlapp.com/publicapi/add";
|
||||
$Fields = array(
|
||||
|
@ -1,6 +1,7 @@
|
||||
var PUSHOVER = 5;
|
||||
var TOASTY = 4;
|
||||
var PUSHBULLET = 6;
|
||||
var PUSHJET = 7;
|
||||
|
||||
$(document).ready(function() {
|
||||
var top = $('#settings_sections').offset().top - parseFloat($('#settings_sections').css('marginTop').replace(/auto/, 0));
|
||||
@ -76,6 +77,8 @@ $(document).ready(function() {
|
||||
$('#pushservice_title').text("Device ID");
|
||||
} else if ($(this).val() == PUSHOVER) {
|
||||
$('#pushservice_title').text("User Key");
|
||||
} else if ($(this).val() == PUSHJET) {
|
||||
$('#pushservice_title').text("Secret");
|
||||
} else {
|
||||
$('#pushservice_title').text("API Key");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user