Pusher/pkg/internal/grpc/pusher.go
2024-10-25 00:56:22 +08:00

37 lines
1.3 KiB
Go

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")
}