node-red-contrib-wazo-platform
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -5,4 +5,4 @@ module.exports = function (RED) { | ||
RED.nodes.createNode(this, n); | ||
wazoConn = RED.nodes.getNode(n.server); | ||
this.client = wazoConn.client.application; | ||
conn = RED.nodes.getNode(n.server); | ||
this.client = conn.client.application; | ||
@@ -14,2 +14,3 @@ var node = this; | ||
application_uuid = msg.payload.application_uuid; | ||
if (call_id && application_uuid) { | ||
@@ -16,0 +17,0 @@ node.log('Call answer'); |
@@ -20,4 +20,4 @@ module.exports = function (RED) { | ||
node.on('input', msg => { | ||
call_id = msg.payload.call.id || msg.payload.call_id; | ||
node.on('input', async msg => { | ||
call_id = msg.payload.call ? msg.payload.call.id : msg.payload.call_id; | ||
application_uuid = msg.payload.application_uuid; | ||
@@ -32,3 +32,6 @@ exten = node.exten || msg.payload.exten; | ||
try { | ||
msg.payload = node.client.bridgeCall(application_uuid, call_id, context, exten, autoAnswer, callerId); | ||
const { ...bridgeCall } = await node.client.bridgeCall(application_uuid, call_id, context, exten, autoAnswer, callerId); | ||
msg.payload.call_id = call_id; | ||
msg.payload.applicaton_uuid = application_uuid; | ||
msg.payload.data = bridgeCall; | ||
node.send(msg); | ||
@@ -45,3 +48,3 @@ } | ||
// FIXME: Remove when SDK will be ready | ||
async function listContexts(url, token) { | ||
const listContexts = async (url, token) => { | ||
const options = { | ||
@@ -48,0 +51,0 @@ method: 'GET', |
@@ -19,5 +19,5 @@ module.exports = function (RED) { | ||
node.on('input', async msg => { | ||
call_id = msg.payload.call ? msg.payload.call.id : msg.payload.call_id; | ||
application_uuid = msg.payload.application_uuid; | ||
node_uuid = msg.payload.node_uuid; | ||
application_uuid = msg.payload.application_uuid; | ||
call_id = msg.payload.call_id; | ||
@@ -24,0 +24,0 @@ if (call_id && application_uuid) { |
@@ -22,14 +22,2 @@ module.exports = function (RED) { | ||
const authenticate = async () => { | ||
if (!node.conn.client.client.token) { | ||
try { | ||
await node.conn.authenticate(); | ||
} | ||
catch(err) { | ||
node.error(err); | ||
throw err; | ||
} | ||
} | ||
} | ||
const create_room = async (room_name, user_uuid, bot_uuid) => { | ||
@@ -49,3 +37,3 @@ try { | ||
const send_message = async (message) => { | ||
authenticate(); | ||
const token = await node.conn.authenticate(); | ||
let room_uuid; | ||
@@ -52,0 +40,0 @@ if (!node.room_uuid) { |
@@ -5,4 +5,4 @@ module.exports = function (RED) { | ||
RED.nodes.createNode(this, n); | ||
wazoConn = RED.nodes.getNode(n.server); | ||
this.client = wazoConn.client.application; | ||
conn = RED.nodes.getNode(n.server); | ||
this.client = conn.client.application; | ||
@@ -14,2 +14,3 @@ var node = this; | ||
application_uuid = msg.payload.application_uuid; | ||
if (call_id && application_uuid) { | ||
@@ -16,0 +17,0 @@ const result = await node.client.hangupCall(application_uuid, call_id); |
@@ -5,4 +5,4 @@ module.exports = function (RED) { | ||
RED.nodes.createNode(this, n); | ||
wazoConn = RED.nodes.getNode(n.server); | ||
this.client = wazoConn.client.application; | ||
conn = RED.nodes.getNode(n.server); | ||
this.client = conn.client.application; | ||
@@ -12,9 +12,11 @@ var node = this; | ||
node.on('input', async msg => { | ||
if (msg.payload.call.id) { | ||
call_id = msg.payload.call.id; | ||
application_uuid = msg.payload.application_uuid; | ||
node.log('Call hold'); | ||
call_id = msg.payload.call ? msg.payload.call.id : msg.payload.call_id; | ||
applicaton_uuid = msg.payload.application_uuid; | ||
if (call_id && application_uuid) { | ||
node.log('Hold call'); | ||
try { | ||
const result = await node.client.startHoldCall(application_uuid, call_id); | ||
msg.payload = result; | ||
msg.payload.call_id = call_id; | ||
msg.payload.application_uuid = application_uuid; | ||
msg.payload.data = result; | ||
node.send(msg); | ||
@@ -21,0 +23,0 @@ } |
@@ -12,5 +12,5 @@ module.exports = function (RED) { | ||
RED.nodes.createNode(this, n); | ||
wazoConn = RED.nodes.getNode(n.server); | ||
conn = RED.nodes.getNode(n.server); | ||
this.moh_uuid = n.moh_uuid; | ||
this.client = wazoConn.client.application; | ||
this.client = conn.client.application; | ||
@@ -24,6 +24,9 @@ var node = this; | ||
moh_uuid = node.moh_uuid || msg.payload.moh_uuid; | ||
node.log('Call moh'); | ||
node.log('Start moh'); | ||
try { | ||
const result = await node.client.startMohCall(application_uuid, call_id, moh_uuid); | ||
msg.payload = result; | ||
msg.payload.call_id = call_id; | ||
msg.payload.application_uuid = application_uuid; | ||
msg.payload.moh_uuid = moh_uuid; | ||
msg.payload.data = result; | ||
node.send(msg); | ||
@@ -30,0 +33,0 @@ } |
@@ -5,4 +5,4 @@ module.exports = function (RED) { | ||
RED.nodes.createNode(this, n); | ||
wazoConn = RED.nodes.getNode(n.server); | ||
this.client = wazoConn.client.application; | ||
conn = RED.nodes.getNode(n.server); | ||
this.client = conn.client.application; | ||
@@ -12,9 +12,12 @@ var node = this; | ||
node.on('input', async msg => { | ||
if (msg.payload.call.id) { | ||
call_id = msg.payload.call.id; | ||
application_uuid = msg.payload.application_uuid; | ||
node.log('Call mute'); | ||
call_id = msg.payload.call ? msg.payload.call.id : msg.payload.call_id; | ||
application_uuid = msg.payload.application_uuid; | ||
if (call_id && application_uuid) { | ||
node.log('Mute call'); | ||
try { | ||
const result = await node.client.startMuteCall(application_uuid, call_id); | ||
msg.payload = result; | ||
msg.payload.call_id = call_id; | ||
msg.payload.application_uuid = application_uuid; | ||
msg.payload.data = result; | ||
node.send(msg); | ||
@@ -21,0 +24,0 @@ } |
@@ -18,7 +18,5 @@ module.exports = function (RED) { | ||
node.on('input', async msg => { | ||
if (msg.payload.application_uuid) { | ||
node.app_uuid = msg.payload.application_uuid; | ||
} | ||
application_uuid = msg.payload.application_uuid ? msg.payload.application_uuid : node.app_uuid; | ||
if (node.app_uuid) { | ||
if (application_uuid) { | ||
try { | ||
@@ -33,6 +31,8 @@ const call = { | ||
} | ||
const url = `https://${node.conn.host}:${node.conn.port}/api/calld/1.0/applications/${node.app_uuid}/calls`; | ||
const url = `https://${node.conn.host}:${node.conn.port}/api/calld/1.0/applications/${application_uuid}/calls`; | ||
const token = await node.conn.authenticate(); | ||
const { ...new_call} = await createNewCall(url, token, call); | ||
msg.payload = new_call; | ||
msg.payload.application_uuid = application_uuid; | ||
msg.payload.call_id = new_call.id;; | ||
msg.payload.data = new_call; | ||
node.send(msg); | ||
@@ -39,0 +39,0 @@ } |
@@ -16,2 +16,3 @@ module.exports = function (RED) { | ||
playback_uri = node.uri || msg.payload.uri; | ||
if (call_id && application_uuid && playback_uri) { | ||
@@ -18,0 +19,0 @@ node.log('Call playback'); |
@@ -11,4 +11,5 @@ module.exports = function (RED) { | ||
node.on('input', async msg => { | ||
call_id = msg.payload.call.id; | ||
call_id = msg.payload.call ? msg.payload.call.id : msg.payload.call_id; | ||
application_uuid = msg.payload.application_uuid; | ||
if (call_id && application_uuid) { | ||
@@ -15,0 +16,0 @@ const result = await node.client.startProgressCall(application_uuid, call_id); |
@@ -5,4 +5,4 @@ module.exports = function (RED) { | ||
RED.nodes.createNode(this, n); | ||
wazoConn = RED.nodes.getNode(n.server); | ||
this.client = wazoConn.client.application; | ||
conn = RED.nodes.getNode(n.server); | ||
this.client = conn.client.application; | ||
@@ -12,10 +12,14 @@ var node = this; | ||
node.on('input', async msg => { | ||
if (msg.payload.call.id) { | ||
call_id = msg.payload.call.id; | ||
application_uuid = msg.payload.application_uuid; | ||
stop_moh_uuid = msg.payload.stop_moh_uuid; | ||
node.log('Call stop_moh'); | ||
call_id = msg.payload.call.id; | ||
application_uuid = msg.payload.application_uuid; | ||
moh_uuid = msg.payload.moh_uuid; | ||
if (call_id && application_uuid && moh_uuid) { | ||
node.log('Stop MOH'); | ||
try { | ||
const result = await node.client.stopMohCall(application_uuid, call_id, stop_moh_uuid); | ||
msg.payload = result; | ||
const result = await node.client.stopMohCall(application_uuid, call_id, moh_uuid); | ||
msg.payload.call_id = call_id; | ||
msg.payload.application_uuid = application_uuid; | ||
msg.payload.moh_uuid = moh_uuid; | ||
msg.payload.data = result; | ||
node.send(msg); | ||
@@ -22,0 +26,0 @@ } |
@@ -5,4 +5,4 @@ module.exports = function (RED) { | ||
RED.nodes.createNode(this, n); | ||
wazoConn = RED.nodes.getNode(n.server); | ||
this.client = wazoConn.client.application; | ||
conn = RED.nodes.getNode(n.server); | ||
this.client = conn.client.application; | ||
@@ -14,2 +14,3 @@ var node = this; | ||
playback_uuid = msg.payload.playback_uuid; | ||
if (application_uuid && playback_uuid) { | ||
@@ -19,3 +20,5 @@ node.log('Stop playback'); | ||
const result = await node.client.stopPlaybackCall(application_uuid, playback_uuid); | ||
msg.payload = result; | ||
msg.payload.application_uuid = application_uuid; | ||
msg.payload.playback_uuid = playback_uuid; | ||
msg.payload.data = result; | ||
node.send(msg); | ||
@@ -22,0 +25,0 @@ } |
@@ -11,8 +11,11 @@ module.exports = function (RED) { | ||
node.on('input', async msg => { | ||
call_id = msg.payload.call.id; | ||
call_id = msg.payload.call ? msg.payload.call.id : msg.payload.call_id; | ||
application_uuid = msg.payload.application_uuid; | ||
if (call_id && application_uuid) { | ||
const result = await node.client.stopProgressCall(application_uuid, call_id); | ||
node.log('Stop call progress'); | ||
msg.payload = result; | ||
msg.payload.call_id = call_id; | ||
msg.payload.application_uuid = application_uuid; | ||
msg.payload.data = result; | ||
node.send(msg); | ||
@@ -19,0 +22,0 @@ } |
@@ -5,4 +5,4 @@ module.exports = function (RED) { | ||
RED.nodes.createNode(this, n); | ||
wazoConn = RED.nodes.getNode(n.server); | ||
this.client = wazoConn.client.application; | ||
conn = RED.nodes.getNode(n.server); | ||
this.client = conn.client.application; | ||
@@ -12,9 +12,12 @@ var node = this; | ||
node.on('input', async msg => { | ||
if (msg.payload.call.id) { | ||
call_id = msg.payload.call.id; | ||
application_uuid = msg.payload.application_uuid; | ||
node.log('Call unhold'); | ||
call_id = msg.payload.call ? msg.payload.call.id : msg.payload.call_id; | ||
application_uuid = msg.payload.application_uuid; | ||
if (call_id && application_uuid) { | ||
node.log('Unhold call'); | ||
try { | ||
const result = await node.client.stopHoldCall(application_uuid, call_id); | ||
msg.payload = result; | ||
msg.payload.call_id = call_id; | ||
msg.payload.application_uuid = application_uuid; | ||
msg.payload.data = result; | ||
node.send(msg); | ||
@@ -21,0 +24,0 @@ } |
@@ -5,4 +5,4 @@ module.exports = function (RED) { | ||
RED.nodes.createNode(this, n); | ||
wazoConn = RED.nodes.getNode(n.server); | ||
this.client = wazoConn.client.application; | ||
conn = RED.nodes.getNode(n.server); | ||
this.client = conn.client.application; | ||
@@ -12,9 +12,12 @@ var node = this; | ||
node.on('input', async msg => { | ||
if (msg.payload.call.id) { | ||
call_id = msg.payload.call.id; | ||
application_uuid = msg.payload.application_uuid; | ||
node.log('Call unmute'); | ||
call_id = msg.payload.call ? msg.payload.call.id : msg.payload.call_id; | ||
application_uuid = msg.payload.application_uuid; | ||
if (call_id && application_uuid) { | ||
node.log('Unmute call'); | ||
try { | ||
const result = await node.client.stopMuteCall(application_uuid, call_id); | ||
msg.payload = result; | ||
msg.payload.call_id = call_id; | ||
msg.payload.application_uuid = application_uuid; | ||
msg.payload.data = result; | ||
node.send(msg); | ||
@@ -21,0 +24,0 @@ } |
{ | ||
"name": "node-red-contrib-wazo-platform", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Node Red module for the Wazo Platform API", | ||
@@ -46,2 +46,3 @@ "main": "index.js", | ||
"node": "nodes/node.js", | ||
"delete_node": "nodes/delete_node.js", | ||
"playback": "nodes/playback.js", | ||
@@ -48,0 +49,0 @@ "stop_playback": "nodes/stop_playback.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
861564
59
1571