push

package
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeVAPIDPrivateKey

func DecodeVAPIDPrivateKey(privKeyB64 string) (*ecdsa.PrivateKey, error)

DecodeVAPIDPrivateKey decodes a base64url-encoded VAPID private key into an ECDSA key.

func DeleteSubscriptionByEndpoint

func DeleteSubscriptionByEndpoint(ctx context.Context, db *sql.DB, endpoint string) error

DeleteSubscriptionByEndpoint removes a push subscription by endpoint URL.

func DeleteUserSubscription added in v0.10.0

func DeleteUserSubscription(ctx context.Context, db *sql.DB, userID int, userType, endpoint string) error

DeleteUserSubscription removes the caller's own push subscription for an endpoint. A subscription owned by another user is left untouched.

func DispatchPushReminder

func DispatchPushReminder(ctx context.Context, db *sql.DB, recipients []int, reminder notifications.PendingReminder, cfg PushConfig)

DispatchPushReminder sends push notifications for a pending reminder to all subscribed recipients.

func GenerateVAPIDKeys

func GenerateVAPIDKeys() (publicKey, privateKey string, err error)

GenerateVAPIDKeys generates a new VAPID key pair encoded as base64url strings.

func GetVAPIDKeys

func GetVAPIDKeys(vapidPublic, vapidPrivate string) (pub, priv string, err error)

GetVAPIDKeys reads VAPID keys from the given public/private strings. If empty, generates new keys and logs a warning.

func SaveSubscription

func SaveSubscription(ctx context.Context, db *sql.DB, userID int, userType, endpoint, p256dh, auth string) error

SaveSubscription stores or updates a push subscription.

func Send

func Send(sub Subscription, payload []byte, vapidPublicKey, vapidPrivateKey, vapidContact string) error

Send delivers a push notification to a single subscription.

Types

type PushConfig

type PushConfig struct {
	VAPIDPublicKey  string
	VAPIDPrivateKey string
	VAPIDContact    string
}

PushConfig holds VAPID configuration for push dispatching.

type Subscription

type Subscription struct {
	Endpoint string
	P256dh   string
	Auth     string
}

Subscription represents a Web Push subscription.

func GetSubscriptionsForUser

func GetSubscriptionsForUser(ctx context.Context, db *sql.DB, userID int, userType string) ([]Subscription, error)

GetSubscriptionsForUser returns all push subscriptions for a specific user.

func GetSubscriptionsForUsers

func GetSubscriptionsForUsers(ctx context.Context, db *sql.DB, userIDs []int, userType string) ([]Subscription, error)

GetSubscriptionsForUsers returns push subscriptions for multiple users.

type SubscriptionExpiredError

type SubscriptionExpiredError struct {
	Endpoint   string
	StatusCode int
}

SubscriptionExpiredError indicates a subscription endpoint is no longer valid.

func (*SubscriptionExpiredError) Error

func (e *SubscriptionExpiredError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL