Skip to content

Commit 780f2b5

Browse files
committed
Model quick replies as structs instead of strings
1 parent 00d1c97 commit 780f2b5

34 files changed

+196
-155
lines changed

Diff for: backends/rapidpro/backend_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (ts *BackendTestSuite) TestMsgUnmarshal() {
172172
ts.Equal([]string{"https://foo.bar/image.jpg"}, msg.Attachments())
173173
ts.Equal("5ApPVsFDcFt:RZdK9ne7LgfvBYdtCYg7tv99hC9P2", msg.URNAuth_)
174174
ts.Equal("", msg.ExternalID())
175-
ts.Equal([]string{"Yes", "No"}, msg.QuickReplies())
175+
ts.Equal([]courier.QuickReply{{Text: "Yes"}, {Text: "No"}}, msg.QuickReplies())
176176
ts.Equal("event", msg.Topic())
177177
ts.Equal("external-id", msg.ResponseToExternalID())
178178
ts.True(msg.HighPriority())
@@ -1605,7 +1605,6 @@ SELECT
16051605
direction,
16061606
text,
16071607
attachments,
1608-
quick_replies,
16091608
msg_count,
16101609
error_count,
16111610
failed_reason,

Diff for: backends/rapidpro/msg.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ const (
4545

4646
// Msg is our base struct to represent msgs both in our JSON and db representations
4747
type Msg struct {
48-
OrgID_ OrgID `json:"org_id" db:"org_id"`
49-
ID_ courier.MsgID `json:"id" db:"id"`
50-
UUID_ courier.MsgUUID `json:"uuid" db:"uuid"`
51-
Direction_ MsgDirection ` db:"direction"`
52-
Status_ courier.MsgStatus ` db:"status"`
53-
Visibility_ MsgVisibility ` db:"visibility"`
54-
HighPriority_ bool `json:"high_priority" db:"high_priority"`
55-
Text_ string `json:"text" db:"text"`
56-
Attachments_ pq.StringArray `json:"attachments" db:"attachments"`
57-
QuickReplies_ pq.StringArray `json:"quick_replies" db:"quick_replies"`
58-
Locale_ null.String `json:"locale" db:"locale"`
59-
Templating_ *courier.Templating `json:"templating" db:"templating"`
60-
ExternalID_ null.String ` db:"external_id"`
61-
Metadata_ json.RawMessage `json:"metadata" db:"metadata"`
48+
OrgID_ OrgID `json:"org_id" db:"org_id"`
49+
ID_ courier.MsgID `json:"id" db:"id"`
50+
UUID_ courier.MsgUUID `json:"uuid" db:"uuid"`
51+
Direction_ MsgDirection ` db:"direction"`
52+
Status_ courier.MsgStatus ` db:"status"`
53+
Visibility_ MsgVisibility ` db:"visibility"`
54+
HighPriority_ bool `json:"high_priority" db:"high_priority"`
55+
Text_ string `json:"text" db:"text"`
56+
Attachments_ pq.StringArray `json:"attachments" db:"attachments"`
57+
QuickReplies_ []courier.QuickReply `json:"quick_replies"`
58+
Locale_ null.String `json:"locale" db:"locale"`
59+
Templating_ *courier.Templating `json:"templating" db:"templating"`
60+
ExternalID_ null.String ` db:"external_id"`
61+
Metadata_ json.RawMessage `json:"metadata" db:"metadata"`
6262

6363
ChannelID_ courier.ChannelID ` db:"channel_id"`
6464
ContactID_ ContactID `json:"contact_id" db:"contact_id"`
@@ -135,12 +135,12 @@ func (m *Msg) URN() urns.URN { return m.URN_ }
135135
func (m *Msg) Channel() courier.Channel { return m.channel }
136136

137137
// outgoing specific
138-
func (m *Msg) QuickReplies() []string { return m.QuickReplies_ }
139-
func (m *Msg) Locale() i18n.Locale { return i18n.Locale(string(m.Locale_)) }
140-
func (m *Msg) Templating() *courier.Templating { return m.Templating_ }
141-
func (m *Msg) URNAuth() string { return m.URNAuth_ }
142-
func (m *Msg) Origin() courier.MsgOrigin { return m.Origin_ }
143-
func (m *Msg) ContactLastSeenOn() *time.Time { return m.ContactLastSeenOn_ }
138+
func (m *Msg) QuickReplies() []courier.QuickReply { return m.QuickReplies_ }
139+
func (m *Msg) Locale() i18n.Locale { return i18n.Locale(string(m.Locale_)) }
140+
func (m *Msg) Templating() *courier.Templating { return m.Templating_ }
141+
func (m *Msg) URNAuth() string { return m.URNAuth_ }
142+
func (m *Msg) Origin() courier.MsgOrigin { return m.Origin_ }
143+
func (m *Msg) ContactLastSeenOn() *time.Time { return m.ContactLastSeenOn_ }
144144
func (m *Msg) Topic() string {
145145
if m.Metadata_ == nil {
146146
return ""

Diff for: handlers/dialog360/handler.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
357357
Type: "reply",
358358
}
359359
btns[i].Reply.ID = fmt.Sprint(i)
360-
btns[i].Reply.Title = qr
360+
btns[i].Reply.Title = qr.Text
361361
}
362362
interactive.Action = &struct {
363363
Button string "json:\"button,omitempty\""
@@ -376,7 +376,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
376376
for i, qr := range qrs {
377377
section.Rows[i] = whatsapp.SectionRow{
378378
ID: fmt.Sprint(i),
379-
Title: qr,
379+
Title: qr.Text,
380380
}
381381
}
382382

@@ -510,7 +510,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
510510
Type: "reply",
511511
}
512512
btns[i].Reply.ID = fmt.Sprint(i)
513-
btns[i].Reply.Title = qr
513+
btns[i].Reply.Title = qr.Text
514514
}
515515
interactive.Action = &struct {
516516
Button string "json:\"button,omitempty\""
@@ -530,7 +530,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
530530
for i, qr := range qrs {
531531
section.Rows[i] = whatsapp.SectionRow{
532532
ID: fmt.Sprint(i),
533-
Title: qr,
533+
Title: qr.Text,
534534
}
535535
}
536536

Diff for: handlers/dialog360/handler_test.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
487487
Label: "Interactive Button Message Send",
488488
MsgText: "Interactive Button Msg",
489489
MsgURN: "whatsapp:250788123123",
490-
MsgQuickReplies: []string{"BUTTON1"},
490+
MsgQuickReplies: []courier.QuickReply{{Text: "BUTTON1"}},
491491
MockResponses: map[string][]*httpx.MockResponse{
492492
"https://waba-v2.360dialog.io/messages": {
493493
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -502,7 +502,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
502502
Label: "Interactive List Message Send",
503503
MsgText: "Interactive List Msg",
504504
MsgURN: "whatsapp:250788123123",
505-
MsgQuickReplies: []string{"ROW1", "ROW2", "ROW3", "ROW4"},
505+
MsgQuickReplies: []courier.QuickReply{{Text: "ROW1"}, {Text: "ROW2"}, {Text: "ROW3"}, {Text: "ROW4"}},
506506
MockResponses: map[string][]*httpx.MockResponse{
507507
"https://waba-v2.360dialog.io/messages": {
508508
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -517,7 +517,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
517517
Label: "Interactive List Message Send more than 10 QRs",
518518
MsgText: "Interactive List Msg",
519519
MsgURN: "whatsapp:250788123123",
520-
MsgQuickReplies: []string{"ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8", "ROW9", "ROW10", "ROW11", "ROW12"},
520+
MsgQuickReplies: []courier.QuickReply{{Text: "ROW1"}, {Text: "ROW2"}, {Text: "ROW3"}, {Text: "ROW4"}, {Text: "ROW5"}, {Text: "ROW6"}, {Text: "ROW7"}, {Text: "ROW8"}, {Text: "ROW9"}, {Text: "ROW10"}, {Text: "ROW11"}, {Text: "ROW12"}},
521521
MockResponses: map[string][]*httpx.MockResponse{
522522
"https://waba-v2.360dialog.io/messages": {
523523
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -534,7 +534,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
534534
MsgText: "Hola",
535535
MsgURN: "whatsapp:250788123123",
536536
MsgLocale: "spa",
537-
MsgQuickReplies: []string{"ROW1", "ROW2", "ROW3", "ROW4"},
537+
MsgQuickReplies: []courier.QuickReply{{Text: "ROW1"}, {Text: "ROW2"}, {Text: "ROW3"}, {Text: "ROW4"}},
538538
MockResponses: map[string][]*httpx.MockResponse{
539539
"https://waba-v2.360dialog.io/messages": {
540540
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
@@ -549,7 +549,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
549549
Label: "Interactive Button Message Send with image attachment",
550550
MsgText: "Interactive Button Msg",
551551
MsgURN: "whatsapp:250788123123",
552-
MsgQuickReplies: []string{"BUTTON1"},
552+
MsgQuickReplies: []courier.QuickReply{{Text: "BUTTON1"}},
553553
MsgAttachments: []string{"image/jpeg:https://foo.bar/image.jpg"},
554554
MockResponses: map[string][]*httpx.MockResponse{
555555
"https://waba-v2.360dialog.io/messages": {
@@ -569,7 +569,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
569569
Label: "Interactive Button Message Send with video attachment",
570570
MsgText: "Interactive Button Msg",
571571
MsgURN: "whatsapp:250788123123",
572-
MsgQuickReplies: []string{"BUTTON1"},
572+
MsgQuickReplies: []courier.QuickReply{{Text: "BUTTON1"}},
573573
MsgAttachments: []string{"video/mp4:https://foo.bar/video.mp4"},
574574
MockResponses: map[string][]*httpx.MockResponse{
575575
"https://waba-v2.360dialog.io/messages": {
@@ -589,7 +589,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
589589
Label: "Interactive Button Message Send with document attachment",
590590
MsgText: "Interactive Button Msg",
591591
MsgURN: "whatsapp:250788123123",
592-
MsgQuickReplies: []string{"BUTTON1"},
592+
MsgQuickReplies: []courier.QuickReply{{Text: "BUTTON1"}},
593593
MsgAttachments: []string{"document/pdf:https://foo.bar/document.pdf"},
594594
MockResponses: map[string][]*httpx.MockResponse{
595595
"https://waba-v2.360dialog.io/messages": {
@@ -609,7 +609,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
609609
Label: "Interactive Button Message Send with audio attachment",
610610
MsgText: "Interactive Button Msg",
611611
MsgURN: "whatsapp:250788123123",
612-
MsgQuickReplies: []string{"ROW1", "ROW2", "ROW3"},
612+
MsgQuickReplies: []courier.QuickReply{{Text: "ROW1"}, {Text: "ROW2"}, {Text: "ROW3"}},
613613
MsgAttachments: []string{"audio/mp3:https://foo.bar/audio.mp3"},
614614
MockResponses: map[string][]*httpx.MockResponse{
615615
"*/messages": {
@@ -627,7 +627,7 @@ var SendTestCasesD3C = []OutgoingTestCase{
627627
Label: "Interactive List Message Send with attachment",
628628
MsgText: "Interactive List Msg",
629629
MsgURN: "whatsapp:250788123123",
630-
MsgQuickReplies: []string{"ROW1", "ROW2", "ROW3", "ROW4"},
630+
MsgQuickReplies: []courier.QuickReply{{Text: "ROW1"}, {Text: "ROW2"}, {Text: "ROW3"}, {Text: "ROW4"}},
631631
MsgAttachments: []string{"image/jpeg:https://foo.bar/image.jpg"},
632632
MockResponses: map[string][]*httpx.MockResponse{
633633
"*/messages": {

Diff for: handlers/discord/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
171171
To: msg.URN().Path(),
172172
Channel: string(msg.Channel().UUID()),
173173
Attachments: attachmentURLs,
174-
QuickReplies: msg.QuickReplies(),
174+
QuickReplies: handlers.TextOnlyQuickReplies(msg.QuickReplies()),
175175
}
176176

177177
var body io.Reader

Diff for: handlers/discord/handler_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ var testChannels = []courier.Channel{
2424

2525
var testCases = []IncomingTestCase{
2626
{
27-
Label: "Recieve Message",
27+
Label: "Receive Message",
2828
URL: "/c/ds/bac782c2-7aeb-4389-92f5-97887744f573/receive",
2929
Data: `from=694634743521607802&text=hello`,
3030
ExpectedRespStatus: 200,
3131
ExpectedMsgText: Sp("hello"),
3232
ExpectedURN: "discord:694634743521607802",
3333
},
3434
{
35-
Label: "Recieve Message with attachment",
35+
Label: "Receive Message with attachment",
3636
URL: "/c/ds/bac782c2-7aeb-4389-92f5-97887744f573/receive",
3737
Data: `from=694634743521607802&text=hello&attachments=https://test.test/foo.png`,
3838
ExpectedRespStatus: 200,
@@ -90,7 +90,7 @@ var sendTestCases = []OutgoingTestCase{
9090
ExpectedRequests: []ExpectedRequest{
9191
{
9292
Path: "/discord/rp/send",
93-
Body: `{"id":"10","text":"Hello World","to":"694634743521607802","channel":"bac782c2-7aeb-4389-92f5-97887744f573","attachments":[],"quick_replies":null}`,
93+
Body: `{"id":"10","text":"Hello World","to":"694634743521607802","channel":"bac782c2-7aeb-4389-92f5-97887744f573","attachments":[],"quick_replies":[]}`,
9494
},
9595
},
9696
},
@@ -107,15 +107,15 @@ var sendTestCases = []OutgoingTestCase{
107107
ExpectedRequests: []ExpectedRequest{
108108
{
109109
Path: "/discord/rp/send",
110-
Body: `{"id":"10","text":"Hello World","to":"694634743521607802","channel":"bac782c2-7aeb-4389-92f5-97887744f573","attachments":["https://foo.bar/image.jpg"],"quick_replies":null}`,
110+
Body: `{"id":"10","text":"Hello World","to":"694634743521607802","channel":"bac782c2-7aeb-4389-92f5-97887744f573","attachments":["https://foo.bar/image.jpg"],"quick_replies":[]}`,
111111
},
112112
},
113113
},
114114
{
115115
Label: "Attachement and quick replies",
116116
MsgText: "Hello World",
117117
MsgAttachments: []string{"image/jpeg:https://foo.bar/image.jpg"},
118-
MsgQuickReplies: []string{"hello", "world"},
118+
MsgQuickReplies: []courier.QuickReply{{Text: "hello"}, {Text: "world"}},
119119
MsgURN: "discord:694634743521607802",
120120
MockResponses: map[string][]*httpx.MockResponse{
121121
"http://example.com/discord/rp/send": {
@@ -141,7 +141,7 @@ var sendTestCases = []OutgoingTestCase{
141141
ExpectedRequests: []ExpectedRequest{
142142
{
143143
Path: "/discord/rp/send",
144-
Body: `{"id":"10","text":"Error Sending","to":"694634743521607802","channel":"bac782c2-7aeb-4389-92f5-97887744f573","attachments":[],"quick_replies":null}`,
144+
Body: `{"id":"10","text":"Error Sending","to":"694634743521607802","channel":"bac782c2-7aeb-4389-92f5-97887744f573","attachments":[],"quick_replies":[]}`,
145145
},
146146
},
147147
ExpectedError: courier.ErrResponseStatus,
@@ -158,7 +158,7 @@ var sendTestCases = []OutgoingTestCase{
158158
ExpectedRequests: []ExpectedRequest{
159159
{
160160
Path: "/discord/rp/send",
161-
Body: `{"id":"10","text":"Error","to":"694634743521607802","channel":"bac782c2-7aeb-4389-92f5-97887744f573","attachments":[],"quick_replies":null}`,
161+
Body: `{"id":"10","text":"Error","to":"694634743521607802","channel":"bac782c2-7aeb-4389-92f5-97887744f573","attachments":[],"quick_replies":[]}`,
162162
},
163163
},
164164
ExpectedError: courier.ErrConnectionFailed,

Diff for: handlers/external/handler.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/nyaruka/courier"
1717
"github.com/nyaruka/courier/handlers"
1818
"github.com/nyaruka/gocommon/gsm7"
19+
"github.com/nyaruka/gocommon/jsonx"
1920
"github.com/nyaruka/gocommon/urns"
2021
)
2122

@@ -328,7 +329,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
328329
if i == len(parts)-1 {
329330
formEncoded["quick_replies"] = buildQuickRepliesResponse(msg.QuickReplies(), sendMethod, contentURLEncoded)
330331
} else {
331-
formEncoded["quick_replies"] = buildQuickRepliesResponse([]string{}, sendMethod, contentURLEncoded)
332+
formEncoded["quick_replies"] = buildQuickRepliesResponse([]courier.QuickReply{}, sendMethod, contentURLEncoded)
332333
}
333334
url := replaceVariables(sendURL, formEncoded)
334335

@@ -339,7 +340,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
339340
if i == len(parts)-1 {
340341
formEncoded["quick_replies"] = buildQuickRepliesResponse(msg.QuickReplies(), sendMethod, contentType)
341342
} else {
342-
formEncoded["quick_replies"] = buildQuickRepliesResponse([]string{}, sendMethod, contentType)
343+
formEncoded["quick_replies"] = buildQuickRepliesResponse([]courier.QuickReply{}, sendMethod, contentType)
343344
}
344345
body = strings.NewReader(replaceVariables(sendBody, formEncoded))
345346
}
@@ -381,27 +382,26 @@ type quickReplyXMLItem struct {
381382
Value string `xml:",chardata"`
382383
}
383384

384-
func buildQuickRepliesResponse(quickReplies []string, sendMethod string, contentType string) string {
385+
func buildQuickRepliesResponse(quickReplies []courier.QuickReply, sendMethod string, contentType string) string {
385386
if quickReplies == nil {
386-
quickReplies = []string{}
387+
quickReplies = []courier.QuickReply{}
387388
}
388389
if (sendMethod == http.MethodPost || sendMethod == http.MethodPut) && contentType == contentJSON {
389-
marshalled, _ := json.Marshal(quickReplies)
390-
return string(marshalled)
390+
return string(jsonx.MustMarshal(handlers.TextOnlyQuickReplies(quickReplies)))
391391
} else if (sendMethod == http.MethodPost || sendMethod == http.MethodPut) && contentType == contentXML {
392392
items := make([]quickReplyXMLItem, len(quickReplies))
393393

394394
for i, v := range quickReplies {
395-
items[i] = quickReplyXMLItem{Value: v}
395+
items[i] = quickReplyXMLItem{Value: v.Text}
396396
}
397397
marshalled, _ := xml.Marshal(items)
398398
return string(marshalled)
399399
} else {
400400
response := bytes.Buffer{}
401401

402402
for _, reply := range quickReplies {
403-
reply = url.QueryEscape(reply)
404-
response.WriteString(fmt.Sprintf("&quick_reply=%s", reply))
403+
reply.Text = url.QueryEscape(reply.Text)
404+
response.WriteString(fmt.Sprintf("&quick_reply=%s", reply.Text))
405405
}
406406
return response.String()
407407
}

Diff for: handlers/external/handler_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ var longSendTestCases = []OutgoingTestCase{
313313
{
314314
Label: "Long Send",
315315
MsgText: "This is a long message that will be longer than 30....... characters", MsgURN: "tel:+250788383383",
316-
MsgQuickReplies: []string{"One"},
316+
MsgQuickReplies: []courier.QuickReply{{Text: "One"}},
317317
MockResponses: map[string][]*httpx.MockResponse{
318318
"http://example.com/send*": {
319319
httpx.NewMockResponse(200, nil, []byte(`0: Accepted for delivery`)),
@@ -627,7 +627,7 @@ var jsonSendTestCases = []OutgoingTestCase{
627627
Label: "Send Quick Replies",
628628
MsgText: "Some message",
629629
MsgURN: "tel:+250788383383",
630-
MsgQuickReplies: []string{"One", "Two", "Three"},
630+
MsgQuickReplies: []courier.QuickReply{{Text: "One"}, {Text: "Two"}, {Text: "Three"}},
631631
MockResponses: map[string][]*httpx.MockResponse{
632632
"http://example.com/send": {
633633
httpx.NewMockResponse(200, nil, []byte(`0: Accepted for delivery`)),
@@ -645,7 +645,7 @@ var jsonLongSendTestCases = []OutgoingTestCase{
645645
Label: "Send Long message JSON",
646646
MsgText: "This is a long message that will be longer than 30....... characters",
647647
MsgURN: "tel:+250788383383",
648-
MsgQuickReplies: []string{"One", "Two", "Three"},
648+
MsgQuickReplies: []courier.QuickReply{{Text: "One"}, {Text: "Two"}, {Text: "Three"}},
649649
MockResponses: map[string][]*httpx.MockResponse{
650650
"*": {
651651
httpx.NewMockResponse(200, nil, []byte(`0: Accepted for delivery`)),
@@ -733,7 +733,7 @@ var xmlSendTestCases = []OutgoingTestCase{
733733
Label: "Send Quick Replies",
734734
MsgText: "Some message",
735735
MsgURN: "tel:+250788383383",
736-
MsgQuickReplies: []string{"One", "Two", "Three"},
736+
MsgQuickReplies: []courier.QuickReply{{Text: "One"}, {Text: "Two"}, {Text: "Three"}},
737737
MockResponses: map[string][]*httpx.MockResponse{
738738
"http://example.com/send": {
739739
httpx.NewMockResponse(200, nil, []byte(`0: Accepted for delivery`)),
@@ -751,7 +751,7 @@ var xmlLongSendTestCases = []OutgoingTestCase{
751751
Label: "Send Long message XML",
752752
MsgText: "This is a long message that will be longer than 30....... characters",
753753
MsgURN: "tel:+250788383383",
754-
MsgQuickReplies: []string{"One", "Two", "Three"},
754+
MsgQuickReplies: []courier.QuickReply{{Text: "One"}, {Text: "Two"}, {Text: "Three"}},
755755
MockResponses: map[string][]*httpx.MockResponse{
756756
"*": {
757757
httpx.NewMockResponse(200, nil, []byte(`0: Accepted for delivery`)),
@@ -855,7 +855,7 @@ var xmlSendWithResponseContentTestCases = []OutgoingTestCase{
855855
Label: "Send Quick Replies",
856856
MsgText: "Some message",
857857
MsgURN: "tel:+250788383383",
858-
MsgQuickReplies: []string{"One", "Two", "Three"},
858+
MsgQuickReplies: []courier.QuickReply{{Text: "One"}, {Text: "Two"}, {Text: "Three"}},
859859
MockResponses: map[string][]*httpx.MockResponse{
860860
"http://example.com/send": {
861861
httpx.NewMockResponse(200, nil, []byte(`<return>0</return>`)),

Diff for: handlers/facebook_legacy/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
530530
// include any quick replies on the last piece we send
531531
if i == (len(msgParts)+len(msg.Attachments()))-1 {
532532
for _, qr := range msg.QuickReplies() {
533-
payload.Message.QuickReplies = append(payload.Message.QuickReplies, mtQuickReply{qr, qr, "text"})
533+
payload.Message.QuickReplies = append(payload.Message.QuickReplies, mtQuickReply{qr.Text, qr.Text, "text"})
534534
}
535535
} else {
536536
payload.Message.QuickReplies = nil

0 commit comments

Comments
 (0)