Established Participants and Tickets model. Migrated concepts.

This commit is contained in:
Pen Anderson 2026-03-04 10:53:42 -06:00
parent 0df93e1886
commit cd8e1e3b3b
22 changed files with 1345 additions and 191 deletions

View file

@ -122,25 +122,36 @@ func (app *App) eventName() string {
return "the event"
}
// sendTokenEmail sends a volunteer token link to the attendee's email address.
func (app *App) sendTokenEmail(a Attendee) error {
if a.Email == "" {
return fmt.Errorf("attendee has no email address")
// sendTicketTokenEmail sends a volunteer token link for a ticket to its participant's email.
func (app *App) sendTicketTokenEmail(tk Ticket) error {
if tk.Code == nil || *tk.Code == "" {
return fmt.Errorf("ticket has no code")
}
if a.VolunteerToken == nil || *a.VolunteerToken == "" {
return fmt.Errorf("attendee has no volunteer token")
if tk.ParticipantID == nil {
return fmt.Errorf("ticket has no participant")
}
p, err := app.getParticipant(*tk.ParticipantID)
if err != nil || p == nil {
return fmt.Errorf("participant not found")
}
if p.Email == "" {
return fmt.Errorf("participant has no email address")
}
cfg := app.loadSMTPConfig()
eventName := app.eventName()
link := fmt.Sprintf("%s/v/%s", app.resolveBaseURL(), *a.VolunteerToken)
link := fmt.Sprintf("%s/v/%s", app.resolveBaseURL(), *tk.Code)
name := p.PreferredName
if name == "" {
name = tk.Name
}
subject := fmt.Sprintf("Your volunteer link for %s", eventName)
body := fmt.Sprintf(
"Hi %s,\n\nThank you for volunteering at %s!\n\nYour volunteer token: %s\nYour signup link: %s\n\nUse this link to sign up for available shifts in your department.\n\nSee you there!\n",
a.Name, eventName, *a.VolunteerToken, link,
name, eventName, *tk.Code, link,
)
return sendEmail(cfg, a.Email, subject, body)
return sendEmail(cfg, p.Email, subject, body)
}
func (app *App) sendConfirmationEmail(to, name, confirmToken string) error {