Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / webbar / webbar.controller.js
index 831e653..9bab1e7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf403=['answer\x20fired:','webbar:answer','answer\x20executed!','hold','hold\x20fired:','webbar:hold','hold\x20executed!','unhold','webbar:unhold','unhold\x20executed!','calls','calls\x20fired:','conference\x20fired:','conference\x20executed!','transfer','transfer\x20fired:','transfer\x20executed!','path','../../mysqldb','../../config/environment','util','bluebird','jayson/promise','client','http','../../config/logger','redis','defaults','localhost','userId\x20is\x20required','string','callNumber\x20is\x20required','number','transferNumber\x20is\x20required','stringify','emit','log','error','stack','name','status','send','NotFound','request','then','code','result','User','findOne','agent','VoiceChannels','all','filter','rows','UserId','sessionId','length','sessionId\x20','originate','info','originate\x20fired:','validate','body','json','userId','callNumber','callerId','callbackUrl','entityFound:','format','user:%s','webbar:originate','originate\x20executed!','catch','hangup'];(function(_0x3bbe72,_0x8d69f7){var _0x15d332=function(_0x2b850b){while(--_0x2b850b){_0x3bbe72['push'](_0x3bbe72['shift']());}};_0x15d332(++_0x8d69f7);}(_0xf403,0x1d3));var _0x3f40=function(_0x25bec2,_0x2a046c){_0x25bec2=_0x25bec2-0x0;var _0x116315=_0xf403[_0x25bec2];return _0x116315;};'use strict';var path=require(_0x3f40('0x0'));var fs=require('fs');var _=require('lodash');var db=require(_0x3f40('0x1'))['db'];var config=require(_0x3f40('0x2'));var util=require(_0x3f40('0x3'));var BPromise=require(_0x3f40('0x4'));var jayson=require(_0x3f40('0x5'));var amiClient=jayson[_0x3f40('0x6')][_0x3f40('0x7')]({'port':0x232a});var logger=require(_0x3f40('0x8'))('webbarapi');var Redis=require('ioredis');config[_0x3f40('0x9')]=_[_0x3f40('0xa')](config[_0x3f40('0x9')],{'host':_0x3f40('0xb'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x3f40('0x9')]));var Schema=require('validate');var originateValidation=new Schema({'userId':{'type':'number','required':[!![],_0x3f40('0xc')]},'callNumber':{'type':_0x3f40('0xd'),'required':[!![],_0x3f40('0xe')]},'callerId':{'type':'string'},'callbackUrl':{'type':'string'}});var hangupValidation=new Schema({'userId':{'type':_0x3f40('0xf'),'required':[!![],_0x3f40('0xc')]},'sessionId':{'type':_0x3f40('0xd'),'required':![]}});var answerValidation=new Schema({'userId':{'type':'number','required':[!![],_0x3f40('0xc')]},'sessionId':{'type':_0x3f40('0xd'),'required':![]}});var transferValidation=new Schema({'userId':{'type':_0x3f40('0xf'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0x3f40('0xd'),'required':[!![],'sessionId\x20is\x20required']},'transferNumber':{'type':_0x3f40('0xd'),'required':[!![],_0x3f40('0x10')]}});var holdValidation=new Schema({'userId':{'type':_0x3f40('0xf'),'required':[!![],_0x3f40('0xc')]},'sessionId':{'type':'string','required':![]}});var unholdValidation=new Schema({'userId':{'type':_0x3f40('0xf'),'required':[!![],_0x3f40('0xc')]},'sessionId':{'type':_0x3f40('0xd'),'required':![]}});var callsValidation=new Schema({'userId':{'type':_0x3f40('0xf'),'required':[!![],_0x3f40('0xc')]}});var conferenceValidation=new Schema({'userId':{'type':'number','required':[!![],_0x3f40('0xc')]}});function emit(_0x3d11c9,_0x535f85,_0x4ef80e){logger['info'](_0x3d11c9,_0x535f85,JSON[_0x3f40('0x11')](_0x4ef80e));io['to'](_0x3d11c9)[_0x3f40('0x12')](_0x535f85,_0x4ef80e);}function handleError(_0x59718c){return function(_0x131e55){console[_0x3f40('0x13')]('handleError:',_0x131e55,_0x131e55 instanceof RangeError);logger[_0x3f40('0x14')](_0x131e55[_0x3f40('0x15')]);if(_0x131e55 instanceof RangeError){if(_0x131e55[_0x3f40('0x16')]){delete _0x131e55[_0x3f40('0x16')];}_0x59718c[_0x3f40('0x17')](0x194)['send'](_0x131e55);}else{if(_0x131e55[_0x3f40('0x16')]){delete _0x131e55['name'];}_0x59718c[_0x3f40('0x17')](0x1f4)[_0x3f40('0x18')](_0x131e55);}};}function checkError(){return function(_0x3f4a93){if(!_0x3f4a93){throw new RangeError(_0x3f40('0x19'));}return _0x3f4a93;};}function respondWithRpcPromise(_0x628816,_0x4aa559){return new BPromise(function(_0x27f5a5,_0x379b4e){var _0x117823=amiClient;return _0x117823[_0x3f40('0x1a')](_0x628816,_0x4aa559)[_0x3f40('0x1b')](function(_0xa1f39d){if(_0xa1f39d['error']){if(_0xa1f39d[_0x3f40('0x14')][_0x3f40('0x1c')]===0x1f4){return _0x379b4e(_0xa1f39d[_0x3f40('0x14')]['message']);}return _0x27f5a5(_0xa1f39d[_0x3f40('0x14')]['message']);}else{_0x27f5a5(_0xa1f39d[_0x3f40('0x1d')]);}})['catch'](function(_0x4b206b){_0x379b4e(_0x4b206b);});});}function getAgent(_0x4b0ade){return db[_0x3f40('0x1e')][_0x3f40('0x1f')]({'where':{'id':_0x4b0ade,'role':_0x3f40('0x20')}})[_0x3f40('0x1b')](checkError());}function getAgentCheckSession(_0x5b1079,_0x300665){return new BPromise(function(_0x47ec1c,_0x319997){var _0xbaf5d4=respondWithRpcPromise(_0x3f40('0x21'));var _0x5e0f25=getAgent(_0x5b1079);Promise[_0x3f40('0x22')]([_0xbaf5d4,_0x5e0f25])['then'](function(_0x1cab5c){var _0x5b9079=_0x1cab5c[0x0];var _0x49057b=_0x1cab5c[0x1];var _0xb6ab4d=_[_0x3f40('0x23')](_0x5b9079[_0x3f40('0x24')],function(_0xb23186){return _0xb23186[_0x3f40('0x25')]==_0x49057b['id']&&_0xb23186[_0x3f40('0x26')]==_0x300665;});if(_0xb6ab4d[_0x3f40('0x27')]==0x1){_0x47ec1c(_0x49057b);}else{_0x319997(new RangeError(_0x3f40('0x28')+_0x300665+'\x20not\x20found!'));}});});}exports[_0x3f40('0x29')]=function(_0x2d2624,_0x18dbb3){logger[_0x3f40('0x2a')](_0x3f40('0x2b'),_0x2d2624['body']);var _0x42b6b4=originateValidation[_0x3f40('0x2c')](_0x2d2624[_0x3f40('0x2d')]);if(_0x42b6b4['length']>0x0){return _0x18dbb3[_0x3f40('0x17')](0x190)[_0x3f40('0x2e')](_0x42b6b4);}var _0x239fd5=_0x2d2624[_0x3f40('0x2d')][_0x3f40('0x2f')];var _0x323908=_0x2d2624[_0x3f40('0x2d')][_0x3f40('0x30')];var _0x10356d=_0x2d2624[_0x3f40('0x2d')][_0x3f40('0x31')];var _0x25399a=_0x2d2624[_0x3f40('0x2d')][_0x3f40('0x32')];return getAgent(_0x239fd5)[_0x3f40('0x1b')](function(_0xf26a2f){logger[_0x3f40('0x2a')](_0x3f40('0x33'),_0xf26a2f[_0x3f40('0x16')]);emit(util[_0x3f40('0x34')](_0x3f40('0x35'),_0xf26a2f[_0x3f40('0x16')]),_0x3f40('0x36'),{'callNumber':_0x323908,'callerId':_0x10356d,'callbackUrl':_0x25399a});return _0x18dbb3[_0x3f40('0x17')](0xc8)[_0x3f40('0x2e')]({'error':![],'message':_0x3f40('0x37')});})[_0x3f40('0x38')](handleError(_0x18dbb3));};exports[_0x3f40('0x39')]=function(_0x411c98,_0x2df15b){logger['info']('hangup\x20fired:',_0x411c98[_0x3f40('0x2d')]);var _0x1b005e=hangupValidation[_0x3f40('0x2c')](_0x411c98[_0x3f40('0x2d')]);if(_0x1b005e[_0x3f40('0x27')]>0x0){return _0x2df15b[_0x3f40('0x17')](0x190)[_0x3f40('0x2e')](_0x1b005e);}var _0x4de3e7=_0x411c98[_0x3f40('0x2d')]['userId'];var _0x229bff=_0x411c98[_0x3f40('0x2d')][_0x3f40('0x26')];return getAgent(_0x4de3e7)['then'](function(_0x37a83d){logger[_0x3f40('0x2a')]('entityFound:',_0x37a83d[_0x3f40('0x16')]);emit(util[_0x3f40('0x34')]('user:%s',_0x37a83d[_0x3f40('0x16')]),'webbar:hangup',{'sessionId':_0x229bff});return _0x2df15b[_0x3f40('0x17')](0xc8)['json']({'error':![],'message':'hangup\x20executed!'});})[_0x3f40('0x38')](handleError(_0x2df15b));};exports['answer']=function(_0x2210bc,_0xe04271){logger[_0x3f40('0x2a')](_0x3f40('0x3a'),_0x2210bc['body']);var _0x237c91=answerValidation['validate'](_0x2210bc[_0x3f40('0x2d')]);if(_0x237c91[_0x3f40('0x27')]>0x0){return _0xe04271[_0x3f40('0x17')](0x190)['json'](_0x237c91);}var _0x4a198d=_0x2210bc[_0x3f40('0x2d')][_0x3f40('0x2f')];var _0x41bd93=_0x2210bc[_0x3f40('0x2d')][_0x3f40('0x26')];return getAgent(_0x4a198d)[_0x3f40('0x1b')](function(_0x38c5d6){logger[_0x3f40('0x2a')]('entityFound:',_0x38c5d6[_0x3f40('0x16')]);emit(util['format']('user:%s',_0x38c5d6[_0x3f40('0x16')]),_0x3f40('0x3b'),{'sessionId':_0x41bd93});return _0xe04271[_0x3f40('0x17')](0xc8)[_0x3f40('0x2e')]({'error':![],'message':_0x3f40('0x3c')});})[_0x3f40('0x38')](handleError(_0xe04271));};exports[_0x3f40('0x3d')]=function(_0x3d6cf8,_0x1cc958){logger[_0x3f40('0x2a')](_0x3f40('0x3e'),_0x3d6cf8[_0x3f40('0x2d')]);var _0x2068ab=holdValidation[_0x3f40('0x2c')](_0x3d6cf8['body']);if(_0x2068ab[_0x3f40('0x27')]>0x0){return _0x1cc958['status'](0x190)[_0x3f40('0x2e')](_0x2068ab);}var _0x2f16d6=_0x3d6cf8['body'][_0x3f40('0x2f')];var _0x1f66fa=_0x3d6cf8[_0x3f40('0x2d')][_0x3f40('0x26')];return getAgent(_0x2f16d6)[_0x3f40('0x1b')](function(_0x268ae4){logger[_0x3f40('0x2a')](_0x3f40('0x33'),_0x268ae4[_0x3f40('0x16')]);emit(util[_0x3f40('0x34')](_0x3f40('0x35'),_0x268ae4[_0x3f40('0x16')]),_0x3f40('0x3f'),{'sessionId':_0x1f66fa});return _0x1cc958[_0x3f40('0x17')](0xc8)[_0x3f40('0x2e')]({'error':![],'message':_0x3f40('0x40')});})[_0x3f40('0x38')](handleError(_0x1cc958));};exports[_0x3f40('0x41')]=function(_0x32bd05,_0x2d7e66){logger[_0x3f40('0x2a')]('unhold\x20fired:',_0x32bd05[_0x3f40('0x2d')]);var _0x50db96=unholdValidation[_0x3f40('0x2c')](_0x32bd05[_0x3f40('0x2d')]);if(_0x50db96[_0x3f40('0x27')]>0x0){return _0x2d7e66['status'](0x190)['json'](_0x50db96);}var _0x54b7cd=_0x32bd05[_0x3f40('0x2d')][_0x3f40('0x2f')];var _0x5f4f1a=_0x32bd05[_0x3f40('0x2d')][_0x3f40('0x26')];return getAgent(_0x54b7cd)['then'](function(_0x1cd70d){logger['info'](_0x3f40('0x33'),_0x1cd70d[_0x3f40('0x16')]);emit(util[_0x3f40('0x34')](_0x3f40('0x35'),_0x1cd70d[_0x3f40('0x16')]),_0x3f40('0x42'),{'sessionId':_0x5f4f1a});return _0x2d7e66[_0x3f40('0x17')](0xc8)[_0x3f40('0x2e')]({'error':![],'message':_0x3f40('0x43')});})[_0x3f40('0x38')](handleError(_0x2d7e66));};exports[_0x3f40('0x44')]=function(_0x13f191,_0x109752){logger['info'](_0x3f40('0x45'),_0x109752[_0x3f40('0x2d')]);var _0x1c94a1=callsValidation[_0x3f40('0x2c')](_0x13f191[_0x3f40('0x2d')]);if(_0x1c94a1['length']>0x0){return _0x109752[_0x3f40('0x17')](0x190)[_0x3f40('0x2e')](_0x1c94a1);}var _0x1c4b44=_0x13f191[_0x3f40('0x2d')][_0x3f40('0x2f')];var _0x5c030a=respondWithRpcPromise('VoiceChannels');var _0x6c81fe=getAgent(_0x1c4b44);return Promise[_0x3f40('0x22')]([_0x5c030a,_0x6c81fe])['then'](function(_0x701ed0){var _0x5a3456=_0x701ed0[0x0];var _0x204cff=_0x701ed0[0x1];var _0x557c0c=_[_0x3f40('0x23')](_0x5a3456['rows'],function(_0xab34b){return _0xab34b[_0x3f40('0x25')]==_0x204cff['id'];});return _0x109752[_0x3f40('0x17')](0xc8)['json']({'count':_0x557c0c['length'],'rows':_0x557c0c});})['catch'](handleError(_0x109752));};exports['conference']=function(_0x273739,_0x4e1c35){logger['info'](_0x3f40('0x46'),_0x273739[_0x3f40('0x2d')]);var _0x37f636=conferenceValidation[_0x3f40('0x2c')](_0x273739['body']);if(_0x37f636[_0x3f40('0x27')]>0x0){return _0x4e1c35['status'](0x190)['json'](_0x37f636);}var _0x48b0ed=_0x273739[_0x3f40('0x2d')]['userId'];return getAgent(_0x48b0ed)['then'](function(_0x45d7e5){logger[_0x3f40('0x2a')](_0x3f40('0x33'),_0x45d7e5[_0x3f40('0x16')]);emit(util[_0x3f40('0x34')]('user:%s',_0x45d7e5[_0x3f40('0x16')]),'webbar:conference');return _0x4e1c35[_0x3f40('0x17')](0xc8)[_0x3f40('0x2e')]({'error':![],'message':_0x3f40('0x47')});})['catch'](handleError(_0x4e1c35));};exports[_0x3f40('0x48')]=function(_0x2408f4,_0x46821c){logger[_0x3f40('0x2a')](_0x3f40('0x49'),_0x2408f4['body']);var _0x2f76a1=transferValidation[_0x3f40('0x2c')](_0x2408f4[_0x3f40('0x2d')]);if(_0x2f76a1[_0x3f40('0x27')]>0x0){return _0x46821c[_0x3f40('0x17')](0x190)[_0x3f40('0x2e')](_0x2f76a1);}var _0x29fdfc=_0x2408f4[_0x3f40('0x2d')][_0x3f40('0x2f')];var _0x37add1=_0x2408f4[_0x3f40('0x2d')][_0x3f40('0x26')];var _0x52c075=_0x2408f4['body']['transferNumber'];return getAgent(_0x29fdfc)[_0x3f40('0x1b')](function(_0x137cd8){logger[_0x3f40('0x2a')](_0x3f40('0x33'),_0x137cd8[_0x3f40('0x16')]);emit(util[_0x3f40('0x34')]('user:%s',_0x137cd8[_0x3f40('0x16')]),'webbar:transfer',{'sessionId':_0x37add1,'transferNumber':_0x52c075});return _0x46821c[_0x3f40('0x17')](0xc8)[_0x3f40('0x2e')]({'error':![],'message':_0x3f40('0x4a')});})[_0x3f40('0x38')](handleError(_0x46821c));};
\ No newline at end of file
+var _0x0ba7=['client','http','../../config/logger','webbarapi','ioredis','redis','defaults','localhost','socket.io-emitter','validate','number','userId\x20is\x20required','string','transferNumber\x20is\x20required','info','stringify','emit','error','stack','name','status','send','NotFound','request','code','message','result','findOne','agent','then','VoiceChannels','filter','UserId','length','sessionId\x20','\x20not\x20found!','originate','originate\x20fired:','body','json','callNumber','callerId','callbackUrl','format','user:%s','webbar:originate','originate\x20executed!','hangup','hangup\x20fired:','userId','sessionId','hangup\x20executed!','catch','answer','answer\x20fired:','entityFound:','webbar:answer','answer\x20executed!','hold\x20fired:','webbar:hold','unhold','calls','calls\x20fired:','conference','conference\x20fired:','transfer','transfer\x20fired:','transferNumber','webbar:transfer','path','../../mysqldb','../../config/environment','util','bluebird'];(function(_0x1840c1,_0x217972){var _0x4587b0=function(_0x799208){while(--_0x799208){_0x1840c1['push'](_0x1840c1['shift']());}};_0x4587b0(++_0x217972);}(_0x0ba7,0x16d));var _0x70ba=function(_0x15615a,_0x77e2f4){_0x15615a=_0x15615a-0x0;var _0x141e50=_0x0ba7[_0x15615a];return _0x141e50;};'use strict';var path=require(_0x70ba('0x0'));var fs=require('fs');var _=require('lodash');var db=require(_0x70ba('0x1'))['db'];var config=require(_0x70ba('0x2'));var util=require(_0x70ba('0x3'));var BPromise=require(_0x70ba('0x4'));var jayson=require('jayson/promise');var amiClient=jayson[_0x70ba('0x5')][_0x70ba('0x6')]({'port':0x232a});var logger=require(_0x70ba('0x7'))(_0x70ba('0x8'));var Redis=require(_0x70ba('0x9'));config[_0x70ba('0xa')]=_[_0x70ba('0xb')](config[_0x70ba('0xa')],{'host':_0x70ba('0xc'),'port':0x18eb});var io=require(_0x70ba('0xd'))(new Redis(config[_0x70ba('0xa')]));var Schema=require(_0x70ba('0xe'));var originateValidation=new Schema({'userId':{'type':_0x70ba('0xf'),'required':[!![],_0x70ba('0x10')]},'callNumber':{'type':_0x70ba('0x11'),'required':[!![],'callNumber\x20is\x20required']},'callerId':{'type':_0x70ba('0x11')},'callbackUrl':{'type':'string'}});var hangupValidation=new Schema({'userId':{'type':_0x70ba('0xf'),'required':[!![],_0x70ba('0x10')]},'sessionId':{'type':_0x70ba('0x11'),'required':![]}});var answerValidation=new Schema({'userId':{'type':_0x70ba('0xf'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':'string','required':![]}});var transferValidation=new Schema({'userId':{'type':_0x70ba('0xf'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0x70ba('0x11'),'required':[!![],'sessionId\x20is\x20required']},'transferNumber':{'type':_0x70ba('0x11'),'required':[!![],_0x70ba('0x12')]}});var holdValidation=new Schema({'userId':{'type':'number','required':[!![],_0x70ba('0x10')]},'sessionId':{'type':'string','required':![]}});var unholdValidation=new Schema({'userId':{'type':_0x70ba('0xf'),'required':[!![],_0x70ba('0x10')]},'sessionId':{'type':_0x70ba('0x11'),'required':![]}});var callsValidation=new Schema({'userId':{'type':_0x70ba('0xf'),'required':[!![],_0x70ba('0x10')]}});var conferenceValidation=new Schema({'userId':{'type':_0x70ba('0xf'),'required':[!![],_0x70ba('0x10')]}});function emit(_0x164521,_0x18334a,_0x3e27e8){logger[_0x70ba('0x13')](_0x164521,_0x18334a,JSON[_0x70ba('0x14')](_0x3e27e8));io['to'](_0x164521)[_0x70ba('0x15')](_0x18334a,_0x3e27e8);}function handleError(_0xb6d69a){return function(_0x5ed907){console['log']('handleError:',_0x5ed907,_0x5ed907 instanceof RangeError);logger[_0x70ba('0x16')](_0x5ed907[_0x70ba('0x17')]);if(_0x5ed907 instanceof RangeError){if(_0x5ed907[_0x70ba('0x18')]){delete _0x5ed907[_0x70ba('0x18')];}_0xb6d69a[_0x70ba('0x19')](0x194)[_0x70ba('0x1a')](_0x5ed907);}else{if(_0x5ed907[_0x70ba('0x18')]){delete _0x5ed907[_0x70ba('0x18')];}_0xb6d69a[_0x70ba('0x19')](0x1f4)[_0x70ba('0x1a')](_0x5ed907);}};}function checkError(){return function(_0x26c039){if(!_0x26c039){throw new RangeError(_0x70ba('0x1b'));}return _0x26c039;};}function respondWithRpcPromise(_0x2a1328,_0x4570b0){return new BPromise(function(_0x273ce4,_0x5ebe9d){var _0x3b31ef=amiClient;return _0x3b31ef[_0x70ba('0x1c')](_0x2a1328,_0x4570b0)['then'](function(_0x123b0c){if(_0x123b0c['error']){if(_0x123b0c['error'][_0x70ba('0x1d')]===0x1f4){return _0x5ebe9d(_0x123b0c['error'][_0x70ba('0x1e')]);}return _0x273ce4(_0x123b0c[_0x70ba('0x16')]['message']);}else{_0x273ce4(_0x123b0c[_0x70ba('0x1f')]);}})['catch'](function(_0x5ad828){_0x5ebe9d(_0x5ad828);});});}function getAgent(_0x39482c){return db['User'][_0x70ba('0x20')]({'where':{'id':_0x39482c,'role':_0x70ba('0x21')}})[_0x70ba('0x22')](checkError());}function getAgentCheckSession(_0x33e218,_0x2c6d18){return new BPromise(function(_0x265423,_0x5a8558){var _0x2d840e=respondWithRpcPromise(_0x70ba('0x23'));var _0x797467=getAgent(_0x33e218);Promise['all']([_0x2d840e,_0x797467])[_0x70ba('0x22')](function(_0x51b5cb){var _0x5955dc=_0x51b5cb[0x0];var _0x505f98=_0x51b5cb[0x1];var _0x77e564=_[_0x70ba('0x24')](_0x5955dc['rows'],function(_0x51b3e3){return _0x51b3e3[_0x70ba('0x25')]==_0x505f98['id']&&_0x51b3e3['sessionId']==_0x2c6d18;});if(_0x77e564[_0x70ba('0x26')]==0x1){_0x265423(_0x505f98);}else{_0x5a8558(new RangeError(_0x70ba('0x27')+_0x2c6d18+_0x70ba('0x28')));}});});}exports[_0x70ba('0x29')]=function(_0x1db0c4,_0x269943){logger[_0x70ba('0x13')](_0x70ba('0x2a'),_0x1db0c4[_0x70ba('0x2b')]);var _0x6055d3=originateValidation[_0x70ba('0xe')](_0x1db0c4['body']);if(_0x6055d3['length']>0x0){return _0x269943[_0x70ba('0x19')](0x190)[_0x70ba('0x2c')](_0x6055d3);}var _0x943e49=_0x1db0c4['body']['userId'];var _0x507f00=_0x1db0c4[_0x70ba('0x2b')][_0x70ba('0x2d')];var _0x2200d3=_0x1db0c4['body'][_0x70ba('0x2e')];var _0x5bc56f=_0x1db0c4['body'][_0x70ba('0x2f')];return getAgent(_0x943e49)['then'](function(_0x15774e){logger[_0x70ba('0x13')]('entityFound:',_0x15774e[_0x70ba('0x18')]);emit(util[_0x70ba('0x30')](_0x70ba('0x31'),_0x15774e['name']),_0x70ba('0x32'),{'callNumber':_0x507f00,'callerId':_0x2200d3,'callbackUrl':_0x5bc56f});return _0x269943[_0x70ba('0x19')](0xc8)[_0x70ba('0x2c')]({'error':![],'message':_0x70ba('0x33')});})['catch'](handleError(_0x269943));};exports[_0x70ba('0x34')]=function(_0x569ae3,_0x17707a){logger[_0x70ba('0x13')](_0x70ba('0x35'),_0x569ae3[_0x70ba('0x2b')]);var _0x16ce39=hangupValidation[_0x70ba('0xe')](_0x569ae3[_0x70ba('0x2b')]);if(_0x16ce39['length']>0x0){return _0x17707a[_0x70ba('0x19')](0x190)[_0x70ba('0x2c')](_0x16ce39);}var _0x31e713=_0x569ae3[_0x70ba('0x2b')][_0x70ba('0x36')];var _0x473489=_0x569ae3['body'][_0x70ba('0x37')];return getAgent(_0x31e713)[_0x70ba('0x22')](function(_0x1861ed){logger['info']('entityFound:',_0x1861ed['name']);emit(util[_0x70ba('0x30')](_0x70ba('0x31'),_0x1861ed[_0x70ba('0x18')]),'webbar:hangup',{'sessionId':_0x473489});return _0x17707a[_0x70ba('0x19')](0xc8)[_0x70ba('0x2c')]({'error':![],'message':_0x70ba('0x38')});})[_0x70ba('0x39')](handleError(_0x17707a));};exports[_0x70ba('0x3a')]=function(_0x54e732,_0x5ee74c){logger[_0x70ba('0x13')](_0x70ba('0x3b'),_0x54e732[_0x70ba('0x2b')]);var _0x5a1edb=answerValidation['validate'](_0x54e732[_0x70ba('0x2b')]);if(_0x5a1edb['length']>0x0){return _0x5ee74c[_0x70ba('0x19')](0x190)[_0x70ba('0x2c')](_0x5a1edb);}var _0x705ca4=_0x54e732[_0x70ba('0x2b')][_0x70ba('0x36')];var _0x51f4df=_0x54e732[_0x70ba('0x2b')][_0x70ba('0x37')];return getAgent(_0x705ca4)[_0x70ba('0x22')](function(_0x3dc2f7){logger[_0x70ba('0x13')](_0x70ba('0x3c'),_0x3dc2f7[_0x70ba('0x18')]);emit(util[_0x70ba('0x30')](_0x70ba('0x31'),_0x3dc2f7[_0x70ba('0x18')]),_0x70ba('0x3d'),{'sessionId':_0x51f4df});return _0x5ee74c[_0x70ba('0x19')](0xc8)[_0x70ba('0x2c')]({'error':![],'message':_0x70ba('0x3e')});})[_0x70ba('0x39')](handleError(_0x5ee74c));};exports['hold']=function(_0xd7638f,_0x3121f6){logger['info'](_0x70ba('0x3f'),_0xd7638f[_0x70ba('0x2b')]);var _0x3de825=holdValidation[_0x70ba('0xe')](_0xd7638f[_0x70ba('0x2b')]);if(_0x3de825[_0x70ba('0x26')]>0x0){return _0x3121f6[_0x70ba('0x19')](0x190)['json'](_0x3de825);}var _0x2e2613=_0xd7638f[_0x70ba('0x2b')][_0x70ba('0x36')];var _0x3d1f89=_0xd7638f[_0x70ba('0x2b')][_0x70ba('0x37')];return getAgent(_0x2e2613)[_0x70ba('0x22')](function(_0x400c37){logger[_0x70ba('0x13')](_0x70ba('0x3c'),_0x400c37[_0x70ba('0x18')]);emit(util[_0x70ba('0x30')](_0x70ba('0x31'),_0x400c37[_0x70ba('0x18')]),_0x70ba('0x40'),{'sessionId':_0x3d1f89});return _0x3121f6[_0x70ba('0x19')](0xc8)[_0x70ba('0x2c')]({'error':![],'message':'hold\x20executed!'});})[_0x70ba('0x39')](handleError(_0x3121f6));};exports[_0x70ba('0x41')]=function(_0x2dc3c5,_0x19c99c){logger['info']('unhold\x20fired:',_0x2dc3c5['body']);var _0x471d19=unholdValidation[_0x70ba('0xe')](_0x2dc3c5['body']);if(_0x471d19['length']>0x0){return _0x19c99c[_0x70ba('0x19')](0x190)[_0x70ba('0x2c')](_0x471d19);}var _0x3e3779=_0x2dc3c5[_0x70ba('0x2b')][_0x70ba('0x36')];var _0x4e2397=_0x2dc3c5[_0x70ba('0x2b')]['sessionId'];return getAgent(_0x3e3779)['then'](function(_0x361699){logger[_0x70ba('0x13')](_0x70ba('0x3c'),_0x361699[_0x70ba('0x18')]);emit(util['format'](_0x70ba('0x31'),_0x361699[_0x70ba('0x18')]),'webbar:unhold',{'sessionId':_0x4e2397});return _0x19c99c['status'](0xc8)['json']({'error':![],'message':'unhold\x20executed!'});})[_0x70ba('0x39')](handleError(_0x19c99c));};exports[_0x70ba('0x42')]=function(_0x1cb9c7,_0x4cc5b1){logger[_0x70ba('0x13')](_0x70ba('0x43'),_0x4cc5b1[_0x70ba('0x2b')]);var _0x5214eb=callsValidation[_0x70ba('0xe')](_0x1cb9c7[_0x70ba('0x2b')]);if(_0x5214eb['length']>0x0){return _0x4cc5b1['status'](0x190)[_0x70ba('0x2c')](_0x5214eb);}var _0x15b3ab=_0x1cb9c7[_0x70ba('0x2b')][_0x70ba('0x36')];var _0x10e824=respondWithRpcPromise(_0x70ba('0x23'));var _0x44cb31=getAgent(_0x15b3ab);return Promise['all']([_0x10e824,_0x44cb31])[_0x70ba('0x22')](function(_0x27d101){var _0x4de412=_0x27d101[0x0];var _0x508da6=_0x27d101[0x1];var _0x137b7d=_[_0x70ba('0x24')](_0x4de412['rows'],function(_0x4ea26b){return _0x4ea26b[_0x70ba('0x25')]==_0x508da6['id'];});return _0x4cc5b1['status'](0xc8)['json']({'count':_0x137b7d[_0x70ba('0x26')],'rows':_0x137b7d});})[_0x70ba('0x39')](handleError(_0x4cc5b1));};exports[_0x70ba('0x44')]=function(_0xb03649,_0x10bb90){logger[_0x70ba('0x13')](_0x70ba('0x45'),_0xb03649['body']);var _0x46a8a6=conferenceValidation[_0x70ba('0xe')](_0xb03649[_0x70ba('0x2b')]);if(_0x46a8a6[_0x70ba('0x26')]>0x0){return _0x10bb90[_0x70ba('0x19')](0x190)[_0x70ba('0x2c')](_0x46a8a6);}var _0x5d58a1=_0xb03649[_0x70ba('0x2b')]['userId'];return getAgent(_0x5d58a1)[_0x70ba('0x22')](function(_0x4b385b){logger[_0x70ba('0x13')](_0x70ba('0x3c'),_0x4b385b[_0x70ba('0x18')]);emit(util[_0x70ba('0x30')](_0x70ba('0x31'),_0x4b385b[_0x70ba('0x18')]),'webbar:conference');return _0x10bb90[_0x70ba('0x19')](0xc8)['json']({'error':![],'message':'conference\x20executed!'});})[_0x70ba('0x39')](handleError(_0x10bb90));};exports[_0x70ba('0x46')]=function(_0x5b1824,_0x208333){logger['info'](_0x70ba('0x47'),_0x5b1824[_0x70ba('0x2b')]);var _0x378893=transferValidation['validate'](_0x5b1824[_0x70ba('0x2b')]);if(_0x378893['length']>0x0){return _0x208333[_0x70ba('0x19')](0x190)['json'](_0x378893);}var _0x2ee3d0=_0x5b1824[_0x70ba('0x2b')][_0x70ba('0x36')];var _0x4ebc09=_0x5b1824['body'][_0x70ba('0x37')];var _0x530324=_0x5b1824[_0x70ba('0x2b')][_0x70ba('0x48')];return getAgent(_0x2ee3d0)[_0x70ba('0x22')](function(_0x32a246){logger['info'](_0x70ba('0x3c'),_0x32a246[_0x70ba('0x18')]);emit(util[_0x70ba('0x30')](_0x70ba('0x31'),_0x32a246[_0x70ba('0x18')]),_0x70ba('0x49'),{'sessionId':_0x4ebc09,'transferNumber':_0x530324});return _0x208333[_0x70ba('0x19')](0xc8)[_0x70ba('0x2c')]({'error':![],'message':'transfer\x20executed!'});})[_0x70ba('0x39')](handleError(_0x208333));};
\ No newline at end of file