Skip to content

Commit

Permalink
Merge pull request #83 from weni-ai/fix/product-card-panic
Browse files Browse the repository at this point in the history
Manipulate function return to avoid errors
  • Loading branch information
Robi9 authored Oct 8, 2024
2 parents bd34c57 + 0f4c1f3 commit 2b8f1b2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions flows/actions/send_msg_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,25 @@ func (a *SendMsgCatalogAction) Execute(run flows.FlowRun, step flows.Step, logMo
}

params := assets.NewMsgCatalogParam(evaluatedSearch, uuids.UUID(dest.Channel.UUID()), a.SearchType, evaluatedURL, apiType, evaluatedPostalCode, evaluatedSellerId, hasVtexAds, language)
c, err := a.call(run, step, params, mc, logEvent)
catalogCall, err := a.call(run, step, params, mc, logEvent)
if err != nil {
for _, trace := range c.Traces {
call := &flows.WebhookCall{Trace: trace}
logEvent(events.NewWebhookCalled(call, callStatus(call, nil, true), ""))
if catalogCall != nil {
for _, trace := range catalogCall.Traces {
call := &flows.WebhookCall{Trace: trace}
if trace != nil {
logEvent(events.NewWebhookCalled(call, callStatus(call, nil, false), ""))
}
}
}
a.saveResult(run, step, a.ResultName, fmt.Sprintf("%s", err), CategoryFailure, "", "", nil, logEvent)
return nil
}
for _, trace := range c.Traces {
for _, trace := range catalogCall.Traces {
call := &flows.WebhookCall{Trace: trace}
logEvent(events.NewWebhookCalled(call, callStatus(call, nil, true), ""))
logEvent(events.NewWebhookCalled(call, callStatus(call, nil, false), ""))
}
a.saveResult(run, step, a.ResultName, string(c.ResponseJSON), CategorySuccess, "", "", c.ResponseJSON, logEvent)
ProductEntries = c.ProductRetailerIDS
a.saveResult(run, step, a.ResultName, string(catalogCall.ResponseJSON), CategorySuccess, "", "", catalogCall.ResponseJSON, logEvent)
ProductEntries = catalogCall.ProductRetailerIDS
} else {
a.saveResult(run, step, a.ResultName, "", CategorySuccess, "", "", nil, logEvent)
}
Expand Down

0 comments on commit 2b8f1b2

Please sign in to comment.