cleanupStaleSubscriptions deletes the rows the push service flagged as permanently invalid (see isStaleSubscriptionStatus) and clears the cached entries for the affected user. Failures are logged at error level rather than returned: the caller is in the middle of returning a delivery error and shoul
(ctx context.Context, userID uuid.UUID, ids []uuid.UUID)
| 275 | // prune is gated on a successful database delete so a partial state cannot |
| 276 | // leak into the cache. |
| 277 | func (n *Webpusher) cleanupStaleSubscriptions(ctx context.Context, userID uuid.UUID, ids []uuid.UUID) { |
| 278 | if len(ids) == 0 { |
| 279 | return |
| 280 | } |
| 281 | // nolint:gocritic // These are known to be invalid subscriptions. |
| 282 | if err := n.store.DeleteWebpushSubscriptions(dbauthz.AsNotifier(ctx), ids); err != nil { |
| 283 | n.log.Error(ctx, "failed to delete stale push subscriptions", slog.Error(err)) |
| 284 | return |
| 285 | } |
| 286 | n.pruneSubscriptions(userID, ids) |
| 287 | } |
| 288 | |
| 289 | func (n *Webpusher) subscriptionsForUser(ctx context.Context, userID uuid.UUID) ([]database.WebpushSubscription, error) { |
| 290 | if subscriptions, ok := n.cachedSubscriptions(userID); ok { |
no test coverage detected