Skip to content

Commit

Permalink
Ignore requests with empty events instead of returnin error
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Feb 15, 2018
1 parent f03d0d1 commit f987593
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions handlers/line/line.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ func (h *handler) ReceiveMessage(ctx context.Context, channel courier.Channel, w
}

if len(msgs) == 0 {
if len(lineRequest.Events) > 0 {
return nil, courier.WriteAndLogRequestIgnored(ctx, w, r, channel, "ignoring request, no message")
}
return nil, courier.WriteAndLogRequestError(ctx, w, r, channel, fmt.Errorf("missing message, source or type in the event"))

return nil, courier.WriteAndLogRequestIgnored(ctx, w, r, channel, "ignoring request, no message")
}

return events, courier.WriteMsgSuccess(ctx, w, r, msgs)
Expand Down
2 changes: 1 addition & 1 deletion handlers/line/line_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var handleTestCases = []ChannelHandleTestCase{
{Label: "Receive Valid Message", URL: receiveURL, Data: receiveValidMessageLast, Status: 200, Response: "Accepted",
Text: Sp("Last event"), URN: Sp("line:uabcdefghij"), Date: Tp(time.Date(2016, 4, 7, 1, 11, 27, 970000000, time.UTC))},
{Label: "Missing message", URL: receiveURL, Data: missingMessage, Status: 200, Response: "ignoring request, no message"},
{Label: "No event request", URL: receiveURL, Data: noEvent, Status: 400, Response: "missing message, source or type in the event"},
{Label: "No event request", URL: receiveURL, Data: noEvent, Status: 200, Response: "ignoring request, no message"},
}

func TestHandler(t *testing.T) {
Expand Down

0 comments on commit f987593

Please sign in to comment.