Read a receipt reporting a transient state as non-final too, so the merge waits for the real one

This commit is contained in:
2026-09-03 19:28:08 +02:00
parent dd458bfa53
commit 42e6e97447
6 changed files with 77 additions and 16 deletions
+7 -2
View File
@@ -130,6 +130,9 @@ export function parseReceipt(message: string): Receipt {
type MessageType = 'intermediate' | 'other' | 'receipt' | 'unmarked';
/** SMPP 3.4 Appendix B lists every other receipt state as final. */
const transientStates: MessageState[] = ['ENROUTE', 'SCHEDULED'];
/** Written by the far-end SME, not by the MC reporting on a message we submitted. */
const smeMessageTypes: number[] = [
consts.ESM_CLASS.CONVERSATION_ABORT,
@@ -212,13 +215,15 @@ export function dlrFromPdu(pduObj: PduObject, format: SmsIdFormat = {}): Dlr | u
if (type === 'unmarked' && (smsId === undefined || statusMsg === undefined)) return undefined;
const state = statusMsg ?? 'UNKNOWN';
return {
doneDate: receiptDate(receipt?.doneDate),
errorCode: receipt?.err,
intermediate: type === 'intermediate',
intermediate: type === 'intermediate' || transientStates.includes(state),
receipt,
smsId,
statusId,
statusMsg: statusMsg ?? 'UNKNOWN',
statusMsg: state,
};
}