Skip to content

Commit

Permalink
Fix notifications send
Browse files Browse the repository at this point in the history
  • Loading branch information
ybizeul committed Oct 14, 2024
1 parent 4e76f58 commit f7739d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/feed/pushnotifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ func (f *Feed) sendPushNotification() error {
// For each subscription we send the notification
for _, subscription := range f.Config.Subscriptions {
pnL.Logger.Debug("Sending push notification", slog.String("endpoint", subscription.Endpoint))
resp, _ := webpush.SendNotification([]byte(fmt.Sprintf("New item posted to feed %s", f.Name())), &subscription, &webpush.Options{
resp, err := webpush.SendNotification([]byte(fmt.Sprintf("New item posted to feed %s", f.Name())), &subscription, &webpush.Options{
Subscriber: "ybfeed@tynsoe.org", // Do not include "mailto:"
VAPIDPublicKey: f.NotificationSettings.VAPIDPublicKey,
VAPIDPrivateKey: f.NotificationSettings.VAPIDPrivateKey,
TTL: 30,
})
if err != nil {
pnL.Logger.Error("Sending push notification failed:", slog.String("error", err.Error()))
continue
}
if pnL.Level() == slog.LevelDebug {
b, _ := io.ReadAll(resp.Body)
pnL.Logger.Debug("Response", slog.String("resp", string(b)), slog.String("status", resp.Status))
Expand Down

0 comments on commit f7739d1

Please sign in to comment.