-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for other campaigns to backend
- Loading branch information
Showing
6 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,12 @@ func getEnvWithFallback(key string, fallback string) string { | |
} | ||
return v | ||
} | ||
|
||
var EmailSettings = map[string]struct { | ||
FromDomain string | ||
Subject string | ||
To string | ||
}{ | ||
"duck": {FromDomain: "mail.helptheducks.com", Subject: "Prosecute Reichardt Duck Farm for Animal Abuse", To: "[email protected]"}, | ||
"sonoma": {FromDomain: "mail.righttorescue.com", Subject: "Prosecute animal cruelty, not animal rescuers", To: "[email protected]"}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ func main() { | |
r.Use(middleware.Recoverer) | ||
r.Use(middleware.Timeout(30 * time.Second)) | ||
r.Use(cors.Handler(cors.Options{ | ||
AllowedOrigins: []string{"http://localhost:5173", "https://helptheducks.com"}, | ||
AllowedOrigins: []string{"http://localhost:5173", "https://helptheducks.com", "https://righttorescue.com"}, | ||
AllowedMethods: []string{"GET", "POST", "OPTIONS"}, | ||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"}, | ||
AllowCredentials: false, | ||
|
@@ -78,12 +78,18 @@ func processNewMessages() { | |
|
||
for _, message := range messages { | ||
fmt.Printf("Processing message id: %v\n", message.ID) | ||
fromEmail := strings.Join(strings.Split(strings.ToLower(message.Name), " "), ".") + "@mail.helptheducks.com" | ||
|
||
settings, ok := config.EmailSettings[message.Campaign.String] | ||
if !ok { | ||
settings = config.EmailSettings["duck"] | ||
} | ||
|
||
fromEmail := strings.Join(strings.Split(strings.ToLower(message.Name), " "), ".") + "@" + settings.FromDomain | ||
err := mailer.Send(mailClient, mailer.SendOptions{ | ||
From: fmt.Sprintf("%s <%s>", message.Name, fromEmail), | ||
ReplyTo: message.Email, | ||
To: "[email protected]", | ||
Subject: "Prosecute Reichardt Duck Farm for Animal Abuse", | ||
To: settings.To, | ||
Subject: settings.Subject, | ||
Body: message.Message, | ||
}) | ||
if err != nil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters