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 (
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue