diff --git a/docs/lwpCall.md b/docs/lwpCall.md index 4afc19d..bddc271 100644 --- a/docs/lwpCall.md +++ b/docs/lwpCall.md @@ -429,6 +429,7 @@ direction terminating originating localIdentity remoteIdentity | Name | Type | Default | Description | | --------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| autoAnswer | boolean | true | If set to false the phone will not honor the auto-answer=0 header, requiring the user to always explicitly answer all calls | | useAudioContext | boolean | false | Should the lwpAudioContext be used as the destination for the remote audio. See note. | | globalKeyShortcuts | boolean | true | Should the event listeners in the 'keys' property be added to the document | | keys.spacebar.enabled | boolean | true | If true, and globalKeyShortcuts is also true, preform keys.spacebar.action if the spacebar is pressed when the body of the document has the focus | diff --git a/src/libwebphone.js b/src/libwebphone.js index 9d94b54..1b0a33c 100644 --- a/src/libwebphone.js +++ b/src/libwebphone.js @@ -122,6 +122,7 @@ export default class extends EventEmitter { userAgent: { enabled: true }, videoCanvas: { enabled: true }, call: { + autoAnswer: true, useAudioContext: false, globalKeyShortcuts: true, startWithAudioMuted: false, diff --git a/src/lwpCall.js b/src/lwpCall.js index 4030b1f..e04d944 100644 --- a/src/lwpCall.js +++ b/src/lwpCall.js @@ -31,8 +31,18 @@ export default class lwpCall { } _shouldAutoAnswer() { - return this._session?._request?.headers["Call-Info"] - && this._session._request.headers["Call-Info"][0].raw.includes("answer-after=0"); + // Return false if autoAnswer is explicitly set to false + if (this._config.autoAnswer === false) { + return false; + } + + // Check for the presence of Call-Info header and the "answer-after=0" value + if (this._session && this._session._request && this._session._request.headers && this._session._request.headers["Call-Info"]) { + const callInfo = this._session._request.headers["Call-Info"][0].raw; + return callInfo.includes("answer-after=0"); + } + + return false; } getId() {