fix(notifications): disable notification and events have no effect (#1754)

fix(notifications): disable notificatio nand events
This commit is contained in:
ze0s 2024-10-06 14:12:01 +02:00 committed by GitHub
parent 009647fcd1
commit ca2d956e02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 118 additions and 125 deletions

View file

@ -179,15 +179,7 @@ func (r *NotificationRepo) FindByID(ctx context.Context, id int) (*domain.Notifi
return &n, nil return &n, nil
} }
func (r *NotificationRepo) Store(ctx context.Context, notification domain.Notification) (*domain.Notification, error) { func (r *NotificationRepo) Store(ctx context.Context, notification *domain.Notification) error {
webhook := toNullString(notification.Webhook)
token := toNullString(notification.Token)
apiKey := toNullString(notification.APIKey)
channel := toNullString(notification.Channel)
topic := toNullString(notification.Topic)
host := toNullString(notification.Host)
username := toNullString(notification.Username)
queryBuilder := r.db.squirrel. queryBuilder := r.db.squirrel.
Insert("notification"). Insert("notification").
Columns( Columns(
@ -209,68 +201,56 @@ func (r *NotificationRepo) Store(ctx context.Context, notification domain.Notifi
notification.Type, notification.Type,
notification.Enabled, notification.Enabled,
pq.Array(notification.Events), pq.Array(notification.Events),
webhook, toNullString(notification.Webhook),
token, toNullString(notification.Token),
apiKey, toNullString(notification.APIKey),
channel, toNullString(notification.Channel),
notification.Priority, notification.Priority,
topic, toNullString(notification.Topic),
host, toNullString(notification.Host),
username, toNullString(notification.Username),
). ).
Suffix("RETURNING id").RunWith(r.db.handler) Suffix("RETURNING id").RunWith(r.db.handler)
// return values if err := queryBuilder.QueryRowContext(ctx).Scan(&notification.ID); err != nil {
var retID int64 return errors.Wrap(err, "error executing query")
if err := queryBuilder.QueryRowContext(ctx).Scan(&retID); err != nil {
return nil, errors.Wrap(err, "error executing query")
} }
r.log.Debug().Msgf("notification.store: added new %v", retID) r.log.Debug().Msgf("notification.store: added new %v", notification.ID)
notification.ID = int(retID)
return &notification, nil return nil
} }
func (r *NotificationRepo) Update(ctx context.Context, notification domain.Notification) (*domain.Notification, error) { func (r *NotificationRepo) Update(ctx context.Context, notification *domain.Notification) error {
webhook := toNullString(notification.Webhook)
token := toNullString(notification.Token)
apiKey := toNullString(notification.APIKey)
channel := toNullString(notification.Channel)
topic := toNullString(notification.Topic)
host := toNullString(notification.Host)
username := toNullString(notification.Username)
queryBuilder := r.db.squirrel. queryBuilder := r.db.squirrel.
Update("notification"). Update("notification").
Set("name", notification.Name). Set("name", notification.Name).
Set("type", notification.Type). Set("type", notification.Type).
Set("enabled", notification.Enabled). Set("enabled", notification.Enabled).
Set("events", pq.Array(notification.Events)). Set("events", pq.Array(notification.Events)).
Set("webhook", webhook). Set("webhook", toNullString(notification.Webhook)).
Set("token", token). Set("token", toNullString(notification.Token)).
Set("api_key", apiKey). Set("api_key", toNullString(notification.APIKey)).
Set("channel", channel). Set("channel", toNullString(notification.Channel)).
Set("priority", notification.Priority). Set("priority", notification.Priority).
Set("topic", topic). Set("topic", toNullString(notification.Topic)).
Set("host", host). Set("host", toNullString(notification.Host)).
Set("username", username). Set("username", toNullString(notification.Username)).
Set("updated_at", sq.Expr("CURRENT_TIMESTAMP")). Set("updated_at", sq.Expr("CURRENT_TIMESTAMP")).
Where(sq.Eq{"id": notification.ID}) Where(sq.Eq{"id": notification.ID})
query, args, err := queryBuilder.ToSql() query, args, err := queryBuilder.ToSql()
if err != nil { if err != nil {
return nil, errors.Wrap(err, "error building query") return errors.Wrap(err, "error building query")
} }
if _, err = r.db.handler.ExecContext(ctx, query, args...); err != nil { if _, err = r.db.handler.ExecContext(ctx, query, args...); err != nil {
return nil, errors.Wrap(err, "error executing query") return errors.Wrap(err, "error executing query")
} }
r.log.Debug().Msgf("notification.update: %v", notification.Name) r.log.Debug().Msgf("notification.update: %v", notification.Name)
return &notification, nil return nil
} }
func (r *NotificationRepo) Delete(ctx context.Context, notificationID int) error { func (r *NotificationRepo) Delete(ctx context.Context, notificationID int) error {

View file

@ -54,8 +54,10 @@ func TestNotificationRepo_Store(t *testing.T) {
// Setup // Setup
assert.NotNil(t, mockData) assert.NotNil(t, mockData)
notification := getMockNotification()
// Execute // Execute
notification, err := repo.Store(context.Background(), mockData) err := repo.Store(context.Background(), &notification)
// Verify // Verify
assert.NoError(t, err) assert.NoError(t, err)
@ -77,28 +79,32 @@ func TestNotificationRepo_Update(t *testing.T) {
t.Run(fmt.Sprintf("Update_Succeeds [%s]", dbType), func(t *testing.T) { t.Run(fmt.Sprintf("Update_Succeeds [%s]", dbType), func(t *testing.T) {
// Initial setup and Store // Initial setup and Store
notification, err := repo.Store(context.Background(), mockData) err := repo.Store(context.Background(), &mockData)
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, notification) assert.NotNil(t, &mockData)
// Modify some fields // Modify some fields
updatedMockData := *notification newName := "UpdatedName"
updatedMockData.Name = "UpdatedName" newType := domain.NotificationTypeTelegram
updatedMockData.Type = domain.NotificationTypeTelegram newPriority := int32(2)
updatedMockData.Priority = 2
updatedMockData := &mockData
updatedMockData.Name = newName
updatedMockData.Type = newType
updatedMockData.Priority = newPriority
// Execute Update // Execute Update
updatedNotification, err := repo.Update(context.Background(), updatedMockData) err = repo.Update(context.Background(), updatedMockData)
// Verify // Verify
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, updatedNotification) assert.NotNil(t, &mockData)
assert.Equal(t, updatedMockData.Name, updatedNotification.Name) assert.Equal(t, updatedMockData.Name, newName)
assert.Equal(t, updatedMockData.Type, updatedNotification.Type) assert.Equal(t, updatedMockData.Type, newType)
assert.Equal(t, updatedMockData.Priority, updatedNotification.Priority) assert.Equal(t, updatedMockData.Priority, newPriority)
// Cleanup // Cleanup
_ = repo.Delete(context.Background(), updatedNotification.ID) _ = repo.Delete(context.Background(), mockData.ID)
}) })
} }
} }
@ -108,11 +114,13 @@ func TestNotificationRepo_Delete(t *testing.T) {
log := setupLoggerForTest() log := setupLoggerForTest()
repo := NewNotificationRepo(log, db) repo := NewNotificationRepo(log, db)
mockData := getMockNotification() //mockData := getMockNotification()
t.Run(fmt.Sprintf("Delete_Succeeds [%s]", dbType), func(t *testing.T) { t.Run(fmt.Sprintf("Delete_Succeeds [%s]", dbType), func(t *testing.T) {
notification := getMockNotification()
// Initial setup and Store // Initial setup and Store
notification, err := repo.Store(context.Background(), mockData) err := repo.Store(context.Background(), &notification)
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, notification) assert.NotNil(t, notification)
@ -148,11 +156,11 @@ func TestNotificationRepo_Find(t *testing.T) {
_ = repo.Delete(context.Background(), notification.ID) _ = repo.Delete(context.Background(), notification.ID)
} }
_, err := repo.Store(context.Background(), mockData1) err := repo.Store(context.Background(), &mockData1)
assert.NoError(t, err) assert.NoError(t, err)
_, err = repo.Store(context.Background(), mockData2) err = repo.Store(context.Background(), &mockData2)
assert.NoError(t, err) assert.NoError(t, err)
_, err = repo.Store(context.Background(), mockData3) err = repo.Store(context.Background(), &mockData3)
assert.NoError(t, err) assert.NoError(t, err)
// Setup query params // Setup query params
@ -188,11 +196,13 @@ func TestNotificationRepo_FindByID(t *testing.T) {
t.Run(fmt.Sprintf("FindByID_Succeeds [%s]", dbType), func(t *testing.T) { t.Run(fmt.Sprintf("FindByID_Succeeds [%s]", dbType), func(t *testing.T) {
// Setup // Setup
//notification := getMockNotification()
assert.NotNil(t, mockData) assert.NotNil(t, mockData)
notification, err := repo.Store(context.Background(), mockData) err := repo.Store(context.Background(), &mockData)
// Execute // Execute
notification, err = repo.FindByID(context.Background(), notification.ID) notification, err := repo.FindByID(context.Background(), mockData.ID)
// Verify // Verify
assert.NoError(t, err) assert.NoError(t, err)
@ -221,7 +231,7 @@ func TestNotificationRepo_List(t *testing.T) {
} }
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
_, err := repo.Store(context.Background(), mockData) err := repo.Store(context.Background(), &mockData)
assert.NoError(t, err) assert.NoError(t, err)
} }

View file

@ -12,8 +12,8 @@ type NotificationRepo interface {
List(ctx context.Context) ([]Notification, error) List(ctx context.Context) ([]Notification, error)
Find(ctx context.Context, params NotificationQueryParams) ([]Notification, int, error) Find(ctx context.Context, params NotificationQueryParams) ([]Notification, int, error)
FindByID(ctx context.Context, id int) (*Notification, error) FindByID(ctx context.Context, id int) (*Notification, error)
Store(ctx context.Context, notification Notification) (*Notification, error) Store(ctx context.Context, notification *Notification) error
Update(ctx context.Context, notification Notification) (*Notification, error) Update(ctx context.Context, notification *Notification) error
Delete(ctx context.Context, notificationID int) error Delete(ctx context.Context, notificationID int) error
} }

View file

@ -18,10 +18,10 @@ import (
type notificationService interface { type notificationService interface {
Find(context.Context, domain.NotificationQueryParams) ([]domain.Notification, int, error) Find(context.Context, domain.NotificationQueryParams) ([]domain.Notification, int, error)
FindByID(ctx context.Context, id int) (*domain.Notification, error) FindByID(ctx context.Context, id int) (*domain.Notification, error)
Store(ctx context.Context, n domain.Notification) (*domain.Notification, error) Store(ctx context.Context, notification *domain.Notification) error
Update(ctx context.Context, n domain.Notification) (*domain.Notification, error) Update(ctx context.Context, notification *domain.Notification) error
Delete(ctx context.Context, id int) error Delete(ctx context.Context, id int) error
Test(ctx context.Context, notification domain.Notification) error Test(ctx context.Context, notification *domain.Notification) error
} }
type notificationHandler struct { type notificationHandler struct {
@ -59,19 +59,19 @@ func (h notificationHandler) list(w http.ResponseWriter, r *http.Request) {
} }
func (h notificationHandler) store(w http.ResponseWriter, r *http.Request) { func (h notificationHandler) store(w http.ResponseWriter, r *http.Request) {
var data domain.Notification var data *domain.Notification
if err := json.NewDecoder(r.Body).Decode(&data); err != nil { if err := json.NewDecoder(r.Body).Decode(&data); err != nil {
h.encoder.Error(w, err) h.encoder.Error(w, err)
return return
} }
filter, err := h.service.Store(r.Context(), data) err := h.service.Store(r.Context(), data)
if err != nil { if err != nil {
h.encoder.Error(w, err) h.encoder.Error(w, err)
return return
} }
h.encoder.StatusResponse(w, http.StatusCreated, filter) h.encoder.StatusResponse(w, http.StatusCreated, data)
} }
func (h notificationHandler) findByID(w http.ResponseWriter, r *http.Request) { func (h notificationHandler) findByID(w http.ResponseWriter, r *http.Request) {
@ -96,19 +96,19 @@ func (h notificationHandler) findByID(w http.ResponseWriter, r *http.Request) {
} }
func (h notificationHandler) update(w http.ResponseWriter, r *http.Request) { func (h notificationHandler) update(w http.ResponseWriter, r *http.Request) {
var data domain.Notification var data *domain.Notification
if err := json.NewDecoder(r.Body).Decode(&data); err != nil { if err := json.NewDecoder(r.Body).Decode(&data); err != nil {
h.encoder.Error(w, err) h.encoder.Error(w, err)
return return
} }
filter, err := h.service.Update(r.Context(), data) err := h.service.Update(r.Context(), data)
if err != nil { if err != nil {
h.encoder.Error(w, err) h.encoder.Error(w, err)
return return
} }
h.encoder.StatusResponse(w, http.StatusOK, filter) h.encoder.StatusResponse(w, http.StatusOK, data)
} }
func (h notificationHandler) delete(w http.ResponseWriter, r *http.Request) { func (h notificationHandler) delete(w http.ResponseWriter, r *http.Request) {
@ -127,7 +127,7 @@ func (h notificationHandler) delete(w http.ResponseWriter, r *http.Request) {
} }
func (h notificationHandler) test(w http.ResponseWriter, r *http.Request) { func (h notificationHandler) test(w http.ResponseWriter, r *http.Request) {
var data domain.Notification var data *domain.Notification
if err := json.NewDecoder(r.Body).Decode(&data); err != nil { if err := json.NewDecoder(r.Body).Decode(&data); err != nil {
h.encoder.Error(w, err) h.encoder.Error(w, err)
return return

View file

@ -50,7 +50,7 @@ const (
type discordSender struct { type discordSender struct {
log zerolog.Logger log zerolog.Logger
Settings domain.Notification Settings *domain.Notification
httpClient *http.Client httpClient *http.Client
} }
@ -59,7 +59,7 @@ func (a *discordSender) Name() string {
return "discord" return "discord"
} }
func NewDiscordSender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender { func NewDiscordSender(log zerolog.Logger, settings *domain.Notification) domain.NotificationSender {
return &discordSender{ return &discordSender{
log: log.With().Str("sender", "discord").Logger(), log: log.With().Str("sender", "discord").Logger(),
Settings: settings, Settings: settings,

View file

@ -26,7 +26,7 @@ type gotifyMessage struct {
type gotifySender struct { type gotifySender struct {
log zerolog.Logger log zerolog.Logger
Settings domain.Notification Settings *domain.Notification
builder MessageBuilderPlainText builder MessageBuilderPlainText
httpClient *http.Client httpClient *http.Client
@ -36,7 +36,7 @@ func (s *gotifySender) Name() string {
return "gotify" return "gotify"
} }
func NewGotifySender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender { func NewGotifySender(log zerolog.Logger, settings *domain.Notification) domain.NotificationSender {
return &gotifySender{ return &gotifySender{
log: log.With().Str("sender", "gotify").Logger(), log: log.With().Str("sender", "gotify").Logger(),
Settings: settings, Settings: settings,

View file

@ -27,7 +27,7 @@ type LunaSeaMessage struct {
type lunaSeaSender struct { type lunaSeaSender struct {
log zerolog.Logger log zerolog.Logger
Settings domain.Notification Settings *domain.Notification
builder MessageBuilderPlainText builder MessageBuilderPlainText
httpClient *http.Client httpClient *http.Client
@ -43,7 +43,7 @@ func (s *lunaSeaSender) rewriteWebhookURL(url string) string {
return lunaWebhook.ReplaceAllString(url, "/custom/") return lunaWebhook.ReplaceAllString(url, "/custom/")
} // `custom` is not mentioned in their docs, so I thought this would be a good idea to add to avoid user errors } // `custom` is not mentioned in their docs, so I thought this would be a good idea to add to avoid user errors
func NewLunaSeaSender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender { func NewLunaSeaSender(log zerolog.Logger, settings *domain.Notification) domain.NotificationSender {
return &lunaSeaSender{ return &lunaSeaSender{
log: log.With().Str("sender", "lunasea").Logger(), log: log.With().Str("sender", "lunasea").Logger(),
Settings: settings, Settings: settings,

View file

@ -44,7 +44,7 @@ type notifiarrMessageData struct {
type notifiarrSender struct { type notifiarrSender struct {
log zerolog.Logger log zerolog.Logger
Settings domain.Notification Settings *domain.Notification
baseUrl string baseUrl string
httpClient *http.Client httpClient *http.Client
@ -54,7 +54,7 @@ func (s *notifiarrSender) Name() string {
return "notifiarr" return "notifiarr"
} }
func NewNotifiarrSender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender { func NewNotifiarrSender(log zerolog.Logger, settings *domain.Notification) domain.NotificationSender {
return &notifiarrSender{ return &notifiarrSender{
log: log.With().Str("sender", "notifiarr").Logger(), log: log.With().Str("sender", "notifiarr").Logger(),
Settings: settings, Settings: settings,

View file

@ -25,7 +25,7 @@ type ntfyMessage struct {
type ntfySender struct { type ntfySender struct {
log zerolog.Logger log zerolog.Logger
Settings domain.Notification Settings *domain.Notification
builder MessageBuilderPlainText builder MessageBuilderPlainText
httpClient *http.Client httpClient *http.Client
@ -35,7 +35,7 @@ func (s *ntfySender) Name() string {
return "ntfy" return "ntfy"
} }
func NewNtfySender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender { func NewNtfySender(log zerolog.Logger, settings *domain.Notification) domain.NotificationSender {
return &ntfySender{ return &ntfySender{
log: log.With().Str("sender", "ntfy").Logger(), log: log.With().Str("sender", "ntfy").Logger(),
Settings: settings, Settings: settings,

View file

@ -32,7 +32,7 @@ type pushoverMessage struct {
type pushoverSender struct { type pushoverSender struct {
log zerolog.Logger log zerolog.Logger
Settings domain.Notification Settings *domain.Notification
baseUrl string baseUrl string
builder MessageBuilderHTML builder MessageBuilderHTML
@ -43,7 +43,7 @@ func (s *pushoverSender) Name() string {
return "pushover" return "pushover"
} }
func NewPushoverSender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender { func NewPushoverSender(log zerolog.Logger, settings *domain.Notification) domain.NotificationSender {
return &pushoverSender{ return &pushoverSender{
log: log.With().Str("sender", "pushover").Logger(), log: log.With().Str("sender", "pushover").Logger(),
Settings: settings, Settings: settings,

View file

@ -19,11 +19,11 @@ import (
type Service interface { type Service interface {
Find(ctx context.Context, params domain.NotificationQueryParams) ([]domain.Notification, int, error) Find(ctx context.Context, params domain.NotificationQueryParams) ([]domain.Notification, int, error)
FindByID(ctx context.Context, id int) (*domain.Notification, error) FindByID(ctx context.Context, id int) (*domain.Notification, error)
Store(ctx context.Context, n domain.Notification) (*domain.Notification, error) Store(ctx context.Context, notification *domain.Notification) error
Update(ctx context.Context, n domain.Notification) (*domain.Notification, error) Update(ctx context.Context, notification *domain.Notification) error
Delete(ctx context.Context, id int) error Delete(ctx context.Context, id int) error
Send(event domain.NotificationEvent, payload domain.NotificationPayload) Send(event domain.NotificationEvent, payload domain.NotificationPayload)
Test(ctx context.Context, notification domain.Notification) error Test(ctx context.Context, notification *domain.Notification) error
} }
type service struct { type service struct {
@ -64,30 +64,30 @@ func (s *service) FindByID(ctx context.Context, id int) (*domain.Notification, e
return notification, err return notification, err
} }
func (s *service) Store(ctx context.Context, notification domain.Notification) (*domain.Notification, error) { func (s *service) Store(ctx context.Context, notification *domain.Notification) error {
_, err := s.repo.Store(ctx, notification) err := s.repo.Store(ctx, notification)
if err != nil { if err != nil {
s.log.Error().Err(err).Msgf("could not store notification: %+v", notification) s.log.Error().Err(err).Msgf("could not store notification: %+v", notification)
return nil, err return err
} }
// register sender // register sender
s.registerSender(notification) s.registerSender(notification)
return nil, nil return nil
} }
func (s *service) Update(ctx context.Context, notification domain.Notification) (*domain.Notification, error) { func (s *service) Update(ctx context.Context, notification *domain.Notification) error {
_, err := s.repo.Update(ctx, notification) err := s.repo.Update(ctx, notification)
if err != nil { if err != nil {
s.log.Error().Err(err).Msgf("could not update notification: %+v", notification) s.log.Error().Err(err).Msgf("could not update notification: %+v", notification)
return nil, err return err
} }
// register sender // register sender
s.registerSender(notification) s.registerSender(notification)
return nil, nil return nil
} }
func (s *service) Delete(ctx context.Context, id int) error { func (s *service) Delete(ctx context.Context, id int) error {
@ -111,33 +111,36 @@ func (s *service) registerSenders() {
} }
for _, notificationSender := range notificationSenders { for _, notificationSender := range notificationSenders {
s.registerSender(notificationSender) s.registerSender(&notificationSender)
} }
return return
} }
// registerSender registers an enabled notification via it's id // registerSender registers an enabled notification via it's id
func (s *service) registerSender(notification domain.Notification) { func (s *service) registerSender(notification *domain.Notification) {
if notification.Enabled { if !notification.Enabled {
switch notification.Type { delete(s.senders, notification.ID)
case domain.NotificationTypeDiscord: return
s.senders[notification.ID] = NewDiscordSender(s.log, notification) }
case domain.NotificationTypeGotify:
s.senders[notification.ID] = NewGotifySender(s.log, notification) switch notification.Type {
case domain.NotificationTypeLunaSea: case domain.NotificationTypeDiscord:
s.senders[notification.ID] = NewLunaSeaSender(s.log, notification) s.senders[notification.ID] = NewDiscordSender(s.log, notification)
case domain.NotificationTypeNotifiarr: case domain.NotificationTypeGotify:
s.senders[notification.ID] = NewNotifiarrSender(s.log, notification) s.senders[notification.ID] = NewGotifySender(s.log, notification)
case domain.NotificationTypeNtfy: case domain.NotificationTypeLunaSea:
s.senders[notification.ID] = NewNtfySender(s.log, notification) s.senders[notification.ID] = NewLunaSeaSender(s.log, notification)
case domain.NotificationTypePushover: case domain.NotificationTypeNotifiarr:
s.senders[notification.ID] = NewPushoverSender(s.log, notification) s.senders[notification.ID] = NewNotifiarrSender(s.log, notification)
case domain.NotificationTypeShoutrrr: case domain.NotificationTypeNtfy:
s.senders[notification.ID] = NewShoutrrrSender(s.log, notification) s.senders[notification.ID] = NewNtfySender(s.log, notification)
case domain.NotificationTypeTelegram: case domain.NotificationTypePushover:
s.senders[notification.ID] = NewTelegramSender(s.log, notification) s.senders[notification.ID] = NewPushoverSender(s.log, notification)
} case domain.NotificationTypeShoutrrr:
s.senders[notification.ID] = NewShoutrrrSender(s.log, notification)
case domain.NotificationTypeTelegram:
s.senders[notification.ID] = NewTelegramSender(s.log, notification)
} }
return return
@ -163,7 +166,7 @@ func (s *service) Send(event domain.NotificationEvent, payload domain.Notificati
return return
} }
func (s *service) Test(ctx context.Context, notification domain.Notification) error { func (s *service) Test(ctx context.Context, notification *domain.Notification) error {
var agent domain.NotificationSender var agent domain.NotificationSender
// send test events // send test events

View file

@ -9,7 +9,7 @@ import (
type shoutrrrSender struct { type shoutrrrSender struct {
log zerolog.Logger log zerolog.Logger
Settings domain.Notification Settings *domain.Notification
builder MessageBuilderPlainText builder MessageBuilderPlainText
} }
@ -17,7 +17,7 @@ func (s *shoutrrrSender) Name() string {
return "shoutrrr" return "shoutrrr"
} }
func NewShoutrrrSender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender { func NewShoutrrrSender(log zerolog.Logger, settings *domain.Notification) domain.NotificationSender {
return &shoutrrrSender{ return &shoutrrrSender{
log: log.With().Str("sender", "shoutrrr").Logger(), log: log.With().Str("sender", "shoutrrr").Logger(),
Settings: settings, Settings: settings,

View file

@ -30,7 +30,7 @@ type TelegramMessage struct {
type telegramSender struct { type telegramSender struct {
log zerolog.Logger log zerolog.Logger
Settings domain.Notification Settings *domain.Notification
ThreadID int ThreadID int
builder MessageBuilderHTML builder MessageBuilderHTML
@ -41,7 +41,7 @@ func (s *telegramSender) Name() string {
return "telegram" return "telegram"
} }
func NewTelegramSender(log zerolog.Logger, settings domain.Notification) domain.NotificationSender { func NewTelegramSender(log zerolog.Logger, settings *domain.Notification) domain.NotificationSender {
threadID := 0 threadID := 0
if t := settings.Topic; t != "" { if t := settings.Topic; t != "" {
var err error var err error