diff --git a/assets/static/template.go b/assets/static/template.go index 7880b3b0a..ca8b1c671 100644 --- a/assets/static/template.go +++ b/assets/static/template.go @@ -40,16 +40,14 @@ func (t *Template) Translations() []assets.TemplateTranslation { type TemplateTranslation struct { Channel_ *assets.ChannelReference `json:"channel" validate:"required"` Locale_ i18n.Locale `json:"locale" validate:"required"` - Namespace_ string `json:"namespace"` Components_ []*TemplateComponent `json:"components"` Variables_ []*TemplateVariable `json:"variables"` } // NewTemplateTranslation creates a new template translation -func NewTemplateTranslation(channel *assets.ChannelReference, locale i18n.Locale, namespace string, components []*TemplateComponent, variables []*TemplateVariable) *TemplateTranslation { +func NewTemplateTranslation(channel *assets.ChannelReference, locale i18n.Locale, components []*TemplateComponent, variables []*TemplateVariable) *TemplateTranslation { return &TemplateTranslation{ Channel_: channel, - Namespace_: namespace, Locale_: locale, Components_: components, Variables_: variables, @@ -74,10 +72,7 @@ func (t *TemplateTranslation) Variables() []assets.TemplateVariable { return vs } -// Namespace returns the namespace for this template -func (t *TemplateTranslation) Namespace() string { return t.Namespace_ } - -// Language returns the locale this translation is in +// Locale returns the locale this translation is in func (t *TemplateTranslation) Locale() i18n.Locale { return t.Locale_ } // Channel returns the channel this template translation is for diff --git a/assets/static/template_test.go b/assets/static/template_test.go index 173373030..4c1de4431 100644 --- a/assets/static/template_test.go +++ b/assets/static/template_test.go @@ -27,10 +27,9 @@ func TestTemplate(t *testing.T) { assert.Equal(t, "", c1.Display()) assert.Equal(t, map[string]int{"1": 0}, c1.Variables()) - translation := static.NewTemplateTranslation(channel, i18n.Locale("eng-US"), "0162a7f4_dfe4_4c96_be07_854d5dba3b2b", []*static.TemplateComponent{c1, c2}, []*static.TemplateVariable{v1, v2}) + translation := static.NewTemplateTranslation(channel, i18n.Locale("eng-US"), []*static.TemplateComponent{c1, c2}, []*static.TemplateVariable{v1, v2}) assert.Equal(t, channel, translation.Channel()) assert.Equal(t, i18n.Locale("eng-US"), translation.Locale()) - assert.Equal(t, "0162a7f4_dfe4_4c96_be07_854d5dba3b2b", translation.Namespace()) assert.Equal(t, []assets.TemplateComponent{ (assets.TemplateComponent)(c1), (assets.TemplateComponent)(c2), @@ -51,5 +50,4 @@ func TestTemplate(t *testing.T) { assert.Equal(t, copy.Name(), template.Name()) assert.Equal(t, copy.UUID(), template.UUID()) - assert.Equal(t, copy.Translations()[0].Namespace(), template.Translations()[0].Namespace()) } diff --git a/assets/template.go b/assets/template.go index 8ea61c779..34d094e80 100644 --- a/assets/template.go +++ b/assets/template.go @@ -73,7 +73,6 @@ type TemplateComponent interface { // TemplateTranslation represents a single translation for a specific template and channel type TemplateTranslation interface { Locale() i18n.Locale - Namespace() string Channel() *ChannelReference Components() []TemplateComponent Variables() []TemplateVariable diff --git a/flows/actions/send_msg.go b/flows/actions/send_msg.go index dd759ad25..3c7ac9a93 100644 --- a/flows/actions/send_msg.go +++ b/flows/actions/send_msg.go @@ -150,7 +150,7 @@ func (a *SendMsgAction) getTemplateMsg(run flows.Run, urn urns.URN, channelRef * // the message we return is an approximate preview of what the channel will send using the template preview := translation.Preview(variables) locale := translation.Locale() - templating := flows.NewMsgTemplating(a.Template, translation.Namespace(), components, variables) + templating := flows.NewMsgTemplating(a.Template, components, variables) return flows.NewMsgOut(urn, channelRef, preview.Text, preview.Attachments, preview.QuickReplies, templating, flows.NilMsgTopic, locale, unsendableReason) } diff --git a/flows/actions/testdata/send_msg.json b/flows/actions/testdata/send_msg.json index a4278f0f4..341a7facf 100644 --- a/flows/actions/testdata/send_msg.json +++ b/flows/actions/testdata/send_msg.json @@ -442,7 +442,6 @@ "uuid": "5722e1fd-fe32-4e74-ac78-3cf41a6adb7e", "name": "affirmation" }, - "namespace": "", "components": [ { "name": "body", @@ -535,7 +534,6 @@ "uuid": "5722e1fd-fe32-4e74-ac78-3cf41a6adb7e", "name": "affirmation" }, - "namespace": "", "components": [ { "name": "body", @@ -615,8 +613,7 @@ "template": { "uuid": "2edc8dfd-aef0-41cf-a900-8a71bdb00900", "name": "wakeup" - }, - "namespace": "" + } }, "locale": "eng" } @@ -679,8 +676,7 @@ "template": { "uuid": "2edc8dfd-aef0-41cf-a900-8a71bdb00900", "name": "wakeup" - }, - "namespace": "" + } }, "locale": "eng" } @@ -840,7 +836,6 @@ "uuid": "ce00c80e-991a-4c03-b373-3273c23ee042", "name": "gender_update" }, - "namespace": "", "components": [ { "name": "body", @@ -952,7 +947,6 @@ "uuid": "be68beff-1a5b-424b-815e-023cc53c1ddc", "name": "cat_fact" }, - "namespace": "", "components": [ { "name": "header", diff --git a/flows/msg.go b/flows/msg.go index f6bbb46d2..6454d4b90 100644 --- a/flows/msg.go +++ b/flows/msg.go @@ -185,14 +185,13 @@ type TemplatingComponent struct { // MsgTemplating represents any substituted message template that should be applied when sending this message type MsgTemplating struct { Template *assets.TemplateReference `json:"template"` - Namespace string `json:"namespace"` Components []*TemplatingComponent `json:"components,omitempty"` Variables []*TemplatingVariable `json:"variables,omitempty"` } // NewMsgTemplating creates and returns a new msg template -func NewMsgTemplating(template *assets.TemplateReference, namespace string, components []*TemplatingComponent, variables []*TemplatingVariable) *MsgTemplating { - return &MsgTemplating{Template: template, Namespace: namespace, Components: components, Variables: variables} +func NewMsgTemplating(template *assets.TemplateReference, components []*TemplatingComponent, variables []*TemplatingVariable) *MsgTemplating { + return &MsgTemplating{Template: template, Components: components, Variables: variables} } // MsgContent is message content in a particular language diff --git a/flows/msg_test.go b/flows/msg_test.go index ab9fb6b82..1a5d9e96f 100644 --- a/flows/msg_test.go +++ b/flows/msg_test.go @@ -218,13 +218,11 @@ func TestMsgTemplating(t *testing.T) { msgTemplating := flows.NewMsgTemplating( templateRef, - "0162a7f4_dfe4_4c96_be07_854d5dba3b2b", []*flows.TemplatingComponent{{Type: "body/text", Name: "body", Variables: map[string]int{"1": 0, "2": 1}}}, []*flows.TemplatingVariable{{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, []*flows.TemplatingComponent{{Type: "body/text", Name: "body", Variables: map[string]int{"1": 0, "2": 1}}}, msgTemplating.Components) assert.Equal(t, []*flows.TemplatingVariable{{Type: "text", Value: "Ryan Lewis"}, {Type: "text", Value: "boy"}}, msgTemplating.Variables) @@ -237,7 +235,6 @@ func TestMsgTemplating(t *testing.T) { "name":"Affirmation", "uuid":"61602f3e-f603-4c70-8a8f-c477505bf4bf" }, - "namespace":"0162a7f4_dfe4_4c96_be07_854d5dba3b2b", "components":[ { "name": "body", diff --git a/flows/template_test.go b/flows/template_test.go index d87b33ee4..42350976f 100644 --- a/flows/template_test.go +++ b/flows/template_test.go @@ -21,10 +21,10 @@ func TestFindTranslation(t *testing.T) { channel1Ref := assets.NewChannelReference(channel1.UUID(), channel1.Name()) channel2Ref := assets.NewChannelReference(channel2.UUID(), channel2.Name()) - tt1 := static.NewTemplateTranslation(channel1Ref, i18n.Locale("eng"), "", []*static.TemplateComponent{}, []*static.TemplateVariable{}) - tt2 := static.NewTemplateTranslation(channel1Ref, i18n.Locale("spa-EC"), "", []*static.TemplateComponent{}, []*static.TemplateVariable{}) - tt3 := static.NewTemplateTranslation(channel1Ref, i18n.Locale("spa-ES"), "", []*static.TemplateComponent{}, []*static.TemplateVariable{}) - tt4 := static.NewTemplateTranslation(channel2Ref, i18n.Locale("kin"), "", []*static.TemplateComponent{}, []*static.TemplateVariable{}) + tt1 := static.NewTemplateTranslation(channel1Ref, i18n.Locale("eng"), []*static.TemplateComponent{}, []*static.TemplateVariable{}) + tt2 := static.NewTemplateTranslation(channel1Ref, i18n.Locale("spa-EC"), []*static.TemplateComponent{}, []*static.TemplateVariable{}) + tt3 := static.NewTemplateTranslation(channel1Ref, i18n.Locale("spa-ES"), []*static.TemplateComponent{}, []*static.TemplateVariable{}) + tt4 := static.NewTemplateTranslation(channel2Ref, i18n.Locale("kin"), []*static.TemplateComponent{}, []*static.TemplateVariable{}) template := flows.NewTemplate(static.NewTemplate("c520cbda-e118-440f-aaf6-c0485088384f", "greeting", []*static.TemplateTranslation{tt1, tt2, tt3, tt4})) tas := flows.NewTemplateAssets([]assets.Template{template})