MCPcopy Index your code
hub / github.com/coder/coder / cleanupStaleSubscriptions

Method cleanupStaleSubscriptions

coderd/webpush/webpush.go:277–287  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

275// prune is gated on a successful database delete so a partial state cannot
276// leak into the cache.
277func (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
289func (n *Webpusher) subscriptionsForUser(ctx context.Context, userID uuid.UUID) ([]database.WebpushSubscription, error) {
290 if subscriptions, ok := n.cachedSubscriptions(userID); ok {

Callers 1

DispatchMethod · 0.95

Calls 4

pruneSubscriptionsMethod · 0.95
AsNotifierFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected