|
|
@ -274,13 +274,12 @@ func (emailer *Emailer) constructConfirmation(code, username, key string, app *a
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
template := emailer.confirmationValues(code, username, key, app, noSub)
|
|
|
|
template := emailer.confirmationValues(code, username, key, app, noSub)
|
|
|
|
if app.storage.customEmails.EmailConfirmation.Enabled {
|
|
|
|
if app.storage.customEmails.EmailConfirmation.Enabled {
|
|
|
|
content := app.storage.customEmails.EmailConfirmation.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.EmailConfirmation.Variables {
|
|
|
|
app.storage.customEmails.EmailConfirmation.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.EmailConfirmation.Variables,
|
|
|
|
if ok {
|
|
|
|
nil,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "email_confirmation", "email_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "email_confirmation", "email_", template)
|
|
|
@ -346,13 +345,12 @@ func (emailer *Emailer) constructInvite(code string, invite Invite, app *appCont
|
|
|
|
template := emailer.inviteValues(code, invite, app, noSub)
|
|
|
|
template := emailer.inviteValues(code, invite, app, noSub)
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
if app.storage.customEmails.InviteEmail.Enabled {
|
|
|
|
if app.storage.customEmails.InviteEmail.Enabled {
|
|
|
|
content := app.storage.customEmails.InviteEmail.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.InviteEmail.Variables {
|
|
|
|
app.storage.customEmails.InviteEmail.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.InviteEmail.Variables,
|
|
|
|
if ok {
|
|
|
|
nil,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "invite_emails", "email_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "invite_emails", "email_", template)
|
|
|
@ -386,13 +384,12 @@ func (emailer *Emailer) constructExpiry(code string, invite Invite, app *appCont
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
template := emailer.expiryValues(code, invite, app, noSub)
|
|
|
|
template := emailer.expiryValues(code, invite, app, noSub)
|
|
|
|
if app.storage.customEmails.InviteExpiry.Enabled {
|
|
|
|
if app.storage.customEmails.InviteExpiry.Enabled {
|
|
|
|
content := app.storage.customEmails.InviteExpiry.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.InviteExpiry.Variables {
|
|
|
|
app.storage.customEmails.InviteExpiry.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.InviteExpiry.Variables,
|
|
|
|
if ok {
|
|
|
|
nil,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "notifications", "expiry_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "notifications", "expiry_", template)
|
|
|
@ -441,13 +438,12 @@ func (emailer *Emailer) constructCreated(code, username, address string, invite
|
|
|
|
template := emailer.createdValues(code, username, address, invite, app, noSub)
|
|
|
|
template := emailer.createdValues(code, username, address, invite, app, noSub)
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
if app.storage.customEmails.UserCreated.Enabled {
|
|
|
|
if app.storage.customEmails.UserCreated.Enabled {
|
|
|
|
content := app.storage.customEmails.UserCreated.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.UserCreated.Variables {
|
|
|
|
app.storage.customEmails.UserCreated.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.UserCreated.Variables,
|
|
|
|
if ok {
|
|
|
|
nil,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "notifications", "created_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "notifications", "created_", template)
|
|
|
@ -516,13 +512,12 @@ func (emailer *Emailer) constructReset(pwr PasswordReset, app *appContext, noSub
|
|
|
|
template := emailer.resetValues(pwr, app, noSub)
|
|
|
|
template := emailer.resetValues(pwr, app, noSub)
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
if app.storage.customEmails.PasswordReset.Enabled {
|
|
|
|
if app.storage.customEmails.PasswordReset.Enabled {
|
|
|
|
content := app.storage.customEmails.PasswordReset.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.PasswordReset.Variables {
|
|
|
|
app.storage.customEmails.PasswordReset.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.PasswordReset.Variables,
|
|
|
|
if ok {
|
|
|
|
nil,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "password_resets", "email_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "password_resets", "email_", template)
|
|
|
@ -558,13 +553,12 @@ func (emailer *Emailer) constructDeleted(reason string, app *appContext, noSub b
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
template := emailer.deletedValues(reason, app, noSub)
|
|
|
|
template := emailer.deletedValues(reason, app, noSub)
|
|
|
|
if app.storage.customEmails.UserDeleted.Enabled {
|
|
|
|
if app.storage.customEmails.UserDeleted.Enabled {
|
|
|
|
content := app.storage.customEmails.UserDeleted.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.UserDeleted.Variables {
|
|
|
|
app.storage.customEmails.UserDeleted.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.UserDeleted.Variables,
|
|
|
|
if ok {
|
|
|
|
nil,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "deletion", "email_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "deletion", "email_", template)
|
|
|
@ -600,13 +594,12 @@ func (emailer *Emailer) constructDisabled(reason string, app *appContext, noSub
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
template := emailer.disabledValues(reason, app, noSub)
|
|
|
|
template := emailer.disabledValues(reason, app, noSub)
|
|
|
|
if app.storage.customEmails.UserDisabled.Enabled {
|
|
|
|
if app.storage.customEmails.UserDisabled.Enabled {
|
|
|
|
content := app.storage.customEmails.UserDisabled.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.UserDisabled.Variables {
|
|
|
|
app.storage.customEmails.UserDisabled.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.UserDisabled.Variables,
|
|
|
|
if ok {
|
|
|
|
nil,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "disable_enable", "disabled_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "disable_enable", "disabled_", template)
|
|
|
@ -642,13 +635,12 @@ func (emailer *Emailer) constructEnabled(reason string, app *appContext, noSub b
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
template := emailer.enabledValues(reason, app, noSub)
|
|
|
|
template := emailer.enabledValues(reason, app, noSub)
|
|
|
|
if app.storage.customEmails.UserEnabled.Enabled {
|
|
|
|
if app.storage.customEmails.UserEnabled.Enabled {
|
|
|
|
content := app.storage.customEmails.UserEnabled.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.UserEnabled.Variables {
|
|
|
|
app.storage.customEmails.UserEnabled.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.UserEnabled.Variables,
|
|
|
|
if ok {
|
|
|
|
nil,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "disable_enable", "enabled_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "disable_enable", "enabled_", template)
|
|
|
@ -677,6 +669,7 @@ func (emailer *Emailer) welcomeValues(username string, expiry time.Time, app *ap
|
|
|
|
template["username"] = username
|
|
|
|
template["username"] = username
|
|
|
|
template["message"] = app.config.Section("email").Key("message").String()
|
|
|
|
template["message"] = app.config.Section("email").Key("message").String()
|
|
|
|
exp := app.formatDatetime(expiry)
|
|
|
|
exp := app.formatDatetime(expiry)
|
|
|
|
|
|
|
|
if !expiry.IsZero() {
|
|
|
|
if custom {
|
|
|
|
if custom {
|
|
|
|
template["yourAccountWillExpire"] = exp
|
|
|
|
template["yourAccountWillExpire"] = exp
|
|
|
|
} else if !expiry.IsZero() {
|
|
|
|
} else if !expiry.IsZero() {
|
|
|
@ -685,6 +678,7 @@ func (emailer *Emailer) welcomeValues(username string, expiry time.Time, app *ap
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return template
|
|
|
|
return template
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -705,13 +699,12 @@ func (emailer *Emailer) constructWelcome(username string, expiry time.Time, app
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if app.storage.customEmails.WelcomeEmail.Enabled {
|
|
|
|
if app.storage.customEmails.WelcomeEmail.Enabled {
|
|
|
|
content := app.storage.customEmails.WelcomeEmail.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.WelcomeEmail.Variables {
|
|
|
|
app.storage.customEmails.WelcomeEmail.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.WelcomeEmail.Variables,
|
|
|
|
if ok {
|
|
|
|
app.storage.customEmails.WelcomeEmail.Conditionals,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "welcome_email", "email_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "welcome_email", "email_", template)
|
|
|
@ -741,13 +734,12 @@ func (emailer *Emailer) constructUserExpired(app *appContext, noSub bool) (*Emai
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
template := emailer.userExpiredValues(app, noSub)
|
|
|
|
template := emailer.userExpiredValues(app, noSub)
|
|
|
|
if app.storage.customEmails.UserExpired.Enabled {
|
|
|
|
if app.storage.customEmails.UserExpired.Enabled {
|
|
|
|
content := app.storage.customEmails.UserExpired.Content
|
|
|
|
content := templateEmail(
|
|
|
|
for _, v := range app.storage.customEmails.UserExpired.Variables {
|
|
|
|
app.storage.customEmails.UserExpired.Content,
|
|
|
|
replaceWith, ok := template[v[1:len(v)-1]]
|
|
|
|
app.storage.customEmails.UserExpired.Variables,
|
|
|
|
if ok {
|
|
|
|
nil,
|
|
|
|
content = strings.ReplaceAll(content, v, replaceWith.(string))
|
|
|
|
template,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
email, err = emailer.constructTemplate(email.Subject, content, app)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "user_expiry", "email_", template)
|
|
|
|
email.HTML, email.Text, err = emailer.construct(app, "user_expiry", "email_", template)
|
|
|
|