From 92f612e1b9317c1f6b54f716a029ce9713273303 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Tue, 20 Aug 2024 14:45:53 +0000 Subject: [PATCH] Drop support for localizing template variables in send_msg actions --- flows/actions/send_msg.go | 8 +- flows/actions/testdata/send_msg.json | 119 ++------------------------- 2 files changed, 8 insertions(+), 119 deletions(-) diff --git a/flows/actions/send_msg.go b/flows/actions/send_msg.go index 649044053..8e3e3711e 100644 --- a/flows/actions/send_msg.go +++ b/flows/actions/send_msg.go @@ -3,7 +3,6 @@ package actions import ( "github.com/nyaruka/gocommon/i18n" "github.com/nyaruka/gocommon/urns" - "github.com/nyaruka/gocommon/uuids" "github.com/nyaruka/goflow/assets" "github.com/nyaruka/goflow/flows" "github.com/nyaruka/goflow/flows/events" @@ -91,12 +90,9 @@ func (a *SendMsgAction) Execute(run flows.Run, step flows.Step, logModifier flow locales := []i18n.Locale{run.Session().MergedEnvironment().DefaultLocale(), run.Session().Environment().DefaultLocale()} translation := template.FindTranslation(dest.Channel, locales) if translation != nil { - // TODO in future we won't be localizing template variables - localizedVariables, _ := run.GetTextArray(uuids.UUID(a.UUID()), "template_variables", a.TemplateVariables, nil) - // evaluate the variables - evaluatedVariables := make([]string, len(localizedVariables)) - for i, varExp := range localizedVariables { + evaluatedVariables := make([]string, len(a.TemplateVariables)) + for i, varExp := range a.TemplateVariables { v, _ := run.EvaluateTemplate(varExp, logEvent) evaluatedVariables[i] = v } diff --git a/flows/actions/testdata/send_msg.json b/flows/actions/testdata/send_msg.json index 883e92ffc..e9f77b384 100644 --- a/flows/actions/testdata/send_msg.json +++ b/flows/actions/testdata/send_msg.json @@ -491,100 +491,6 @@ "parent_refs": [] } }, - { - "description": "Msg with a matching template with localized variables", - "action": { - "type": "send_msg", - "uuid": "ad154980-7bf7-4ab8-8728-545fd6378912", - "text": "Hi Ryan Lewis, who's a good boy?", - "template": { - "uuid": "5722e1fd-fe32-4e74-ac78-3cf41a6adb7e", - "name": "affirmation" - }, - "template_variables": [ - "@contact.name", - "boy" - ] - }, - "localization": { - "spa": { - "ad154980-7bf7-4ab8-8728-545fd6378912": { - "template_variables": [ - "@contact.name", - "niño" - ] - } - } - }, - "events": [ - { - "type": "msg_created", - "created_on": "2018-10-18T14:20:30.000123456Z", - "step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", - "msg": { - "uuid": "9688d21d-95aa-4bed-afc7-f31b35731a3d", - "urn": "tel:+12065551212?channel=57f1078f-88aa-46f4-a59a-948a5739c03d&id=123", - "channel": { - "uuid": "57f1078f-88aa-46f4-a59a-948a5739c03d", - "name": "My Android Phone" - }, - "text": "Hola Ryan Lewis, quien es un niño excelente?", - "templating": { - "template": { - "uuid": "5722e1fd-fe32-4e74-ac78-3cf41a6adb7e", - "name": "affirmation" - }, - "components": [ - { - "name": "body", - "type": "body/text", - "variables": { - "1": 0, - "2": 1 - } - } - ], - "variables": [ - { - "type": "text", - "value": "Ryan Lewis" - }, - { - "type": "text", - "value": "niño" - } - ] - }, - "locale": "spa" - } - } - ], - "templates": [ - "Hi Ryan Lewis, who's a good boy?", - "@contact.name", - "boy", - "@contact.name", - "niño" - ], - "localizables": [ - "Hi Ryan Lewis, who's a good boy?", - "@contact.name", - "boy" - ], - "inspection": { - "dependencies": [ - { - "uuid": "5722e1fd-fe32-4e74-ac78-3cf41a6adb7e", - "name": "affirmation", - "type": "template" - } - ], - "issues": [], - "results": [], - "waiting_exits": [], - "parent_refs": [] - } - }, { "description": "Msg with template but no variables", "action": { @@ -803,16 +709,7 @@ ] }, "localization": { - "spa": { - "ad154980-7bf7-4ab8-8728-545fd6378912": { - "template_variables": [ - "@contact.name", - "niño", - "Sip", - "Nop" - ] - } - } + "spa": {} }, "events": [ { @@ -826,9 +723,9 @@ "uuid": "57f1078f-88aa-46f4-a59a-948a5739c03d", "name": "My Android Phone" }, - "text": "Actualizar\n\nHola, Ryan Lewis, tu género está guardado como niño.", + "text": "Actualizar\n\nHola, Ryan Lewis, tu género está guardado como boy.", "quick_replies": [ - "Sip", + "Yeah", "No" ], "templating": { @@ -860,11 +757,11 @@ }, { "type": "text", - "value": "niño" + "value": "boy" }, { "type": "text", - "value": "Sip" + "value": "Yeah" } ] }, @@ -879,11 +776,7 @@ "@contact.name", "boy", "Yeah", - "Nope", - "@contact.name", - "niño", - "Sip", - "Nop" + "Nope" ], "localizables": [ "Hey Ryan Lewis, your gender is saved as boy.",