Skip to content

Commit

Permalink
ignore viber dlrs as they are sent for both in and out
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Jun 15, 2019
1 parent 00758b3 commit 403f0b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions handlers/viber/viber.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,8 @@ func (h *handler) receiveEvent(ctx context.Context, channel courier.Channel, w h
return handlers.WriteMsgStatusAndResponse(ctx, h, channel, msgStatus, w, r)

case "delivered":
msgStatus := h.Backend().NewMsgStatusForExternalID(channel, fmt.Sprintf("%d", payload.MessageToken), courier.MsgDelivered)

err = h.Backend().WriteMsgStatus(ctx, msgStatus)
return handlers.WriteMsgStatusAndResponse(ctx, h, channel, msgStatus, w, r)
// we ignore delivered events for viber as they send these for incoming messages too and its not worth the db hit to verify that
return nil, handlers.WriteAndLogRequestIgnored(ctx, h, channel, w, r, "ignoring delivered status")

case "message":
sender := payload.Sender.ID
Expand Down
2 changes: 1 addition & 1 deletion handlers/viber/viber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ var testCases = []ChannelHandleTestCase{
PrepRequest: addValidSignature},
{Label: "Webhook validation", URL: receiveURL, Data: webhookCheck, Status: 200, Response: "webhook valid", PrepRequest: addValidSignature},
{Label: "Failed Status Report", URL: receiveURL, Data: failedStatusReport, Status: 200, Response: `"status":"F"`, PrepRequest: addValidSignature},
{Label: "Delivered Status Report", URL: receiveURL, Data: deliveredStatusReport, Status: 200, Response: `"status":"D"`, PrepRequest: addValidSignature},
{Label: "Delivered Status Report", URL: receiveURL, Data: deliveredStatusReport, Status: 200, Response: `Ignored`, PrepRequest: addValidSignature},
{Label: "Subcribe", URL: receiveURL, Data: validSubscribed, Status: 200, Response: "Accepted", PrepRequest: addValidSignature},
{Label: "Subcribe Invalid URN", URL: receiveURL, Data: invalidURNSubscribed, Status: 400, Response: "invalid viber id", PrepRequest: addValidSignature},
{Label: "Unsubcribe", URL: receiveURL, Data: validUnsubscribed, Status: 200, Response: "Accepted", ChannelEvent: Sp(string(courier.StopContact)), PrepRequest: addValidSignature},
Expand Down

0 comments on commit 403f0b0

Please sign in to comment.