Skip to content

Commit 89d90a1

Browse files
bretticus-mcBrett McStotts
and
Brett McStotts
authored
adding bug fixes for voice and chat (#972)
Co-authored-by: Brett McStotts <mcstotts@amazon.com>
1 parent 5941fd5 commit 89d90a1

12 files changed

+1095
-16
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# CHANGELOG.md
22

3+
## [2.18.1] - 2025-01-28
4+
- adding bug fixes for voice and chat
5+
6+
## [2.18.0]
7+
(Deprecated)
8+
39
## [2.17.0] - 2024-11-29
10+
(Deprecated)
411
Added:
512
- Email
613

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "amazon-connect-streams",
3-
"version": "2.18.0",
3+
"version": "2.18.1",
44
"description": "Amazon Connect Streams Library",
55
"engines": {
66
"node": ">=12.0.0"

release/connect-streams-dr-min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/connect-streams-dr.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/connect-streams-min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/connect-streams.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -2847,9 +2847,12 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
28472847
return segmentAttributes && segmentAttributes["connect:Subtype"] ? segmentAttributes["connect:Subtype"].ValueString : null;
28482848
};
28492849
Contact.prototype.isSoftphoneCall = function () {
2850-
return connect.find(this.getConnections(), function (conn) {
2851-
return conn.getSoftphoneMediaInfo() != null;
2852-
}) != null;
2850+
if (this.getType() !== connect.ContactType.VOICE && this.getType() !== connect.ContactType.QUEUE_CALLBACK) {
2851+
return false;
2852+
}
2853+
return Boolean(this.getConnections().find(function (conn) {
2854+
return conn.getSoftphoneMediaInfo();
2855+
}));
28532856
};
28542857
Contact.prototype.hasVideoRTCCapabilities = function () {
28552858
return connect.find(this.getConnections(), function (conn) {
@@ -8940,7 +8943,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
89408943
connect.core = {};
89418944
connect.globalResiliency = connect.globalResiliency || {};
89428945
connect.core.initialized = false;
8943-
connect.version = "2.18.0";
8946+
connect.version = "2.18.1";
89448947
connect.outerContextStreamsVersion = null;
89458948
connect.DEFAULT_BATCH_SIZE = 500;
89468949

@@ -10754,7 +10757,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
1075410757
connectionGain: new Set(),
1075510758
connectionLost: new Set(),
1075610759
connectionOpen: new Set(),
10757-
connectionClose: new Set()
10760+
connectionClose: new Set(),
10761+
deepHeartbeatSuccess: new Set(),
10762+
deepHeartbeatFailure: new Set(),
10763+
topicFailure: new Set()
1075810764
};
1075910765
var invokeCallbacks = function invokeCallbacks(callbacks, response) {
1076010766
callbacks.forEach(function (callback) {

src/api.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1016,9 +1016,11 @@
10161016
}
10171017

10181018
Contact.prototype.isSoftphoneCall = function () {
1019-
return connect.find(this.getConnections(), function (conn) {
1020-
return conn.getSoftphoneMediaInfo() != null;
1021-
}) != null;
1019+
if (this.getType() !== connect.ContactType.VOICE && this.getType() !== connect.ContactType.QUEUE_CALLBACK) {
1020+
return false;
1021+
}
1022+
1023+
return Boolean(this.getConnections().find((conn) => conn.getSoftphoneMediaInfo()));
10221024
};
10231025

10241026
Contact.prototype.hasVideoRTCCapabilities = function () {

src/core.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,10 @@ connect.core.setSoftphoneUserMediaStream = function (stream) {
18681868
connectionGain: new Set(),
18691869
connectionLost: new Set(),
18701870
connectionOpen: new Set(),
1871-
connectionClose: new Set()
1871+
connectionClose: new Set(),
1872+
deepHeartbeatSuccess: new Set(),
1873+
deepHeartbeatFailure: new Set(),
1874+
topicFailure: new Set(),
18721875
};
18731876

18741877
var invokeCallbacks = function (callbacks, response) {

test/unit/contact.spec.js

+66-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require("./test-setup.js");
2+
const SAMPLE_SNAPSHOTS = require("./sample-snapshots.js");
23

34
let sampleContactData = {
45
"attributes": {},
@@ -97,7 +98,71 @@ describe('Contact APIs', () => {
9798
expect(result).to.be.a("null");
9899
});
99100
});
100-
})
101+
});
102+
103+
describe("contact.isSoftphoneCall", () => {
104+
const sandbox = sinon.createSandbox();
105+
106+
afterEach(() => {
107+
sandbox.restore();
108+
});
109+
110+
it("should return true if the contact is voice and has a connection with softphoneMediaInfo populated", () => {
111+
sandbox.stub(connect.Contact.prototype, "_getData").returns({
112+
contactId: "test-contact-id",
113+
type: "voice",
114+
connections: [{ connectionId: "test-connection-id" }],
115+
});
116+
sandbox.stub(connect, "VoiceConnection").returns({
117+
getSoftphoneMediaInfo: () => true,
118+
});
119+
const contact = new connect.Contact(contactId);
120+
const result = contact.isSoftphoneCall();
121+
expect(result).to.equal(true);
122+
});
123+
124+
it("should return true if the contact is queue_callback and has a connection with softphoneMediaInfo populated", () => {
125+
sandbox.stub(connect.Contact.prototype, "_getData").returns({
126+
contactId: "test-contact-id",
127+
type: "queue_callback",
128+
connections: [{ connectionId: "test-connection-id" }],
129+
});
130+
sandbox.stub(connect, "VoiceConnection").returns({
131+
getSoftphoneMediaInfo: () => true,
132+
});
133+
const contact = new connect.Contact(contactId);
134+
const result = contact.isSoftphoneCall();
135+
expect(result).to.equal(true);
136+
});
137+
138+
it("should return false if the contact does not have a connection with softphoneMediaInfo", () => {
139+
sandbox.stub(connect.Contact.prototype, "_getData").returns({
140+
contactId: "test-contact-id",
141+
type: "voice",
142+
connections: [{ connectionId: "test-connection-id" }],
143+
});
144+
sandbox.stub(connect, "VoiceConnection").returns({
145+
getSoftphoneMediaInfo: () => false,
146+
});
147+
const contact = new connect.Contact(contactId);
148+
const result = contact.isSoftphoneCall();
149+
expect(result).to.equal(false);
150+
});
151+
152+
it("should return false if the contact is non-voice", () => {
153+
sandbox.stub(connect.Contact.prototype, "_getData").returns({
154+
contactId: "test-contact-id",
155+
type: "chat",
156+
connections: [{ connectionId: "test-connection-id" }],
157+
});
158+
sandbox.stub(connect, "VoiceConnection").returns({
159+
getSoftphoneMediaInfo: () => false,
160+
});
161+
const contact = new connect.Contact(contactId);
162+
const result = contact.isSoftphoneCall();
163+
expect(result).to.equal(false);
164+
});
165+
});
101166

102167

103168
describe("contact APIs", () => {

0 commit comments

Comments
 (0)