mirror of
https://gitlab.com/gridtracker.org/gridtracker
synced 2026-08-13 17:52:40 -04:00
call roster notifications using push notifications
This commit is contained in:
parent
361e5653c2
commit
0500aecfb1
3 changed files with 94 additions and 6 deletions
|
|
@ -469,6 +469,7 @@ GT.unconfirmedCalls = new Map();
|
|||
|
||||
GT.tracker = {};
|
||||
GT.lastTrasmissionTimeSec = timeNowSec();
|
||||
GT.getPostBuffer = getPostBuffer;
|
||||
|
||||
const PSKREPORTER_INTERVAL_IN_SECONDS = 5 * 60;
|
||||
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@ function htmlEntities(str)
|
|||
.replace(/"/g, """);
|
||||
}
|
||||
|
||||
function sendSimplePushMessage(cid, jsmesg)
|
||||
function sendSimplePushMessage(jsmesg)
|
||||
{
|
||||
const url = "https://api.simplepush.io/send";
|
||||
let data = { key: GT.msgSettings.msgSimplePushApiKey, title: "GridTracker Chat Message", msg: jsmesg.call + ": " + jsmesg.msg };
|
||||
|
|
@ -584,7 +584,7 @@ function sendSimplePushMessage(cid, jsmesg)
|
|||
);
|
||||
}
|
||||
|
||||
function sendPushOverMessage(cid, jsmesg)
|
||||
function sendPushOverMessage(jsmesg)
|
||||
{
|
||||
const url = "https://api.pushover.net/1/messages.json";
|
||||
let data = {
|
||||
|
|
@ -631,12 +631,12 @@ function gtChatMessage(jsmesg)
|
|||
|
||||
if (GT.msgSettings.msgSimplepush && GT.msgSettings.msgSimplePushApiKey != null)
|
||||
{
|
||||
sendSimplePushMessage(cid, jsmesg);
|
||||
sendSimplePushMessage(jsmesg);
|
||||
}
|
||||
if (GT.msgSettings.msgPushover && GT.msgSettings.msgPushoverUsername != null &&
|
||||
GT.msgSettings.msgPushoverToken != null)
|
||||
{
|
||||
sendPushOverMessage(cid, jsmesg);
|
||||
sendPushOverMessage(jsmesg);
|
||||
}
|
||||
|
||||
if (newChatMessage(cid, jsmesg) == false) alertChatMessage();
|
||||
|
|
|
|||
|
|
@ -110,8 +110,95 @@ function sendAlerts(callRoster, rosterSettings)
|
|||
{
|
||||
conosle.log(e);
|
||||
}
|
||||
CR.scriptReport = Object();
|
||||
}
|
||||
else CR.scriptReport = Object();
|
||||
if (window.opener.GT.msgSettings.msgPushover)
|
||||
{
|
||||
sendPushOverAlert(parseCRJson(CR.scriptReport));
|
||||
}
|
||||
if (window.opener.GT.msgSettings.msgSimplepush)
|
||||
{
|
||||
sendSimplePushMessage(parseCRJson(CR.scriptReport));
|
||||
}
|
||||
CR.scriptReport = Object();
|
||||
}
|
||||
}
|
||||
|
||||
function sendSimplePushMessage(message)
|
||||
{
|
||||
const url = "https://api.simplepush.io/send";
|
||||
let data = {
|
||||
key: window.opener.GT.msgSettings.msgSimplePushApiKey,
|
||||
title: "GridTracker Alert " + window.opener.GT.appSettings.myCall,
|
||||
msg: message
|
||||
};
|
||||
window.opener.GT.getPostBuffer(
|
||||
url,
|
||||
null, // callback,
|
||||
null,
|
||||
"https",
|
||||
443,
|
||||
data,
|
||||
500, // timeoutMs,
|
||||
null, // timeoutCallback,
|
||||
"simplepush"
|
||||
);
|
||||
}
|
||||
function sendPushOverAlert(message)
|
||||
{
|
||||
const url = "https://api.pushover.net/1/messages.json";
|
||||
let data = {
|
||||
user: window.opener.GT.msgSettings.msgPushoverUsername,
|
||||
token: window.opener.GT.msgSettings.msgPushoverToken,
|
||||
title:
|
||||
"GridTracker Alert " + window.opener.GT.appSettings.myCall,
|
||||
message: message
|
||||
};
|
||||
window.opener.GT.getPostBuffer(
|
||||
url,
|
||||
null, // callback,
|
||||
null,
|
||||
"https",
|
||||
443,
|
||||
data,
|
||||
500, // timeoutMs,
|
||||
null, // timeoutCallback,
|
||||
"pushover"
|
||||
);
|
||||
}
|
||||
|
||||
function parseCRJson(data)
|
||||
{
|
||||
let message = "";
|
||||
for (let callsign in data)
|
||||
{
|
||||
if (data[callsign].shouldAlert === true && data[callsign].alerted === false)
|
||||
{
|
||||
if (data[callsign].grid)
|
||||
{
|
||||
if (data[callsign].state)
|
||||
{
|
||||
message = message + callsign + ", " + data[callsign].dxccName + ", " + data[callsign].RSTsent.toString() + ", " + data[callsign].grid + ", " + data[callsign].band + ", " + data[callsign].state + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = message + callsign + ", " + data[callsign].dxccName + ", " + data[callsign].RSTsent.toString() + ", " + data[callsign].grid + ", " + data[callsign].band + "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!data[callsign].grid)
|
||||
{
|
||||
if (data[callsign].state)
|
||||
{
|
||||
message = message + callsign + ", " + data[callsign].dxccName + ", " + data[callsign].RSTsent.toString() + ", " + data[callsign].band + ", " + data[callsign].state + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = message + callsign + ", " + data[callsign].dxccName + ", " + data[callsign].RSTsent.toString() + ", " + data[callsign].band + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue