master
Evan Chen 2021-12-29 02:17:44 +08:00
parent bf299a6385
commit 0a1c865421
2 changed files with 34 additions and 4 deletions

View File

@ -45,7 +45,7 @@ func ToHTML(mdtext string) (template.HTML, error) {
}
func Parse(b *Body) (string, error) {
b.App = app
merge(&b.App)
buf := &bytes.Buffer{}
err := engine.Execute(buf, b)
if err != nil {
@ -58,3 +58,21 @@ func Parse(b *Body) (string, error) {
html, err := pre.Transform()
return html, err
}
func merge(base *App) {
if base.Name == "" {
base.Name = app.Name
}
if base.Link == "" {
base.Link = app.Link
}
if base.Logo == "" {
base.Logo = app.Logo
}
if base.Copyright == "" {
base.Copyright = app.Copyright
}
if base.TroubleText == "" {
base.TroubleText = app.TroubleText
}
}

View File

@ -22,13 +22,17 @@ func (srv *Service) Init() error {
app.Link = viper.GetString("server.url")
app.Logo = viper.GetString("logo")
dial = gomail.NewDialer(
dial = DefaultDailer()
return nil
}
func DefaultDailer() *gomail.Dialer {
return gomail.NewDialer(
viper.GetString("email.host"),
viper.GetInt("email.port"),
viper.GetString("email.username"),
viper.GetString("email.password"))
return nil
}
func setupDefault() {
@ -40,3 +44,11 @@ func setupDefault() {
app.TroubleText = "If youre having trouble with the button '{ACTION}', copy and paste the URL below into your web browser."
dial = gomail.NewDialer("mail.kumoly.io", 587, "test@kumoly.io", "test")
}
func SetDefault(a App) {
app = a
}
func SetDailer(d *gomail.Dialer) {
dial = d
}