feat: establish NekoNest Cloud control and relay

This commit is contained in:
2026-08-12 23:25:43 +08:00
commit f27606b709
222 changed files with 71456 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
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)
}