Forráskód Böngészése

fix(gotify): avoid nil feed dereference in notifications

Fred 2 napja
szülő
commit
214aca7dc2
1 módosított fájl, 6 hozzáadás és 6 törlés
  1. 6 6
      internal/integration/gotify/gotify.go

+ 6 - 6
internal/integration/gotify/gotify.go

@@ -101,6 +101,11 @@ func (c *Client) SendMessages(feed *model.Feed, entries model.Entries) error {
 		return errors.New("gotify: missing base URL or token")
 	}
 
+	var title string
+	if feed != nil {
+		title = feed.Title
+	}
+
 	for _, entry := range entries {
 		if entry == nil {
 			continue
@@ -117,16 +122,11 @@ func (c *Client) SendMessages(feed *model.Feed, entries model.Entries) error {
 
 		slog.Debug("Sending Gotify notification",
 			slog.String("url", c.baseURL),
-			slog.String("title", feed.Title),
+			slog.String("title", title),
 			slog.String("entry_title", entry.Title),
 			slog.String("entry_url", entry.URL),
 		)
 
-		var title string
-		if feed != nil {
-			title = feed.Title
-		}
-
 		extras := make(map[string]any)
 		if entry.URL != "" {
 			extras["client::notification"] = map[string]any{