From eb9eeb518f41f3bb07c5eeadfd4f526b5a7ec6d1 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 29 Nov 2024 15:52:44 -0800 Subject: [PATCH] something like this --- pkg/service/submissions.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/service/submissions.go b/pkg/service/submissions.go index 32e2a0e..60add5f 100644 --- a/pkg/service/submissions.go +++ b/pkg/service/submissions.go @@ -302,7 +302,14 @@ func (svc *Service) ActionSubmissionTriggerPublish(ctx context.Context, params a // transaction smap := datastore.Optional() smap.Add("status_id",model.StatusPublishing) - return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.Status{model.StatusValidated}, smap) + err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.Status{model.StatusValidated}, smap) + if err != nil{ + return err + } + + svc.Nats.Publish("publish", []byte(params.SubmissionID)) + + return nil } // ActionSubmissionTriggerValidate invokes actionSubmissionTriggerValidate operation. // @@ -323,7 +330,14 @@ func (svc *Service) ActionSubmissionTriggerValidate(ctx context.Context, params // transaction smap := datastore.Optional() smap.Add("status_id",model.StatusValidating) - return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.Status{model.StatusSubmitted,model.StatusAccepted}, smap) + err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.Status{model.StatusSubmitted,model.StatusAccepted}, smap) + if err != nil{ + return err + } + + svc.Nats.Publish("validate", []byte(params.SubmissionID)) + + return nil } // ActionSubmissionValidate invokes actionSubmissionValidate operation. //