Files
worker/internal/notifyrender/text_down_one.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

54 строки
1.8 KiB
Go

package notifyrender
import (
"bytes"
"html/template"
"rocketgit.ru/rsmon/worker/app/models"
)
var (
// DownOneSubject provides functionality.
DownOneSubject *template.Template
// DownOneBody provides functionality.
DownOneBody *template.Template
// DownOneHTML provides functionality.
DownOneHTML *template.Template
)
func init() {
DownOneSubject = template.Must(template.New("down_one_subject").Parse(`Не доступен {{.Monitor.GetLabel}}`))
// DownOneBody provides functionality.
DownOneBody = template.Must(template.New("down_one_body").Parse(`Монитор {{.Monitor.GetLabel}} не доступен :warning:
Проверки: {{.ChecksDown}}.
Ошибка: {{.Reason}}
Начало события: {{.StartTime.Format "02.01.2006 15:04:05"}}
Недоступные проверки:
{{range .Checks}}
{{.Kind}} - {{if .Name}}{{.Name}}{{else}}Нет имени{{end}} - {{if .URL}}{{.URL}}{{else}}URL не указан{{end}} {{if .Error}}({{.Error}}){{end}}
{{end}}`))
DownOneHTML = template.Must(template.New("down_one_html").Parse(`<h4>Монитор {{.Monitor.GetLabel}} не доступен</h4>
Проверки: {{.ChecksDown}}.
<h5 style='background-color: red;'>Ошибка:</h5>
{{.Reason}}
<div>Начало события: {{.StartTime.Format "02.01.2006 15:04:05"}}</div>
<h5>Недоступные проверки:<h5>
{{range .Checks}}
<div>
{{.Kind}} - {{if .Name}}{{.Name}}{{else}}Нет имени{{end}} - {{if .URL}}{{.URL}}{{else}}URL не указан{{end}} {{if .Error}}({{.Error}}){{end}}
</div>
{{end}}`))
}
// TextDownOne provides functionality.
func TextDownOne(event *models.Event) (bytes.Buffer, bytes.Buffer, bytes.Buffer, bytes.Buffer) {
return executeTemplates(event, DownOneSubject, DownOneBody, DownOneHTML, " :warning:")
}