Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / webbar / webbar.controller.js
index 48da338..ebc0e5b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x296f=['callbackUrl','format','user:%s','webbar:originate','json','hangup','hangup\x20fired:','userId','entityFound:','webbar:hangup','hangup\x20executed!','answer\x20fired:','webbar:answer','answer\x20executed!','hold','hold\x20fired:','webbar:hold','unhold\x20fired:','webbar:unhold','unhold\x20executed!','calls','all','conference\x20fired:','webbar:conference','conference\x20executed!','transfer','transfer\x20executed!','path','lodash','../../mysqldb','../../config/environment','util','bluebird','http','../../config/logger','defaults','redis','socket.io-emitter','number','string','callNumber\x20is\x20required','userId\x20is\x20required','transferNumber\x20is\x20required','info','stringify','emit','handleError:','error','stack','name','status','send','NotFound','then','code','message','result','catch','findOne','agent','VoiceChannels','filter','sessionId','sessionId\x20','\x20not\x20found!','originate','originate\x20fired:','body','validate','length','callerId'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x296f,0xf0));var _0xf296=function(_0x5581ba,_0x268887){_0x5581ba=_0x5581ba-0x0;var _0x1e927f=_0x296f[_0x5581ba];return _0x1e927f;};'use strict';var path=require(_0xf296('0x0'));var fs=require('fs');var _=require(_0xf296('0x1'));var db=require(_0xf296('0x2'))['db'];var config=require(_0xf296('0x3'));var util=require(_0xf296('0x4'));var BPromise=require(_0xf296('0x5'));var jayson=require('jayson/promise');var amiClient=jayson['client'][_0xf296('0x6')]({'port':0x232a});var logger=require(_0xf296('0x7'))('webbarapi');var Redis=require('ioredis');config['redis']=_[_0xf296('0x8')](config[_0xf296('0x9')],{'host':'localhost','port':0x18eb});var io=require(_0xf296('0xa'))(new Redis(config[_0xf296('0x9')]));var Schema=require('validate');var originateValidation=new Schema({'userId':{'type':_0xf296('0xb'),'required':[!![],'userId\x20is\x20required']},'callNumber':{'type':_0xf296('0xc'),'required':[!![],_0xf296('0xd')]},'callerId':{'type':_0xf296('0xc')},'callbackUrl':{'type':'string'}});var hangupValidation=new Schema({'userId':{'type':_0xf296('0xb'),'required':[!![],_0xf296('0xe')]},'sessionId':{'type':_0xf296('0xc'),'required':![]}});var answerValidation=new Schema({'userId':{'type':'number','required':[!![],_0xf296('0xe')]},'sessionId':{'type':_0xf296('0xc'),'required':![]}});var transferValidation=new Schema({'userId':{'type':_0xf296('0xb'),'required':[!![],_0xf296('0xe')]},'sessionId':{'type':_0xf296('0xc'),'required':[!![],'sessionId\x20is\x20required']},'transferNumber':{'type':'string','required':[!![],_0xf296('0xf')]}});var holdValidation=new Schema({'userId':{'type':_0xf296('0xb'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0xf296('0xc'),'required':![]}});var unholdValidation=new Schema({'userId':{'type':_0xf296('0xb'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0xf296('0xc'),'required':![]}});var callsValidation=new Schema({'userId':{'type':_0xf296('0xb'),'required':[!![],'userId\x20is\x20required']}});var conferenceValidation=new Schema({'userId':{'type':'number','required':[!![],'userId\x20is\x20required']}});function emit(_0x25ba1e,_0x422b54,_0x1f3b5b){logger[_0xf296('0x10')](_0x25ba1e,_0x422b54,JSON[_0xf296('0x11')](_0x1f3b5b));io['to'](_0x25ba1e)[_0xf296('0x12')](_0x422b54,_0x1f3b5b);}function handleError(_0x3db703){return function(_0x2ea567){console['log'](_0xf296('0x13'),_0x2ea567,_0x2ea567 instanceof RangeError);logger[_0xf296('0x14')](_0x2ea567[_0xf296('0x15')]);if(_0x2ea567 instanceof RangeError){if(_0x2ea567[_0xf296('0x16')]){delete _0x2ea567[_0xf296('0x16')];}_0x3db703[_0xf296('0x17')](0x194)['send'](_0x2ea567);}else{if(_0x2ea567[_0xf296('0x16')]){delete _0x2ea567['name'];}_0x3db703[_0xf296('0x17')](0x1f4)[_0xf296('0x18')](_0x2ea567);}};}function checkError(){return function(_0x4a9bc1){if(!_0x4a9bc1){throw new RangeError(_0xf296('0x19'));}return _0x4a9bc1;};}function respondWithRpcPromise(_0x3bdc0e,_0x20ffdf){return new BPromise(function(_0x4f337b,_0x3f8a9e){var _0x396227=amiClient;return _0x396227['request'](_0x3bdc0e,_0x20ffdf)[_0xf296('0x1a')](function(_0xb497cf){if(_0xb497cf[_0xf296('0x14')]){if(_0xb497cf[_0xf296('0x14')][_0xf296('0x1b')]===0x1f4){return _0x3f8a9e(_0xb497cf[_0xf296('0x14')]['message']);}return _0x4f337b(_0xb497cf[_0xf296('0x14')][_0xf296('0x1c')]);}else{_0x4f337b(_0xb497cf[_0xf296('0x1d')]);}})[_0xf296('0x1e')](function(_0x40dfcd){_0x3f8a9e(_0x40dfcd);});});}function getAgent(_0x357fd5){return db['User'][_0xf296('0x1f')]({'where':{'id':_0x357fd5,'role':_0xf296('0x20')}})[_0xf296('0x1a')](checkError());}function getAgentCheckSession(_0x3f5067,_0x380831){return new BPromise(function(_0x1393c1,_0x23a55f){var _0x20693c=respondWithRpcPromise(_0xf296('0x21'));var _0x57b4e5=getAgent(_0x3f5067);Promise['all']([_0x20693c,_0x57b4e5])['then'](function(_0x1609ed){var _0x286498=_0x1609ed[0x0];var _0x21a38a=_0x1609ed[0x1];var _0xc76eef=_[_0xf296('0x22')](_0x286498['rows'],function(_0x95d538){return _0x95d538['UserId']==_0x21a38a['id']&&_0x95d538[_0xf296('0x23')]==_0x380831;});if(_0xc76eef['length']==0x1){_0x1393c1(_0x21a38a);}else{_0x23a55f(new RangeError(_0xf296('0x24')+_0x380831+_0xf296('0x25')));}});});}exports[_0xf296('0x26')]=function(_0x2edf4d,_0x402c95){logger[_0xf296('0x10')](_0xf296('0x27'),_0x2edf4d[_0xf296('0x28')]);var _0x5eb657=originateValidation[_0xf296('0x29')](_0x2edf4d['body']);if(_0x5eb657[_0xf296('0x2a')]>0x0){return _0x402c95[_0xf296('0x17')](0x190)['json'](_0x5eb657);}var _0x21058d=_0x2edf4d[_0xf296('0x28')]['userId'];var _0x30f39c=_0x2edf4d['body']['callNumber'];var _0x1e97c9=_0x2edf4d['body'][_0xf296('0x2b')];var _0x56ba3a=_0x2edf4d[_0xf296('0x28')][_0xf296('0x2c')];return getAgent(_0x21058d)[_0xf296('0x1a')](function(_0x262487){logger[_0xf296('0x10')]('entityFound:',_0x262487['name']);emit(util[_0xf296('0x2d')](_0xf296('0x2e'),_0x262487[_0xf296('0x16')]),_0xf296('0x2f'),{'callNumber':_0x30f39c,'callerId':_0x1e97c9,'callbackUrl':_0x56ba3a});return _0x402c95[_0xf296('0x17')](0xc8)[_0xf296('0x30')]({'error':![],'message':'originate\x20executed!'});})[_0xf296('0x1e')](handleError(_0x402c95));};exports[_0xf296('0x31')]=function(_0x128bb7,_0x157bf0){logger[_0xf296('0x10')](_0xf296('0x32'),_0x128bb7['body']);var _0x4a54d6=hangupValidation[_0xf296('0x29')](_0x128bb7[_0xf296('0x28')]);if(_0x4a54d6[_0xf296('0x2a')]>0x0){return _0x157bf0[_0xf296('0x17')](0x190)['json'](_0x4a54d6);}var _0x1e3255=_0x128bb7['body'][_0xf296('0x33')];var _0x2b098c=_0x128bb7[_0xf296('0x28')]['sessionId'];return getAgent(_0x1e3255)['then'](function(_0xdd90ae){logger['info'](_0xf296('0x34'),_0xdd90ae['name']);emit(util['format'](_0xf296('0x2e'),_0xdd90ae['name']),_0xf296('0x35'),{'sessionId':_0x2b098c});return _0x157bf0['status'](0xc8)[_0xf296('0x30')]({'error':![],'message':_0xf296('0x36')});})[_0xf296('0x1e')](handleError(_0x157bf0));};exports['answer']=function(_0x5333ff,_0x397f02){logger['info'](_0xf296('0x37'),_0x5333ff[_0xf296('0x28')]);var _0x28729c=answerValidation['validate'](_0x5333ff['body']);if(_0x28729c[_0xf296('0x2a')]>0x0){return _0x397f02[_0xf296('0x17')](0x190)[_0xf296('0x30')](_0x28729c);}var _0x15f6ed=_0x5333ff[_0xf296('0x28')][_0xf296('0x33')];var _0x309c8d=_0x5333ff[_0xf296('0x28')]['sessionId'];return getAgent(_0x15f6ed)[_0xf296('0x1a')](function(_0x5eabd6){logger[_0xf296('0x10')](_0xf296('0x34'),_0x5eabd6['name']);emit(util[_0xf296('0x2d')](_0xf296('0x2e'),_0x5eabd6[_0xf296('0x16')]),_0xf296('0x38'),{'sessionId':_0x309c8d});return _0x397f02['status'](0xc8)[_0xf296('0x30')]({'error':![],'message':_0xf296('0x39')});})[_0xf296('0x1e')](handleError(_0x397f02));};exports[_0xf296('0x3a')]=function(_0x1f7e94,_0xef69dc){logger[_0xf296('0x10')](_0xf296('0x3b'),_0x1f7e94[_0xf296('0x28')]);var _0x2cd465=holdValidation[_0xf296('0x29')](_0x1f7e94[_0xf296('0x28')]);if(_0x2cd465[_0xf296('0x2a')]>0x0){return _0xef69dc['status'](0x190)['json'](_0x2cd465);}var _0x16d8b5=_0x1f7e94[_0xf296('0x28')]['userId'];var _0xcf413d=_0x1f7e94['body']['sessionId'];return getAgent(_0x16d8b5)[_0xf296('0x1a')](function(_0xf6f1c9){logger[_0xf296('0x10')]('entityFound:',_0xf6f1c9[_0xf296('0x16')]);emit(util[_0xf296('0x2d')](_0xf296('0x2e'),_0xf6f1c9[_0xf296('0x16')]),_0xf296('0x3c'),{'sessionId':_0xcf413d});return _0xef69dc[_0xf296('0x17')](0xc8)[_0xf296('0x30')]({'error':![],'message':'hold\x20executed!'});})[_0xf296('0x1e')](handleError(_0xef69dc));};exports['unhold']=function(_0x2a7155,_0x181a2b){logger[_0xf296('0x10')](_0xf296('0x3d'),_0x2a7155[_0xf296('0x28')]);var _0x5ed02a=unholdValidation[_0xf296('0x29')](_0x2a7155[_0xf296('0x28')]);if(_0x5ed02a[_0xf296('0x2a')]>0x0){return _0x181a2b[_0xf296('0x17')](0x190)[_0xf296('0x30')](_0x5ed02a);}var _0x15a64f=_0x2a7155[_0xf296('0x28')][_0xf296('0x33')];var _0x4c04fb=_0x2a7155[_0xf296('0x28')][_0xf296('0x23')];return getAgent(_0x15a64f)[_0xf296('0x1a')](function(_0x108c77){logger[_0xf296('0x10')](_0xf296('0x34'),_0x108c77[_0xf296('0x16')]);emit(util['format'](_0xf296('0x2e'),_0x108c77['name']),_0xf296('0x3e'),{'sessionId':_0x4c04fb});return _0x181a2b[_0xf296('0x17')](0xc8)['json']({'error':![],'message':_0xf296('0x3f')});})[_0xf296('0x1e')](handleError(_0x181a2b));};exports[_0xf296('0x40')]=function(_0xf6d81,_0x1478a2){logger[_0xf296('0x10')]('calls\x20fired:',_0x1478a2[_0xf296('0x28')]);var _0xd34b0f=callsValidation[_0xf296('0x29')](_0xf6d81[_0xf296('0x28')]);if(_0xd34b0f['length']>0x0){return _0x1478a2[_0xf296('0x17')](0x190)[_0xf296('0x30')](_0xd34b0f);}var _0x45c1f3=_0xf6d81['body'][_0xf296('0x33')];var _0x4bfff9=respondWithRpcPromise('VoiceChannels');var _0x51628a=getAgent(_0x45c1f3);return Promise[_0xf296('0x41')]([_0x4bfff9,_0x51628a])[_0xf296('0x1a')](function(_0x5f3fae){var _0x56e19c=_0x5f3fae[0x0];var _0x53a384=_0x5f3fae[0x1];var _0x423c4c=_[_0xf296('0x22')](_0x56e19c['rows'],function(_0x3d4f38){return _0x3d4f38['UserId']==_0x53a384['id'];});return _0x1478a2['status'](0xc8)[_0xf296('0x30')]({'count':_0x423c4c[_0xf296('0x2a')],'rows':_0x423c4c});})[_0xf296('0x1e')](handleError(_0x1478a2));};exports['conference']=function(_0x47a6f2,_0x161429){logger[_0xf296('0x10')](_0xf296('0x42'),_0x47a6f2[_0xf296('0x28')]);var _0x2d9d74=conferenceValidation['validate'](_0x47a6f2[_0xf296('0x28')]);if(_0x2d9d74['length']>0x0){return _0x161429['status'](0x190)[_0xf296('0x30')](_0x2d9d74);}var _0xe4f62=_0x47a6f2[_0xf296('0x28')]['userId'];return getAgent(_0xe4f62)[_0xf296('0x1a')](function(_0x17cb02){logger[_0xf296('0x10')](_0xf296('0x34'),_0x17cb02[_0xf296('0x16')]);emit(util['format']('user:%s',_0x17cb02[_0xf296('0x16')]),_0xf296('0x43'));return _0x161429['status'](0xc8)[_0xf296('0x30')]({'error':![],'message':_0xf296('0x44')});})[_0xf296('0x1e')](handleError(_0x161429));};exports[_0xf296('0x45')]=function(_0x186bc5,_0x432edb){logger[_0xf296('0x10')]('transfer\x20fired:',_0x186bc5['body']);var _0x4df190=transferValidation[_0xf296('0x29')](_0x186bc5[_0xf296('0x28')]);if(_0x4df190[_0xf296('0x2a')]>0x0){return _0x432edb['status'](0x190)[_0xf296('0x30')](_0x4df190);}var _0x450b8f=_0x186bc5[_0xf296('0x28')]['userId'];var _0x3eac0b=_0x186bc5['body']['sessionId'];var _0x450206=_0x186bc5['body']['transferNumber'];return getAgent(_0x450b8f)[_0xf296('0x1a')](function(_0x4a045b){logger['info']('entityFound:',_0x4a045b['name']);emit(util[_0xf296('0x2d')](_0xf296('0x2e'),_0x4a045b[_0xf296('0x16')]),'webbar:transfer',{'sessionId':_0x3eac0b,'transferNumber':_0x450206});return _0x432edb['status'](0xc8)[_0xf296('0x30')]({'error':![],'message':_0xf296('0x46')});})[_0xf296('0x1e')](handleError(_0x432edb));};
\ No newline at end of file
+var _0x1714=['length','originate\x20fired:','body','json','userId','callNumber','callerId','format','webbar:originate','originate\x20executed!','hangup','hangup\x20fired:','entityFound:','user:%s','webbar:hangup','hangup\x20executed!','answer','answer\x20fired:','sessionId','webbar:answer','answer\x20executed!','hold','hold\x20fired:','hold\x20executed!','unhold','unhold\x20fired:','webbar:unhold','unhold\x20executed!','calls','calls\x20fired:','UserId','conference\x20fired:','conference\x20executed!','transfer','transfer\x20fired:','webbar:transfer','path','lodash','../../mysqldb','../../config/environment','util','bluebird','jayson/promise','client','http','../../config/logger','webbarapi','ioredis','redis','defaults','localhost','socket.io-emitter','validate','number','userId\x20is\x20required','callNumber\x20is\x20required','string','transferNumber\x20is\x20required','info','emit','log','handleError:','error','stack','name','status','send','code','message','result','catch','User','findOne','agent','then','VoiceChannels','all','filter','rows'];(function(_0x55291a,_0x814018){var _0x3c870c=function(_0x1fd787){while(--_0x1fd787){_0x55291a['push'](_0x55291a['shift']());}};_0x3c870c(++_0x814018);}(_0x1714,0x160));var _0x4171=function(_0x2f2643,_0x3b9b0d){_0x2f2643=_0x2f2643-0x0;var _0x395b99=_0x1714[_0x2f2643];return _0x395b99;};'use strict';var path=require(_0x4171('0x0'));var fs=require('fs');var _=require(_0x4171('0x1'));var db=require(_0x4171('0x2'))['db'];var config=require(_0x4171('0x3'));var util=require(_0x4171('0x4'));var BPromise=require(_0x4171('0x5'));var jayson=require(_0x4171('0x6'));var amiClient=jayson[_0x4171('0x7')][_0x4171('0x8')]({'port':0x232a});var logger=require(_0x4171('0x9'))(_0x4171('0xa'));var Redis=require(_0x4171('0xb'));config[_0x4171('0xc')]=_[_0x4171('0xd')](config[_0x4171('0xc')],{'host':_0x4171('0xe'),'port':0x18eb});var io=require(_0x4171('0xf'))(new Redis(config[_0x4171('0xc')]));var Schema=require(_0x4171('0x10'));var originateValidation=new Schema({'userId':{'type':_0x4171('0x11'),'required':[!![],_0x4171('0x12')]},'callNumber':{'type':'string','required':[!![],_0x4171('0x13')]},'callerId':{'type':_0x4171('0x14')},'callbackUrl':{'type':_0x4171('0x14')}});var hangupValidation=new Schema({'userId':{'type':_0x4171('0x11'),'required':[!![],_0x4171('0x12')]},'sessionId':{'type':_0x4171('0x14'),'required':![]}});var answerValidation=new Schema({'userId':{'type':_0x4171('0x11'),'required':[!![],_0x4171('0x12')]},'sessionId':{'type':_0x4171('0x14'),'required':![]}});var transferValidation=new Schema({'userId':{'type':_0x4171('0x11'),'required':[!![],_0x4171('0x12')]},'sessionId':{'type':_0x4171('0x14'),'required':[!![],'sessionId\x20is\x20required']},'transferNumber':{'type':_0x4171('0x14'),'required':[!![],_0x4171('0x15')]}});var holdValidation=new Schema({'userId':{'type':_0x4171('0x11'),'required':[!![],_0x4171('0x12')]},'sessionId':{'type':_0x4171('0x14'),'required':![]}});var unholdValidation=new Schema({'userId':{'type':_0x4171('0x11'),'required':[!![],_0x4171('0x12')]},'sessionId':{'type':_0x4171('0x14'),'required':![]}});var callsValidation=new Schema({'userId':{'type':_0x4171('0x11'),'required':[!![],_0x4171('0x12')]}});var conferenceValidation=new Schema({'userId':{'type':_0x4171('0x11'),'required':[!![],'userId\x20is\x20required']}});function emit(_0x76e9,_0x11a4b9,_0xb91fc3){logger[_0x4171('0x16')](_0x76e9,_0x11a4b9,JSON['stringify'](_0xb91fc3));io['to'](_0x76e9)[_0x4171('0x17')](_0x11a4b9,_0xb91fc3);}function handleError(_0x2f47e1){return function(_0x555e56){console[_0x4171('0x18')](_0x4171('0x19'),_0x555e56,_0x555e56 instanceof RangeError);logger[_0x4171('0x1a')](_0x555e56[_0x4171('0x1b')]);if(_0x555e56 instanceof RangeError){if(_0x555e56[_0x4171('0x1c')]){delete _0x555e56[_0x4171('0x1c')];}_0x2f47e1[_0x4171('0x1d')](0x194)[_0x4171('0x1e')](_0x555e56);}else{if(_0x555e56[_0x4171('0x1c')]){delete _0x555e56[_0x4171('0x1c')];}_0x2f47e1[_0x4171('0x1d')](0x1f4)[_0x4171('0x1e')](_0x555e56);}};}function checkError(){return function(_0x8fcf3a){if(!_0x8fcf3a){throw new RangeError('NotFound');}return _0x8fcf3a;};}function respondWithRpcPromise(_0x4262f5,_0x28de6f){return new BPromise(function(_0x26f288,_0x4ce28f){var _0x2f2f4=amiClient;return _0x2f2f4['request'](_0x4262f5,_0x28de6f)['then'](function(_0x15ce8a){if(_0x15ce8a[_0x4171('0x1a')]){if(_0x15ce8a[_0x4171('0x1a')][_0x4171('0x1f')]===0x1f4){return _0x4ce28f(_0x15ce8a[_0x4171('0x1a')][_0x4171('0x20')]);}return _0x26f288(_0x15ce8a[_0x4171('0x1a')][_0x4171('0x20')]);}else{_0x26f288(_0x15ce8a[_0x4171('0x21')]);}})[_0x4171('0x22')](function(_0x2df6f9){_0x4ce28f(_0x2df6f9);});});}function getAgent(_0x3f14c0){return db[_0x4171('0x23')][_0x4171('0x24')]({'where':{'id':_0x3f14c0,'role':_0x4171('0x25')}})[_0x4171('0x26')](checkError());}function getAgentCheckSession(_0x16b6d1,_0x370745){return new BPromise(function(_0x52321c,_0x2313e9){var _0x44ff04=respondWithRpcPromise(_0x4171('0x27'));var _0x41dabd=getAgent(_0x16b6d1);Promise[_0x4171('0x28')]([_0x44ff04,_0x41dabd])['then'](function(_0x1e7f71){var _0x3eeab3=_0x1e7f71[0x0];var _0x3de050=_0x1e7f71[0x1];var _0x24ca00=_[_0x4171('0x29')](_0x3eeab3[_0x4171('0x2a')],function(_0x3e6f54){return _0x3e6f54['UserId']==_0x3de050['id']&&_0x3e6f54['sessionId']==_0x370745;});if(_0x24ca00[_0x4171('0x2b')]==0x1){_0x52321c(_0x3de050);}else{_0x2313e9(new RangeError('sessionId\x20'+_0x370745+'\x20not\x20found!'));}});});}exports['originate']=function(_0x2c8a1c,_0x3aae40){logger[_0x4171('0x16')](_0x4171('0x2c'),_0x2c8a1c['body']);var _0x1a8b12=originateValidation[_0x4171('0x10')](_0x2c8a1c[_0x4171('0x2d')]);if(_0x1a8b12[_0x4171('0x2b')]>0x0){return _0x3aae40[_0x4171('0x1d')](0x190)[_0x4171('0x2e')](_0x1a8b12);}var _0x49644b=_0x2c8a1c[_0x4171('0x2d')][_0x4171('0x2f')];var _0x153644=_0x2c8a1c[_0x4171('0x2d')][_0x4171('0x30')];var _0x4ad225=_0x2c8a1c[_0x4171('0x2d')][_0x4171('0x31')];var _0x3caee7=_0x2c8a1c[_0x4171('0x2d')]['callbackUrl'];return getAgent(_0x49644b)[_0x4171('0x26')](function(_0x11bfac){logger['info']('entityFound:',_0x11bfac[_0x4171('0x1c')]);emit(util[_0x4171('0x32')]('user:%s',_0x11bfac[_0x4171('0x1c')]),_0x4171('0x33'),{'callNumber':_0x153644,'callerId':_0x4ad225,'callbackUrl':_0x3caee7});return _0x3aae40[_0x4171('0x1d')](0xc8)[_0x4171('0x2e')]({'error':![],'message':_0x4171('0x34')});})['catch'](handleError(_0x3aae40));};exports[_0x4171('0x35')]=function(_0x2cadd1,_0x2d4c21){logger[_0x4171('0x16')](_0x4171('0x36'),_0x2cadd1['body']);var _0x4a4a71=hangupValidation['validate'](_0x2cadd1[_0x4171('0x2d')]);if(_0x4a4a71[_0x4171('0x2b')]>0x0){return _0x2d4c21[_0x4171('0x1d')](0x190)[_0x4171('0x2e')](_0x4a4a71);}var _0x91360b=_0x2cadd1[_0x4171('0x2d')][_0x4171('0x2f')];var _0x5f1ff1=_0x2cadd1[_0x4171('0x2d')]['sessionId'];return getAgent(_0x91360b)[_0x4171('0x26')](function(_0x56520a){logger['info'](_0x4171('0x37'),_0x56520a['name']);emit(util[_0x4171('0x32')](_0x4171('0x38'),_0x56520a[_0x4171('0x1c')]),_0x4171('0x39'),{'sessionId':_0x5f1ff1});return _0x2d4c21[_0x4171('0x1d')](0xc8)[_0x4171('0x2e')]({'error':![],'message':_0x4171('0x3a')});})[_0x4171('0x22')](handleError(_0x2d4c21));};exports[_0x4171('0x3b')]=function(_0x16ac69,_0x577558){logger[_0x4171('0x16')](_0x4171('0x3c'),_0x16ac69[_0x4171('0x2d')]);var _0x180382=answerValidation[_0x4171('0x10')](_0x16ac69[_0x4171('0x2d')]);if(_0x180382['length']>0x0){return _0x577558[_0x4171('0x1d')](0x190)[_0x4171('0x2e')](_0x180382);}var _0x3fc014=_0x16ac69[_0x4171('0x2d')][_0x4171('0x2f')];var _0x40a325=_0x16ac69[_0x4171('0x2d')][_0x4171('0x3d')];return getAgent(_0x3fc014)[_0x4171('0x26')](function(_0x2341eb){logger[_0x4171('0x16')](_0x4171('0x37'),_0x2341eb[_0x4171('0x1c')]);emit(util[_0x4171('0x32')](_0x4171('0x38'),_0x2341eb[_0x4171('0x1c')]),_0x4171('0x3e'),{'sessionId':_0x40a325});return _0x577558[_0x4171('0x1d')](0xc8)[_0x4171('0x2e')]({'error':![],'message':_0x4171('0x3f')});})[_0x4171('0x22')](handleError(_0x577558));};exports[_0x4171('0x40')]=function(_0x4ef5a5,_0x8bb2d1){logger[_0x4171('0x16')](_0x4171('0x41'),_0x4ef5a5[_0x4171('0x2d')]);var _0x358893=holdValidation[_0x4171('0x10')](_0x4ef5a5[_0x4171('0x2d')]);if(_0x358893[_0x4171('0x2b')]>0x0){return _0x8bb2d1['status'](0x190)[_0x4171('0x2e')](_0x358893);}var _0x4f2198=_0x4ef5a5[_0x4171('0x2d')][_0x4171('0x2f')];var _0x279e21=_0x4ef5a5[_0x4171('0x2d')][_0x4171('0x3d')];return getAgent(_0x4f2198)[_0x4171('0x26')](function(_0x1f39a2){logger[_0x4171('0x16')](_0x4171('0x37'),_0x1f39a2['name']);emit(util[_0x4171('0x32')](_0x4171('0x38'),_0x1f39a2[_0x4171('0x1c')]),'webbar:hold',{'sessionId':_0x279e21});return _0x8bb2d1[_0x4171('0x1d')](0xc8)['json']({'error':![],'message':_0x4171('0x42')});})[_0x4171('0x22')](handleError(_0x8bb2d1));};exports[_0x4171('0x43')]=function(_0x57a0aa,_0x4e4f50){logger[_0x4171('0x16')](_0x4171('0x44'),_0x57a0aa['body']);var _0x4cd410=unholdValidation[_0x4171('0x10')](_0x57a0aa['body']);if(_0x4cd410[_0x4171('0x2b')]>0x0){return _0x4e4f50[_0x4171('0x1d')](0x190)['json'](_0x4cd410);}var _0x3d3f52=_0x57a0aa[_0x4171('0x2d')][_0x4171('0x2f')];var _0x227d75=_0x57a0aa[_0x4171('0x2d')][_0x4171('0x3d')];return getAgent(_0x3d3f52)['then'](function(_0xa3d4a5){logger['info'](_0x4171('0x37'),_0xa3d4a5[_0x4171('0x1c')]);emit(util[_0x4171('0x32')](_0x4171('0x38'),_0xa3d4a5['name']),_0x4171('0x45'),{'sessionId':_0x227d75});return _0x4e4f50['status'](0xc8)[_0x4171('0x2e')]({'error':![],'message':_0x4171('0x46')});})[_0x4171('0x22')](handleError(_0x4e4f50));};exports[_0x4171('0x47')]=function(_0x491e26,_0x3591ad){logger[_0x4171('0x16')](_0x4171('0x48'),_0x3591ad[_0x4171('0x2d')]);var _0x42a88e=callsValidation['validate'](_0x491e26['body']);if(_0x42a88e[_0x4171('0x2b')]>0x0){return _0x3591ad[_0x4171('0x1d')](0x190)[_0x4171('0x2e')](_0x42a88e);}var _0x3b5c9f=_0x491e26['body'][_0x4171('0x2f')];var _0x414fa7=respondWithRpcPromise('VoiceChannels');var _0xed6e12=getAgent(_0x3b5c9f);return Promise[_0x4171('0x28')]([_0x414fa7,_0xed6e12])[_0x4171('0x26')](function(_0xbbfb2f){var _0x281a0a=_0xbbfb2f[0x0];var _0x38fdc7=_0xbbfb2f[0x1];var _0x2700a6=_['filter'](_0x281a0a[_0x4171('0x2a')],function(_0x52c8ec){return _0x52c8ec[_0x4171('0x49')]==_0x38fdc7['id'];});return _0x3591ad[_0x4171('0x1d')](0xc8)['json']({'count':_0x2700a6[_0x4171('0x2b')],'rows':_0x2700a6});})[_0x4171('0x22')](handleError(_0x3591ad));};exports['conference']=function(_0x39e911,_0x562085){logger[_0x4171('0x16')](_0x4171('0x4a'),_0x39e911[_0x4171('0x2d')]);var _0x49d0c2=conferenceValidation[_0x4171('0x10')](_0x39e911[_0x4171('0x2d')]);if(_0x49d0c2['length']>0x0){return _0x562085['status'](0x190)[_0x4171('0x2e')](_0x49d0c2);}var _0x326fb9=_0x39e911['body']['userId'];return getAgent(_0x326fb9)['then'](function(_0x5caebb){logger[_0x4171('0x16')](_0x4171('0x37'),_0x5caebb[_0x4171('0x1c')]);emit(util[_0x4171('0x32')]('user:%s',_0x5caebb[_0x4171('0x1c')]),'webbar:conference');return _0x562085['status'](0xc8)[_0x4171('0x2e')]({'error':![],'message':_0x4171('0x4b')});})[_0x4171('0x22')](handleError(_0x562085));};exports[_0x4171('0x4c')]=function(_0x49c201,_0x5dc744){logger[_0x4171('0x16')](_0x4171('0x4d'),_0x49c201['body']);var _0x194cde=transferValidation[_0x4171('0x10')](_0x49c201[_0x4171('0x2d')]);if(_0x194cde[_0x4171('0x2b')]>0x0){return _0x5dc744[_0x4171('0x1d')](0x190)[_0x4171('0x2e')](_0x194cde);}var _0x1a44a0=_0x49c201[_0x4171('0x2d')][_0x4171('0x2f')];var _0x58ada6=_0x49c201[_0x4171('0x2d')]['sessionId'];var _0x5432bd=_0x49c201['body']['transferNumber'];return getAgent(_0x1a44a0)[_0x4171('0x26')](function(_0x4c12b1){logger['info'](_0x4171('0x37'),_0x4c12b1[_0x4171('0x1c')]);emit(util[_0x4171('0x32')]('user:%s',_0x4c12b1[_0x4171('0x1c')]),_0x4171('0x4e'),{'sessionId':_0x58ada6,'transferNumber':_0x5432bd});return _0x5dc744[_0x4171('0x1d')](0xc8)[_0x4171('0x2e')]({'error':![],'message':'transfer\x20executed!'});})[_0x4171('0x22')](handleError(_0x5dc744));};
\ No newline at end of file