Skip to content

Commit

Permalink
Merge branch 'main' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck authored Mar 10, 2023
2 parents fb665d5 + bab105d commit 111be34
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
14 changes: 7 additions & 7 deletions lib/archiving.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ exports.listArchives = function (config, options, callback) {
callback(new errors.AuthError('Invalid API key or secret'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body)));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand Down Expand Up @@ -299,11 +299,11 @@ exports.startArchive = function (ot, config, sessionId, options, callback) {
callback(new errors.ArchiveError('Recording already in progress or session not using OpenTok Media Router'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body)));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else if (body.status !== 'started') {
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body)));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
else {
callback(null, new Archive(config, body));
Expand Down Expand Up @@ -340,7 +340,7 @@ exports.stopArchive = function (config, archiveId, callback) {
callback(new errors.AuthError('Invalid API key or secret'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body)));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand Down Expand Up @@ -380,7 +380,7 @@ exports.getArchive = function (config, archiveId, callback) {
callback(new errors.AuthError('Invalid API key or secret'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body)));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand Down Expand Up @@ -435,7 +435,7 @@ function patchArchive(config, archiveId, options, callback) {
callback(new errors.ArchiveError('Unsupported Stream Mode'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body)));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand Down Expand Up @@ -509,7 +509,7 @@ exports.deleteArchive = function (config, archiveId, callback) {
callback(new errors.AuthError('Invalid API key or secret'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body)));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand Down
11 changes: 6 additions & 5 deletions lib/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ exports.listCallbacks = function (config, options, callback) {
callback(new errors.AuthError('Invalid API key or secret'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok'));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand Down Expand Up @@ -89,7 +89,7 @@ exports.registerCallback = function (config, options, callback) {
callback(new errors.AuthError('Invalid API key or secret'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok'));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand All @@ -107,8 +107,9 @@ exports.unregisterCallback = function (config, callbackId, callback) {
return;
}
api(
config, 'DELETE', '/callback/' + encodeURIComponent(callbackId), {},
function (err, response) {
config, 'DELETE', '/callback/' + encodeURIComponent(callbackId),
null,
function (err, response, body) {
if (err) {
callback(err);
}
Expand All @@ -120,7 +121,7 @@ exports.unregisterCallback = function (config, callbackId, callback) {
callback(new errors.AuthError('Invalid API key or secret'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok'));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand Down
4 changes: 2 additions & 2 deletions lib/moderation.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports.forceDisconnect = function (config, sessionId, connectionId, callback) {
if (sessionId == null || connectionId == null) {
return callback(new errors.ArgumentError('No sessionId or connectionId tiven to signal'));
}
return api(config, 'DELETE', sessionId, connectionId, null, function (err, response) {
return api(config, 'DELETE', sessionId, connectionId, null, function (err, response, body) {
if (err || Math.floor(response.statusCode / 100) !== 2) {
if (response && response.statusCode === 403) {
callback(new errors.AuthError('Invalid API key or secret'));
Expand All @@ -37,7 +37,7 @@ exports.forceDisconnect = function (config, sessionId, connectionId, callback) {
callback(new errors.ForceDisconnectError('Session or Connection not found'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok'));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand Down
4 changes: 2 additions & 2 deletions lib/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.signal = function (config, sessionId, connectionId, payload, callback) {
if (sessionId == null || payload == null) {
return callback(new errors.ArgumentError('No sessionId or payload given to signal'));
}
return api(config, 'POST', sessionId, connectionId, payload, function (err, response) {
return api(config, 'POST', sessionId, connectionId, payload, function (err, response, body) {
if (err || Math.floor(response.statusCode / 100) !== 2) {
if (response && response.statusCode === 403) {
callback(new errors.AuthError('Invalid API key or secret'));
Expand All @@ -43,7 +43,7 @@ exports.signal = function (config, sessionId, connectionId, payload, callback) {
callback(new errors.SignalError('Session or Connection not found'));
}
else {
callback(new errors.RequestError('Unexpected response from OpenTok'));
callback(new errors.RequestError('Unexpected response from OpenTok: ' + JSON.stringify(body || { statusCode: response.statusCode, statusMessage: response.statusMessage })));
}
}
else {
Expand Down

0 comments on commit 111be34

Please sign in to comment.