Postman the notifier

This commit is contained in:
2024-07-21 13:51:46 +08:00
parent 037fc8a18c
commit d74cdddbaf
22 changed files with 1361 additions and 195 deletions

View File

@ -0,0 +1,41 @@
package grpc
import (
"context"
"git.solsynth.dev/hydrogen/dealer/pkg/internal/services"
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
)
func (v *Server) DeliverNotification(ctx context.Context, request *proto.DeliverNotificationRequest) (*proto.DeliverResponse, error) {
services.PublishDeliveryTask(request)
return &proto.DeliverResponse{}, nil
}
func (v *Server) DeliverNotificationBatch(ctx context.Context, request *proto.DeliverNotificationBatchRequest) (*proto.DeliverResponse, error) {
for idx, provider := range request.GetProviders() {
token := request.GetDeviceTokens()[idx]
services.PublishDeliveryTask(&proto.DeliverNotificationRequest{
Provider: provider,
DeviceToken: token,
Notify: request.GetNotify(),
})
}
return &proto.DeliverResponse{}, nil
}
func (v *Server) DeliverEmail(ctx context.Context, request *proto.DeliverEmailRequest) (*proto.DeliverResponse, error) {
services.PublishDeliveryTask(request)
return &proto.DeliverResponse{}, nil
}
func (v *Server) DeliverEmailBatch(ctx context.Context, request *proto.DeliverEmailBatchRequest) (*proto.DeliverResponse, error) {
for _, to := range request.GetTo() {
services.PublishDeliveryTask(&proto.DeliverEmailRequest{
To: to,
Email: request.GetEmail(),
})
}
return &proto.DeliverResponse{}, nil
}

View File

@ -16,6 +16,7 @@ import (
type Server struct {
proto.UnimplementedServiceDirectoryServer
proto.UnimplementedStreamControllerServer
proto.UnimplementedPostmanServer
proto.UnimplementedAuthServer
srv *grpc.Server
@ -29,6 +30,7 @@ func NewServer() *Server {
proto.RegisterServiceDirectoryServer(server.srv, server)
proto.RegisterStreamControllerServer(server.srv, server)
proto.RegisterAuthServer(server.srv, server)
proto.RegisterPostmanServer(server.srv, server)
health.RegisterHealthServer(server.srv, server)
reflection.Register(server.srv)