unified code verification service
This commit is contained in:
@@ -31,10 +31,10 @@ func (ccn *ConfirmationCodeNotification) Serialize() ([]byte, error) {
|
||||
}
|
||||
|
||||
func newConfirmationEvent(action nm.NotificationAction) model.NotificationEvent {
|
||||
return model.NewNotification(mservice.Confirmations, action)
|
||||
return model.NewNotification(mservice.Verification, action)
|
||||
}
|
||||
|
||||
func NewConfirmationCodeEnvelope(sender string, accountRef bson.ObjectID, destination string, target model.ConfirmationTarget, code string) messaging.Envelope {
|
||||
func NewConfirmationCodeEnvelope(sender string, accountRef bson.ObjectID, destination string, target model.VerificationPurpose, code string) messaging.Envelope {
|
||||
return &ConfirmationCodeNotification{
|
||||
Envelope: messaging.CreateEnvelope(sender, newConfirmationEvent(nm.NAPending)),
|
||||
payload: confirmationCodePayload{
|
||||
|
||||
@@ -42,10 +42,12 @@ func (ccp *ConfirmationCodeProcessor) Process(ctx context.Context, envelope me.E
|
||||
return err
|
||||
}
|
||||
|
||||
target := model.ConfirmationTarget(msg.Target)
|
||||
if target != model.ConfirmationTargetLogin && target != model.ConfirmationTargetPayout {
|
||||
return merrors.InvalidArgument("invalid confirmation target", "target")
|
||||
target, err := model.VPFromString(msg.Target)
|
||||
if err != nil {
|
||||
ccp.logger.Warn("Failed to parse confirmation target from envelope", zap.Error(err), zap.String("topic", ccp.event.ToString()), zap.String("target", msg.Target))
|
||||
return err
|
||||
}
|
||||
|
||||
if msg.Code == "" {
|
||||
return merrors.InvalidArgument("empty confirmation code", "code")
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func confirmationResultEvent(sourceService, rail string) model.NotificationEvent
|
||||
rail = "default"
|
||||
}
|
||||
rail = strings.ToLower(rail)
|
||||
return model.NewNotification(mservice.Confirmations, nm.NotificationAction(action+"."+rail))
|
||||
return model.NewNotification(mservice.Verification, nm.NotificationAction(action+"."+rail))
|
||||
}
|
||||
|
||||
func NewConfirmationRequestEnvelope(sender string, request *model.ConfirmationRequest) messaging.Envelope {
|
||||
|
||||
Reference in New Issue
Block a user