Skip to content

Commit 3f70e5a

Browse files
authored
fix: mount notification email templates (#4755)
2 parents eb3e9fd + 6d2d022 commit 3f70e5a

1 file changed

Lines changed: 38 additions & 10 deletions

File tree

internal/start/start.go

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,12 @@ vector --config /etc/vector/vector.yaml
470470
}
471471

472472
binds := []string{}
473-
for id, tmpl := range utils.Config.Auth.Email.Template {
474-
if len(tmpl.ContentPath) == 0 {
475-
continue
473+
mountEmailTemplates := func(id, contentPath string) error {
474+
if len(contentPath) == 0 {
475+
return nil
476476
}
477-
hostPath := tmpl.ContentPath
478-
if !filepath.IsAbs(tmpl.ContentPath) {
477+
hostPath := contentPath
478+
if !filepath.IsAbs(contentPath) {
479479
var err error
480480
hostPath, err = filepath.Abs(hostPath)
481481
if err != nil {
@@ -484,6 +484,23 @@ vector --config /etc/vector/vector.yaml
484484
}
485485
dockerPath := path.Join(nginxEmailTemplateDir, id+filepath.Ext(hostPath))
486486
binds = append(binds, fmt.Sprintf("%s:%s:rw", hostPath, dockerPath))
487+
return nil
488+
}
489+
490+
for id, tmpl := range utils.Config.Auth.Email.Template {
491+
err := mountEmailTemplates(id, tmpl.ContentPath)
492+
if err != nil {
493+
return err
494+
}
495+
}
496+
497+
for id, tmpl := range utils.Config.Auth.Email.Notification {
498+
if tmpl.Enabled {
499+
err := mountEmailTemplates(id+"_notification", tmpl.ContentPath)
500+
if err != nil {
501+
return err
502+
}
503+
}
487504
}
488505

489506
dockerPort := uint16(8000)
@@ -661,23 +678,34 @@ EOF
661678
env = append(env, fmt.Sprintf("GOTRUE_SESSIONS_INACTIVITY_TIMEOUT=%v", utils.Config.Auth.Sessions.InactivityTimeout))
662679
}
663680

664-
for id, tmpl := range utils.Config.Auth.Email.Template {
665-
if len(tmpl.ContentPath) > 0 {
681+
addMailerEnvVars := func(id, contentPath string, subject *string) {
682+
if len(contentPath) > 0 {
666683
env = append(env, fmt.Sprintf("GOTRUE_MAILER_TEMPLATES_%s=http://%s:%d/email/%s",
667684
strings.ToUpper(id),
668685
utils.KongId,
669686
nginxTemplateServerPort,
670-
id+filepath.Ext(tmpl.ContentPath),
687+
id+filepath.Ext(contentPath),
671688
))
672689
}
673-
if tmpl.Subject != nil {
690+
if subject != nil {
674691
env = append(env, fmt.Sprintf("GOTRUE_MAILER_SUBJECTS_%s=%s",
675692
strings.ToUpper(id),
676-
*tmpl.Subject,
693+
*subject,
677694
))
678695
}
679696
}
680697

698+
for id, tmpl := range utils.Config.Auth.Email.Template {
699+
addMailerEnvVars(id, tmpl.ContentPath, tmpl.Subject)
700+
}
701+
702+
for id, tmpl := range utils.Config.Auth.Email.Notification {
703+
if tmpl.Enabled {
704+
env = append(env, fmt.Sprintf("GOTRUE_MAILER_NOTIFICATIONS_%s_ENABLED=true", strings.ToUpper(id)))
705+
addMailerEnvVars(id+"_notification", tmpl.ContentPath, tmpl.Subject)
706+
}
707+
}
708+
681709
switch {
682710
case utils.Config.Auth.Sms.Twilio.Enabled:
683711
env = append(

0 commit comments

Comments
 (0)