Skip to content

Commit

Permalink
support referBy display name (#1000)
Browse files Browse the repository at this point in the history
* support referBy display name

* wip

* update verb specification
  • Loading branch information
xquanluu authored Dec 11, 2024
1 parent 71d4c90 commit c29ab0d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 6 additions & 2 deletions lib/tasks/sip_refer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class TaskSipRefer extends Task {

this.referTo = this.data.referTo;
this.referredBy = this.data.referredBy;
this.referredByDisplayName = this.data.referredByDisplayName;
this.headers = this.data.headers || {};
this.eventHook = this.data.eventHook;
}
Expand Down Expand Up @@ -105,7 +106,7 @@ class TaskSipRefer extends Task {
}

_normalizeReferHeaders(cs, dlg) {
let {referTo, referredBy} = this;
let {referTo, referredBy, referredByDisplayName} = this;

/* get IP address of the SBC to use as hostname if needed */
const {host} = parseUri(dlg.remote.uri);
Expand All @@ -120,9 +121,12 @@ class TaskSipRefer extends Task {
referredBy = cs.req?.callingNumber || dlg.local.uri;
this.logger.info({referredBy}, 'setting referredby');
}
if (!referredByDisplayName) {
referredByDisplayName = cs.req?.callingName;
}
if (!referredBy.startsWith('<') && !referredBy.startsWith('sip') && !referredBy.startsWith('"')) {
/* they may have only provided a phone number/user */
referredBy = `sip:${referredBy}@${host}`;
referredBy = `${referredByDisplayName ? `"${referredByDisplayName}"` : ''}<sip:${referredBy}@${host}>`;
}
return {referTo, referredBy};
}
Expand Down
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@jambonz/speech-utils": "^0.1.22",
"@jambonz/stats-collector": "^0.1.10",
"@jambonz/time-series": "^0.2.12",
"@jambonz/verb-specifications": "^0.0.86",
"@jambonz/verb-specifications": "^0.0.90",
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/exporter-jaeger": "^1.23.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.50.0",
Expand Down

0 comments on commit c29ab0d

Please sign in to comment.