Skip to content

Commit

Permalink
Add send error for channel and contact pair limit hit to allow retryi…
Browse files Browse the repository at this point in the history
…ng the message
  • Loading branch information
norkans7 committed Nov 25, 2024
1 parent 9e07701 commit 411c508
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions handlers/meta/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,10 @@ func (h *handler) requestWAC(payload whatsapp.SendRequest, accessToken string, r
return courier.ErrResponseUnparseable
}

if respPayload.Error.Code == 131056 {
return courier.ErrConnectionThrottled
}

if respPayload.Error.Code != 0 {
return courier.ErrFailedWithReason(strconv.Itoa(respPayload.Error.Code), respPayload.Error.Message)
}
Expand Down
11 changes: 11 additions & 0 deletions handlers/meta/whataspp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,17 @@ var whatsappOutgoingTests = []OutgoingTestCase{
},
ExpectedError: courier.ErrResponseUnparseable,
},
{
Label: "Error Channel Contact Pair limit hit",
MsgText: "Pair limit",
MsgURN: "whatsapp:250788123123",
MockResponses: map[string][]*httpx.MockResponse{
"*/12345_ID/messages": {
httpx.NewMockResponse(403, nil, []byte(`{ "error": {"message": "(#131056) (Business Account, Consumer Account) pair rate limit hit","code": 131056 }}`)),
},
},
ExpectedError: courier.ErrConnectionThrottled,
},
{
Label: "Error",
MsgText: "Error",
Expand Down

0 comments on commit 411c508

Please sign in to comment.