🎉 Initial Commit

This commit is contained in:
2024-10-25 00:56:22 +08:00
commit 7597bff972
26 changed files with 2052 additions and 0 deletions

9
pkg/pushkit/const.go Normal file
View File

@@ -0,0 +1,9 @@
package pushkit
const (
PushMqTopic = "pusher.push.*"
PushNotificationMqTopic = "pusher.push.notification"
PushNotificationBatchMqTopic = "pusher.push.notification.batch"
PushEmailMqTopic = "pusher.push.email"
PushEmailBatchMqTopic = "pusher.push.email.batch"
)

View File

@@ -0,0 +1,38 @@
package pushkit
import (
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/pusher/pkg/proto"
)
type NotificationPushRequest struct {
Provider string `json:"provider" validate:"required"`
Token string `json:"token" validate:"required"`
Notification Notification `json:"notification" validate:"required"`
}
type NotificationPushBatchRequest struct {
Providers []string `json:"provider" validate:"required"`
Tokens []string `json:"tokens" validate:"required"`
Notification Notification `json:"notification" validate:"required"`
}
type Notification struct {
Topic string `json:"topic" validate:"required"`
Title string `json:"title" validate:"required"`
Subtitle string `json:"subtitle"`
Body string `json:"body" validate:"required"`
Metadata map[string]any `json:"metadata"`
Priority int `json:"priority"`
}
func NewNotificationFromProto(in *proto.NotifyInfo) Notification {
return Notification{
Topic: in.GetTopic(),
Title: in.GetTitle(),
Subtitle: in.GetSubtitle(),
Body: in.GetBody(),
Metadata: nex.DecodeMap(in.GetMetadata()),
Priority: int(in.GetPriority()),
}
}