mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(notifications): Notifiarr use auth header (#542)
This commit is contained in:
parent
4b7e393ce9
commit
dc42ca0042
1 changed files with 4 additions and 4 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
|
@ -42,12 +41,14 @@ type notifiarrMessageData struct {
|
|||
type notifiarrSender struct {
|
||||
log zerolog.Logger
|
||||
Settings domain.Notification
|
||||
baseUrl string
|
||||
}
|
||||
|
||||
func NewNotifiarrSender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender {
|
||||
return ¬ifiarrSender{
|
||||
log: log.With().Str("sender", "notifiarr").Logger(),
|
||||
Settings: settings,
|
||||
baseUrl: "https://notifiarr.com/api/v1/notification/autobrr",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,9 +64,7 @@ func (s *notifiarrSender) Send(event domain.NotificationEvent, payload domain.No
|
|||
return errors.Wrap(err, "could not marshal data: %+v", m)
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("https://notifiarr.com/api/v1/notification/autobrr/%v", s.Settings.APIKey)
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonData))
|
||||
req, err := http.NewRequest(http.MethodPost, s.baseUrl, bytes.NewBuffer(jsonData))
|
||||
if err != nil {
|
||||
s.log.Error().Err(err).Msgf("notifiarr client request error: %v", event)
|
||||
return errors.Wrap(err, "could not create request")
|
||||
|
@ -73,6 +72,7 @@ func (s *notifiarrSender) Send(event domain.NotificationEvent, payload domain.No
|
|||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("User-Agent", "autobrr")
|
||||
req.Header.Set("X-API-Key", s.Settings.APIKey)
|
||||
|
||||
t := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue