Documentation
¶
Index ¶
- func Configure(c Config)
- func DeletePushSubscription(userID int64, endpoint string) error
- func GetVAPIDPublicKey() (string, error)
- func SavePushSubscription(userID int64, endpoint, p256dh, auth, userAgent string) error
- func SendSessionEndedPush(userID int64)
- func SendWebPushToUser(userID int64, title, body, link string, unreadCount *int64)
- func UserHasPushSubscription(userID int64) bool
- type Config
- type PushSubscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeletePushSubscription ¶
DeletePushSubscription removes one subscription by endpoint - called when the browser reports the subscription as no longer valid, or the user explicitly turns push off on that device.
func GetVAPIDPublicKey ¶
GetVAPIDPublicKey returns the raw (uncompressed point) VAPID public key, base64url-encoded for use as a PushManager applicationServerKey. Keys are generated on first use and stored in business_config, the private half encrypted at rest the same way payment-provider secrets are (see secretStoreConfigKeys in services/config.go).
func SavePushSubscription ¶
SavePushSubscription upserts a subscription by its endpoint - re-subscribing the same browser (e.g. after clearing site data reissues the same endpoint in some browsers, or a plain re-registration) just refreshes the row instead of accumulating duplicates.
func SendSessionEndedPush ¶
func SendSessionEndedPush(userID int64)
SendSessionEndedPush tells every device userID has subscribed that their session was just killed server-side (account disabled or deleted - see handleAdminUserUpdate/handleAdminUserDelete) so an open tab can prompt an in-place reauth instead of the next click just silently failing. Carries no title/body: the service worker only forwards this kind to a visible tab's page script (see sw.js) and never surfaces it as an OS notification, since there's nothing for a closed tab to usefully show.
func SendWebPushToUser ¶
SendWebPushToUser encrypts and delivers title/body (already localized plain text - a service worker has no i18n framework to hand a key to) to every device userID has subscribed. Dead subscriptions (410 Gone / 404 Not Found, meaning the browser or OS discarded the registration) are pruned as they're discovered rather than retried forever.
func UserHasPushSubscription ¶
UserHasPushSubscription reports whether userID has at least one registered device - used to skip the work of building a push payload for users who have never enabled it.