kopia lustrzana https://gitlab.com/gridtracker.org/gridtracker
WIP: initial push notification implementation
rodzic
2c7a1aefc2
commit
c0aab489c3
|
@ -2978,6 +2978,59 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mapItem">
|
||||
<table align="center">
|
||||
<tr>
|
||||
<td>
|
||||
<label data-i18n="settings.OAMS.simplepush.enable.label" for="msgSimplepush">Enable / Disable Simplepush Message forwarding</label>
|
||||
<input title="Enable / Disable Simplepush" type="checkbox" id="msgSimplepush"
|
||||
onclick="setOamsSimplepush(this);" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td data-i18n="settings.OAMS.simplepush.apikey.label"
|
||||
title="SimplePush API Key to forward messages to your phone">SimplePush API Key</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input title="SimplePush API Key to forward messages to your phone" type="text" id="msgSimplePushApiKey"
|
||||
class="inputTextValue" maxlength="255" size="16"
|
||||
oninput="ValidateText(this); newMessageSetting(this);" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mapItem">
|
||||
<table align="center">
|
||||
<tr>
|
||||
<td>
|
||||
<label data-i18n="settings.OAMS.pushover.enable.label" for="msgPushover">Enable / Disable Pushover Message forwarding</label>
|
||||
<input title="Enable / Disable Pushover" type="checkbox" id="msgPushover"
|
||||
onclick="setOamsPushover(this);" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td data-i18n="settings.OAMS.pushover.credentials.label"
|
||||
title="Pushover Credentials to forward messages to your phone">Pushover Credentials</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label data-i18n="settings.OAMS.pushover.username.label" for="msgPushoverUsername">Username</label>
|
||||
<input title="Pushover Username to forward messages to your phone" type="text" id="msgPushoverUsername"
|
||||
class="inputTextValue" maxlength="255" size="16"
|
||||
oninput="ValidateText(this); newMessageSetting(this);" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label data-i18n="settings.OAMS.pushover.token.label" for="msgPushoverToken">Token</label>
|
||||
<input title="Pushover Token to forward messages to your phone" type="text" id="msgPushoverToken"
|
||||
class="inputTextValue" maxlength="255" size="16"
|
||||
oninput="ValidateText(this); newMessageSetting(this);" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<br />
|
||||
<div class="mapItem" id="msgFrequencySelectDiv">
|
||||
<table align="center">
|
||||
|
|
|
@ -166,6 +166,12 @@
|
|||
"settings.Alerts.label": "Alarme",
|
||||
"settings.CallRoster.label": "Rufzeichenliste",
|
||||
"settings.OAMS.label": "OAMS",
|
||||
"settings.OAMS.simplepush.enable.label": "Simplepush Nachrichtenweiterleitung ein/aus",
|
||||
"settings.OAMS.simplepush.apikey.label": "Simplepush API Key",
|
||||
"settings.OAMS.pushover.enable.label": "Pushover Nachrichtenweiterleitung ein/aus",
|
||||
"settings.OAMS.pushover.credentials.label": "Pushover Zugangsdaten",
|
||||
"settings.OAMS.pushover.username.label": "Benutzername",
|
||||
"settings.OAMS.pushover.token.label": "Token",
|
||||
"settings.Logbook.label": "Logbook",
|
||||
"settings.Update.label": "Update",
|
||||
"settings.About.label": "Über",
|
||||
|
|
|
@ -193,7 +193,12 @@ var def_msgSettings = {
|
|||
msgFrequencySelect: 0,
|
||||
msgActionSelect: 1,
|
||||
msgAwaySelect: 0,
|
||||
msgAwayText: "I am away from the shack at the moment"
|
||||
msgAwayText: "I am away from the shack at the moment",
|
||||
msgSimplepush: false,
|
||||
msgSimplePushApiKey: "",
|
||||
msgPushover: false,
|
||||
msgPushoverUsername: "",
|
||||
msgPushoverToken: ""
|
||||
};
|
||||
|
||||
var def_receptionSettings = {
|
||||
|
|
|
@ -10677,6 +10677,16 @@ function setOamsBandActivityNeighbors(checkbox)
|
|||
oamsBandActivityCheck();
|
||||
}
|
||||
|
||||
function setOamsSimplepush(checkbox)
|
||||
{
|
||||
GT.appSettings.msgSimplepush = checkbox.checked;
|
||||
}
|
||||
|
||||
function setOamsPushover(checkbox)
|
||||
{
|
||||
GT.appSettings.msgPushover = checkbox.checked;
|
||||
}
|
||||
|
||||
function setMsgEnable(checkbox)
|
||||
{
|
||||
GT.appSettings.gtMsgEnable = checkbox.checked;
|
||||
|
|
|
@ -567,6 +567,46 @@ function htmlEntities(str)
|
|||
.replace(/"/g, """);
|
||||
}
|
||||
|
||||
function sendSimplePushMessage(cid, jsmesg)
|
||||
{
|
||||
const url = "https://api.simplepush.io/send";
|
||||
let data = { key: GT.msgSettings.msgSimplePushApiKey, title: "GridTracker Chat Message", msg: jsmesg.call + ": " + jsmesg.msg };
|
||||
getPostBuffer(
|
||||
url,
|
||||
null, // callback,
|
||||
null,
|
||||
"https",
|
||||
443,
|
||||
data,
|
||||
500, // timeoutMs,
|
||||
null, // timeoutCallback,
|
||||
"simplepush"
|
||||
);
|
||||
}
|
||||
|
||||
function sendPushOverMessage(cid, jsmesg)
|
||||
{
|
||||
const url = "https://api.pushover.net/1/messages.json";
|
||||
let data = {
|
||||
user: GT.msgSettings.msgPushoverUsername,
|
||||
token: GT.msgSettings.msgPushoverToken,
|
||||
title:
|
||||
"GridTracker Chat Message",
|
||||
message: jsmesg.call + ": " + jsmesg.msg
|
||||
};
|
||||
getPostBuffer(
|
||||
url,
|
||||
null, // callback,
|
||||
null,
|
||||
"https",
|
||||
443,
|
||||
data,
|
||||
500, // timeoutMs,
|
||||
null, // timeoutCallback,
|
||||
"pushover"
|
||||
);
|
||||
}
|
||||
|
||||
function gtChatMessage(jsmesg)
|
||||
{
|
||||
if (GT.appSettings.gtMsgEnable == true)
|
||||
|
@ -580,7 +620,7 @@ function gtChatMessage(jsmesg)
|
|||
}
|
||||
catch (e)
|
||||
{
|
||||
jsmesg.msg = "Corrupt message recieved";
|
||||
jsmesg.msg = "Corrupt message received";
|
||||
}
|
||||
|
||||
if (jsmesg.call != null && jsmesg.call != "" && jsmesg.call != "NOCALL")
|
||||
|
@ -589,6 +629,16 @@ function gtChatMessage(jsmesg)
|
|||
GT.gtUnread[cid] = true;
|
||||
GT.gtCurrentMessageCount++;
|
||||
|
||||
if (GT.msgSettings.msgSimplepush && GT.msgSettings.msgSimplePushApiKey != null)
|
||||
{
|
||||
sendSimplePushMessage(cid, jsmesg);
|
||||
}
|
||||
if (GT.msgSettings.msgPushover && GT.msgSettings.pushoverUsername != null &&
|
||||
GT.msgSettings.pushoverToken != null)
|
||||
{
|
||||
sendPushOverMessage(cid, jsmesg);
|
||||
}
|
||||
|
||||
if (newChatMessage(cid, jsmesg) == false) alertChatMessage();
|
||||
|
||||
if (GT.msgSettings.msgAwaySelect == 1 && !(cid in GT.gtSentAwayToCid))
|
||||
|
|
Ładowanie…
Reference in New Issue