+ call request
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/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
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
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/frontend Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
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
This commit is contained in:
11
api/pkg/messaging/notifications/site/call_request.go
Normal file
11
api/pkg/messaging/notifications/site/call_request.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package notifications
|
||||
|
||||
import (
|
||||
messaging "github.com/tech/sendico/pkg/messaging/envelope"
|
||||
internalsite "github.com/tech/sendico/pkg/messaging/internal/notifications/site"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
)
|
||||
|
||||
func CallRequest(sender string, request *model.CallRequest) messaging.Envelope {
|
||||
return internalsite.NewCallRequestEnvelope(sender, request)
|
||||
}
|
||||
@@ -8,3 +8,4 @@ import (
|
||||
|
||||
type DemoRequestHandler = func(context.Context, *model.DemoRequest) error
|
||||
type ContactRequestHandler = func(context.Context, *model.ContactRequest) error
|
||||
type CallRequestHandler = func(context.Context, *model.CallRequest) error
|
||||
|
||||
@@ -18,6 +18,7 @@ type SiteRequestProcessor struct {
|
||||
logger mlogger.Logger
|
||||
demoHandler handler.DemoRequestHandler
|
||||
contactHandler handler.ContactRequestHandler
|
||||
callHandler handler.CallRequestHandler
|
||||
event model.NotificationEvent
|
||||
}
|
||||
|
||||
@@ -67,6 +68,25 @@ func (srp *SiteRequestProcessor) Process(ctx context.Context, envelope me.Envelo
|
||||
Message: contact.GetMessage(),
|
||||
}
|
||||
return srp.contactHandler(ctx, request)
|
||||
case gmessaging.SiteRequestEvent_REQUEST_TYPE_CALL:
|
||||
if srp.callHandler == nil {
|
||||
srp.logger.Warn("Call request handler is not configured")
|
||||
return nil
|
||||
}
|
||||
call := msg.GetCall()
|
||||
if call == nil {
|
||||
srp.logger.Warn("Call request payload is empty")
|
||||
return nil
|
||||
}
|
||||
request := &model.CallRequest{
|
||||
Name: call.GetName(),
|
||||
Phone: call.GetPhone(),
|
||||
Email: call.GetEmail(),
|
||||
Company: call.GetCompany(),
|
||||
PreferredTime: call.GetPreferredTime(),
|
||||
Message: call.GetMessage(),
|
||||
}
|
||||
return srp.callHandler(ctx, request)
|
||||
default:
|
||||
srp.logger.Warn("Received site request with unsupported type", zap.Any("type", msg.GetType()))
|
||||
return nil
|
||||
@@ -77,11 +97,12 @@ func (srp *SiteRequestProcessor) GetSubject() model.NotificationEvent {
|
||||
return srp.event
|
||||
}
|
||||
|
||||
func NewSiteRequestProcessor(logger mlogger.Logger, demo handler.DemoRequestHandler, contact handler.ContactRequestHandler) np.EnvelopeProcessor {
|
||||
func NewSiteRequestProcessor(logger mlogger.Logger, demo handler.DemoRequestHandler, contact handler.ContactRequestHandler, call handler.CallRequestHandler) np.EnvelopeProcessor {
|
||||
return &SiteRequestProcessor{
|
||||
logger: logger.Named("site_request_processor"),
|
||||
demoHandler: demo,
|
||||
contactHandler: contact,
|
||||
callHandler: call,
|
||||
event: internalsite.NewDemoRequestEvent(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user