package pushsink import ( "context" "github.com/klarkxy/nekonest/relaycore" corestore "github.com/klarkxy/nekonest/relaycore/store" webpush "github.com/klarkxy/nekonest/relaycore/webpush" ) type Sink struct{} func (Sink) Enabled() bool { return webpush.Enabled() } func (Sink) PublicKey() string { return webpush.PublicKey() } func (Sink) Validate(endpoint, p256dh, auth string) error { if err := webpush.ValidateEndpoint(endpoint); err != nil { return err } return webpush.ValidateKeys(p256dh, auth) } func (Sink) Send(_ context.Context, subscriptions []corestore.PushSubscription, message relaycore.PushMessage, onGone func(string)) bool { converted := make([]webpush.Subscription, 0, len(subscriptions)) for _, subscription := range subscriptions { converted = append(converted, webpush.Subscription{ Endpoint: subscription.Endpoint, P256DH: subscription.P256DH, Auth: subscription.Auth, }) } return webpush.Send(converted, message.Title, message.Body, message.URL, message.DeviceID, message.SessionID, onGone) }