mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +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"
|
"bytes"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -42,12 +41,14 @@ type notifiarrMessageData struct {
|
||||||
type notifiarrSender struct {
|
type notifiarrSender struct {
|
||||||
log zerolog.Logger
|
log zerolog.Logger
|
||||||
Settings domain.Notification
|
Settings domain.Notification
|
||||||
|
baseUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNotifiarrSender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender {
|
func NewNotifiarrSender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender {
|
||||||
return ¬ifiarrSender{
|
return ¬ifiarrSender{
|
||||||
log: log.With().Str("sender", "notifiarr").Logger(),
|
log: log.With().Str("sender", "notifiarr").Logger(),
|
||||||
Settings: settings,
|
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)
|
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, s.baseUrl, bytes.NewBuffer(jsonData))
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonData))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Error().Err(err).Msgf("notifiarr client request error: %v", event)
|
s.log.Error().Err(err).Msgf("notifiarr client request error: %v", event)
|
||||||
return errors.Wrap(err, "could not create request")
|
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("Content-Type", "application/json")
|
||||||
req.Header.Set("User-Agent", "autobrr")
|
req.Header.Set("User-Agent", "autobrr")
|
||||||
|
req.Header.Set("X-API-Key", s.Settings.APIKey)
|
||||||
|
|
||||||
t := &http.Transport{
|
t := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{
|
TLSClientConfig: &tls.Config{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue