mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-06 23:43:15 -06:00
use noop email sender in tests
This commit is contained in:
parent
b0cc815189
commit
8fdb3256e5
23 changed files with 110 additions and 88 deletions
|
|
@ -19,8 +19,10 @@
|
|||
package email
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -28,16 +30,19 @@ const (
|
|||
Content-Type: text/html;`
|
||||
)
|
||||
|
||||
func (s *sender) ExecuteTemplate(templateName string, data interface{}) (string, error) {
|
||||
buf := &bytes.Buffer{}
|
||||
if err := s.template.ExecuteTemplate(buf, templateName, data); err != nil {
|
||||
return "", err
|
||||
func loadTemplates(templateBaseDir string) (*template.Template, error) {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting current working directory: %s", err)
|
||||
}
|
||||
return buf.String(), nil
|
||||
|
||||
// look for all templates that start with 'email_'
|
||||
tmPath := filepath.Join(cwd, fmt.Sprintf("%semail_*", templateBaseDir))
|
||||
return template.ParseGlob(tmPath)
|
||||
}
|
||||
|
||||
func (s *sender) AssembleMessage(mailSubject string, mailBody string, mailTo string) []byte {
|
||||
from := fmt.Sprintf("From: GoToSocial <%s>", s.from)
|
||||
func assembleMessage(mailSubject string, mailBody string, mailTo string, mailFrom string) []byte {
|
||||
from := fmt.Sprintf("From: GoToSocial <%s>", mailFrom)
|
||||
to := fmt.Sprintf("To: %s", mailTo)
|
||||
|
||||
msg := []byte(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue