[feature] Email notifications for new / closed moderation reports (#1628)

* start fiddling about with email sending to allow multiple recipients

* do some fiddling

* notifs working

* notify on closed report

* finishing up

* envparsing

* use strings.ContainsAny
This commit is contained in:
tobi
2023-03-19 13:11:46 +01:00
committed by GitHub
parent 9c55c07be9
commit 7db81cde44
35 changed files with 773 additions and 420 deletions

View File

@@ -17,15 +17,8 @@
package email
import (
"bytes"
"net/smtp"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
)
const (
testTemplate = "email_test_text.tmpl"
testTemplate = "email_test.tmpl"
testSubject = "GoToSocial Test Email"
)
@@ -39,20 +32,5 @@ type TestData struct {
}
func (s *sender) 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, s.from)
if err != nil {
return err
}
if err := smtp.SendMail(s.hostAddress, s.auth, s.from, []string{toAddress}, msg); err != nil {
return gtserror.SetType(err, gtserror.TypeSMTP)
}
return nil
return s.sendTemplate(testTemplate, testSubject, data, toAddress)
}