Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dispatcher ¶
type Dispatcher interface {
// Dispatch sends a web push notification to all subscriptions
// for a user. Any notifications that fail to send are silently dropped.
Dispatch(ctx context.Context, userID uuid.UUID, notification codersdk.WebpushMessage) error
// Test sends a test web push notificatoin to a subscription to ensure it is valid.
Test(ctx context.Context, req codersdk.WebpushSubscription) error
// PublicKey returns the VAPID public key for the webpush dispatcher.
PublicKey() string
}
Dispatcher is an interface that can be used to dispatch web push notifications to clients such as browsers.
func New ¶
func New(ctx context.Context, log *slog.Logger, db database.Store, vapidSub string) (Dispatcher, error)
New creates a new Dispatcher to dispatch web push notifications.
This is *not* integrated into the enqueue system unfortunately. That's because the notifications system has a enqueue system, and push notifications at time of implementation are being used for updates inside of a workspace, which we want to be immediate.
type NoopWebpusher ¶
type NoopWebpusher struct {
Msg string
}
NoopWebpusher is a Dispatcher that does nothing except return an error. This is returned when web push notifications are disabled, or if there was an error generating the VAPID keys.
func (*NoopWebpusher) Dispatch ¶
func (n *NoopWebpusher) Dispatch(context.Context, uuid.UUID, codersdk.WebpushMessage) error
func (*NoopWebpusher) PublicKey ¶
func (*NoopWebpusher) PublicKey() string
func (*NoopWebpusher) Test ¶
func (n *NoopWebpusher) Test(context.Context, codersdk.WebpushSubscription) error
type Webpusher ¶
type Webpusher struct {
// public and private keys for VAPID. These are used to sign and encrypt
// the message payload.
VAPIDPublicKey string
VAPIDPrivateKey string
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.