Skip to content

Commit

Permalink
Update to support D3 contact check for whatspp contact not in contact…
Browse files Browse the repository at this point in the history
… store
  • Loading branch information
norkans7 committed Feb 25, 2022
1 parent f28d4be commit 89125d1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion handlers/whatsapp/whatsapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ func hasTiersError(payload mtErrorPayload) bool {

func hasWhatsAppContactError(payload mtErrorPayload) bool {
for _, err := range payload.Errors {
if err.Code == 1006 && err.Title == "Resource not found" && err.Details == "unknown contact" {
if err.Code == 1006 && err.Title == "Resource not found" && (err.Details == "unknown contact" || err.Details == "Could not retrieve phone number from contact store") {
return true
}
}
Expand Down
32 changes: 32 additions & 0 deletions handlers/whatsapp/whatsapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,38 @@ var defaultSendTestCases = []ChannelSendTestCase{
},
SendPrep: setSendURL,
},
{Label: "Try Messaging Again After WhatsApp Contact Check",
Text: "try again", URN: "whatsapp:250788123123",
Status: "W", ExternalID: "157b5e14568e8",
Responses: map[MockedRequest]MockedResponse{
MockedRequest{
Method: "POST",
Path: "/v1/messages",
Body: `{"to":"250788123123","type":"text","text":{"body":"try again"}}`,
}: MockedResponse{
Status: 404,
Body: `{"errors": [{"code": 1006, "title": "Resource not found", "details": "Could not retrieve phone number from contact store"}]}`,
},
MockedRequest{
Method: "POST",
Path: "/v1/contacts",
Body: `{"blocking":"wait","contacts":["+250788123123"],"force_check":true}`,
}: MockedResponse{
Status: 200,
Body: `{"contacts": [{"input": "+250788123123", "status": "valid", "wa_id": "250788123123"}]}`,
},
MockedRequest{
Method: "POST",
Path: "/v1/messages",
RawQuery: "retry=1",
Body: `{"to":"250788123123","type":"text","text":{"body":"try again"}}`,
}: MockedResponse{
Status: 201,
Body: `{"messages": [{"id": "157b5e14568e8"}]}`,
},
},
SendPrep: setSendURL,
},
{Label: "Try Messaging Again After WhatsApp Contact Check With Returned WhatsApp ID",
Text: "try again", URN: "whatsapp:5582999887766",
Status: "W", ExternalID: "157b5e14568e8",
Expand Down

0 comments on commit 89125d1

Please sign in to comment.