isStaleSubscriptionStatus reports whether a status code from a push service indicates that the subscription is permanently invalid and should be removed from the database. Other 4xx and 5xx responses (rate limits, transient failures) leave the subscription in place so it can be retried on the next d
(statusCode int)
| 35 | // (rate limits, transient failures) leave the subscription in place |
| 36 | // so it can be retried on the next dispatch. |
| 37 | func isStaleSubscriptionStatus(statusCode int) bool { |
| 38 | switch statusCode { |
| 39 | case http.StatusBadRequest, // 400: malformed subscription per the push service. |
| 40 | http.StatusForbidden, // 403: Apple BadJwtToken / VAPID rejected, key rotation. |
| 41 | http.StatusNotFound, // 404: FCM/Mozilla endpoint no longer valid. |
| 42 | http.StatusGone: // 410: standard "subscription expired" signal. |
| 43 | return true |
| 44 | } |
| 45 | return false |
| 46 | } |
| 47 | |
| 48 | // Dispatcher is an interface that can be used to dispatch |
| 49 | // web push notifications to clients such as browsers. |