only send abo reminder 10, 5 and 0 days before expiration

This commit is contained in:
Joerg Lehmann 2022-07-22 19:28:45 +02:00
parent 9ae18a7da8
commit 138af6b4ac
1 changed files with 5 additions and 4 deletions

View File

@ -34,9 +34,6 @@ func sendEmailAbo(username string, alias string, deveui string, days_left int, l
} else if days_left > 0 {
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."
} else {
fmt.Printf("DO NOT SEND EMAIL ABO (%s) - %s:%s\n", level, username, deveui)
return
}
mail_message := "To: " + username + `
From: info@mini-beieli.ch
@ -84,6 +81,10 @@ func CheckThreshold(d string, vp int, u2 string, last_metric OneMetric, info_thr
return true
}
func sendReminder(days int) bool {
return (days == 0 || days == 5 || days == 10)
}
func checkNodes() {
logit("Starting check_battery...")
@ -105,7 +106,7 @@ func checkNodes() {
}
}
// 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)
alias := getDevAlias(d)
sendEmailAbo(u2, alias, d, last_metric.DaysUntilDeactivated, "INFO")