Files
worker/internal/notifyrender/text_expires.go
Gleb Tv 2c884c5612
Некоторые проверки не удались
CI / test (push) Successful in 2m5s
Docker / Build and publish worker image (push) Failing after 31s
refactor: adopt worker module path
2026-07-13 17:56:12 +03:00

49 строки
1.3 KiB
Go

package notifyrender
import (
"bytes"
"html/template"
"rocketgit.ru/rsmon/worker/app/models"
)
var (
// ExpSubject provides functionality.
ExpSubject *template.Template
// ExpBody provides functionality.
ExpBody *template.Template
// ExpHTML provides functionality.
ExpHTML *template.Template
)
func init() {
ExpSubject = template.Must(template.New("exp_subject").Parse(`Скоро истекает {{.GetLabel}} ({{.KindLabel}}) по {{.Monitor.GetLabel}}`))
// ExpBody provides functionality.
ExpBody = template.Must(template.New("exp_body").Parse(`Монитор {{.Monitor.GetLabel}}
{{.Expires.Format "02.01.2006 15:04:05"}} истекает {{.GetLabel}} ({{.KindLabel}})
`))
ExpHTML = template.Must(template.New("exp_html").Parse(`Монитор {{.Monitor.GetLabel}}
{{.Expires.Format "02.01.2006 15:04:05"}} истекает {{.GetLabel}} <strong>({{.KindLabel}})</strong>
`))
}
// TextExpires provides functionality.
func TextExpires(check *models.Check) (bytes.Buffer, bytes.Buffer, bytes.Buffer, bytes.Buffer) {
var err error
var subject, textBody, htmlBody bytes.Buffer
err = ExpSubject.Execute(&subject, check)
if err != nil {
panic(err)
}
err = ExpBody.Execute(&textBody, check)
if err != nil {
panic(err)
}
err = ExpHTML.Execute(&htmlBody, check)
if err != nil {
panic(err)
}
return subject, textBody, textBody, htmlBody
}