Skip to content

Commit c7e6376

Browse files
authored
Merge pull request #1245 from nyaruka/rem_templating_params
Remove deprecated params in templating
2 parents e85ce5f + abdc2a7 commit c7e6376

File tree

4 files changed

+13
-57
lines changed

4 files changed

+13
-57
lines changed

flows/actions/send_msg.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/nyaruka/goflow/assets"
1212
"github.com/nyaruka/goflow/flows"
1313
"github.com/nyaruka/goflow/flows/events"
14-
"github.com/nyaruka/goflow/utils"
1514
)
1615

1716
func init() {
@@ -177,16 +176,11 @@ func (a *SendMsgAction) getTemplateMsg(run flows.Run, urn urns.URN, channelRef *
177176
components := make([]*flows.TemplatingComponent, 0, len(translation.Components()))
178177
for _, comp := range translation.Components() {
179178
if len(comp.Variables()) > 0 {
180-
tc := &flows.TemplatingComponent{Type: comp.Type(), Name: comp.Name(), Variables: comp.Variables()}
181-
182-
// TODO remove when courier updated
183-
tc.Params = make([]*flows.TemplatingVariable, 0, len(comp.Variables()))
184-
for _, vn := range utils.SortedKeys(comp.Variables()) {
185-
vi := comp.Variables()[vn]
186-
tc.Params = append(tc.Params, variables[vi])
187-
}
188-
189-
components = append(components, tc)
179+
components = append(components, &flows.TemplatingComponent{
180+
Type: comp.Type(),
181+
Name: comp.Name(),
182+
Variables: comp.Variables(),
183+
})
190184
}
191185
}
192186

flows/actions/testdata/send_msg.json

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -466,17 +466,7 @@
466466
"variables": {
467467
"1": 0,
468468
"2": 1
469-
},
470-
"params": [
471-
{
472-
"type": "text",
473-
"value": "Ryan Lewis"
474-
},
475-
{
476-
"type": "text",
477-
"value": "boy"
478-
}
479-
]
469+
}
480470
}
481471
],
482472
"variables": [
@@ -577,17 +567,7 @@
577567
"variables": {
578568
"1": 0,
579569
"2": 1
580-
},
581-
"params": [
582-
{
583-
"type": "text",
584-
"value": "Ryan Lewis"
585-
},
586-
{
587-
"type": "text",
588-
"value": "niño"
589-
}
590-
]
570+
}
591571
}
592572
],
593573
"variables": [
@@ -927,30 +907,14 @@
927907
"variables": {
928908
"1": 0,
929909
"2": 1
930-
},
931-
"params": [
932-
{
933-
"type": "text",
934-
"value": "Ryan Lewis"
935-
},
936-
{
937-
"type": "text",
938-
"value": "niño"
939-
}
940-
]
910+
}
941911
},
942912
{
943913
"type": "button/quick_reply",
944914
"name": "button.0",
945915
"variables": {
946916
"1": 2
947-
},
948-
"params": [
949-
{
950-
"type": "text",
951-
"value": "Sip"
952-
}
953-
]
917+
}
954918
}
955919
],
956920
"variables": [

flows/msg.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,9 @@ type TemplatingVariable struct {
174174
}
175175

176176
type TemplatingComponent struct {
177-
Type string `json:"type"`
178-
Name string `json:"name"`
179-
Variables map[string]int `json:"variables"`
180-
Params []*TemplatingVariable `json:"params"` // deprecated
177+
Type string `json:"type"`
178+
Name string `json:"name"`
179+
Variables map[string]int `json:"variables"`
181180
}
182181

183182
// MsgTemplating represents any substituted message template that should be applied when sending this message

flows/msg_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ func TestMsgTemplating(t *testing.T) {
189189
{
190190
"type": "body",
191191
"name": "body",
192-
"variables": {"1": 0, "2": 1},
193-
"params": null
192+
"variables": {"1": 0, "2": 1}
194193
}
195194
],
196195
"variables": [

0 commit comments

Comments
 (0)