Skip to content

Commit 3aa1619

Browse files
authored
Merge pull request #1236 from nyaruka/rem_templating_params
Remove no longer used templating.params
2 parents 5c1d910 + 7597a76 commit 3aa1619

File tree

4 files changed

+7
-74
lines changed

4 files changed

+7
-74
lines changed

flows/actions/send_msg.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ func (a *SendMsgAction) getTemplateMsg(run flows.Run, urn urns.URN, channelRef *
156156

157157
// next we cross reference with params defined in the template translation to get types
158158
components := make([]*flows.TemplatingComponent, 0, len(translation.Components()))
159-
legacy := make(map[string][]flows.TemplatingParam, len(translation.Components())) // TODO deprecated
160159

161160
// the message we return is an approximate preview of what the channel will send using the template
162161
var previewParts []string
@@ -187,14 +186,13 @@ func (a *SendMsgAction) getTemplateMsg(run flows.Run, urn urns.URN, channelRef *
187186

188187
if len(params) > 0 {
189188
components = append(components, compTemplating)
190-
legacy[comp.Name()] = params
191189
}
192190
}
193191

194192
previewText := strings.Join(previewParts, "\n\n")
195193

196194
locale := translation.Locale()
197-
templating := flows.NewMsgTemplating(a.Templating.Template, legacy, components, translation.Namespace())
195+
templating := flows.NewMsgTemplating(a.Templating.Template, translation.Namespace(), components)
198196

199197
return flows.NewMsgOut(urn, channelRef, previewText, nil, previewQRs, templating, flows.NilMsgTopic, locale, unsendableReason)
200198
}

flows/actions/testdata/send_msg.json

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -458,18 +458,6 @@
458458
"uuid": "5722e1fd-fe32-4e74-ac78-3cf41a6adb7e",
459459
"name": "affirmation"
460460
},
461-
"params": {
462-
"body": [
463-
{
464-
"type": "text",
465-
"value": "Ryan Lewis"
466-
},
467-
{
468-
"type": "text",
469-
"value": "boy"
470-
}
471-
]
472-
},
473461
"components": [
474462
{
475463
"type": "body",
@@ -567,18 +555,6 @@
567555
"uuid": "5722e1fd-fe32-4e74-ac78-3cf41a6adb7e",
568556
"name": "affirmation"
569557
},
570-
"params": {
571-
"body": [
572-
{
573-
"type": "text",
574-
"value": "Ryan Lewis"
575-
},
576-
{
577-
"type": "text",
578-
"value": "niño"
579-
}
580-
]
581-
},
582558
"components": [
583559
{
584560
"type": "body",
@@ -922,30 +898,6 @@
922898
"uuid": "ce00c80e-991a-4c03-b373-3273c23ee042",
923899
"name": "gender_update"
924900
},
925-
"params": {
926-
"body": [
927-
{
928-
"type": "text",
929-
"value": "Ryan Lewis"
930-
},
931-
{
932-
"type": "text",
933-
"value": "niño"
934-
}
935-
],
936-
"button.0": [
937-
{
938-
"type": "text",
939-
"value": "Sip"
940-
}
941-
],
942-
"header": [
943-
{
944-
"type": "image",
945-
"value": "http://templates.com/rojo.jpg"
946-
}
947-
]
948-
},
949901
"components": [
950902
{
951903
"type": "header",

flows/msg.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,14 @@ func (tc *TemplatingComponent) Preview(c assets.TemplateComponent) string {
198198

199199
// MsgTemplating represents any substituted message template that should be applied when sending this message
200200
type MsgTemplating struct {
201-
Template_ *assets.TemplateReference `json:"template"`
202-
Params_ map[string][]TemplatingParam `json:"params,omitempty"`
203-
Components_ []*TemplatingComponent `json:"components,omitempty"`
204-
Namespace_ string `json:"namespace"`
201+
Template_ *assets.TemplateReference `json:"template"`
202+
Namespace_ string `json:"namespace"`
203+
Components_ []*TemplatingComponent `json:"components,omitempty"`
205204
}
206205

207206
// NewMsgTemplating creates and returns a new msg template
208-
func NewMsgTemplating(template *assets.TemplateReference, params map[string][]TemplatingParam, components []*TemplatingComponent, namespace string) *MsgTemplating {
209-
return &MsgTemplating{Template_: template, Namespace_: namespace, Components_: components, Params_: params}
207+
func NewMsgTemplating(template *assets.TemplateReference, namespace string, components []*TemplatingComponent) *MsgTemplating {
208+
return &MsgTemplating{Template_: template, Namespace_: namespace, Components_: components}
210209
}
211210

212211
// Template returns the template this msg template is for
@@ -218,9 +217,6 @@ func (t *MsgTemplating) Namespace() string { return t.Namespace_ }
218217
// Components returns the components that should be used for the templates
219218
func (t *MsgTemplating) Components() []*TemplatingComponent { return t.Components_ }
220219

221-
// Params returns the params that should be used for the template
222-
func (t *MsgTemplating) Params() map[string][]TemplatingParam { return t.Params_ }
223-
224220
// BroadcastTranslation is the broadcast content in a particular language
225221
type BroadcastTranslation struct {
226222
Text string `json:"text"`

flows/msg_test.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,10 @@ func TestMsgTemplating(t *testing.T) {
163163

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

166-
msgTemplating := flows.NewMsgTemplating(templateRef, map[string][]flows.TemplatingParam{"body": {{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}, []*flows.TemplatingComponent{{Type: "body", Name: "body", Params: []flows.TemplatingParam{{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}}, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b")
166+
msgTemplating := flows.NewMsgTemplating(templateRef, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b", []*flows.TemplatingComponent{{Type: "body", Name: "body", Params: []flows.TemplatingParam{{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}})
167167

168168
assert.Equal(t, templateRef, msgTemplating.Template())
169169
assert.Equal(t, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b", msgTemplating.Namespace())
170-
assert.Equal(t, map[string][]flows.TemplatingParam{"body": {{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}, msgTemplating.Params())
171170
assert.Equal(t, []*flows.TemplatingComponent{{Type: "body", Name: "body", Params: []flows.TemplatingParam{{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}}, msgTemplating.Components())
172171

173172
// test marshaling our msg
@@ -180,18 +179,6 @@ func TestMsgTemplating(t *testing.T) {
180179
"uuid":"61602f3e-f603-4c70-8a8f-c477505bf4bf"
181180
},
182181
"namespace":"0162a7f4_dfe4_4c96_be07_854d5dba3b2b",
183-
"params": {
184-
"body": [
185-
{
186-
"type": "text",
187-
"value": "Ryan Lewis"
188-
},
189-
{
190-
"type": "text",
191-
"value": "boy"
192-
}
193-
]
194-
},
195182
"components":[
196183
{
197184
"type": "body",

0 commit comments

Comments
 (0)