Mark email addresses confirmed when they click the big button.
This commit is contained in:
parent
4f56915f15
commit
a52f5da87a
2 changed files with 16 additions and 0 deletions
14
rmo/email.go
14
rmo/email.go
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
|
|
@ -42,6 +43,19 @@ func getEmailByCode(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
func getEmailSubscribe(w http.ResponseWriter, r *http.Request) {
|
||||
email := r.FormValue("email")
|
||||
if email == "" {
|
||||
respondError(w, "Not sure what to do with an empty email", nil, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
ctx := r.Context()
|
||||
email_contact, err := models.FindCommsEmailContact(ctx, db.PGInstance.BobDB, email)
|
||||
if err != nil {
|
||||
respondError(w, "Email not in the database", err, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
err = email_contact.Update(ctx, db.PGInstance.BobDB, &models.CommsEmailContactSetter{
|
||||
Confirmed: omit.From(true),
|
||||
})
|
||||
html.RenderOrError(
|
||||
w,
|
||||
EmailSubscribeT,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
<div class="container">
|
||||
<h1>Thanks!</h1>
|
||||
<p>You've allowed emails from Report Mosquitoes Online to {{.Email}}.</p>
|
||||
<p>Go ahead and close this page/tab/window whenever you're ready...</p>
|
||||
<p>...or maybe <a href="/">check out the site</a></p>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue