push

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

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 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