Skip to content

Commit 5710576

Browse files
committed
Fail msg when template missing content SID
1 parent 94881e1 commit 5710576

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: handlers/twiml/handlers.go

+5
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
240240
}
241241

242242
if templating != nil && channel.IsScheme(urns.WhatsAppScheme) {
243+
244+
if templating.ExternalID == "" {
245+
return courier.ErrFailedWithReason("", "template missing contentSID")
246+
}
247+
243248
// build our request
244249
form := url.Values{
245250
"To": []string{fmt.Sprintf("%s:+%s", urns.WhatsAppScheme, msg.URN().Path())},

Diff for: handlers/twiml/handlers_test.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,14 @@ var twaSendTestCases = []OutgoingTestCase{
11101110
}},
11111111
ExpectedExtIDs: []string{"1002"},
11121112
},
1113-
1113+
{
1114+
Label: "Template Send missing external ID",
1115+
MsgText: "templated message",
1116+
MsgURN: "whatsapp:250788383383",
1117+
MsgLocale: "eng",
1118+
MsgMetadata: json.RawMessage(`{ "templating": { "template": { "name": "revive_issue", "uuid": "171f8a4d-f725-46d7-85a6-11aceff0bfe3" }, "components": [{"type":"body", "params": [{"type":"text", "name": "1", "value":"Chef"}, {"type": "text" , "name": "2", "value": "tomorrow"}]}]}}`),
1119+
ExpectedError: courier.ErrFailedWithReason("", "template missing contentSID"),
1120+
},
11141121
{
11151122
Label: "Error Code",
11161123
MsgText: "Error Code",

0 commit comments

Comments
 (0)