feat(voip): make Daftaresoma setup inbound-first and filter calls by line

Drop required from_number for webhook logging, persist CalleeExtension as lineExtension, and add direction/status/line filters on the calls list.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-07 13:58:42 +03:30
co-authored by Cursor
parent abb1a3a18e
commit f36711174e
8 changed files with 176 additions and 42 deletions
@@ -76,16 +76,17 @@ export function mapDaftaresomaWebhook(
'From',
'fromNumber',
);
const callee = pick(
/** خط سازمانی که تماس روی آن آمده/رفته */
const lineExtension =
pick(obj, 'CalleeExtension', 'calleeExtension', 'Extension', 'extension') ||
undefined;
/** مقصد انتقال / شماره طرف مقابل روی خط */
const transferred = pick(
obj,
'TransferredToNumber',
'transferredToNumber',
'CalleeExtension',
'calleeExtension',
'to',
'To',
'toNumber',
);
const startedAt =
pick(obj, 'StartDateTime', 'startDateTime', 'startedAt') || undefined;
const endedAt =
@@ -128,17 +129,28 @@ export function mapDaftaresomaWebhook(
'recordId',
);
// inbound: from=مشتری، to=همکار/مقصد انتقال یا خود خط
// outbound: from=همکار، to=مشتری (TransferredToNumber)
let from = caller || undefined;
let to: string | undefined;
if (isOutbound) {
to = transferred || undefined;
} else {
to = transferred || lineExtension || undefined;
}
const event: VoipWebhookEvent = {
callId,
direction: isOutbound ? 'outbound' : 'inbound',
status,
from: caller || undefined,
to: callee || undefined,
from,
to,
lineExtension,
startedAt,
endedAt,
durationSec,
caller: caller || undefined,
callee: callee || undefined,
caller: from,
callee: to,
};
if (recordingId) {
event.recordingUrl = daftareshomaRecordingRef(recordingId);