diff --git a/internal/push/handlers.go b/internal/push/handlers.go index 95a1947..6b3aa6a 100644 --- a/internal/push/handlers.go +++ b/internal/push/handlers.go @@ -169,17 +169,20 @@ func (h *Handler) SendPush(ctx context.Context, userID string, payload map[strin VAPIDPrivateKey: h.vapidPriv, TTL: 86400, Urgency: webpush.UrgencyHigh, - Topic: userID, }) if err != nil { - h.logger.Error("failed to send push", "error", err, "user_id", userID) + h.logger.Error("failed to send push", "error", err, "user_id", userID, "endpoint", endpoint[:min(60, len(endpoint))]) if resp != nil && resp.StatusCode == 410 { h.db.ExecContext(ctx, `DELETE FROM push_subscriptions WHERE endpoint = $1`, endpoint) } continue } if resp != nil { + h.logger.Info("push sent", "user_id", userID, "status", resp.StatusCode, "endpoint", endpoint[:min(60, len(endpoint))]) resp.Body.Close() + if resp.StatusCode == 410 { + h.db.ExecContext(ctx, `DELETE FROM push_subscriptions WHERE endpoint = $1`, endpoint) + } } } } @@ -246,7 +249,6 @@ func (h *Handler) SendChannelNotification(ctx context.Context, channelID, author VAPIDPrivateKey: h.vapidPriv, TTL: 86400, Urgency: webpush.UrgencyHigh, - Topic: userID, }) if err != nil { h.logger.Error("failed to send push", "error", err, "user_id", userID)