fix(notifications): Pushover and Telegram formatting (#1362)

* fix(notifications): Pushover and Telegram formatting

* fix(notifications): html builder

* fix(notifications): escape html

* fix(notifications): escaping
This commit is contained in:
ze0s 2024-01-23 13:03:20 +01:00 committed by GitHub
parent c377bc9157
commit ae4427175f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 140 additions and 38 deletions

View file

@ -25,7 +25,7 @@ type ntfyMessage struct {
type ntfySender struct {
log zerolog.Logger
Settings domain.Notification
builder NotificationBuilderPlainText
builder MessageBuilderPlainText
httpClient *http.Client
}
@ -34,7 +34,7 @@ func NewNtfySender(log zerolog.Logger, settings domain.Notification) domain.Noti
return &ntfySender{
log: log.With().Str("sender", "ntfy").Logger(),
Settings: settings,
builder: NotificationBuilderPlainText{},
builder: MessageBuilderPlainText{},
httpClient: &http.Client{
Timeout: time.Second * 30,
Transport: sharedhttp.Transport,
@ -45,7 +45,7 @@ func NewNtfySender(log zerolog.Logger, settings domain.Notification) domain.Noti
func (s *ntfySender) Send(event domain.NotificationEvent, payload domain.NotificationPayload) error {
m := ntfyMessage{
Message: s.builder.BuildBody(payload),
Title: s.builder.BuildTitle(event),
Title: BuildTitle(event),
}
req, err := http.NewRequest(http.MethodPost, s.Settings.Host, strings.NewReader(m.Message))