Skip to content

Commit

Permalink
(BIDS-2496) move support emails to config (#2575)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuccaBitfly authored Oct 2, 2023
1 parent f0a817e commit 2a5ba87
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 94 deletions.
1 change: 0 additions & 1 deletion cmd/explorer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 5 additions & 3 deletions handlers/advertisewithus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -66,7 +68,7 @@ func AdvertiseWithUsPost(w http.ResponseWriter, r *http.Request) {
// escape html
msg = template.HTMLEscapeString(msg)

err = mail.SendTextMail("[email protected]", "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")
Expand Down
44 changes: 0 additions & 44 deletions handlers/mobilepage.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package handlers

import (
"eth2-exporter/mail"
"eth2-exporter/templates"
"eth2-exporter/types"
"eth2-exporter/utils"
"fmt"
"html/template"
"net/http"
)

Expand All @@ -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("[email protected]", "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)
}
7 changes: 4 additions & 3 deletions handlers/pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -141,7 +142,7 @@ func PricingPost(w http.ResponseWriter, r *http.Request) {
// escape html
msg = template.HTMLEscapeString(msg)

err = mail.SendTextMail("[email protected]", "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")
Expand Down
2 changes: 1 addition & 1 deletion handlers/stripe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]. 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{})
Expand Down
42 changes: 0 additions & 42 deletions templates/mobilepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,48 +251,6 @@ <h2 class="mb-4">Keeping the network secure is hard enough.<br />Let us help you
</div>
</div>
</section>
<br />
<hr />
<br />
<section class="my-5">
<div class="row">
<div class="col-md-12">
<div class="row justify-content-center">
<div class="col-md-12 col-lg-8 text-center">
<h1 class="h4">You want your pool supported by the app?</h1>
<p class="text-muted col-md-8 px-0 mx-auto">Reach out to us if you are interested in a partnership.</p>
<form id="contact" action="/mobile" method="post">
<div class="text-left">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputName">Contact name (required)</label>
<input type="text" class="form-control" id="inputName" placeholder="Ex.: Vitalik Buterin" required name="name" />
</div>
<div class="form-group col-md-6">
<label for="inputEmail">Email (required)</label>
<input type="email" class="form-control" id="inputEmail" placeholder="Ex.: [email protected]" required name="email" />
</div>
</div>
<div class="form-group">
<label for="inputUrl">Official Website URL (required)</label>
<input type="text" class="form-control" id="inputUrl" placeholder="Ex.: https://example.com/" required name="url" />
</div>
<div class="form-group">
<label for="inputCompanyName">Company / Project name (required)</label>
<input type="text" class="form-control" id="inputCompanyName" placeholder="Ex.: Chainlab" required name="company" />
</div>
<div class="form-group">
<label for="inputAddress2">What can we do for you? (required)</label>
<textarea type="text" class="form-control" id="inputAdText" required name="text"></textarea>
</div>
</div>
<button data-sitekey="{{ .RecaptchaKey }}" data-callback="onSubmit" data-action="submit" type="submit" class="g-recaptcha btn btn-primary text-center text-white">Send Message</button>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
{{ end }}
{{ end }}
4 changes: 4 additions & 0 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 2a5ba87

Please sign in to comment.