From ffc24e90f7fe38622979da28ee1416c185411db2 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Wed, 20 Mar 2024 17:33:33 -0500 Subject: [PATCH] Remove no longer used templating.params --- flows/actions/send_msg.go | 4 +-- flows/actions/testdata/send_msg.json | 48 ---------------------------- flows/msg.go | 14 +++----- flows/msg_test.go | 15 +-------- 4 files changed, 7 insertions(+), 74 deletions(-) diff --git a/flows/actions/send_msg.go b/flows/actions/send_msg.go index fe53115aa..c6b9aad00 100644 --- a/flows/actions/send_msg.go +++ b/flows/actions/send_msg.go @@ -156,7 +156,6 @@ func (a *SendMsgAction) getTemplateMsg(run flows.Run, urn urns.URN, channelRef * // next we cross reference with params defined in the template translation to get types components := make([]*flows.TemplatingComponent, 0, len(translation.Components())) - legacy := make(map[string][]flows.TemplatingParam, len(translation.Components())) // TODO deprecated // the message we return is an approximate preview of what the channel will send using the template var previewParts []string @@ -187,14 +186,13 @@ func (a *SendMsgAction) getTemplateMsg(run flows.Run, urn urns.URN, channelRef * if len(params) > 0 { components = append(components, compTemplating) - legacy[comp.Name()] = params } } previewText := strings.Join(previewParts, "\n\n") locale := translation.Locale() - templating := flows.NewMsgTemplating(a.Templating.Template, legacy, components, translation.Namespace()) + templating := flows.NewMsgTemplating(a.Templating.Template, translation.Namespace(), components) return flows.NewMsgOut(urn, channelRef, previewText, nil, previewQRs, templating, flows.NilMsgTopic, locale, unsendableReason) } diff --git a/flows/actions/testdata/send_msg.json b/flows/actions/testdata/send_msg.json index 93bad0668..5e0ea5ec5 100644 --- a/flows/actions/testdata/send_msg.json +++ b/flows/actions/testdata/send_msg.json @@ -458,18 +458,6 @@ "uuid": "5722e1fd-fe32-4e74-ac78-3cf41a6adb7e", "name": "affirmation" }, - "params": { - "body": [ - { - "type": "text", - "value": "Ryan Lewis" - }, - { - "type": "text", - "value": "boy" - } - ] - }, "components": [ { "params": [ @@ -566,18 +554,6 @@ "uuid": "5722e1fd-fe32-4e74-ac78-3cf41a6adb7e", "name": "affirmation" }, - "params": { - "body": [ - { - "type": "text", - "value": "Ryan Lewis" - }, - { - "type": "text", - "value": "niño" - } - ] - }, "components": [ { "params": [ @@ -920,30 +896,6 @@ "uuid": "ce00c80e-991a-4c03-b373-3273c23ee042", "name": "gender_update" }, - "params": { - "header": [ - { - "type": "image", - "value": "http://templates.com/rojo.jpg" - } - ], - "body": [ - { - "type": "text", - "value": "Ryan Lewis" - }, - { - "type": "text", - "value": "niño" - } - ], - "button.0": [ - { - "type": "text", - "value": "Sip" - } - ] - }, "components": [ { "params": [ diff --git a/flows/msg.go b/flows/msg.go index 330f94929..becd9ec52 100644 --- a/flows/msg.go +++ b/flows/msg.go @@ -197,15 +197,14 @@ func (tc *TemplatingComponent) Preview(c assets.TemplateComponent) string { // MsgTemplating represents any substituted message template that should be applied when sending this message type MsgTemplating struct { - Template_ *assets.TemplateReference `json:"template"` - Params_ map[string][]TemplatingParam `json:"params,omitempty"` - Components_ []*TemplatingComponent `json:"components,omitempty"` - Namespace_ string `json:"namespace"` + Template_ *assets.TemplateReference `json:"template"` + Namespace_ string `json:"namespace"` + Components_ []*TemplatingComponent `json:"components,omitempty"` } // NewMsgTemplating creates and returns a new msg template -func NewMsgTemplating(template *assets.TemplateReference, params map[string][]TemplatingParam, components []*TemplatingComponent, namespace string) *MsgTemplating { - return &MsgTemplating{Template_: template, Namespace_: namespace, Components_: components, Params_: params} +func NewMsgTemplating(template *assets.TemplateReference, namespace string, components []*TemplatingComponent) *MsgTemplating { + return &MsgTemplating{Template_: template, Namespace_: namespace, Components_: components} } // Template returns the template this msg template is for @@ -217,9 +216,6 @@ func (t *MsgTemplating) Namespace() string { return t.Namespace_ } // Components returns the components that should be used for the templates func (t *MsgTemplating) Components() []*TemplatingComponent { return t.Components_ } -// Params returns the params that should be used for the template -func (t *MsgTemplating) Params() map[string][]TemplatingParam { return t.Params_ } - // BroadcastTranslation is the broadcast content in a particular language type BroadcastTranslation struct { Text string `json:"text"` diff --git a/flows/msg_test.go b/flows/msg_test.go index b088c8423..5e65be2b7 100644 --- a/flows/msg_test.go +++ b/flows/msg_test.go @@ -163,11 +163,10 @@ func TestMsgTemplating(t *testing.T) { templateRef := assets.NewTemplateReference("61602f3e-f603-4c70-8a8f-c477505bf4bf", "Affirmation") - msgTemplating := flows.NewMsgTemplating(templateRef, map[string][]flows.TemplatingParam{"body": {{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}, []*flows.TemplatingComponent{{Type: "body", Params: []flows.TemplatingParam{{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}}, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b") + msgTemplating := flows.NewMsgTemplating(templateRef, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b", []*flows.TemplatingComponent{{Type: "body", Params: []flows.TemplatingParam{{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}}) assert.Equal(t, templateRef, msgTemplating.Template()) assert.Equal(t, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b", msgTemplating.Namespace()) - assert.Equal(t, map[string][]flows.TemplatingParam{"body": {{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}, msgTemplating.Params()) assert.Equal(t, []*flows.TemplatingComponent{{Type: "body", Params: []flows.TemplatingParam{{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}}}, msgTemplating.Components()) // test marshaling our msg @@ -180,18 +179,6 @@ func TestMsgTemplating(t *testing.T) { "uuid":"61602f3e-f603-4c70-8a8f-c477505bf4bf" }, "namespace":"0162a7f4_dfe4_4c96_be07_854d5dba3b2b", - "params": { - "body": [ - { - "type": "text", - "value": "Ryan Lewis" - }, - { - "type": "text", - "value": "boy" - } - ] - }, "components":[ { "type": "body",