[feature] Allow admins to send test emails (#1620)

* [feature] Allow admins to send test emails

* implement unwrap on new error type

* add + use gtserror types

* GoToSocial Email Test -> GoToSocial Test Email

* add + use getInstance db call

* removed unused "unknown" error type
This commit is contained in:
tobi
2023-03-14 17:11:04 +01:00
committed by GitHub
parent d5529d6c9f
commit 196cd88b1c
17 changed files with 460 additions and 83 deletions

View File

@@ -88,3 +88,24 @@ func (s *noopSender) SendResetEmail(toAddress string, data ResetData) error {
return nil
}
func (s *noopSender) SendTestEmail(toAddress string, data TestData) error {
buf := &bytes.Buffer{}
if err := s.template.ExecuteTemplate(buf, testTemplate, data); err != nil {
return err
}
testBody := buf.String()
msg, err := assembleMessage(testSubject, testBody, toAddress, "test@example.org")
if err != nil {
return err
}
log.Tracef(nil, "NOT SENDING test email to %s with contents: %s", toAddress, msg)
if s.sendCallback != nil {
s.sendCallback(toAddress, string(msg))
}
return nil
}