From 695e44da29828fdbf35fbc9d38e03bed4db2d467 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Fri, 9 Jun 2023 13:58:36 -0400 Subject: [PATCH] Fix/trace (#92) * fix docker build * fix: trace_id in cdrs --- .github/workflows/docker-publish.yml | 4 +++- lib/call-session.js | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7024235..5cfc72a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,6 +2,8 @@ name: Docker on: push: + branches: + - main tags: - '*' @@ -18,7 +20,7 @@ jobs: - name: prepare tag id: prepare_tag run: | - IMAGE_ID=$GITHUB_REPOSITORY + IMAGE_ID=jambonz/sbc-outbound # Strip git ref prefix from version VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') diff --git a/lib/call-session.js b/lib/call-session.js index e636863..4173423 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -33,19 +33,21 @@ const createBLegToHeader = (req, teams) => { return `sip:anonymous@${host}`; }; -const initCdr = (srf, req) => { - const uri = parseUri(req.uri); +const initCdr = (req, invite) => { + const {srf} = req; + const {trace_id} = req.locals; + const uri = parseUri(invite.uri); const regex = /^\+(\d+)$/; - let arr = regex.exec(req.calledNumber); - const to = arr ? arr[1] : req.calledNumber; - arr = regex.exec(req.callingNumber); - const from = arr ? arr[1] : req.callingNumber; + let arr = regex.exec(invite.calledNumber); + const to = arr ? arr[1] : invite.calledNumber; + arr = regex.exec(invite.callingNumber); + const from = arr ? arr[1] : invite.callingNumber; const applicationSid = req.get('X-Application-Sid'); return { account_sid: req.get('X-Account-Sid'), call_sid: req.get('X-Call-Sid'), - sip_callid: req.get('Call-ID'), + sip_callid: invite.get('Call-ID'), ...(applicationSid && {application_sid: applicationSid}), from, to, @@ -55,7 +57,7 @@ const initCdr = (srf, req) => { direction: 'outbound', host: srf.locals.sipAddress, remote_host: uri.host, - trace_id: req.get('X-Trace-ID') || '00000000000000000000000000000000' + trace_id: trace_id || '00000000000000000000000000000000' }; }; @@ -424,7 +426,7 @@ class CallSession extends Emitter { } else { this.req.locals.cdr = { - ...initCdr(this.req.srf, inv), + ...initCdr(this.req, inv), service_provider_sid: this.req.locals.service_provider_sid, account_sid: this.req.locals.account_sid, ...(this.req.locals.application_sid && {application_sid: this.req.locals.application_sid}),