mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-01 23:32:24 -05:00
[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:
parent
9c55c07be9
commit
7db81cde44
35 changed files with 773 additions and 420 deletions
|
|
@ -17,15 +17,8 @@
|
|||
|
||||
package email
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/smtp"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
)
|
||||
|
||||
const (
|
||||
resetTemplate = "email_reset_text.tmpl"
|
||||
resetTemplate = "email_reset.tmpl"
|
||||
resetSubject = "GoToSocial Password Reset"
|
||||
)
|
||||
|
||||
|
|
@ -43,20 +36,5 @@ type ResetData struct {
|
|||
}
|
||||
|
||||
func (s *sender) SendResetEmail(toAddress string, data ResetData) error {
|
||||
buf := &bytes.Buffer{}
|
||||
if err := s.template.ExecuteTemplate(buf, resetTemplate, data); err != nil {
|
||||
return err
|
||||
}
|
||||
resetBody := buf.String()
|
||||
|
||||
msg, err := assembleMessage(resetSubject, resetBody, 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(resetTemplate, resetSubject, data, toAddress)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue