🎉 Initial Commit
This commit is contained in:
39
pkg/internal/gap/server.go
Normal file
39
pkg/internal/gap/server.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package gap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
||||
"github.com/rs/zerolog/log"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var Nx *nex.Conn
|
||||
|
||||
func InitializeToNexus() error {
|
||||
grpcBind := strings.SplitN(viper.GetString("grpc_bind"), ":", 2)
|
||||
|
||||
outboundIp, _ := nex.GetOutboundIP()
|
||||
|
||||
grpcOutbound := fmt.Sprintf("%s:%s", outboundIp, grpcBind[1])
|
||||
|
||||
var err error
|
||||
Nx, err = nex.NewNexusConn(viper.GetString("nexus_addr"), &proto.ServiceInfo{
|
||||
Id: viper.GetString("id"),
|
||||
Type: nex.ServiceTypePusher,
|
||||
Label: "Pusher",
|
||||
GrpcAddr: grpcOutbound,
|
||||
})
|
||||
if err == nil {
|
||||
go func() {
|
||||
err := Nx.RunRegistering()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("An error occurred while registering service...")
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
26
pkg/internal/grpc/health.go
Normal file
26
pkg/internal/grpc/health.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
health "google.golang.org/grpc/health/grpc_health_v1"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (v *Server) Check(ctx context.Context, request *health.HealthCheckRequest) (*health.HealthCheckResponse, error) {
|
||||
return &health.HealthCheckResponse{
|
||||
Status: health.HealthCheckResponse_SERVING,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (v *Server) Watch(request *health.HealthCheckRequest, server health.Health_WatchServer) error {
|
||||
for {
|
||||
if server.Send(&health.HealthCheckResponse{
|
||||
Status: health.HealthCheckResponse_SERVING,
|
||||
}) != nil {
|
||||
break
|
||||
}
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
36
pkg/internal/grpc/pusher.go
Normal file
36
pkg/internal/grpc/pusher.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/internal/provider"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/proto"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||
)
|
||||
|
||||
func (v *Server) PushNotification(ctx context.Context, request *proto.PushNotificationRequest) (*proto.DeliveryResponse, error) {
|
||||
err := provider.PushNotification(pushkit.NotificationPushRequest{
|
||||
Provider: request.GetProvider(),
|
||||
Token: request.GetDeviceToken(),
|
||||
Notification: pushkit.NewNotificationFromProto(request.GetNotify()),
|
||||
})
|
||||
return &proto.DeliveryResponse{IsSuccess: err == nil}, nil
|
||||
}
|
||||
|
||||
func (v *Server) PushNotificationBatch(ctx context.Context, request *proto.PushNotificationBatchRequest) (*proto.DeliveryResponse, error) {
|
||||
go provider.PushNotificationBatch(pushkit.NotificationPushBatchRequest{
|
||||
Providers: request.GetProviders(),
|
||||
Tokens: request.GetDeviceTokens(),
|
||||
Notification: pushkit.NewNotificationFromProto(request.GetNotify()),
|
||||
})
|
||||
return &proto.DeliveryResponse{IsSuccess: true}, nil
|
||||
}
|
||||
|
||||
func (v *Server) DeliverEmail(ctx context.Context, request *proto.DeliverEmailRequest) (*proto.DeliveryResponse, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (v *Server) DeliverEmailBatch(ctx context.Context, request *proto.DeliverEmailBatchRequest) (*proto.DeliveryResponse, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
39
pkg/internal/grpc/server.go
Normal file
39
pkg/internal/grpc/server.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/proto"
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
health "google.golang.org/grpc/health/grpc_health_v1"
|
||||
"google.golang.org/grpc/reflection"
|
||||
"net"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
proto.UnimplementedPusherServiceServer
|
||||
health.UnimplementedHealthServer
|
||||
|
||||
srv *grpc.Server
|
||||
}
|
||||
|
||||
func NewServer() *Server {
|
||||
server := &Server{
|
||||
srv: grpc.NewServer(),
|
||||
}
|
||||
|
||||
proto.RegisterPusherServiceServer(server.srv, server)
|
||||
health.RegisterHealthServer(server.srv, server)
|
||||
|
||||
reflection.Register(server.srv)
|
||||
|
||||
return server
|
||||
}
|
||||
|
||||
func (v *Server) Listen() error {
|
||||
listener, err := net.Listen("tcp", viper.GetString("grpc_bind"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return v.srv.Serve(listener)
|
||||
}
|
5
pkg/internal/meta.go
Normal file
5
pkg/internal/meta.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package pkg
|
||||
|
||||
const (
|
||||
AppVersion = "1.0.0"
|
||||
)
|
48
pkg/internal/provider/apns.go
Normal file
48
pkg/internal/provider/apns.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||
"github.com/sideshow/apns2"
|
||||
payload2 "github.com/sideshow/apns2/payload"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type AppleNotifyProvider struct {
|
||||
topic string
|
||||
conn *apns2.Client
|
||||
}
|
||||
|
||||
func (v *AppleNotifyProvider) Push(in pushkit.Notification, tk string) error {
|
||||
data := payload2.
|
||||
NewPayload().
|
||||
AlertTitle(in.Title).
|
||||
AlertBody(in.Body).
|
||||
Category(in.Topic).
|
||||
Custom("metadata", in.Metadata).
|
||||
Sound("default").
|
||||
MutableContent()
|
||||
if len(in.Subtitle) > 0 {
|
||||
data = data.AlertSubtitle(in.Subtitle)
|
||||
}
|
||||
if avatar, ok := in.Metadata["avatar"]; ok {
|
||||
data = data.Custom("avatar", avatar)
|
||||
}
|
||||
if picture, ok := in.Metadata["picture"]; ok {
|
||||
data = data.Custom("picture", picture)
|
||||
}
|
||||
rawData, err := data.MarshalJSON()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
payload := &apns2.Notification{
|
||||
DeviceToken: tk,
|
||||
Topic: viper.GetString(v.topic),
|
||||
Payload: rawData,
|
||||
}
|
||||
_, err := v.conn.Push(payload)
|
||||
return err
|
||||
}
|
||||
|
||||
func (v *AppleNotifyProvider) GetName() string {
|
||||
return "apns"
|
||||
}
|
67
pkg/internal/provider/caller.go
Normal file
67
pkg/internal/provider/caller.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||
"github.com/rs/zerolog/log"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var notifyProviders = make(map[string]NotificationProvider)
|
||||
|
||||
func AddProvider(in NotificationProvider) {
|
||||
notifyProviders[in.GetName()] = in
|
||||
}
|
||||
|
||||
func PushNotification(in pushkit.NotificationPushRequest) error {
|
||||
prov, ok := notifyProviders[in.Provider]
|
||||
if !ok {
|
||||
return fmt.Errorf("provider not found")
|
||||
}
|
||||
start := time.Now()
|
||||
err := prov.Push(in.Notification, in.Token)
|
||||
if err != nil {
|
||||
log.Warn().Err(err).
|
||||
Str("tk", in.Token).
|
||||
Str("provider", prov.GetName()).
|
||||
Dur("elapsed", time.Since(start)).
|
||||
Msg("Push notification failed once")
|
||||
} else {
|
||||
log.Debug().
|
||||
Str("tk", in.Token).
|
||||
Str("provider", prov.GetName()).
|
||||
Dur("elapsed", time.Since(start)).
|
||||
Msg("Pushed one notification")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func PushNotificationBatch(in pushkit.NotificationPushBatchRequest) {
|
||||
var wg sync.WaitGroup
|
||||
for idx, key := range in.Providers {
|
||||
prov, ok := notifyProviders[key]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
go func() {
|
||||
wg.Add(1)
|
||||
defer wg.Done()
|
||||
start := time.Now()
|
||||
err := prov.Push(in.Notification, in.Tokens[idx])
|
||||
if err != nil {
|
||||
log.Warn().Err(err).
|
||||
Str("tk", in.Tokens[idx]).
|
||||
Str("provider", prov.GetName()).
|
||||
Dur("elapsed", time.Since(start)).
|
||||
Msg("Push notification failed once")
|
||||
} else {
|
||||
log.Debug().
|
||||
Str("tk", in.Tokens[idx]).
|
||||
Str("provider", prov.GetName()).
|
||||
Dur("elapsed", time.Since(start)).
|
||||
Msg("Pushed one notification")
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
40
pkg/internal/provider/firebase.go
Normal file
40
pkg/internal/provider/firebase.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"context"
|
||||
firebase "firebase.google.com/go"
|
||||
"firebase.google.com/go/messaging"
|
||||
"fmt"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||
)
|
||||
|
||||
type FirebaseNotifyProvider struct {
|
||||
conn *firebase.App
|
||||
}
|
||||
|
||||
func (v *FirebaseNotifyProvider) Push(in pushkit.Notification, tk string) error {
|
||||
ctx := context.Background()
|
||||
client, err := v.conn.Messaging(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create firebase client")
|
||||
}
|
||||
|
||||
var subtitle string
|
||||
if len(in.Subtitle) > 0 {
|
||||
subtitle = "\n" + in.Subtitle
|
||||
}
|
||||
message := &messaging.Message{
|
||||
Notification: &messaging.Notification{
|
||||
Title: in.Title,
|
||||
Body: subtitle + in.Body,
|
||||
},
|
||||
Token: tk,
|
||||
}
|
||||
|
||||
_, err = client.Send(ctx, message)
|
||||
return err
|
||||
}
|
||||
|
||||
func (v *FirebaseNotifyProvider) GetName() string {
|
||||
return "fcm"
|
||||
}
|
36
pkg/internal/provider/initializer.go
Normal file
36
pkg/internal/provider/initializer.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"context"
|
||||
firebase "firebase.google.com/go"
|
||||
"github.com/sideshow/apns2"
|
||||
"github.com/sideshow/apns2/token"
|
||||
"google.golang.org/api/option"
|
||||
)
|
||||
|
||||
func InitFCM(in string) error {
|
||||
opt := option.WithCredentialsFile(in)
|
||||
app, err := firebase.NewApp(context.Background(), nil, opt)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
AddProvider(&FirebaseNotifyProvider{app})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func InitAPN(in, keyId, teamId, topic string) error {
|
||||
authKey, err := token.AuthKeyFromFile(in)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
AddProvider(&AppleNotifyProvider{topic, apns2.NewTokenClient(&token.Token{
|
||||
AuthKey: authKey,
|
||||
KeyID: keyId,
|
||||
TeamID: teamId,
|
||||
}).Production()})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
11
pkg/internal/provider/interface.go
Normal file
11
pkg/internal/provider/interface.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||
)
|
||||
|
||||
type NotificationProvider interface {
|
||||
Push(in pushkit.Notification, tk string) error
|
||||
|
||||
GetName() string
|
||||
}
|
51
pkg/internal/scheduler/dispatch.go
Normal file
51
pkg/internal/scheduler/dispatch.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package scheduler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/rx"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/internal/gap"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/internal/provider"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
var validate = validator.New(validator.WithRequiredStructEnabled())
|
||||
|
||||
func SubscribeToQueue() error {
|
||||
mq, err := rx.NewMqConn(gap.Nx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to initialize Nex.Rx connection: %v", err)
|
||||
}
|
||||
|
||||
_, err = mq.Nt.Subscribe(pushkit.PushNotificationMqTopic, func(msg *nats.Msg) {
|
||||
var req pushkit.NotificationPushRequest
|
||||
if json.Unmarshal(msg.Data, &req) != nil {
|
||||
return
|
||||
} else if validate.Struct(&req) != nil {
|
||||
return
|
||||
}
|
||||
|
||||
go provider.PushNotification(req)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to subscribe notification topic: %v", err)
|
||||
}
|
||||
|
||||
_, err = mq.Nt.Subscribe(pushkit.PushNotificationBatchMqTopic, func(msg *nats.Msg) {
|
||||
var req pushkit.NotificationPushBatchRequest
|
||||
if json.Unmarshal(msg.Data, &req) != nil {
|
||||
return
|
||||
} else if validate.Struct(&req) != nil {
|
||||
return
|
||||
}
|
||||
|
||||
go provider.PushNotificationBatch(req)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to subscribe notification batch topic: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
101
pkg/main.go
Normal file
101
pkg/main.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
pkg "git.solsynth.dev/hypernet/pusher/pkg/internal"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/internal/gap"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/internal/grpc"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/internal/provider"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/internal/scheduler"
|
||||
"github.com/fatih/color"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func init() {
|
||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout})
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Booting screen
|
||||
fmt.Println(color.YellowString(` ____ _
|
||||
| _ \ _ _ ___| |__ ___ _ __
|
||||
| |_) | | | / __| '_ \ / _ \ '__|
|
||||
| __/| |_| \__ \ | | | __/ |
|
||||
|_| \__,_|___/_| |_|\___|_|`))
|
||||
fmt.Printf("%s v%s\n", color.New(color.FgHiYellow).Add(color.Bold).Sprintf("Hypernet.Pusher"), pkg.AppVersion)
|
||||
fmt.Printf("The notification / email delivery service in Hypernet\n")
|
||||
color.HiBlack("=====================================================\n")
|
||||
|
||||
// Configure settings
|
||||
viper.AddConfigPath(".")
|
||||
viper.AddConfigPath("..")
|
||||
viper.SetConfigName("settings")
|
||||
viper.SetConfigType("toml")
|
||||
|
||||
// Load settings
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
log.Panic().Err(err).Msg("An error occurred when loading settings.")
|
||||
}
|
||||
|
||||
// Connect to nexus
|
||||
if err := gap.InitializeToNexus(); err != nil {
|
||||
log.Fatal().Err(err).Msg("An error occurred when connecting to nexus...")
|
||||
} else {
|
||||
log.Info().Msg("Connected to nexus successfully!")
|
||||
}
|
||||
|
||||
// Initialize pusher conn
|
||||
fcmCredentials := viper.GetString("provider.fcm.credentials")
|
||||
if len(fcmCredentials) > 0 {
|
||||
if err := provider.InitFCM(fcmCredentials); err != nil {
|
||||
log.Fatal().Err(err).Msg("An error occurred when initializing FCM connection...")
|
||||
} else {
|
||||
log.Info().Msg("Pusher conn with FCM is initialized!")
|
||||
}
|
||||
} else {
|
||||
log.Warn().Msg("Pusher conn with FCM was not configured...")
|
||||
}
|
||||
apnCredentials := viper.GetString("provider.apns.credentials")
|
||||
if len(apnCredentials) > 0 {
|
||||
key := viper.GetString("provider.apns.key")
|
||||
team := viper.GetString("provider.apns.team")
|
||||
topic := viper.GetString("provider.apns.topic")
|
||||
if err := provider.InitAPN(apnCredentials, key, team, topic); err != nil {
|
||||
log.Fatal().Err(err).Msg("An error occurred when initializing APN connection...")
|
||||
} else {
|
||||
log.Info().Msg("Pusher conn with APN is initialized!")
|
||||
}
|
||||
} else {
|
||||
log.Warn().Msg("Pusher conn with APN was not configured...")
|
||||
}
|
||||
|
||||
// Subscribe to MQ
|
||||
if err := scheduler.SubscribeToQueue(); err != nil {
|
||||
log.Error().Err(err).Msg("Unable to subscribe to MQ via nexus, cannot get push requests from MQ...")
|
||||
} else {
|
||||
log.Info().Msg("Subscribed to MQ!")
|
||||
}
|
||||
|
||||
// Grpc Server
|
||||
go grpc.NewServer().Listen()
|
||||
|
||||
// Configure timed tasks
|
||||
quartz := cron.New(cron.WithLogger(cron.VerbosePrintfLogger(&log.Logger)))
|
||||
quartz.Start()
|
||||
|
||||
// Messages
|
||||
quit := make(chan os.Signal, 1)
|
||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||
<-quit
|
||||
|
||||
quartz.Stop()
|
||||
}
|
589
pkg/proto/pusher.pb.go
Normal file
589
pkg/proto/pusher.pb.go
Normal file
@@ -0,0 +1,589 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.35.1
|
||||
// protoc v5.28.2
|
||||
// source: pusher.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type NotifyInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
|
||||
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
|
||||
Subtitle *string `protobuf:"bytes,3,opt,name=subtitle,proto3,oneof" json:"subtitle,omitempty"`
|
||||
Body string `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
|
||||
Metadata []byte `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
Priority int32 `protobuf:"varint,6,opt,name=priority,proto3" json:"priority,omitempty"`
|
||||
}
|
||||
|
||||
func (x *NotifyInfo) Reset() {
|
||||
*x = NotifyInfo{}
|
||||
mi := &file_pusher_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *NotifyInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*NotifyInfo) ProtoMessage() {}
|
||||
|
||||
func (x *NotifyInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pusher_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use NotifyInfo.ProtoReflect.Descriptor instead.
|
||||
func (*NotifyInfo) Descriptor() ([]byte, []int) {
|
||||
return file_pusher_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *NotifyInfo) GetTopic() string {
|
||||
if x != nil {
|
||||
return x.Topic
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NotifyInfo) GetTitle() string {
|
||||
if x != nil {
|
||||
return x.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NotifyInfo) GetSubtitle() string {
|
||||
if x != nil && x.Subtitle != nil {
|
||||
return *x.Subtitle
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NotifyInfo) GetBody() string {
|
||||
if x != nil {
|
||||
return x.Body
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *NotifyInfo) GetMetadata() []byte {
|
||||
if x != nil {
|
||||
return x.Metadata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *NotifyInfo) GetPriority() int32 {
|
||||
if x != nil {
|
||||
return x.Priority
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type PushNotificationRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Provider string `protobuf:"bytes,1,opt,name=provider,proto3" json:"provider,omitempty"`
|
||||
DeviceToken string `protobuf:"bytes,2,opt,name=device_token,json=deviceToken,proto3" json:"device_token,omitempty"`
|
||||
Notify *NotifyInfo `protobuf:"bytes,3,opt,name=notify,proto3" json:"notify,omitempty"`
|
||||
}
|
||||
|
||||
func (x *PushNotificationRequest) Reset() {
|
||||
*x = PushNotificationRequest{}
|
||||
mi := &file_pusher_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *PushNotificationRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PushNotificationRequest) ProtoMessage() {}
|
||||
|
||||
func (x *PushNotificationRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pusher_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PushNotificationRequest.ProtoReflect.Descriptor instead.
|
||||
func (*PushNotificationRequest) Descriptor() ([]byte, []int) {
|
||||
return file_pusher_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *PushNotificationRequest) GetProvider() string {
|
||||
if x != nil {
|
||||
return x.Provider
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PushNotificationRequest) GetDeviceToken() string {
|
||||
if x != nil {
|
||||
return x.DeviceToken
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PushNotificationRequest) GetNotify() *NotifyInfo {
|
||||
if x != nil {
|
||||
return x.Notify
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type PushNotificationBatchRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Providers []string `protobuf:"bytes,1,rep,name=provider,proto3" json:"provider,omitempty"`
|
||||
DeviceTokens []string `protobuf:"bytes,2,rep,name=device_tokens,json=deviceTokens,proto3" json:"device_tokens,omitempty"`
|
||||
Notify *NotifyInfo `protobuf:"bytes,3,opt,name=notify,proto3" json:"notify,omitempty"`
|
||||
}
|
||||
|
||||
func (x *PushNotificationBatchRequest) Reset() {
|
||||
*x = PushNotificationBatchRequest{}
|
||||
mi := &file_pusher_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *PushNotificationBatchRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PushNotificationBatchRequest) ProtoMessage() {}
|
||||
|
||||
func (x *PushNotificationBatchRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pusher_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PushNotificationBatchRequest.ProtoReflect.Descriptor instead.
|
||||
func (*PushNotificationBatchRequest) Descriptor() ([]byte, []int) {
|
||||
return file_pusher_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *PushNotificationBatchRequest) GetProviders() []string {
|
||||
if x != nil {
|
||||
return x.Providers
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PushNotificationBatchRequest) GetDeviceTokens() []string {
|
||||
if x != nil {
|
||||
return x.DeviceTokens
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PushNotificationBatchRequest) GetNotify() *NotifyInfo {
|
||||
if x != nil {
|
||||
return x.Notify
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type EmailInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Subject string `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"`
|
||||
TextBody *string `protobuf:"bytes,2,opt,name=text_body,json=textBody,proto3,oneof" json:"text_body,omitempty"`
|
||||
HtmlBody *string `protobuf:"bytes,3,opt,name=html_body,json=htmlBody,proto3,oneof" json:"html_body,omitempty"`
|
||||
}
|
||||
|
||||
func (x *EmailInfo) Reset() {
|
||||
*x = EmailInfo{}
|
||||
mi := &file_pusher_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *EmailInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*EmailInfo) ProtoMessage() {}
|
||||
|
||||
func (x *EmailInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pusher_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use EmailInfo.ProtoReflect.Descriptor instead.
|
||||
func (*EmailInfo) Descriptor() ([]byte, []int) {
|
||||
return file_pusher_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *EmailInfo) GetSubject() string {
|
||||
if x != nil {
|
||||
return x.Subject
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *EmailInfo) GetTextBody() string {
|
||||
if x != nil && x.TextBody != nil {
|
||||
return *x.TextBody
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *EmailInfo) GetHtmlBody() string {
|
||||
if x != nil && x.HtmlBody != nil {
|
||||
return *x.HtmlBody
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type DeliverEmailRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
To string `protobuf:"bytes,1,opt,name=to,proto3" json:"to,omitempty"`
|
||||
Email *EmailInfo `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DeliverEmailRequest) Reset() {
|
||||
*x = DeliverEmailRequest{}
|
||||
mi := &file_pusher_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DeliverEmailRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeliverEmailRequest) ProtoMessage() {}
|
||||
|
||||
func (x *DeliverEmailRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pusher_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeliverEmailRequest.ProtoReflect.Descriptor instead.
|
||||
func (*DeliverEmailRequest) Descriptor() ([]byte, []int) {
|
||||
return file_pusher_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *DeliverEmailRequest) GetTo() string {
|
||||
if x != nil {
|
||||
return x.To
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DeliverEmailRequest) GetEmail() *EmailInfo {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeliverEmailBatchRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
To []string `protobuf:"bytes,1,rep,name=to,proto3" json:"to,omitempty"`
|
||||
Email *EmailInfo `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DeliverEmailBatchRequest) Reset() {
|
||||
*x = DeliverEmailBatchRequest{}
|
||||
mi := &file_pusher_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DeliverEmailBatchRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeliverEmailBatchRequest) ProtoMessage() {}
|
||||
|
||||
func (x *DeliverEmailBatchRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pusher_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeliverEmailBatchRequest.ProtoReflect.Descriptor instead.
|
||||
func (*DeliverEmailBatchRequest) Descriptor() ([]byte, []int) {
|
||||
return file_pusher_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *DeliverEmailBatchRequest) GetTo() []string {
|
||||
if x != nil {
|
||||
return x.To
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *DeliverEmailBatchRequest) GetEmail() *EmailInfo {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeliveryResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DeliveryResponse) Reset() {
|
||||
*x = DeliveryResponse{}
|
||||
mi := &file_pusher_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DeliveryResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeliveryResponse) ProtoMessage() {}
|
||||
|
||||
func (x *DeliveryResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pusher_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeliveryResponse.ProtoReflect.Descriptor instead.
|
||||
func (*DeliveryResponse) Descriptor() ([]byte, []int) {
|
||||
return file_pusher_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *DeliveryResponse) GetIsSuccess() bool {
|
||||
if x != nil {
|
||||
return x.IsSuccess
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_pusher_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_pusher_proto_rawDesc = []byte{
|
||||
0x0a, 0x0c, 0x70, 0x75, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x01, 0x0a, 0x0a, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79,
|
||||
0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69,
|
||||
0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65,
|
||||
0x12, 0x1f, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x73, 0x75, 0x62, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x88, 0x01,
|
||||
0x01, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
|
||||
0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
|
||||
0x61, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x42, 0x0b, 0x0a,
|
||||
0x09, 0x5f, 0x73, 0x75, 0x62, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x83, 0x01, 0x0a, 0x17, 0x50,
|
||||
0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64,
|
||||
0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64,
|
||||
0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x6b,
|
||||
0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65,
|
||||
0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x29, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f,
|
||||
0x74, 0x69, 0x66, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79,
|
||||
0x22, 0x8c, 0x01, 0x0a, 0x1c, 0x50, 0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01,
|
||||
0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12,
|
||||
0x23, 0x0a, 0x0d, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73,
|
||||
0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x6f,
|
||||
0x6b, 0x65, 0x6e, 0x73, 0x12, 0x29, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74,
|
||||
0x69, 0x66, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x22,
|
||||
0x85, 0x01, 0x0a, 0x09, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
|
||||
0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x20, 0x0a, 0x09, 0x74, 0x65, 0x78, 0x74, 0x5f,
|
||||
0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x74, 0x65,
|
||||
0x78, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x88, 0x01, 0x01, 0x12, 0x20, 0x0a, 0x09, 0x68, 0x74, 0x6d,
|
||||
0x6c, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x08,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0x42, 0x6f, 0x64, 0x79, 0x88, 0x01, 0x01, 0x42, 0x0c, 0x0a, 0x0a, 0x5f,
|
||||
0x74, 0x65, 0x78, 0x74, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x4d, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x69, 0x76,
|
||||
0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e,
|
||||
0x0a, 0x02, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x74, 0x6f, 0x12, 0x26,
|
||||
0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x52,
|
||||
0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x52, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65,
|
||||
0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02,
|
||||
0x74, 0x6f, 0x12, 0x26, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49,
|
||||
0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x31, 0x0a, 0x10, 0x44, 0x65,
|
||||
0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d,
|
||||
0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x32, 0xcf, 0x02,
|
||||
0x0a, 0x0d, 0x50, 0x75, 0x73, 0x68, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
|
||||
0x4d, 0x0a, 0x10, 0x50, 0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68,
|
||||
0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c, 0x69,
|
||||
0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57,
|
||||
0x0a, 0x15, 0x50, 0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
|
||||
0x50, 0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x69, 0x76,
|
||||
0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
|
||||
0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c, 0x69,
|
||||
0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f,
|
||||
0x0a, 0x11, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x61,
|
||||
0x74, 0x63, 0x68, 0x12, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c, 0x69,
|
||||
0x76, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c,
|
||||
0x69, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42,
|
||||
0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_pusher_proto_rawDescOnce sync.Once
|
||||
file_pusher_proto_rawDescData = file_pusher_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_pusher_proto_rawDescGZIP() []byte {
|
||||
file_pusher_proto_rawDescOnce.Do(func() {
|
||||
file_pusher_proto_rawDescData = protoimpl.X.CompressGZIP(file_pusher_proto_rawDescData)
|
||||
})
|
||||
return file_pusher_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_pusher_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_pusher_proto_goTypes = []any{
|
||||
(*NotifyInfo)(nil), // 0: proto.NotifyInfo
|
||||
(*PushNotificationRequest)(nil), // 1: proto.PushNotificationRequest
|
||||
(*PushNotificationBatchRequest)(nil), // 2: proto.PushNotificationBatchRequest
|
||||
(*EmailInfo)(nil), // 3: proto.EmailInfo
|
||||
(*DeliverEmailRequest)(nil), // 4: proto.DeliverEmailRequest
|
||||
(*DeliverEmailBatchRequest)(nil), // 5: proto.DeliverEmailBatchRequest
|
||||
(*DeliveryResponse)(nil), // 6: proto.DeliveryResponse
|
||||
}
|
||||
var file_pusher_proto_depIdxs = []int32{
|
||||
0, // 0: proto.PushNotificationRequest.notify:type_name -> proto.NotifyInfo
|
||||
0, // 1: proto.PushNotificationBatchRequest.notify:type_name -> proto.NotifyInfo
|
||||
3, // 2: proto.DeliverEmailRequest.email:type_name -> proto.EmailInfo
|
||||
3, // 3: proto.DeliverEmailBatchRequest.email:type_name -> proto.EmailInfo
|
||||
1, // 4: proto.PusherService.PushNotification:input_type -> proto.PushNotificationRequest
|
||||
2, // 5: proto.PusherService.PushNotificationBatch:input_type -> proto.PushNotificationBatchRequest
|
||||
4, // 6: proto.PusherService.DeliverEmail:input_type -> proto.DeliverEmailRequest
|
||||
5, // 7: proto.PusherService.DeliverEmailBatch:input_type -> proto.DeliverEmailBatchRequest
|
||||
6, // 8: proto.PusherService.PushNotification:output_type -> proto.DeliveryResponse
|
||||
6, // 9: proto.PusherService.PushNotificationBatch:output_type -> proto.DeliveryResponse
|
||||
6, // 10: proto.PusherService.DeliverEmail:output_type -> proto.DeliveryResponse
|
||||
6, // 11: proto.PusherService.DeliverEmailBatch:output_type -> proto.DeliveryResponse
|
||||
8, // [8:12] is the sub-list for method output_type
|
||||
4, // [4:8] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_pusher_proto_init() }
|
||||
func file_pusher_proto_init() {
|
||||
if File_pusher_proto != nil {
|
||||
return
|
||||
}
|
||||
file_pusher_proto_msgTypes[0].OneofWrappers = []any{}
|
||||
file_pusher_proto_msgTypes[3].OneofWrappers = []any{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_pusher_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_pusher_proto_goTypes,
|
||||
DependencyIndexes: file_pusher_proto_depIdxs,
|
||||
MessageInfos: file_pusher_proto_msgTypes,
|
||||
}.Build()
|
||||
File_pusher_proto = out.File
|
||||
file_pusher_proto_rawDesc = nil
|
||||
file_pusher_proto_goTypes = nil
|
||||
file_pusher_proto_depIdxs = nil
|
||||
}
|
57
pkg/proto/pusher.proto
Normal file
57
pkg/proto/pusher.proto
Normal file
@@ -0,0 +1,57 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = ".;proto";
|
||||
|
||||
package proto;
|
||||
|
||||
service PusherService {
|
||||
rpc PushNotification(PushNotificationRequest) returns (DeliveryResponse) {}
|
||||
rpc PushNotificationBatch(PushNotificationBatchRequest) returns (DeliveryResponse) {}
|
||||
rpc DeliverEmail(DeliverEmailRequest) returns (DeliveryResponse) {}
|
||||
rpc DeliverEmailBatch(DeliverEmailBatchRequest) returns (DeliveryResponse) {}
|
||||
}
|
||||
|
||||
// Notifications parts
|
||||
|
||||
message NotifyInfo {
|
||||
string topic = 1;
|
||||
string title = 2;
|
||||
optional string subtitle = 3;
|
||||
string body = 4;
|
||||
bytes metadata = 5;
|
||||
int32 priority = 6;
|
||||
}
|
||||
|
||||
message PushNotificationRequest {
|
||||
string provider = 1;
|
||||
string device_token = 2;
|
||||
NotifyInfo notify = 3;
|
||||
}
|
||||
|
||||
message PushNotificationBatchRequest {
|
||||
repeated string providers = 1;
|
||||
repeated string device_tokens = 2;
|
||||
NotifyInfo notify = 3;
|
||||
}
|
||||
|
||||
// Email parts
|
||||
|
||||
message EmailInfo {
|
||||
string subject = 1;
|
||||
optional string text_body = 2;
|
||||
optional string html_body = 3;
|
||||
}
|
||||
|
||||
message DeliverEmailRequest {
|
||||
string to = 1;
|
||||
EmailInfo email = 2;
|
||||
}
|
||||
|
||||
message DeliverEmailBatchRequest {
|
||||
repeated string to = 1;
|
||||
EmailInfo email = 2;
|
||||
}
|
||||
|
||||
message DeliveryResponse {
|
||||
bool is_success = 1;
|
||||
}
|
235
pkg/proto/pusher_grpc.pb.go
Normal file
235
pkg/proto/pusher_grpc.pb.go
Normal file
@@ -0,0 +1,235 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.28.2
|
||||
// source: pusher.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
PusherService_PushNotification_FullMethodName = "/proto.PusherService/PushNotification"
|
||||
PusherService_PushNotificationBatch_FullMethodName = "/proto.PusherService/PushNotificationBatch"
|
||||
PusherService_DeliverEmail_FullMethodName = "/proto.PusherService/DeliverEmail"
|
||||
PusherService_DeliverEmailBatch_FullMethodName = "/proto.PusherService/DeliverEmailBatch"
|
||||
)
|
||||
|
||||
// PusherServiceClient is the client API for PusherService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type PusherServiceClient interface {
|
||||
PushNotification(ctx context.Context, in *PushNotificationRequest, opts ...grpc.CallOption) (*DeliveryResponse, error)
|
||||
PushNotificationBatch(ctx context.Context, in *PushNotificationBatchRequest, opts ...grpc.CallOption) (*DeliveryResponse, error)
|
||||
DeliverEmail(ctx context.Context, in *DeliverEmailRequest, opts ...grpc.CallOption) (*DeliveryResponse, error)
|
||||
DeliverEmailBatch(ctx context.Context, in *DeliverEmailBatchRequest, opts ...grpc.CallOption) (*DeliveryResponse, error)
|
||||
}
|
||||
|
||||
type pusherServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewPusherServiceClient(cc grpc.ClientConnInterface) PusherServiceClient {
|
||||
return &pusherServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *pusherServiceClient) PushNotification(ctx context.Context, in *PushNotificationRequest, opts ...grpc.CallOption) (*DeliveryResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(DeliveryResponse)
|
||||
err := c.cc.Invoke(ctx, PusherService_PushNotification_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *pusherServiceClient) PushNotificationBatch(ctx context.Context, in *PushNotificationBatchRequest, opts ...grpc.CallOption) (*DeliveryResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(DeliveryResponse)
|
||||
err := c.cc.Invoke(ctx, PusherService_PushNotificationBatch_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *pusherServiceClient) DeliverEmail(ctx context.Context, in *DeliverEmailRequest, opts ...grpc.CallOption) (*DeliveryResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(DeliveryResponse)
|
||||
err := c.cc.Invoke(ctx, PusherService_DeliverEmail_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *pusherServiceClient) DeliverEmailBatch(ctx context.Context, in *DeliverEmailBatchRequest, opts ...grpc.CallOption) (*DeliveryResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(DeliveryResponse)
|
||||
err := c.cc.Invoke(ctx, PusherService_DeliverEmailBatch_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// PusherServiceServer is the server API for PusherService service.
|
||||
// All implementations must embed UnimplementedPusherServiceServer
|
||||
// for forward compatibility.
|
||||
type PusherServiceServer interface {
|
||||
PushNotification(context.Context, *PushNotificationRequest) (*DeliveryResponse, error)
|
||||
PushNotificationBatch(context.Context, *PushNotificationBatchRequest) (*DeliveryResponse, error)
|
||||
DeliverEmail(context.Context, *DeliverEmailRequest) (*DeliveryResponse, error)
|
||||
DeliverEmailBatch(context.Context, *DeliverEmailBatchRequest) (*DeliveryResponse, error)
|
||||
mustEmbedUnimplementedPusherServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedPusherServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedPusherServiceServer struct{}
|
||||
|
||||
func (UnimplementedPusherServiceServer) PushNotification(context.Context, *PushNotificationRequest) (*DeliveryResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PushNotification not implemented")
|
||||
}
|
||||
func (UnimplementedPusherServiceServer) PushNotificationBatch(context.Context, *PushNotificationBatchRequest) (*DeliveryResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PushNotificationBatch not implemented")
|
||||
}
|
||||
func (UnimplementedPusherServiceServer) DeliverEmail(context.Context, *DeliverEmailRequest) (*DeliveryResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeliverEmail not implemented")
|
||||
}
|
||||
func (UnimplementedPusherServiceServer) DeliverEmailBatch(context.Context, *DeliverEmailBatchRequest) (*DeliveryResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeliverEmailBatch not implemented")
|
||||
}
|
||||
func (UnimplementedPusherServiceServer) mustEmbedUnimplementedPusherServiceServer() {}
|
||||
func (UnimplementedPusherServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafePusherServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to PusherServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafePusherServiceServer interface {
|
||||
mustEmbedUnimplementedPusherServiceServer()
|
||||
}
|
||||
|
||||
func RegisterPusherServiceServer(s grpc.ServiceRegistrar, srv PusherServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedPusherServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&PusherService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _PusherService_PushNotification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PushNotificationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PusherServiceServer).PushNotification(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: PusherService_PushNotification_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PusherServiceServer).PushNotification(ctx, req.(*PushNotificationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PusherService_PushNotificationBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PushNotificationBatchRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PusherServiceServer).PushNotificationBatch(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: PusherService_PushNotificationBatch_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PusherServiceServer).PushNotificationBatch(ctx, req.(*PushNotificationBatchRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PusherService_DeliverEmail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeliverEmailRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PusherServiceServer).DeliverEmail(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: PusherService_DeliverEmail_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PusherServiceServer).DeliverEmail(ctx, req.(*DeliverEmailRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PusherService_DeliverEmailBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeliverEmailBatchRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PusherServiceServer).DeliverEmailBatch(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: PusherService_DeliverEmailBatch_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PusherServiceServer).DeliverEmailBatch(ctx, req.(*DeliverEmailBatchRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// PusherService_ServiceDesc is the grpc.ServiceDesc for PusherService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var PusherService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "proto.PusherService",
|
||||
HandlerType: (*PusherServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "PushNotification",
|
||||
Handler: _PusherService_PushNotification_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PushNotificationBatch",
|
||||
Handler: _PusherService_PushNotificationBatch_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeliverEmail",
|
||||
Handler: _PusherService_DeliverEmail_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeliverEmailBatch",
|
||||
Handler: _PusherService_DeliverEmailBatch_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "pusher.proto",
|
||||
}
|
9
pkg/pushkit/const.go
Normal file
9
pkg/pushkit/const.go
Normal 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"
|
||||
)
|
38
pkg/pushkit/notification.go
Normal file
38
pkg/pushkit/notification.go
Normal 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()),
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user