support send refer custom header to referhook (#981)

This commit is contained in:
Hoan Luu Huu
2024-11-28 20:34:34 +07:00
committed by GitHub
parent efdb56f0a0
commit 070671a3fb
2 changed files with 15 additions and 1 deletions

View File

@@ -2351,6 +2351,12 @@ Duration=${duration} `
try {
const to = parseUri(req.getParsedHeader('Refer-To').uri);
const by = parseUri(req.getParsedHeader('Referred-By').uri);
const customHeaders = Object.keys(req.headers)
.filter((h) => h.toLowerCase().startsWith('x-'))
.reduce((acc, h) => {
acc[h] = req.get(h);
return acc;
}, {});
const b3 = this.b3;
const httpHeaders = b3 && {b3};
const json = await this.requestor.request('verb:hook', this._referHook, {
@@ -2363,6 +2369,7 @@ Duration=${duration} `
referred_by_user: by.scheme === 'tel' ? by.number : by.user,
referring_call_sid: this.callSid,
referred_call_sid: null,
...customHeaders
}
}, httpHeaders);