From 403f0b0d056f0167969570a021ba85f58bceac51 Mon Sep 17 00:00:00 2001 From: Nic Pottier Date: Sat, 15 Jun 2019 09:13:56 -0500 Subject: [PATCH] ignore viber dlrs as they are sent for both in and out --- handlers/viber/viber.go | 6 ++---- handlers/viber/viber_test.go | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/handlers/viber/viber.go b/handlers/viber/viber.go index b4d61eb32..d747f402b 100644 --- a/handlers/viber/viber.go +++ b/handlers/viber/viber.go @@ -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 diff --git a/handlers/viber/viber_test.go b/handlers/viber/viber_test.go index 2c15def4f..953b77b58 100644 --- a/handlers/viber/viber_test.go +++ b/handlers/viber/viber_test.go @@ -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},