From 352106ec0c739ad4ef02f694465ada38fa4902de Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Wed, 23 Jul 2025 21:52:10 +0700 Subject: [PATCH] support referTo with tel: prefix (#1297) * support referTo with tel: prefix * fix review comment --- lib/tasks/sip_refer.js | 14 ++++++++++++-- package-lock.json | 1 + test/sip-refer-tests.js | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/lib/tasks/sip_refer.js b/lib/tasks/sip_refer.js index 6a31b57a..bac8e4c4 100644 --- a/lib/tasks/sip_refer.js +++ b/lib/tasks/sip_refer.js @@ -111,7 +111,12 @@ class TaskSipRefer extends Task { /* get IP address of the SBC to use as hostname if needed */ const {host} = parseUri(dlg.remote.uri); - if (!referTo.startsWith('<') && !referTo.startsWith('sip') && !referTo.startsWith('"')) { + if ( + !referTo.startsWith('<') && + !referTo.startsWith('sip:') && + !referTo.startsWith('"') && + !referTo.startsWith('tel:') + ) { /* they may have only provided a phone number/user */ referTo = `sip:${referTo}@${host}`; } @@ -124,7 +129,12 @@ class TaskSipRefer extends Task { if (!referredByDisplayName) { referredByDisplayName = cs.req?.callingName; } - if (!referredBy.startsWith('<') && !referredBy.startsWith('sip') && !referredBy.startsWith('"')) { + if ( + !referredBy.startsWith('<') && + !referredBy.startsWith('sip:') && + !referredBy.startsWith('"') && + !referredBy.startsWith('tel:') + ) { /* they may have only provided a phone number/user */ referredBy = `${referredByDisplayName ? `"${referredByDisplayName}"` : ''}`; } diff --git a/package-lock.json b/package-lock.json index d9be9d6e..55c0b457 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8630,6 +8630,7 @@ }, "node_modules/unix-dgram": { "version": "2.0.6", + "hasInstallScript": true, "license": "ISC", "optional": true, "dependencies": { diff --git a/test/sip-refer-tests.js b/test/sip-refer-tests.js index 39015d58..58b3eeaf 100644 --- a/test/sip-refer-tests.js +++ b/test/sip-refer-tests.js @@ -58,6 +58,46 @@ test('\'refer\' tests w/202 and NOTIFY', {timeout: 25000}, async(t) => { } }); +test('\'refer\' tests tel:', {timeout: 25000}, async(t) => { + clearModule.all(); + const {srf, disconnect} = require('../app'); + + try { + await connect(srf); + + // GIVEN + const verbs = [ + { + verb: 'say', + text: 'silence_stream://100' + }, + { + verb: 'sip:refer', + referTo: 'tel:+1234567890', + actionHook: '/actionHook' + } + ]; + const noVerbs = []; + + const from = 'refer_with_tel'; + await provisionCallHook(from, verbs); + await provisionActionHook(from, noVerbs) + + // THEN + await sippUac('uac-refer-with-notify.xml', '172.38.0.10', from); + t.pass('refer: successfully received 202 Accepted'); + await sleepFor(1000); + const obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}_actionHook`); + t.ok(obj.body.final_referred_call_status === 200, 'refer: successfully received NOTIFY with 200 OK'); + // console.log(`obj: ${JSON.stringify(obj)}`); + disconnect(); + } catch (err) { + console.log(`error received: ${err}`); + disconnect(); + t.error(err); + } +}); + test('\'refer\' tests w/202 but no NOTIFY', {timeout: 25000}, async(t) => { clearModule.all(); const {srf, disconnect} = require('../app');