Skip to content

Commit 66ae5b7

Browse files
authored
Merge pull request #711 from nyaruka/line-attachnment-err-log
Add channel log for error with line attachments
2 parents eee6313 + 59765cb commit 66ae5b7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Diff for: handlers/line/handler.go

+2
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
317317

318318
if err == nil {
319319
jsonMsgs = append(jsonMsgs, string(jsonMsg))
320+
} else {
321+
return err
320322
}
321323
}
322324

Diff for: handlers/line/handler_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,22 @@ var defaultSendTestCases = []OutgoingTestCase{
513513
},
514514
},
515515
},
516+
{
517+
Label: "Long messsage, Quick Reply combined and attachment",
518+
MsgText: "This is a longer message than 160 characters and will cause us to split it into two separate parts, isn't that right but it is even longer than before I say, I need to keep adding more things to make it work",
519+
MsgURN: "line:uabcdefghij",
520+
MsgResponseToExternalID: "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
521+
MsgAttachments: []string{"image/jpeg:http://mock.com/1234/test.jpg"},
522+
MsgQuickReplies: []string{"Yes", "No"},
523+
MockResponses: map[string][]*httpx.MockResponse{
524+
"https://api.line.me/v2/bot/message/reply": {httpx.NewMockResponse(200, nil, []byte(`{}`))},
525+
},
526+
ExpectedRequests: []ExpectedRequest{
527+
{
528+
Body: `{"replyToken":"nHuyWiB7yP5Zw52FIkcQobQuGDXCTA","messages":[{"type":"image","originalContentUrl":"http://mock.com/1234/test.jpg","previewImageUrl":"http://mock.com/1234/test.jpg"},{"type":"text","text":"This is a longer message than 160 characters and will cause us to split it into two separate parts, isn't that right but it is even longer than before I say,"},{"type":"text","text":"I need to keep adding more things to make it work","quickReply":{"items":[{"type":"action","action":{"type":"message","label":"Yes","text":"Yes"}},{"type":"action","action":{"type":"message","label":"No","text":"No"}}]}}]}`,
529+
},
530+
},
531+
},
516532
{
517533
Label: "Send Push Message If Invalid Reply",
518534
MsgText: "Simple Message",

0 commit comments

Comments
 (0)