Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / webbar / webbar.controller.js
index 831e653..e4dea9f 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 _0x2356=['stringify','emit','log','handleError:','error','stack','name','status','NotFound','code','message','result','catch','User','VoiceChannels','filter','UserId','length','sessionId\x20','\x20not\x20found!','originate','originate\x20fired:','body','json','userId','callNumber','callbackUrl','entityFound:','format','user:%s','originate\x20executed!','hangup','sessionId','webbar:hangup','hangup\x20executed!','answer','webbar:answer','answer\x20executed!','hold\x20fired:','then','webbar:hold','hold\x20executed!','webbar:unhold','unhold\x20executed!','calls\x20fired:','all','rows','conference','webbar:conference','conference\x20executed!','transfer','transfer\x20fired:','transferNumber','webbar:transfer','transfer\x20executed!','lodash','../../mysqldb','bluebird','jayson/promise','../../config/logger','redis','defaults','validate','userId\x20is\x20required','string','callNumber\x20is\x20required','number','sessionId\x20is\x20required','transferNumber\x20is\x20required','info'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x2356,0x14f));var _0x6235=function(_0x15ab61,_0x2e1df1){_0x15ab61=_0x15ab61-0x0;var _0x35fd48=_0x2356[_0x15ab61];return _0x35fd48;};'use strict';var path=require('path');var fs=require('fs');var _=require(_0x6235('0x0'));var db=require(_0x6235('0x1'))['db'];var config=require('../../config/environment');var util=require('util');var BPromise=require(_0x6235('0x2'));var jayson=require(_0x6235('0x3'));var amiClient=jayson['client']['http']({'port':0x232a});var logger=require(_0x6235('0x4'))('webbarapi');var Redis=require('ioredis');config[_0x6235('0x5')]=_[_0x6235('0x6')](config[_0x6235('0x5')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));var Schema=require(_0x6235('0x7'));var originateValidation=new Schema({'userId':{'type':'number','required':[!![],_0x6235('0x8')]},'callNumber':{'type':_0x6235('0x9'),'required':[!![],_0x6235('0xa')]},'callerId':{'type':_0x6235('0x9')},'callbackUrl':{'type':'string'}});var hangupValidation=new Schema({'userId':{'type':_0x6235('0xb'),'required':[!![],_0x6235('0x8')]},'sessionId':{'type':_0x6235('0x9'),'required':![]}});var answerValidation=new Schema({'userId':{'type':_0x6235('0xb'),'required':[!![],_0x6235('0x8')]},'sessionId':{'type':'string','required':![]}});var transferValidation=new Schema({'userId':{'type':_0x6235('0xb'),'required':[!![],_0x6235('0x8')]},'sessionId':{'type':_0x6235('0x9'),'required':[!![],_0x6235('0xc')]},'transferNumber':{'type':'string','required':[!![],_0x6235('0xd')]}});var holdValidation=new Schema({'userId':{'type':_0x6235('0xb'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0x6235('0x9'),'required':![]}});var unholdValidation=new Schema({'userId':{'type':'number','required':[!![],_0x6235('0x8')]},'sessionId':{'type':_0x6235('0x9'),'required':![]}});var callsValidation=new Schema({'userId':{'type':'number','required':[!![],_0x6235('0x8')]}});var conferenceValidation=new Schema({'userId':{'type':_0x6235('0xb'),'required':[!![],_0x6235('0x8')]}});function emit(_0x3f32af,_0x5d1ab7,_0x37b728){logger[_0x6235('0xe')](_0x3f32af,_0x5d1ab7,JSON[_0x6235('0xf')](_0x37b728));io['to'](_0x3f32af)[_0x6235('0x10')](_0x5d1ab7,_0x37b728);}function handleError(_0x78f0db){return function(_0x2a3554){console[_0x6235('0x11')](_0x6235('0x12'),_0x2a3554,_0x2a3554 instanceof RangeError);logger[_0x6235('0x13')](_0x2a3554[_0x6235('0x14')]);if(_0x2a3554 instanceof RangeError){if(_0x2a3554['name']){delete _0x2a3554[_0x6235('0x15')];}_0x78f0db[_0x6235('0x16')](0x194)['send'](_0x2a3554);}else{if(_0x2a3554['name']){delete _0x2a3554[_0x6235('0x15')];}_0x78f0db['status'](0x1f4)['send'](_0x2a3554);}};}function checkError(){return function(_0x4eead1){if(!_0x4eead1){throw new RangeError(_0x6235('0x17'));}return _0x4eead1;};}function respondWithRpcPromise(_0x3e2e24,_0x1eccae){return new BPromise(function(_0x1c60c7,_0x24c057){var _0x270c49=amiClient;return _0x270c49['request'](_0x3e2e24,_0x1eccae)['then'](function(_0x4663b3){if(_0x4663b3['error']){if(_0x4663b3[_0x6235('0x13')][_0x6235('0x18')]===0x1f4){return _0x24c057(_0x4663b3[_0x6235('0x13')][_0x6235('0x19')]);}return _0x1c60c7(_0x4663b3[_0x6235('0x13')]['message']);}else{_0x1c60c7(_0x4663b3[_0x6235('0x1a')]);}})[_0x6235('0x1b')](function(_0x168b01){_0x24c057(_0x168b01);});});}function getAgent(_0x46f73a){return db[_0x6235('0x1c')]['findOne']({'where':{'id':_0x46f73a,'role':'agent'}})['then'](checkError());}function getAgentCheckSession(_0x4f28f2,_0x5aa9fa){return new BPromise(function(_0x404e30,_0x39f563){var _0x20c633=respondWithRpcPromise(_0x6235('0x1d'));var _0x2acc8c=getAgent(_0x4f28f2);Promise['all']([_0x20c633,_0x2acc8c])['then'](function(_0x5dc066){var _0x94db3c=_0x5dc066[0x0];var _0x50ea93=_0x5dc066[0x1];var _0xc77505=_[_0x6235('0x1e')](_0x94db3c['rows'],function(_0x37580b){return _0x37580b[_0x6235('0x1f')]==_0x50ea93['id']&&_0x37580b['sessionId']==_0x5aa9fa;});if(_0xc77505[_0x6235('0x20')]==0x1){_0x404e30(_0x50ea93);}else{_0x39f563(new RangeError(_0x6235('0x21')+_0x5aa9fa+_0x6235('0x22')));}});});}exports[_0x6235('0x23')]=function(_0x5182e5,_0x452f60){logger[_0x6235('0xe')](_0x6235('0x24'),_0x5182e5[_0x6235('0x25')]);var _0x2e233d=originateValidation['validate'](_0x5182e5[_0x6235('0x25')]);if(_0x2e233d['length']>0x0){return _0x452f60['status'](0x190)[_0x6235('0x26')](_0x2e233d);}var _0x54a6ea=_0x5182e5['body'][_0x6235('0x27')];var _0x4b3564=_0x5182e5['body'][_0x6235('0x28')];var _0x176cab=_0x5182e5[_0x6235('0x25')]['callerId'];var _0x258b8a=_0x5182e5[_0x6235('0x25')][_0x6235('0x29')];return getAgent(_0x54a6ea)['then'](function(_0x358ca9){logger['info'](_0x6235('0x2a'),_0x358ca9[_0x6235('0x15')]);emit(util[_0x6235('0x2b')](_0x6235('0x2c'),_0x358ca9[_0x6235('0x15')]),'webbar:originate',{'callNumber':_0x4b3564,'callerId':_0x176cab,'callbackUrl':_0x258b8a});return _0x452f60[_0x6235('0x16')](0xc8)['json']({'error':![],'message':_0x6235('0x2d')});})[_0x6235('0x1b')](handleError(_0x452f60));};exports[_0x6235('0x2e')]=function(_0x3ab7f6,_0x3cc997){logger['info']('hangup\x20fired:',_0x3ab7f6[_0x6235('0x25')]);var _0x3ed704=hangupValidation[_0x6235('0x7')](_0x3ab7f6[_0x6235('0x25')]);if(_0x3ed704[_0x6235('0x20')]>0x0){return _0x3cc997[_0x6235('0x16')](0x190)[_0x6235('0x26')](_0x3ed704);}var _0xc3969=_0x3ab7f6[_0x6235('0x25')][_0x6235('0x27')];var _0x48b6ed=_0x3ab7f6['body'][_0x6235('0x2f')];return getAgent(_0xc3969)['then'](function(_0x585744){logger[_0x6235('0xe')](_0x6235('0x2a'),_0x585744[_0x6235('0x15')]);emit(util['format'](_0x6235('0x2c'),_0x585744['name']),_0x6235('0x30'),{'sessionId':_0x48b6ed});return _0x3cc997[_0x6235('0x16')](0xc8)[_0x6235('0x26')]({'error':![],'message':_0x6235('0x31')});})[_0x6235('0x1b')](handleError(_0x3cc997));};exports[_0x6235('0x32')]=function(_0x105acc,_0x13f974){logger['info']('answer\x20fired:',_0x105acc[_0x6235('0x25')]);var _0x54cbb1=answerValidation[_0x6235('0x7')](_0x105acc[_0x6235('0x25')]);if(_0x54cbb1[_0x6235('0x20')]>0x0){return _0x13f974[_0x6235('0x16')](0x190)[_0x6235('0x26')](_0x54cbb1);}var _0x38092e=_0x105acc[_0x6235('0x25')]['userId'];var _0x3a99c4=_0x105acc[_0x6235('0x25')][_0x6235('0x2f')];return getAgent(_0x38092e)['then'](function(_0x202f53){logger[_0x6235('0xe')](_0x6235('0x2a'),_0x202f53[_0x6235('0x15')]);emit(util[_0x6235('0x2b')](_0x6235('0x2c'),_0x202f53[_0x6235('0x15')]),_0x6235('0x33'),{'sessionId':_0x3a99c4});return _0x13f974['status'](0xc8)[_0x6235('0x26')]({'error':![],'message':_0x6235('0x34')});})[_0x6235('0x1b')](handleError(_0x13f974));};exports['hold']=function(_0x341680,_0x445518){logger[_0x6235('0xe')](_0x6235('0x35'),_0x341680[_0x6235('0x25')]);var _0x2acca5=holdValidation[_0x6235('0x7')](_0x341680[_0x6235('0x25')]);if(_0x2acca5[_0x6235('0x20')]>0x0){return _0x445518['status'](0x190)[_0x6235('0x26')](_0x2acca5);}var _0x4f30c4=_0x341680[_0x6235('0x25')][_0x6235('0x27')];var _0xe997ab=_0x341680['body']['sessionId'];return getAgent(_0x4f30c4)[_0x6235('0x36')](function(_0x433263){logger[_0x6235('0xe')](_0x6235('0x2a'),_0x433263['name']);emit(util[_0x6235('0x2b')](_0x6235('0x2c'),_0x433263['name']),_0x6235('0x37'),{'sessionId':_0xe997ab});return _0x445518['status'](0xc8)[_0x6235('0x26')]({'error':![],'message':_0x6235('0x38')});})[_0x6235('0x1b')](handleError(_0x445518));};exports['unhold']=function(_0x2aa5f9,_0x5bff03){logger['info']('unhold\x20fired:',_0x2aa5f9[_0x6235('0x25')]);var _0x1d4555=unholdValidation[_0x6235('0x7')](_0x2aa5f9[_0x6235('0x25')]);if(_0x1d4555[_0x6235('0x20')]>0x0){return _0x5bff03[_0x6235('0x16')](0x190)[_0x6235('0x26')](_0x1d4555);}var _0x492ce6=_0x2aa5f9[_0x6235('0x25')][_0x6235('0x27')];var _0x4696e4=_0x2aa5f9[_0x6235('0x25')]['sessionId'];return getAgent(_0x492ce6)[_0x6235('0x36')](function(_0x27ae26){logger[_0x6235('0xe')]('entityFound:',_0x27ae26[_0x6235('0x15')]);emit(util['format']('user:%s',_0x27ae26['name']),_0x6235('0x39'),{'sessionId':_0x4696e4});return _0x5bff03['status'](0xc8)[_0x6235('0x26')]({'error':![],'message':_0x6235('0x3a')});})[_0x6235('0x1b')](handleError(_0x5bff03));};exports['calls']=function(_0x27ba7d,_0x5257cf){logger[_0x6235('0xe')](_0x6235('0x3b'),_0x5257cf[_0x6235('0x25')]);var _0x457af6=callsValidation[_0x6235('0x7')](_0x27ba7d[_0x6235('0x25')]);if(_0x457af6[_0x6235('0x20')]>0x0){return _0x5257cf[_0x6235('0x16')](0x190)['json'](_0x457af6);}var _0x140c69=_0x27ba7d[_0x6235('0x25')]['userId'];var _0x471e6e=respondWithRpcPromise('VoiceChannels');var _0x4f3711=getAgent(_0x140c69);return Promise[_0x6235('0x3c')]([_0x471e6e,_0x4f3711])['then'](function(_0x40fe25){var _0x132612=_0x40fe25[0x0];var _0x6f743b=_0x40fe25[0x1];var _0x3859ff=_[_0x6235('0x1e')](_0x132612[_0x6235('0x3d')],function(_0x2ea969){return _0x2ea969[_0x6235('0x1f')]==_0x6f743b['id'];});return _0x5257cf[_0x6235('0x16')](0xc8)[_0x6235('0x26')]({'count':_0x3859ff[_0x6235('0x20')],'rows':_0x3859ff});})[_0x6235('0x1b')](handleError(_0x5257cf));};exports[_0x6235('0x3e')]=function(_0x2d4d01,_0x1716b9){logger[_0x6235('0xe')]('conference\x20fired:',_0x2d4d01[_0x6235('0x25')]);var _0x35ce3f=conferenceValidation['validate'](_0x2d4d01[_0x6235('0x25')]);if(_0x35ce3f[_0x6235('0x20')]>0x0){return _0x1716b9['status'](0x190)[_0x6235('0x26')](_0x35ce3f);}var _0x27c6f9=_0x2d4d01['body'][_0x6235('0x27')];return getAgent(_0x27c6f9)[_0x6235('0x36')](function(_0x3f9f5f){logger['info'](_0x6235('0x2a'),_0x3f9f5f[_0x6235('0x15')]);emit(util['format']('user:%s',_0x3f9f5f[_0x6235('0x15')]),_0x6235('0x3f'));return _0x1716b9[_0x6235('0x16')](0xc8)[_0x6235('0x26')]({'error':![],'message':_0x6235('0x40')});})[_0x6235('0x1b')](handleError(_0x1716b9));};exports[_0x6235('0x41')]=function(_0x20dbef,_0x1b6716){logger[_0x6235('0xe')](_0x6235('0x42'),_0x20dbef[_0x6235('0x25')]);var _0x22dac8=transferValidation[_0x6235('0x7')](_0x20dbef[_0x6235('0x25')]);if(_0x22dac8[_0x6235('0x20')]>0x0){return _0x1b6716[_0x6235('0x16')](0x190)[_0x6235('0x26')](_0x22dac8);}var _0x42d5b2=_0x20dbef[_0x6235('0x25')]['userId'];var _0x4ac76b=_0x20dbef[_0x6235('0x25')][_0x6235('0x2f')];var _0x3c0b20=_0x20dbef[_0x6235('0x25')][_0x6235('0x43')];return getAgent(_0x42d5b2)['then'](function(_0x8943b1){logger['info'](_0x6235('0x2a'),_0x8943b1['name']);emit(util['format'](_0x6235('0x2c'),_0x8943b1[_0x6235('0x15')]),_0x6235('0x44'),{'sessionId':_0x4ac76b,'transferNumber':_0x3c0b20});return _0x1b6716[_0x6235('0x16')](0xc8)[_0x6235('0x26')]({'error':![],'message':_0x6235('0x45')});})[_0x6235('0x1b')](handleError(_0x1b6716));};
\ No newline at end of file