From 0e1ec604226ee9eaf71420a00cd1801ba63ba642 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sat, 18 Jul 2020 15:01:00 -0400 Subject: [PATCH] clear remaining retries after a final delivery failure --- deliverator.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/deliverator.go b/deliverator.go index 5abe82d..75ac382 100644 --- a/deliverator.go +++ b/deliverator.go @@ -16,6 +16,7 @@ package main import ( + "fmt" "log" notrand "math/rand" "time" @@ -43,6 +44,7 @@ func sayitagain(goarounds int64, userid int64, rcpt string, msg []byte) { drift = 24 * time.Hour default: log.Printf("he's dead jim: %s", rcpt) + clearoutbound(rcpt) return } drift += time.Duration(notrand.Int63n(int64(drift / 10))) @@ -57,6 +59,17 @@ func sayitagain(goarounds int64, userid int64, rcpt string, msg []byte) { } } +func clearoutbound(rcpt string) { + hostname := originate(rcpt) + if hostname == "" { + return + } + xid := fmt.Sprintf("%%https://%s/%%", hostname) + log.Printf("clearing outbound for %s", xid) + db := opendatabase() + db.Exec("delete from doovers where rcpt like ?", xid) +} + var garage = gate.NewLimiter(40) func deliverate(goarounds int64, userid int64, rcpt string, msg []byte) {