Generate confirmation email for manually-entered volunteers.

This commit is contained in:
Pen Anderson 2026-03-05 20:28:21 -06:00
parent e7e542c03c
commit fcf5bf1f34

View file

@ -2,6 +2,7 @@ package main
import ( import (
"encoding/json" "encoding/json"
"log"
"net/http" "net/http"
"strconv" "strconv"
) )
@ -68,11 +69,22 @@ func (app *App) handleCreateVolunteer(w http.ResponseWriter, r *http.Request) {
v.ParticipantID = &p.ID v.ParticipantID = &p.ID
} }
} }
confirmToken, err := generateConfirmationToken()
if err != nil {
writeError(w, "internal error", http.StatusInternalServerError)
return
}
v.ConfirmationToken = &confirmToken
created, err := app.createVolunteer(v) created, err := app.createVolunteer(v)
if err != nil { if err != nil {
writeError(w, err.Error(), http.StatusInternalServerError) writeError(w, err.Error(), http.StatusInternalServerError)
return return
} }
go func() {
if err := app.sendConfirmationEmail(v.Email, v.Name, confirmToken); err != nil {
log.Printf("confirmation email to %s failed: %v", v.Email, err)
}
}()
w.WriteHeader(http.StatusCreated) w.WriteHeader(http.StatusCreated)
writeJSON(w, created) writeJSON(w, created)
} }