fix(courier): parse XFX form-urlencoded track callbacks and raw ACK
Enable urlencoded body parser, return XFX {code,message} without API envelope, and harden callback payload parsing.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -138,7 +138,15 @@ export class XiaofeixiaProvider implements ICourierProvider {
|
||||
|
||||
parseTrackCallback(body: unknown): TrackCallbackPayload | null {
|
||||
if (!body || typeof body !== 'object') return null;
|
||||
const raw = body as Record<string, unknown>;
|
||||
const root = body as Record<string, unknown>;
|
||||
// 兼容顶层字段或 data/payload 包裹
|
||||
const nested =
|
||||
root.data && typeof root.data === 'object'
|
||||
? (root.data as Record<string, unknown>)
|
||||
: root.payload && typeof root.payload === 'object'
|
||||
? (root.payload as Record<string, unknown>)
|
||||
: null;
|
||||
const raw = nested ? { ...nested, ...root } : root;
|
||||
const outNumber = String(raw.outNumber ?? '').trim();
|
||||
const trackingNumber = String(raw.number ?? raw.trackingNumber ?? '').trim();
|
||||
const status = String(raw.status ?? '').trim();
|
||||
|
||||
Reference in New Issue
Block a user