Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor evaluateMessageWpp to message list #82

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions flows/actions/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,34 @@ func (a *baseAction) evaluateMessageWpp(run flows.FlowRun, languages []envs.Lang
}

for i, item := range actionListItems {
evaluatedTitle, err := run.EvaluateTemplate(item.Title)
if err != nil {
logEvent(events.NewError(err))
translatedListMessage := run.GetTranslatedTextArray(uuids.UUID(a.UUID()), "list_message", []string{item.Title, item.Description}, languages)

if len(translatedListMessage[0]) == 0 {
continue
}
actionListItems[i].Title = evaluatedTitle

evaluatedDescription, err := run.EvaluateTemplate(item.Description)
evaluatedTitle, err := run.EvaluateTemplate(translatedListMessage[0])
if err != nil {
logEvent(events.NewError(err))
continue
}

var evaluatedDescription string
if len(translatedListMessage[1]) > 0 {
evaluatedDescription, err = run.EvaluateTemplate(translatedListMessage[1])
if err != nil {
logEvent(events.NewError(err))
}
}

if len(evaluatedTitle) == 0 && len(evaluatedDescription) == 0 {
logEvent(events.NewErrorf("option title and description evaluated to empty strings, skipping"))
continue
} else if len(evaluatedTitle) == 0 {
logEvent(events.NewErrorf("option title text evaluated to empty string"))
}

actionListItems[i].Title = evaluatedTitle
actionListItems[i].Description = evaluatedDescription
}

Expand Down
Loading