diff --git a/handlers/chip/handler.go b/handlers/chip/handler.go index c39df0b8e..4aee81572 100644 --- a/handlers/chip/handler.go +++ b/handlers/chip/handler.go @@ -110,10 +110,11 @@ func (h *handler) receive(ctx context.Context, c courier.Channel, w http.Respons } type sendMsg struct { - ID courier.MsgID `json:"id"` - Text string `json:"text"` - Origin courier.MsgOrigin `json:"origin"` - UserID courier.UserID `json:"user_id,omitempty"` + ID courier.MsgID `json:"id"` + Text string `json:"text"` + Attachments []string `json:"attachments,omitempty"` + Origin courier.MsgOrigin `json:"origin"` + UserID courier.UserID `json:"user_id,omitempty"` } type sendPayload struct { @@ -133,10 +134,11 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen ChatID: msg.URN().Path(), Secret: secret, Msg: sendMsg{ - ID: msg.ID(), - Text: msg.Text(), - Origin: msg.Origin(), - UserID: msg.UserID(), + ID: msg.ID(), + Text: msg.Text(), + Attachments: msg.Attachments(), + Origin: msg.Origin(), + UserID: msg.UserID(), }, } req, _ := http.NewRequest("POST", sendURL+"/"+string(msg.Channel().UUID())+"/", bytes.NewReader(jsonx.MustMarshal(payload))) diff --git a/handlers/chip/handler_test.go b/handlers/chip/handler_test.go index 97c8ff829..62fcb9c0c 100644 --- a/handlers/chip/handler_test.go +++ b/handlers/chip/handler_test.go @@ -91,10 +91,10 @@ var outgoingCases = []OutgoingTestCase{ }, }, { - Label: "Chat message", - MsgText: "Simple message ☺", - MsgURN: "webchat:65vbbDAQCdPdEWlEhDGy4utO", - MsgUserID: 123, + Label: "Chat message that is an attachment", + MsgAttachments: []string{"image/jpeg:https://example.com/image.jpg"}, + MsgURN: "webchat:65vbbDAQCdPdEWlEhDGy4utO", + MsgUserID: 123, MockResponses: map[string][]*httpx.MockResponse{ "http://textit.com/wc/send/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/": { httpx.NewMockResponse(200, nil, []byte(`{"status": "queued"}`)), @@ -102,7 +102,7 @@ var outgoingCases = []OutgoingTestCase{ }, ExpectedRequests: []ExpectedRequest{ { - Body: `{"chat_id":"65vbbDAQCdPdEWlEhDGy4utO","secret":"sesame","msg":{"id":10,"text":"Simple message ☺","origin":"flow","user_id":123}}`, + Body: `{"chat_id":"65vbbDAQCdPdEWlEhDGy4utO","secret":"sesame","msg":{"id":10,"text":"","attachments":["image/jpeg:https://example.com/image.jpg"],"origin":"flow","user_id":123}}`, }, }, },