fix: remove Topic header, add push response logging

- Remove Topic header (causes issues with Apple push service)
- Log push response status codes for debugging
- Log endpoint prefix on errors for identification
- Auto-cleanup 410 (gone) subscriptions on success path too
This commit is contained in:
2026-07-02 15:16:33 -04:00
parent 15f9f6ae07
commit d1022d7c2a
+5 -3
View File
@@ -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)