Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle rejected delivery receipt #388

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ jobs:
with:
token: ${{ secrets.SOMLENG_PERSONAL_ACCESS_TOKEN }}

create-sentry-release:
name: Create Sentry Release
runs-on: ubuntu-latest
needs:
- release
if: ${{ needs.release.outputs.release_created }}
steps:
- uses: actions/checkout@v4

- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: somleng
SENTRY_PROJECT: sms-gateway
with:
environment: production

build-packages:
name: Build Packages
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion lib/gateways/smpp_delivery_receipt.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ class SMPPDeliveryReceipt {
result.status = "delivered";
} else if (matches.groups.stat === "ENROUTE" || matches.groups.stat === "ENROUTE") {
result.status = "sent";
} else if (matches.groups.stat === "UNDELIVERABLE" || matches.groups.stat === "UNDELIV") {
} else if (
matches.groups.stat === "UNDELIVERABLE" ||
matches.groups.stat === "UNDELIV" ||
matches.groups.stat === "REJECTD"
) {
result.status = "failed";
} else {
throw new UnsupportedDeliveryStatusError("Unsupported Delivery Status Error");
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions test/lib/gateways/smpp_delivery_receipt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ describe(SMPPDeliveryReceipt, () => {
expect(deliveryReceipt.status).toEqual("failed");
});

it("parses rejected receipt from Kannel", () => {
const message =
"id:577e505a-dbd7-46ab-a04c-5a927ffb85b1 sub:001 dlvrd:000 submit date:2408201338 done date:240820093823 stat:REJECTD err:00B text:You";

const deliveryReceipt = SMPPDeliveryReceipt.parse(message);

expect(deliveryReceipt.status).toEqual("failed");
});

it("handles unsupported message format", () => {
const message =
"id:88316820 sub:0 dlvrd:0 submit date:2302281324 done date:2302281325 err:500 Text:Hello World from out";
Expand Down