only send email 30, 10 and 0 days before expiration
This commit is contained in:
parent
9aaf966728
commit
5a2204876d
|
|
@ -34,9 +34,6 @@ func sendEmailAbo(username string, alias string, deveui string, days_left int, l
|
||||||
} else if days_left > 0 {
|
} else if days_left > 0 {
|
||||||
fmt.Printf("SEND EMAIL ABO (%s) - %s:%s\n", level, username, deveui)
|
fmt.Printf("SEND EMAIL ABO (%s) - %s:%s\n", level, username, deveui)
|
||||||
ablauftext = "Das Abo von \"" + alias + "\" (DevEUI: " + deveui + ") laeuft in " + strconv.Itoa(days_left) + " Tagen ab."
|
ablauftext = "Das Abo von \"" + alias + "\" (DevEUI: " + deveui + ") laeuft in " + strconv.Itoa(days_left) + " Tagen ab."
|
||||||
} else {
|
|
||||||
fmt.Printf("DO NOT SEND EMAIL ABO (%s) - %s:%s\n", level, username, deveui)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
mail_message := "To: " + username + `
|
mail_message := "To: " + username + `
|
||||||
From: info@wo-bisch.ch
|
From: info@wo-bisch.ch
|
||||||
|
|
@ -84,6 +81,10 @@ func CheckThreshold(d string, vp int, u2 string, last_metric OneMetric, info_thr
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendReminder(days int) bool {
|
||||||
|
return (days == 0 || days == 5 || days == 10)
|
||||||
|
}
|
||||||
|
|
||||||
func checkNodes() {
|
func checkNodes() {
|
||||||
logit("Starting check_battery...")
|
logit("Starting check_battery...")
|
||||||
|
|
||||||
|
|
@ -105,7 +106,7 @@ func checkNodes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Jetzt der Alarm wegen der Abodauer
|
// Jetzt der Alarm wegen der Abodauer
|
||||||
if last_metric.DaysUntilDeactivated < 30 {
|
if sendReminder(last_metric.DaysUntilDeactivated) {
|
||||||
fmt.Printf("SEND EMAIL %s:%s:%s Percent:%s:%d\n", u2, d, last_metric.BatteryPercent, last_metric.ActiveUntil, last_metric.DaysUntilDeactivated)
|
fmt.Printf("SEND EMAIL %s:%s:%s Percent:%s:%d\n", u2, d, last_metric.BatteryPercent, last_metric.ActiveUntil, last_metric.DaysUntilDeactivated)
|
||||||
alias := getDevAlias(d)
|
alias := getDevAlias(d)
|
||||||
sendEmailAbo(u2, alias, d, last_metric.DaysUntilDeactivated, "INFO")
|
sendEmailAbo(u2, alias, d, last_metric.DaysUntilDeactivated, "INFO")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue