Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Jan 17, 2024
1 parent db985db commit 94e59fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
11 changes: 10 additions & 1 deletion flows/actions/send_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,16 @@ func (a *SendMsgAction) Execute(run flows.Run, step flows.Step, logModifier flow
}

evaluatedText = translation.Substitute(evaluatedVariables)
templating = flows.NewMsgTemplating(a.Templating.Template, evaluatedVariables, translation.Namespace())

params := map[string][]flows.TemplateParam{}
if len(evaluatedVariables) > 0 {
params = map[string][]flows.TemplateParam{"body": make([]flows.TemplateParam, len(evaluatedVariables))}
for i, v := range evaluatedVariables {
params["body"][i] = flows.TemplateParam{Type: "text", Value: v}
}
}

templating = flows.NewMsgTemplating(a.Templating.Template, params, translation.Namespace())
locale = translation.Locale()
}
}
Expand Down
9 changes: 1 addition & 8 deletions flows/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,7 @@ func (t MsgTemplating) Namespace() string { return t.Namespace_ }
func (t MsgTemplating) Params() map[string][]TemplateParam { return t.Params_ }

// NewMsgTemplating creates and returns a new msg template
func NewMsgTemplating(template *assets.TemplateReference, variables []string, namespace string) *MsgTemplating {
params := map[string][]TemplateParam{}
if len(variables) > 0 {
params = map[string][]TemplateParam{"body": make([]TemplateParam, len(variables))}
for i, v := range variables {
params["body"][i] = TemplateParam{Type: "text", Value: v}
}
}
func NewMsgTemplating(template *assets.TemplateReference, params map[string][]TemplateParam, namespace string) *MsgTemplating {

return &MsgTemplating{
Template_: template,
Expand Down
2 changes: 1 addition & 1 deletion flows/msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func TestMsgTemplating(t *testing.T) {

templateRef := assets.NewTemplateReference("61602f3e-f603-4c70-8a8f-c477505bf4bf", "Affirmation")

msgTemplating := flows.NewMsgTemplating(templateRef, []string{"Ryan Lewis", "boy"}, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b")
msgTemplating := flows.NewMsgTemplating(templateRef, map[string][]flows.TemplateParam{"body": {{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b")

assert.Equal(t, templateRef, msgTemplating.Template())
assert.Equal(t, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b", msgTemplating.Namespace())
Expand Down

0 comments on commit 94e59fc

Please sign in to comment.