diff --git a/AGENTS.md b/AGENTS.md index ff19045..17d0a0f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -207,7 +207,7 @@ exactly 140. `esm_class` at 0, and reading that as the spec's "default message type" would lose every one of them. A non-empty `receipted_message_id` TLV marks a receipt on the same footing there, since nothing but a receipt carries one. What gets scraped is the decoded `short_message` with any UDH - stripped; receipts never reach the reassembler, so an SMSC that splits one across segments gets a + stripped; a receipt this library recognises never reaches the reassembler, so an SMSC that splits one across segments gets a `dlr` per segment rather than one merged report. The `message_state` TLV is authoritative only where it names a state in the table — SMPP reserves 0x80-0xFF for MC-vendor-specific values, so an unnameable one keeps its raw `statusId` and leaves diff --git a/src/dlr.ts b/src/dlr.ts index db76b7d..61f48e2 100644 --- a/src/dlr.ts +++ b/src/dlr.ts @@ -160,7 +160,7 @@ function receiptBody(pduObj: PduObject): string { } function receiptId(tlvId: ParamValue | undefined, receipt: Receipt | undefined): string | undefined { - return nonEmptyText(tlvId) ?? (receipt?.id === '' ? undefined : receipt?.id); + return nonEmptyText(tlvId) ?? nonEmptyText(receipt?.id); } function isMessageState(name: string | undefined): name is MessageState { diff --git a/test/dlr.test.ts b/test/dlr.test.ts index ffc047d..d1969b0 100644 --- a/test/dlr.test.ts +++ b/test/dlr.test.ts @@ -117,7 +117,7 @@ describe('dlrFromPdu()', () => { assert.equal(dlrFromPdu(deliverSm('id:x stat:DELIVRD done date:2501012560'))?.doneDate, undefined); }); - test('returns nothing when an unmarked deliver_sm identifies no message', () => { + test('returns nothing when an unmarked deliver_sm yields no id or no status', () => { assert.equal(dlrFromPdu(deliverSm('just a normal sms', undefined, 0)), undefined); assert.equal(dlrFromPdu(deliverSm('id:0195f0c7 stat:WEIRDXX', undefined, 0)), undefined); }); @@ -180,8 +180,6 @@ describe('dlrFromPdu()', () => { assert.equal(empty, undefined, 'an empty id marks nothing'); }); - // The spec names six of the sixteen message types and reserves the rest, so a peer that types - // its receipts with one of the reserved bits keeps the body scrape rather than losing them. test('keeps the body scrape for a message type the spec reserves', () => { const dlr = dlrFromPdu(deliverSm(receiptText, undefined, 0x0c));