Generate confirmation email for manually-entered volunteers.
This commit is contained in:
parent
e7e542c03c
commit
fcf5bf1f34
1 changed files with 12 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
|
@ -68,11 +69,22 @@ func (app *App) handleCreateVolunteer(w http.ResponseWriter, r *http.Request) {
|
|||
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)
|
||||
if err != nil {
|
||||
writeError(w, err.Error(), http.StatusInternalServerError)
|
||||
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)
|
||||
writeJSON(w, created)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue