From e97f048eb6b6c303721800c4a91a6195d71fa544 Mon Sep 17 00:00:00 2001 From: abnercoimbre Date: Fri, 18 Oct 2024 20:06:22 -0700 Subject: [PATCH] Improved feedback: Notify when the same email file is being reused, and whether or not that invite was sent to new subscribers --- main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main.go b/main.go index d4b8025..c37f4c5 100644 --- a/main.go +++ b/main.go @@ -284,6 +284,13 @@ func blastMail(cfg *Config, logFile string, trackingFile string, audience []stri } } + existingReaderCount := len(sentToAddresses) + newReaderCount := 0 + + if existingReaderCount > 0 { + fmt.Println("Same email file specified: Sending only to new subscribers...") + } + var group []string for _, a := range audience { if a == "" { @@ -309,6 +316,7 @@ func blastMail(cfg *Config, logFile string, trackingFile string, audience []stri for i, res := range results { log.WriteString(fmt.Sprintf("%s: %s\n", group[i], res.Message)) } + newReaderCount += len(group) group = group[0:0] } } @@ -324,7 +332,17 @@ func blastMail(cfg *Config, logFile string, trackingFile string, audience []stri for i, res := range results { log.WriteString(fmt.Sprintf("%s: %s\n", group[i], res.Message)) } + newReaderCount += len(group) } + + if newReaderCount > 0 { + newSubscribers := existingReaderCount > 0 + if newSubscribers { + fmt.Printf("Sent to %d new subscribers!\n", newReaderCount) + } + } else { + fmt.Printf("Not sent (no new subscribers)\n") + } } var postmarkClient = http.Client{}