Skip to content

Commit

Permalink
adding bug fixes for voice and chat (#972)
Browse files Browse the repository at this point in the history
Co-authored-by: Brett McStotts <[email protected]>
bretticus-mc and Brett McStotts authored Jan 29, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 5941fd5 commit 89d90a1
Showing 12 changed files with 1,095 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# CHANGELOG.md

## [2.18.1] - 2025-01-28
- adding bug fixes for voice and chat

## [2.18.0]
(Deprecated)

## [2.17.0] - 2024-11-29
(Deprecated)
Added:
- Email

4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "amazon-connect-streams",
"version": "2.18.0",
"version": "2.18.1",
"description": "Amazon Connect Streams Library",
"engines": {
"node": ">=12.0.0"
2 changes: 1 addition & 1 deletion release/connect-streams-dr-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/connect-streams-dr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/connect-streams-min.js

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions release/connect-streams.js
Original file line number Diff line number Diff line change
@@ -2847,9 +2847,12 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
return segmentAttributes && segmentAttributes["connect:Subtype"] ? segmentAttributes["connect:Subtype"].ValueString : null;
};
Contact.prototype.isSoftphoneCall = function () {
return connect.find(this.getConnections(), function (conn) {
return conn.getSoftphoneMediaInfo() != null;
}) != null;
if (this.getType() !== connect.ContactType.VOICE && this.getType() !== connect.ContactType.QUEUE_CALLBACK) {
return false;
}
return Boolean(this.getConnections().find(function (conn) {
return conn.getSoftphoneMediaInfo();
}));
};
Contact.prototype.hasVideoRTCCapabilities = function () {
return connect.find(this.getConnections(), function (conn) {
@@ -8940,7 +8943,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
connect.core = {};
connect.globalResiliency = connect.globalResiliency || {};
connect.core.initialized = false;
connect.version = "2.18.0";
connect.version = "2.18.1";
connect.outerContextStreamsVersion = null;
connect.DEFAULT_BATCH_SIZE = 500;

@@ -10754,7 +10757,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
connectionGain: new Set(),
connectionLost: new Set(),
connectionOpen: new Set(),
connectionClose: new Set()
connectionClose: new Set(),
deepHeartbeatSuccess: new Set(),
deepHeartbeatFailure: new Set(),
topicFailure: new Set()
};
var invokeCallbacks = function invokeCallbacks(callbacks, response) {
callbacks.forEach(function (callback) {
8 changes: 5 additions & 3 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -1016,9 +1016,11 @@
}

Contact.prototype.isSoftphoneCall = function () {
return connect.find(this.getConnections(), function (conn) {
return conn.getSoftphoneMediaInfo() != null;
}) != null;
if (this.getType() !== connect.ContactType.VOICE && this.getType() !== connect.ContactType.QUEUE_CALLBACK) {
return false;
}

return Boolean(this.getConnections().find((conn) => conn.getSoftphoneMediaInfo()));
};

Contact.prototype.hasVideoRTCCapabilities = function () {
5 changes: 4 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
@@ -1868,7 +1868,10 @@ connect.core.setSoftphoneUserMediaStream = function (stream) {
connectionGain: new Set(),
connectionLost: new Set(),
connectionOpen: new Set(),
connectionClose: new Set()
connectionClose: new Set(),
deepHeartbeatSuccess: new Set(),
deepHeartbeatFailure: new Set(),
topicFailure: new Set(),
};

var invokeCallbacks = function (callbacks, response) {
67 changes: 66 additions & 1 deletion test/unit/contact.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require("./test-setup.js");
const SAMPLE_SNAPSHOTS = require("./sample-snapshots.js");

let sampleContactData = {
"attributes": {},
@@ -97,7 +98,71 @@ describe('Contact APIs', () => {
expect(result).to.be.a("null");
});
});
})
});

describe("contact.isSoftphoneCall", () => {
const sandbox = sinon.createSandbox();

afterEach(() => {
sandbox.restore();
});

it("should return true if the contact is voice and has a connection with softphoneMediaInfo populated", () => {
sandbox.stub(connect.Contact.prototype, "_getData").returns({
contactId: "test-contact-id",
type: "voice",
connections: [{ connectionId: "test-connection-id" }],
});
sandbox.stub(connect, "VoiceConnection").returns({
getSoftphoneMediaInfo: () => true,
});
const contact = new connect.Contact(contactId);
const result = contact.isSoftphoneCall();
expect(result).to.equal(true);
});

it("should return true if the contact is queue_callback and has a connection with softphoneMediaInfo populated", () => {
sandbox.stub(connect.Contact.prototype, "_getData").returns({
contactId: "test-contact-id",
type: "queue_callback",
connections: [{ connectionId: "test-connection-id" }],
});
sandbox.stub(connect, "VoiceConnection").returns({
getSoftphoneMediaInfo: () => true,
});
const contact = new connect.Contact(contactId);
const result = contact.isSoftphoneCall();
expect(result).to.equal(true);
});

it("should return false if the contact does not have a connection with softphoneMediaInfo", () => {
sandbox.stub(connect.Contact.prototype, "_getData").returns({
contactId: "test-contact-id",
type: "voice",
connections: [{ connectionId: "test-connection-id" }],
});
sandbox.stub(connect, "VoiceConnection").returns({
getSoftphoneMediaInfo: () => false,
});
const contact = new connect.Contact(contactId);
const result = contact.isSoftphoneCall();
expect(result).to.equal(false);
});

it("should return false if the contact is non-voice", () => {
sandbox.stub(connect.Contact.prototype, "_getData").returns({
contactId: "test-contact-id",
type: "chat",
connections: [{ connectionId: "test-connection-id" }],
});
sandbox.stub(connect, "VoiceConnection").returns({
getSoftphoneMediaInfo: () => false,
});
const contact = new connect.Contact(contactId);
const result = contact.isSoftphoneCall();
expect(result).to.equal(false);
});
});


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

0 comments on commit 89d90a1

Please sign in to comment.