1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00

introduced alertOnlyOnce configuration parameter

This commit is contained in:
Massimo Candela
2019-10-27 14:38:28 +01:00
parent f33bd4b4e6
commit a123f6c037
4 changed files with 24 additions and 7 deletions

View File

@@ -134,8 +134,9 @@ export default class Monitor {
};
_clean = (group) => {
if (new Date().getTime() > group.latest + (this.internalConfig.clearNotificationQueueAfterSeconds * 1000)) {
if (this.config.alertOnlyOnce) {
delete this.alerts[group.id];
} else if (this.config.alertOnlyOnce && new Date().getTime() > group.latest + (this.internalConfig.clearNotificationQueueAfterSeconds * 1000)) {
delete this.alerts[group.id];
delete this.sent[group.id];
@@ -148,7 +149,9 @@ export default class Monitor {
_checkLastSent = (group) => {
const lastTimeSent = this.sent[group.id];
if (lastTimeSent) {
if (lastTimeSent && this.config.alertOnlyOnce) {
return false;
} else if (lastTimeSent) {
const isThereSomethingNew = lastTimeSent < group.latest;
const isItTimeToSend = new Date().getTime() > lastTimeSent + (this.internalConfig.notificationIntervalSeconds * 1000);