Added volunteer signup.
This commit is contained in:
parent
ace7f11a60
commit
8dc5d3ed01
12 changed files with 1258 additions and 49 deletions
55
email.go
55
email.go
|
|
@ -106,6 +106,22 @@ func sendEmail(cfg SMTPConfig, to, subject, body string) error {
|
|||
return smtp.SendMail(addr, auth, cfg.From, []string{to}, []byte(msg))
|
||||
}
|
||||
|
||||
func (app *App) resolveBaseURL() string {
|
||||
baseURL := app.baseURL
|
||||
if baseURL == "" {
|
||||
app.db.QueryRow(`SELECT value FROM config WHERE key = 'base_url'`).Scan(&baseURL)
|
||||
}
|
||||
return strings.TrimRight(baseURL, "/")
|
||||
}
|
||||
|
||||
func (app *App) eventName() string {
|
||||
event, _ := app.getEvent()
|
||||
if event != nil && event.Name != "" {
|
||||
return event.Name
|
||||
}
|
||||
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 == "" {
|
||||
|
|
@ -116,20 +132,8 @@ func (app *App) sendTokenEmail(a Attendee) error {
|
|||
}
|
||||
|
||||
cfg := app.loadSMTPConfig()
|
||||
|
||||
baseURL := app.baseURL
|
||||
if baseURL == "" {
|
||||
app.db.QueryRow(`SELECT value FROM config WHERE key = 'base_url'`).Scan(&baseURL)
|
||||
}
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
|
||||
event, _ := app.getEvent()
|
||||
eventName := "the event"
|
||||
if event != nil && event.Name != "" {
|
||||
eventName = event.Name
|
||||
}
|
||||
|
||||
link := fmt.Sprintf("%s/#/v/%s", baseURL, *a.VolunteerToken)
|
||||
eventName := app.eventName()
|
||||
link := fmt.Sprintf("%s/#/v/%s", app.resolveBaseURL(), *a.VolunteerToken)
|
||||
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",
|
||||
|
|
@ -138,3 +142,26 @@ func (app *App) sendTokenEmail(a Attendee) error {
|
|||
|
||||
return sendEmail(cfg, a.Email, subject, body)
|
||||
}
|
||||
|
||||
func (app *App) sendConfirmationEmail(to, name, confirmToken string) error {
|
||||
cfg := app.loadSMTPConfig()
|
||||
eventName := app.eventName()
|
||||
link := fmt.Sprintf("%s/#/confirm/%s", app.resolveBaseURL(), confirmToken)
|
||||
subject := fmt.Sprintf("Please confirm your email for %s", eventName)
|
||||
body := fmt.Sprintf(
|
||||
"Hi %s,\n\nThank you for signing up to volunteer at %s!\n\nPlease confirm your email address by visiting:\n%s\n\nIf you did not sign up, you can safely ignore this email.\n",
|
||||
name, eventName, link,
|
||||
)
|
||||
return sendEmail(cfg, to, subject, body)
|
||||
}
|
||||
|
||||
func (app *App) sendShiftSignupEmail(to, name, kioskLink string) error {
|
||||
cfg := app.loadSMTPConfig()
|
||||
eventName := app.eventName()
|
||||
subject := fmt.Sprintf("Shift signups are open for %s!", eventName)
|
||||
body := fmt.Sprintf(
|
||||
"Hi %s,\n\nShift signups are now open for %s!\n\nUse this link to sign up for available shifts:\n%s\n\nSee you there!\n",
|
||||
name, eventName, kioskLink,
|
||||
)
|
||||
return sendEmail(cfg, to, subject, body)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue