Skip to content

Commit 4459d2b

Browse files
committed
Support sending stickers
1 parent 1c58a29 commit 4459d2b

File tree

5 files changed

+174
-79
lines changed

5 files changed

+174
-79
lines changed

Diff for: handlers/dialog360/handler.go

+44-21
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/nyaruka/courier/utils"
1919
"github.com/nyaruka/gocommon/jsonx"
2020
"github.com/nyaruka/gocommon/urns"
21+
"github.com/pkg/errors"
2122
)
2223

2324
const (
@@ -29,6 +30,15 @@ var (
2930
maxMsgLength = 4096
3031
)
3132

33+
// see https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#supported-media-types
34+
var mediaSupport = map[handlers.MediaType]handlers.MediaTypeSupport{
35+
handlers.MediaType("image/webp"): {Types: []string{"image/webp"}, MaxBytes: 100 * 1024, MaxWidth: 512, MaxHeight: 512},
36+
handlers.MediaTypeImage: {Types: []string{"image/jpeg", "image/png"}, MaxBytes: 5 * 1024 * 1024},
37+
handlers.MediaTypeAudio: {Types: []string{"audio/aac", "audio/mp4", "audio/mpeg", "audio/amr", "audio/ogg"}, MaxBytes: 16 * 1024 * 1024},
38+
handlers.MediaTypeVideo: {Types: []string{"video/mp4", "video/3gp"}, MaxBytes: 16 * 1024 * 1024},
39+
handlers.MediaTypeApplication: {MaxBytes: 100 * 1024 * 1024},
40+
}
41+
3242
func init() {
3343
courier.RegisterHandler(newWAHandler(courier.ChannelType("D3C"), "360Dialog"))
3444
}
@@ -313,23 +323,28 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
313323

314324
var payloadAudio whatsapp.SendRequest
315325

316-
for i := 0; i < len(msgParts)+len(msg.Attachments()); i++ {
326+
attachments, err := handlers.ResolveAttachments(ctx, h.Backend(), msg.Attachments(), mediaSupport, false, clog)
327+
if err != nil {
328+
return errors.Wrap(err, "error resolving attachments")
329+
}
330+
331+
for i := 0; i < len(msgParts)+len(attachments); i++ {
317332
payload := whatsapp.SendRequest{MessagingProduct: "whatsapp", RecipientType: "individual", To: msg.URN().Path()}
318333

319-
if len(msg.Attachments()) == 0 {
334+
if len(attachments) == 0 {
320335
// do we have a template?
321336
if msg.Templating() != nil {
322337
payload.Type = "template"
323338
payload.Template = whatsapp.GetTemplatePayload(msg.Templating())
324339
} else {
325-
if i < (len(msgParts) + len(msg.Attachments()) - 1) {
340+
if i < (len(msgParts) + len(attachments) - 1) {
326341
// this is still a msg part
327342
text := &whatsapp.Text{PreviewURL: false}
328343
payload.Type = "text"
329-
if strings.Contains(msgParts[i-len(msg.Attachments())], "https://") || strings.Contains(msgParts[i-len(msg.Attachments())], "http://") {
344+
if strings.Contains(msgParts[i-len(attachments)], "https://") || strings.Contains(msgParts[i-len(attachments)], "http://") {
330345
text.PreviewURL = true
331346
}
332-
text.Body = msgParts[i-len(msg.Attachments())]
347+
text.Body = msgParts[i-len(attachments)]
333348
payload.Text = text
334349
} else {
335350
if len(qrs) > 0 {
@@ -345,7 +360,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
345360
if len(qrs) <= 3 {
346361
interactive := whatsapp.Interactive{Type: "button", Body: struct {
347362
Text string "json:\"text\""
348-
}{Text: msgParts[i-len(msg.Attachments())]}}
363+
}{Text: msgParts[i-len(attachments)]}}
349364

350365
btns := make([]whatsapp.Button, len(qrs))
351366
for i, qr := range qrs {
@@ -364,7 +379,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
364379
} else {
365380
interactive := whatsapp.Interactive{Type: "list", Body: struct {
366381
Text string "json:\"text\""
367-
}{Text: msgParts[i-len(msg.Attachments())]}}
382+
}{Text: msgParts[i-len(attachments)]}}
368383

369384
section := whatsapp.Section{
370385
Rows: make([]whatsapp.SectionRow, len(qrs)),
@@ -390,31 +405,38 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
390405
// this is still a msg part
391406
text := &whatsapp.Text{PreviewURL: false}
392407
payload.Type = "text"
393-
if strings.Contains(msgParts[i-len(msg.Attachments())], "https://") || strings.Contains(msgParts[i-len(msg.Attachments())], "http://") {
408+
if strings.Contains(msgParts[i-len(attachments)], "https://") || strings.Contains(msgParts[i-len(attachments)], "http://") {
394409
text.PreviewURL = true
395410
}
396-
text.Body = msgParts[i-len(msg.Attachments())]
411+
text.Body = msgParts[i-len(attachments)]
397412
payload.Text = text
398413
}
399414
}
400415
}
401416

402-
} else if i < len(msg.Attachments()) && (len(qrs) == 0 || len(qrs) > 3) {
403-
attType, attURL := handlers.SplitAttachment(msg.Attachments()[i])
404-
attType = strings.Split(attType, "/")[0]
417+
} else if i < len(attachments) && (len(qrs) == 0 || len(qrs) > 3) {
418+
attURL := attachments[i].Media.URL()
419+
attType := attachments[i].Type
420+
attContentType := attachments[i].Media.ContentType()
421+
405422
if attType == "application" {
406423
attType = "document"
407424
}
408-
payload.Type = attType
425+
payload.Type = string(attType)
409426
media := whatsapp.Media{Link: attURL}
410427

411-
if len(msgParts) == 1 && attType != "audio" && len(msg.Attachments()) == 1 && len(msg.QuickReplies()) == 0 {
428+
if len(msgParts) == 1 && attType != "audio" && len(attachments) == 1 && len(msg.QuickReplies()) == 0 {
412429
media.Caption = msgParts[i]
413430
hasCaption = true
414431
}
415432

416433
if attType == "image" {
417-
payload.Image = &media
434+
if attContentType == "image/webp" {
435+
payload.Type = "sticker"
436+
payload.Sticker = &media
437+
} else {
438+
payload.Image = &media
439+
}
418440
} else if attType == "audio" {
419441
payload.Audio = &media
420442
} else if attType == "video" {
@@ -444,10 +466,11 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
444466
Text string "json:\"text\""
445467
}{Text: msgParts[i]}}
446468

447-
if len(msg.Attachments()) > 0 {
469+
if len(attachments) > 0 {
448470
hasCaption = true
449-
attType, attURL := handlers.SplitAttachment(msg.Attachments()[i])
450-
attType = strings.Split(attType, "/")[0]
471+
attURL := attachments[i].Media.URL()
472+
attType := attachments[i].Type
473+
451474
if attType == "application" {
452475
attType = "document"
453476
}
@@ -519,7 +542,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
519542
} else {
520543
interactive := whatsapp.Interactive{Type: "list", Body: struct {
521544
Text string "json:\"text\""
522-
}{Text: msgParts[i-len(msg.Attachments())]}}
545+
}{Text: msgParts[i-len(attachments)]}}
523546

524547
section := whatsapp.Section{
525548
Rows: make([]whatsapp.SectionRow, len(qrs)),
@@ -545,10 +568,10 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
545568
// this is still a msg part
546569
text := &whatsapp.Text{PreviewURL: false}
547570
payload.Type = "text"
548-
if strings.Contains(msgParts[i-len(msg.Attachments())], "https://") || strings.Contains(msgParts[i-len(msg.Attachments())], "http://") {
571+
if strings.Contains(msgParts[i-len(attachments)], "https://") || strings.Contains(msgParts[i-len(attachments)], "http://") {
549572
text.PreviewURL = true
550573
}
551-
text.Body = msgParts[i-len(msg.Attachments())]
574+
text.Body = msgParts[i-len(attachments)]
552575
payload.Text = text
553576
}
554577
}

Diff for: handlers/dialog360/handler_test.go

+43-19
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,15 @@ var SendTestCasesD3C = []OutgoingTestCase{
369369
Label: "Audio Send",
370370
MsgText: "audio caption",
371371
MsgURN: "whatsapp:250788123123",
372-
MsgAttachments: []string{"audio/mpeg:https://foo.bar/audio.mp3"},
372+
MsgAttachments: []string{"audio/mpeg:http://mock.com/3456/test.mp3"},
373373
MockResponses: map[string][]*httpx.MockResponse{
374374
"*/messages": {
375375
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
376376
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
377377
},
378378
},
379379
ExpectedRequests: []ExpectedRequest{
380-
{Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"audio","audio":{"link":"https://foo.bar/audio.mp3"}}`},
380+
{Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"audio","audio":{"link":"http://mock.com/3456/test.mp3"}}`},
381381
{Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"text","text":{"body":"audio caption","preview_url":false}}`},
382382
},
383383
ExpectedExtIDs: []string{"157b5e14568e8", "157b5e14568e8"},
@@ -386,7 +386,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
386386
Label: "Document Send",
387387
MsgText: "document caption",
388388
MsgURN: "whatsapp:250788123123",
389-
MsgAttachments: []string{"application/pdf:https://foo.bar/document.pdf"},
389+
MsgAttachments: []string{"application/pdf:http://mock.com/7890/test.pdf"},
390390
MockResponses: map[string][]*httpx.MockResponse{
391391
"https://waba-v2.360dialog.io/messages": {
392392
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -395,7 +395,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
395395
ExpectedRequests: []ExpectedRequest{
396396
{
397397
Path: "/messages",
398-
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"document","document":{"link":"https://foo.bar/document.pdf","caption":"document caption","filename":"document.pdf"}}`,
398+
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"document","document":{"link":"http://mock.com/7890/test.pdf","caption":"document caption","filename":"test.pdf"}}`,
399399
},
400400
},
401401
ExpectedExtIDs: []string{"157b5e14568e8"},
@@ -404,7 +404,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
404404
Label: "Image Send",
405405
MsgText: "image caption",
406406
MsgURN: "whatsapp:250788123123",
407-
MsgAttachments: []string{"image/jpeg:https://foo.bar/image.jpg"},
407+
MsgAttachments: []string{"image/jpeg:http://mock.com/1234/test.jpg"},
408408
MockResponses: map[string][]*httpx.MockResponse{
409409
"https://waba-v2.360dialog.io/messages": {
410410
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -413,7 +413,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
413413
ExpectedRequests: []ExpectedRequest{
414414
{
415415
Path: "/messages",
416-
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"image","image":{"link":"https://foo.bar/image.jpg","caption":"image caption"}}`,
416+
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"image","image":{"link":"http://mock.com/1234/test.jpg","caption":"image caption"}}`,
417417
},
418418
},
419419
ExpectedExtIDs: []string{"157b5e14568e8"},
@@ -422,7 +422,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
422422
Label: "Video Send",
423423
MsgText: "video caption",
424424
MsgURN: "whatsapp:250788123123",
425-
MsgAttachments: []string{"video/mp4:https://foo.bar/video.mp4"},
425+
MsgAttachments: []string{"video/mp4:http://mock.com/5678/test.mp4"},
426426
MockResponses: map[string][]*httpx.MockResponse{
427427
"https://waba-v2.360dialog.io/messages": {
428428
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -431,7 +431,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
431431
ExpectedRequests: []ExpectedRequest{
432432
{
433433
Path: "/messages",
434-
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"video","video":{"link":"https://foo.bar/video.mp4","caption":"video caption"}}`,
434+
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"video","video":{"link":"http://mock.com/5678/test.mp4","caption":"video caption"}}`,
435435
},
436436
},
437437
ExpectedExtIDs: []string{"157b5e14568e8"},
@@ -524,7 +524,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
524524
MsgText: "Interactive Button Msg",
525525
MsgURN: "whatsapp:250788123123",
526526
MsgQuickReplies: []string{"BUTTON1"},
527-
MsgAttachments: []string{"image/jpeg:https://foo.bar/image.jpg"},
527+
MsgAttachments: []string{"image/jpeg:http://mock.com/1234/test.jpg"},
528528
MockResponses: map[string][]*httpx.MockResponse{
529529
"https://waba-v2.360dialog.io/messages": {
530530
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -534,7 +534,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
534534
ExpectedRequests: []ExpectedRequest{
535535
{
536536
Path: "/messages",
537-
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"image","image":{"link":"https://foo.bar/image.jpg"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}`,
537+
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"image","image":{"link":"http://mock.com/1234/test.jpg"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}`,
538538
},
539539
},
540540
ExpectedExtIDs: []string{"157b5e14568e8"},
@@ -544,7 +544,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
544544
MsgText: "Interactive Button Msg",
545545
MsgURN: "whatsapp:250788123123",
546546
MsgQuickReplies: []string{"BUTTON1"},
547-
MsgAttachments: []string{"video/mp4:https://foo.bar/video.mp4"},
547+
MsgAttachments: []string{"video/mp4:http://mock.com/5678/test.mp4"},
548548
MockResponses: map[string][]*httpx.MockResponse{
549549
"https://waba-v2.360dialog.io/messages": {
550550
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -554,7 +554,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
554554
ExpectedRequests: []ExpectedRequest{
555555
{
556556
Path: "/messages",
557-
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"video","video":{"link":"https://foo.bar/video.mp4"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}`,
557+
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"video","video":{"link":"http://mock.com/5678/test.mp4"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}`,
558558
},
559559
},
560560
ExpectedExtIDs: []string{"157b5e14568e8"},
@@ -564,7 +564,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
564564
MsgText: "Interactive Button Msg",
565565
MsgURN: "whatsapp:250788123123",
566566
MsgQuickReplies: []string{"BUTTON1"},
567-
MsgAttachments: []string{"document/pdf:https://foo.bar/document.pdf"},
567+
MsgAttachments: []string{"document/pdf:http://mock.com/7890/test.pdf"},
568568
MockResponses: map[string][]*httpx.MockResponse{
569569
"https://waba-v2.360dialog.io/messages": {
570570
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -574,7 +574,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
574574
ExpectedRequests: []ExpectedRequest{
575575
{
576576
Path: "/messages",
577-
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"document","document":{"link":"https://foo.bar/document.pdf","filename":"document.pdf"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}`,
577+
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","header":{"type":"document","document":{"link":"http://mock.com/7890/test.pdf","filename":"test.pdf"}},"body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"BUTTON1"}}]}}}`,
578578
},
579579
},
580580
ExpectedExtIDs: []string{"157b5e14568e8"},
@@ -584,15 +584,15 @@ var SendTestCasesD3C = []OutgoingTestCase{
584584
MsgText: "Interactive Button Msg",
585585
MsgURN: "whatsapp:250788123123",
586586
MsgQuickReplies: []string{"ROW1", "ROW2", "ROW3"},
587-
MsgAttachments: []string{"audio/mp3:https://foo.bar/audio.mp3"},
587+
MsgAttachments: []string{"audio/mp3:http://mock.com/3456/test.mp3"},
588588
MockResponses: map[string][]*httpx.MockResponse{
589589
"*/messages": {
590590
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
591591
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
592592
},
593593
},
594594
ExpectedRequests: []ExpectedRequest{
595-
{Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"audio","audio":{"link":"https://foo.bar/audio.mp3"}}`},
595+
{Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"audio","audio":{"link":"http://mock.com/3456/test.mp3"}}`},
596596
{Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"button","body":{"text":"Interactive Button Msg"},"action":{"buttons":[{"type":"reply","reply":{"id":"0","title":"ROW1"}},{"type":"reply","reply":{"id":"1","title":"ROW2"}},{"type":"reply","reply":{"id":"2","title":"ROW3"}}]}}}`},
597597
},
598598
ExpectedExtIDs: []string{"157b5e14568e8", "157b5e14568e8"},
@@ -602,15 +602,15 @@ var SendTestCasesD3C = []OutgoingTestCase{
602602
MsgText: "Interactive List Msg",
603603
MsgURN: "whatsapp:250788123123",
604604
MsgQuickReplies: []string{"ROW1", "ROW2", "ROW3", "ROW4"},
605-
MsgAttachments: []string{"image/jpeg:https://foo.bar/image.jpg"},
605+
MsgAttachments: []string{"image/jpeg:http://mock.com/1234/test.jpg"},
606606
MockResponses: map[string][]*httpx.MockResponse{
607607
"*/messages": {
608608
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
609609
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
610610
},
611611
},
612612
ExpectedRequests: []ExpectedRequest{
613-
{Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"image","image":{"link":"https://foo.bar/image.jpg"}}`},
613+
{Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"image","image":{"link":"http://mock.com/1234/test.jpg"}}`},
614614
{Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"interactive","interactive":{"type":"list","body":{"text":"Interactive List Msg"},"action":{"button":"Menu","sections":[{"rows":[{"id":"0","title":"ROW1"},{"id":"1","title":"ROW2"},{"id":"2","title":"ROW3"},{"id":"3","title":"ROW4"}]}]}}}`},
615615
},
616616
ExpectedExtIDs: []string{"157b5e14568e8", "157b5e14568e8"},
@@ -686,6 +686,30 @@ var SendTestCasesD3C = []OutgoingTestCase{
686686
},
687687
}
688688

689+
// setupMedia takes care of having the media files needed to our test server host
690+
func setupMedia(mb *test.MockBackend) {
691+
imageJPG := test.NewMockMedia("test.jpg", "image/jpeg", "http://mock.com/1234/test.jpg", 1024*1024, 640, 480, 0, nil)
692+
693+
audioM4A := test.NewMockMedia("test.m4a", "audio/mp4", "http://mock.com/2345/test.m4a", 1024*1024, 0, 0, 200, nil)
694+
audioMP3 := test.NewMockMedia("test.mp3", "audio/mpeg", "http://mock.com/3456/test.mp3", 1024*1024, 0, 0, 200, []courier.Media{audioM4A})
695+
696+
thumbJPG := test.NewMockMedia("test.jpg", "image/jpeg", "http://mock.com/4567/test.jpg", 1024*1024, 640, 480, 0, nil)
697+
videoMP4 := test.NewMockMedia("test.mp4", "video/mp4", "http://mock.com/5678/test.mp4", 1024*1024, 0, 0, 1000, []courier.Media{thumbJPG})
698+
699+
videoMOV := test.NewMockMedia("test.mov", "video/quicktime", "http://mock.com/6789/test.mov", 100*1024*1024, 0, 0, 2000, nil)
700+
701+
filePDF := test.NewMockMedia("test.pdf", "application/pdf", "http://mock.com/7890/test.pdf", 100*1024*1024, 0, 0, 0, nil)
702+
703+
stickerWEBP := test.NewMockMedia("test.webp", "image/webp", "http://mock.com/8901/test.webp", 50*1024, 480, 480, 0, nil)
704+
705+
mb.MockMedia(imageJPG)
706+
mb.MockMedia(audioMP3)
707+
mb.MockMedia(videoMP4)
708+
mb.MockMedia(videoMOV)
709+
mb.MockMedia(filePDF)
710+
mb.MockMedia(stickerWEBP)
711+
}
712+
689713
func TestOutgoing(t *testing.T) {
690714
// shorter max msg length for testing
691715
maxMsgLength = 100
@@ -696,5 +720,5 @@ func TestOutgoing(t *testing.T) {
696720
})
697721
checkRedacted := []string{"the-auth-token"}
698722

699-
RunOutgoingTestCases(t, ChannelWAC, newWAHandler(courier.ChannelType("D3C"), "360Dialog"), SendTestCasesD3C, checkRedacted, nil)
723+
RunOutgoingTestCases(t, ChannelWAC, newWAHandler(courier.ChannelType("D3C"), "360Dialog"), SendTestCasesD3C, checkRedacted, setupMedia)
700724
}

0 commit comments

Comments
 (0)