Allow default config structs

This commit is contained in:
Melon 2023-09-11 01:46:58 +01:00
parent a21b4c4871
commit 31186402f7
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
4 changed files with 8 additions and 8 deletions

View File

@ -6,8 +6,8 @@ import (
)
type Conf struct {
Listen string `yaml:"listen"`
Audience string `yaml:"audience"`
SendMail *sendmail.Smtp `yaml:"sendmail"`
Imap *imap.Imap `yaml:"imap"`
Listen string `yaml:"listen"`
Audience string `yaml:"audience"`
SendMail sendmail.SendMail `yaml:"sendmail"`
Imap imap.Imap `yaml:"imap"`
}

View File

@ -48,7 +48,7 @@ func main() {
}
userAuth := api.CheckAuth(verify, conf.Audience)
srv := api.SetupApiServer(conf.Listen, userAuth, conf.SendMail, conf.Imap)
srv := api.SetupApiServer(conf.Listen, userAuth, &conf.SendMail, &conf.Imap)
log.Printf("[Lotus] Starting API server on: '%s'\n", srv.Addr)
go utils.RunBackgroundHttp("Lotus", srv)

View File

@ -5,7 +5,7 @@ import (
"os/exec"
)
type Smtp struct {
type SendMail struct {
SendMailCommand string `json:"send_mail_command"`
}
@ -16,7 +16,7 @@ type Mail struct {
var execCommand = exec.Command
func (s *Smtp) Send(mail *Mail) error {
func (s *SendMail) Send(mail *Mail) error {
// start sendmail caller
if s.SendMailCommand == "" {
s.SendMailCommand = "/usr/sbin/sendmail"

View File

@ -55,7 +55,7 @@ func TestSmtp_Send(t *testing.T) {
listen, err := net.ListenUnix("", addr)
assert.NoError(t, err)
s := &Smtp{SendMailCommand: "/tmp/sendmailXXXXX"}
s := &SendMail{SendMailCommand: "/tmp/sendmailXXXXX"}
assert.NoError(t, s.Send(m))
}