Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
86 lines
2.7 KiB
Go
86 lines
2.7 KiB
Go
package notifications
|
|
|
|
import (
|
|
"context"
|
|
|
|
gmessaging "github.com/tech/sendico/pkg/generated/gmessaging"
|
|
me "github.com/tech/sendico/pkg/messaging/envelope"
|
|
internalsite "github.com/tech/sendico/pkg/messaging/internal/notifications/site"
|
|
np "github.com/tech/sendico/pkg/messaging/notifications/processor"
|
|
handler "github.com/tech/sendico/pkg/messaging/notifications/site/handler"
|
|
"github.com/tech/sendico/pkg/mlogger"
|
|
"github.com/tech/sendico/pkg/model"
|
|
"go.uber.org/zap"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
type DemoRequestProcessor struct {
|
|
logger mlogger.Logger
|
|
handler handler.DemoRequestHandler
|
|
event model.NotificationEvent
|
|
}
|
|
|
|
func (drp *DemoRequestProcessor) Process(ctx context.Context, envelope me.Envelope) error {
|
|
var msg gmessaging.DemoRequestEvent
|
|
if err := proto.Unmarshal(envelope.GetData(), &msg); err != nil {
|
|
drp.logger.Warn("Failed to decode demo request envelope", zap.Error(err), zap.String("topic", drp.event.ToString()))
|
|
return err
|
|
}
|
|
request := &model.DemoRequest{
|
|
Name: msg.GetName(),
|
|
OrganizationName: msg.GetOrganizationName(),
|
|
Phone: msg.GetPhone(),
|
|
WorkEmail: msg.GetWorkEmail(),
|
|
PayoutVolume: msg.GetPayoutVolume(),
|
|
Comment: msg.GetComment(),
|
|
}
|
|
return drp.handler(ctx, request)
|
|
}
|
|
|
|
func (drp *DemoRequestProcessor) GetSubject() model.NotificationEvent {
|
|
return drp.event
|
|
}
|
|
|
|
func NewDemoRequestProcessor(logger mlogger.Logger, handler handler.DemoRequestHandler) np.EnvelopeProcessor {
|
|
return &DemoRequestProcessor{
|
|
logger: logger.Named("demo_request_processor"),
|
|
handler: handler,
|
|
event: internalsite.NewDemoRequestEvent(),
|
|
}
|
|
}
|
|
|
|
type ContactRequestProcessor struct {
|
|
logger mlogger.Logger
|
|
handler handler.ContactRequestHandler
|
|
event model.NotificationEvent
|
|
}
|
|
|
|
func (crp *ContactRequestProcessor) Process(ctx context.Context, envelope me.Envelope) error {
|
|
var msg gmessaging.ContactRequestEvent
|
|
if err := proto.Unmarshal(envelope.GetData(), &msg); err != nil {
|
|
crp.logger.Warn("Failed to decode contact request envelope", zap.Error(err), zap.String("topic", crp.event.ToString()))
|
|
return err
|
|
}
|
|
request := &model.ContactRequest{
|
|
Name: msg.GetName(),
|
|
Email: msg.GetEmail(),
|
|
Phone: msg.GetPhone(),
|
|
Company: msg.GetCompany(),
|
|
Topic: msg.GetTopic(),
|
|
Message: msg.GetMessage(),
|
|
}
|
|
return crp.handler(ctx, request)
|
|
}
|
|
|
|
func (crp *ContactRequestProcessor) GetSubject() model.NotificationEvent {
|
|
return crp.event
|
|
}
|
|
|
|
func NewContactRequestProcessor(logger mlogger.Logger, handler handler.ContactRequestHandler) np.EnvelopeProcessor {
|
|
return &ContactRequestProcessor{
|
|
logger: logger.Named("contact_request_processor"),
|
|
handler: handler,
|
|
event: internalsite.NewContactRequestEvent(),
|
|
}
|
|
}
|