Mark email addresses confirmed when they click the big button.

This commit is contained in:
Eli Ribble 2026-02-02 20:01:28 +00:00
parent 4f56915f15
commit a52f5da87a
No known key found for this signature in database
2 changed files with 16 additions and 0 deletions

View file

@ -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,

View file

@ -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>