From 2a5ba87f79005d64d86da93724539831d4132c59 Mon Sep 17 00:00:00 2001 From: Lucca <109136188+LuccaBitfly@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:00:26 +0200 Subject: [PATCH] (BIDS-2496) move support emails to config (#2575) --- cmd/explorer/main.go | 1 - handlers/advertisewithus.go | 8 ++++--- handlers/mobilepage.go | 44 ------------------------------------- handlers/pricing.go | 7 +++--- handlers/stripe.go | 2 +- templates/mobilepage.html | 42 ----------------------------------- types/config.go | 4 ++++ 7 files changed, 14 insertions(+), 94 deletions(-) diff --git a/cmd/explorer/main.go b/cmd/explorer/main.go index 08dc93cbd0..9b6dc61d23 100644 --- a/cmd/explorer/main.go +++ b/cmd/explorer/main.go @@ -497,7 +497,6 @@ func main() { router.HandleFunc("/search/{type}/{search}", handlers.SearchAhead).Methods("GET") router.HandleFunc("/imprint", handlers.Imprint).Methods("GET") router.HandleFunc("/mobile", handlers.MobilePage).Methods("GET") - router.HandleFunc("/mobile", handlers.MobilePagePost).Methods("POST") router.HandleFunc("/tools/unitConverter", handlers.UnitConverter).Methods("GET") router.HandleFunc("/tools/broadcast", handlers.Broadcast).Methods("GET") router.HandleFunc("/tools/broadcast", handlers.BroadcastPost).Methods("POST") diff --git a/handlers/advertisewithus.go b/handlers/advertisewithus.go index 5c83133db9..db11442a13 100644 --- a/handlers/advertisewithus.go +++ b/handlers/advertisewithus.go @@ -39,13 +39,15 @@ func AdvertiseWithUs(w http.ResponseWriter, r *http.Request) { func AdvertiseWithUsPost(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { - utils.LogError(err, "error parsing form", 0) + utils.LogError(err, "error parsing ad request form", 0, map[string]interface{}{ + "route": r.URL.String(), + }) utils.SetFlash(w, r, "ad_flash", "Error: invalid form submitted") http.Redirect(w, r, "/advertisewithus", http.StatusSeeOther) return } - if err := utils.HandleRecaptcha(w, r, "/pricing"); err != nil { + if err := utils.HandleRecaptcha(w, r, "/advertisewithus"); err != nil { return } @@ -66,7 +68,7 @@ func AdvertiseWithUsPost(w http.ResponseWriter, r *http.Request) { // escape html msg = template.HTMLEscapeString(msg) - err = mail.SendTextMail("support@beaconcha.in", "New ad inquiry", msg, []types.EmailAttachment{}) + err = mail.SendTextMail(utils.Config.Frontend.Mail.Contact.InquiryEmail, "New ad inquiry", msg, []types.EmailAttachment{}) if err != nil { logger.Errorf("error sending ad form: %v", err) utils.SetFlash(w, r, "ad_flash", "Error: unable to submit ad request") diff --git a/handlers/mobilepage.go b/handlers/mobilepage.go index b26d1fc38d..9a549ed580 100644 --- a/handlers/mobilepage.go +++ b/handlers/mobilepage.go @@ -1,12 +1,9 @@ package handlers import ( - "eth2-exporter/mail" "eth2-exporter/templates" "eth2-exporter/types" "eth2-exporter/utils" - "fmt" - "html/template" "net/http" ) @@ -33,44 +30,3 @@ func MobilePage(w http.ResponseWriter, r *http.Request) { return // an error has occurred and was processed } } - -func MobilePagePost(w http.ResponseWriter, r *http.Request) { - err := r.ParseForm() - if err != nil { - utils.LogError(err, "error parsing form", 0) - utils.SetFlash(w, r, "ad_flash", "Error: invalid form submitted") - http.Redirect(w, r, "/mobile", http.StatusSeeOther) - return - } - - if err := utils.HandleRecaptcha(w, r, "/pricing"); err != nil { - return - } - - name := r.FormValue("name") - email := r.FormValue("email") - url := r.FormValue("url") - company := r.FormValue("company") - text := r.FormValue("text") - - msg := fmt.Sprintf(`New app pool support inquiry: - Name: %s - Email: %s - Url: %s - Company: %s - Message: %s`, - name, email, url, company, text) - // escape html - msg = template.HTMLEscapeString(msg) - - err = mail.SendTextMail("support@beaconcha.in", "New app pool support inquiry", msg, []types.EmailAttachment{}) - if err != nil { - logger.Errorf("error sending app pool form: %v", err) - utils.SetFlash(w, r, "ad_flash", "Error: unable to submit app pool request") - http.Redirect(w, r, "/mobile", http.StatusSeeOther) - return - } - - utils.SetFlash(w, r, "ad_flash", "Thank you for your inquiry, we will get back to you as soon as possible.") - http.Redirect(w, r, "/mobile", http.StatusSeeOther) -} diff --git a/handlers/pricing.go b/handlers/pricing.go index 8dc56c3bcd..d127ac7186 100644 --- a/handlers/pricing.go +++ b/handlers/pricing.go @@ -113,9 +113,10 @@ func MobilePricing(w http.ResponseWriter, r *http.Request) { func PricingPost(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { - utils.LogError(err, "error parsing form", 0) + utils.LogError(err, "error parsing form for pricing request", 0, map[string]interface{}{ + "route": r.URL.String(), + }) utils.SetFlash(w, r, "pricing_flash", "Error: invalid form submitted") - logger.Errorf("error parsing pricing request form for %v route: %v", r.URL.String(), err) http.Redirect(w, r, "/pricing", http.StatusSeeOther) return } @@ -141,7 +142,7 @@ func PricingPost(w http.ResponseWriter, r *http.Request) { // escape html msg = template.HTMLEscapeString(msg) - err = mail.SendTextMail("inquiries@beaconcha.in", "New API usage inquiry", msg, []types.EmailAttachment{}) + err = mail.SendTextMail(utils.Config.Frontend.Mail.Contact.InquiryEmail, "New API usage inquiry", msg, []types.EmailAttachment{}) if err != nil { logger.Errorf("error sending ad form: %v", err) utils.SetFlash(w, r, "pricing_flash", "Error: unable to submit api request") diff --git a/handlers/stripe.go b/handlers/stripe.go index af11dd67e4..f4061941bf 100644 --- a/handlers/stripe.go +++ b/handlers/stripe.go @@ -536,7 +536,7 @@ func createNewStripeSubscription(subscription stripe.Subscription, event stripe. } func emailCustomerAboutFailedPayment(email string) { - msg := fmt.Sprintf("Payment processing failed. Could not activate your subscription. Please contact support at support@beaconcha.in. Manage Subscription: https://" + utils.Config.Frontend.SiteDomain + "/user/settings") + msg := fmt.Sprintf("Payment processing failed. Could not activate your subscription. Please contact support at " + utils.Config.Frontend.Mail.Contact.SupportEmail + ". Manage Subscription: https://" + utils.Config.Frontend.SiteDomain + "/user/settings") // escape html msg = template.HTMLEscapeString(msg) err := mail.SendTextMail(email, "Failed Payment", msg, []types.EmailAttachment{}) diff --git a/templates/mobilepage.html b/templates/mobilepage.html index 914919b765..fb8efcdeb6 100644 --- a/templates/mobilepage.html +++ b/templates/mobilepage.html @@ -251,48 +251,6 @@

Keeping the network secure is hard enough.
Let us help you -
-
-
-
-
-
-
-
-

You want your pool supported by the app?

-

Reach out to us if you are interested in a partnership.

-
-
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- -
-
-
-
-
-
{{ end }} {{ end }} diff --git a/types/config.go b/types/config.go index 8c7c98a759..da03a677d1 100644 --- a/types/config.go +++ b/types/config.go @@ -146,6 +146,10 @@ type Config struct { PrivateKey string `yaml:"privateKey" envconfig:"FRONTEND_MAIL_MAILGUN_PRIVATE_KEY"` Sender string `yaml:"sender" envconfig:"FRONTEND_MAIL_MAILGUN_SENDER"` } `yaml:"mailgun"` + Contact struct { + SupportEmail string `yaml:"supportEmail" envconfig:"FRONTEND_MAIL_CONTACT_SUPPORT_EMAIL"` + InquiryEmail string `yaml:"inquiryEmail" envconfig:"FRONTEND_MAIL_CONTACT_INQUIRY_EMAIL"` + } `yaml:"contact"` } `yaml:"mail"` GATag string `yaml:"gatag" envconfig:"GATAG"` VerifyAppSubs bool `yaml:"verifyAppSubscriptions" envconfig:"FRONTEND_VERIFY_APP_SUBSCRIPTIONS"`