Read a peer's submit and receipt message ids into one notation before comparing them
This commit is contained in:
+9
-3
@@ -3,8 +3,10 @@ import type { ParamValue } from './defs/types.ts';
|
||||
import type { PduObject, PduObjectInput } from './pdu.ts';
|
||||
import type { Result } from './result.ts';
|
||||
import type { SmppLog } from './log.ts';
|
||||
import type { SmsIdFormat } from './sms-id.ts';
|
||||
import { consts } from './defs/constants.ts';
|
||||
import { detect } from './defs/encodings.ts';
|
||||
import { normaliseSmsId } from './sms-id.ts';
|
||||
import { paramText } from './defs/types.ts';
|
||||
import { maxSegments, smppTime, splitMessage } from './message.ts';
|
||||
|
||||
@@ -32,6 +34,7 @@ export type SendSmsResult = { err?: Error; pduObjs: PduObject[]; smsIds: string[
|
||||
export type SendSmsDeps = {
|
||||
log: SmppLog;
|
||||
reference: number;
|
||||
respIdFormat?: SmsIdFormat | undefined;
|
||||
send: (input: PduObjectInput) => Promise<Result<{ pduObj: PduObject }>>;
|
||||
};
|
||||
|
||||
@@ -98,7 +101,10 @@ function checkSegments(allowed: number, segments: number): Error | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function collectSent(sent: Result<{ pduObj: PduObject }>[]): SendSmsResult {
|
||||
function collectSent(
|
||||
sent: Result<{ pduObj: PduObject }>[],
|
||||
format: SmsIdFormat | undefined,
|
||||
): SendSmsResult {
|
||||
const pduObjs: PduObject[] = [];
|
||||
const smsIds: string[] = [];
|
||||
let failure: Error | undefined;
|
||||
@@ -108,7 +114,7 @@ function collectSent(sent: Result<{ pduObj: PduObject }>[]): SendSmsResult {
|
||||
failure ??= one.err;
|
||||
} else if (one.pduObj.cmdStatus === 'ESME_ROK') {
|
||||
pduObjs.push(one.pduObj);
|
||||
smsIds.push(paramText(one.pduObj.params.message_id));
|
||||
smsIds.push(normaliseSmsId(paramText(one.pduObj.params.message_id), format));
|
||||
} else {
|
||||
const refusal = one.pduObj.cmdStatus ?? String(one.pduObj.cmdStatusId);
|
||||
|
||||
@@ -138,5 +144,5 @@ export async function submitSms(deps: SendSmsDeps, sms: SendSmsOptions): Promise
|
||||
params: submitSmParams(sms, segment, { encoding, multipart }),
|
||||
})));
|
||||
|
||||
return collectSent(sent);
|
||||
return collectSent(sent, deps.respIdFormat);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user