Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / webbar / webbar.controller.js
index 87f24e9..89a817b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7980=['webbar:hold','hold\x20executed!','unhold','unhold\x20fired:','calls','calls\x20fired:','UserId','conference','conference\x20fired:','webbar:conference','transfer','transfer\x20fired:','transferNumber','webbar:transfer','transfer\x20executed!','path','lodash','../../mysqldb','../../config/environment','util','jayson/promise','client','http','../../config/logger','webbarapi','redis','localhost','socket.io-emitter','number','userId\x20is\x20required','string','callNumber\x20is\x20required','sessionId\x20is\x20required','transferNumber\x20is\x20required','emit','log','handleError:','error','name','send','status','NotFound','request','then','code','message','result','User','agent','VoiceChannels','all','filter','sessionId','length','sessionId\x20','\x20not\x20found!','originate','info','originate\x20fired:','body','validate','callNumber','callerId','user:%s','webbar:originate','json','originate\x20executed!','catch','hangup','hangup\x20fired:','userId','entityFound:','webbar:hangup','hangup\x20executed!','answer\x20fired:','format','answer\x20executed!','hold\x20fired:'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x7980,0xab));var _0x0798=function(_0x59277d,_0x3a4582){_0x59277d=_0x59277d-0x0;var _0x3f5523=_0x7980[_0x59277d];return _0x3f5523;};'use strict';var path=require(_0x0798('0x0'));var fs=require('fs');var _=require(_0x0798('0x1'));var db=require(_0x0798('0x2'))['db'];var config=require(_0x0798('0x3'));var util=require(_0x0798('0x4'));var BPromise=require('bluebird');var jayson=require(_0x0798('0x5'));var amiClient=jayson[_0x0798('0x6')][_0x0798('0x7')]({'port':0x232a});var logger=require(_0x0798('0x8'))(_0x0798('0x9'));var Redis=require('ioredis');config[_0x0798('0xa')]=_['defaults'](config[_0x0798('0xa')],{'host':_0x0798('0xb'),'port':0x18eb});var io=require(_0x0798('0xc'))(new Redis(config['redis']));var Schema=require('validate');var originateValidation=new Schema({'userId':{'type':_0x0798('0xd'),'required':[!![],_0x0798('0xe')]},'callNumber':{'type':_0x0798('0xf'),'required':[!![],_0x0798('0x10')]},'callerId':{'type':_0x0798('0xf')},'callbackUrl':{'type':_0x0798('0xf')}});var hangupValidation=new Schema({'userId':{'type':_0x0798('0xd'),'required':[!![],_0x0798('0xe')]},'sessionId':{'type':_0x0798('0xf'),'required':![]}});var answerValidation=new Schema({'userId':{'type':_0x0798('0xd'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0x0798('0xf'),'required':![]}});var transferValidation=new Schema({'userId':{'type':_0x0798('0xd'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':'string','required':[!![],_0x0798('0x11')]},'transferNumber':{'type':_0x0798('0xf'),'required':[!![],_0x0798('0x12')]}});var holdValidation=new Schema({'userId':{'type':_0x0798('0xd'),'required':[!![],_0x0798('0xe')]},'sessionId':{'type':_0x0798('0xf'),'required':![]}});var unholdValidation=new Schema({'userId':{'type':_0x0798('0xd'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':'string','required':![]}});var callsValidation=new Schema({'userId':{'type':_0x0798('0xd'),'required':[!![],_0x0798('0xe')]}});var conferenceValidation=new Schema({'userId':{'type':'number','required':[!![],'userId\x20is\x20required']}});function emit(_0x21c30b,_0x45cae6,_0x258081){logger['info'](_0x21c30b,_0x45cae6,JSON['stringify'](_0x258081));io['to'](_0x21c30b)[_0x0798('0x13')](_0x45cae6,_0x258081);}function handleError(_0x502635){return function(_0x41e217){console[_0x0798('0x14')](_0x0798('0x15'),_0x41e217,_0x41e217 instanceof RangeError);logger[_0x0798('0x16')](_0x41e217['stack']);if(_0x41e217 instanceof RangeError){if(_0x41e217[_0x0798('0x17')]){delete _0x41e217[_0x0798('0x17')];}_0x502635['status'](0x194)[_0x0798('0x18')](_0x41e217);}else{if(_0x41e217[_0x0798('0x17')]){delete _0x41e217[_0x0798('0x17')];}_0x502635[_0x0798('0x19')](0x1f4)[_0x0798('0x18')](_0x41e217);}};}function checkError(){return function(_0x273ba8){if(!_0x273ba8){throw new RangeError(_0x0798('0x1a'));}return _0x273ba8;};}function respondWithRpcPromise(_0x212ad5,_0x23b37d){return new BPromise(function(_0x4a86d5,_0x2aaabf){var _0x35c141=amiClient;return _0x35c141[_0x0798('0x1b')](_0x212ad5,_0x23b37d)[_0x0798('0x1c')](function(_0x20654b){if(_0x20654b[_0x0798('0x16')]){if(_0x20654b['error'][_0x0798('0x1d')]===0x1f4){return _0x2aaabf(_0x20654b[_0x0798('0x16')][_0x0798('0x1e')]);}return _0x4a86d5(_0x20654b[_0x0798('0x16')][_0x0798('0x1e')]);}else{_0x4a86d5(_0x20654b[_0x0798('0x1f')]);}})['catch'](function(_0x43d99f){_0x2aaabf(_0x43d99f);});});}function getAgent(_0x14f828){return db[_0x0798('0x20')]['findOne']({'where':{'id':_0x14f828,'role':_0x0798('0x21')}})['then'](checkError());}function getAgentCheckSession(_0x53a3d7,_0x406030){return new BPromise(function(_0x2dfbff,_0x134d24){var _0xaa949b=respondWithRpcPromise(_0x0798('0x22'));var _0x161244=getAgent(_0x53a3d7);Promise[_0x0798('0x23')]([_0xaa949b,_0x161244])[_0x0798('0x1c')](function(_0x5bbe3d){var _0x167960=_0x5bbe3d[0x0];var _0x4f5d1d=_0x5bbe3d[0x1];var _0x5f1780=_[_0x0798('0x24')](_0x167960['rows'],function(_0x1dabd5){return _0x1dabd5['UserId']==_0x4f5d1d['id']&&_0x1dabd5[_0x0798('0x25')]==_0x406030;});if(_0x5f1780[_0x0798('0x26')]==0x1){_0x2dfbff(_0x4f5d1d);}else{_0x134d24(new RangeError(_0x0798('0x27')+_0x406030+_0x0798('0x28')));}});});}exports[_0x0798('0x29')]=function(_0x1ebd07,_0xa1376e){logger[_0x0798('0x2a')](_0x0798('0x2b'),_0x1ebd07[_0x0798('0x2c')]);var _0x54a955=originateValidation[_0x0798('0x2d')](_0x1ebd07['body']);if(_0x54a955[_0x0798('0x26')]>0x0){return _0xa1376e['status'](0x190)['json'](_0x54a955);}var _0x104d23=_0x1ebd07[_0x0798('0x2c')]['userId'];var _0x49d5b8=_0x1ebd07[_0x0798('0x2c')][_0x0798('0x2e')];var _0x322adf=_0x1ebd07[_0x0798('0x2c')][_0x0798('0x2f')];var _0x2ad922=_0x1ebd07['body']['callbackUrl'];return getAgent(_0x104d23)[_0x0798('0x1c')](function(_0x23a70b){logger[_0x0798('0x2a')]('entityFound:',_0x23a70b['name']);emit(util['format'](_0x0798('0x30'),_0x23a70b[_0x0798('0x17')]),_0x0798('0x31'),{'callNumber':_0x49d5b8,'callerId':_0x322adf,'callbackUrl':_0x2ad922});return _0xa1376e[_0x0798('0x19')](0xc8)[_0x0798('0x32')]({'error':![],'message':_0x0798('0x33')});})[_0x0798('0x34')](handleError(_0xa1376e));};exports[_0x0798('0x35')]=function(_0x502556,_0x16dae6){logger['info'](_0x0798('0x36'),_0x502556[_0x0798('0x2c')]);var _0x2caa82=hangupValidation['validate'](_0x502556[_0x0798('0x2c')]);if(_0x2caa82['length']>0x0){return _0x16dae6[_0x0798('0x19')](0x190)[_0x0798('0x32')](_0x2caa82);}var _0x223751=_0x502556['body'][_0x0798('0x37')];var _0xb5937b=_0x502556['body'][_0x0798('0x25')];return getAgent(_0x223751)['then'](function(_0x4e9d94){logger[_0x0798('0x2a')](_0x0798('0x38'),_0x4e9d94['name']);emit(util['format'](_0x0798('0x30'),_0x4e9d94[_0x0798('0x17')]),_0x0798('0x39'),{'sessionId':_0xb5937b});return _0x16dae6[_0x0798('0x19')](0xc8)[_0x0798('0x32')]({'error':![],'message':_0x0798('0x3a')});})[_0x0798('0x34')](handleError(_0x16dae6));};exports['answer']=function(_0x3aa79c,_0x11c5bf){logger[_0x0798('0x2a')](_0x0798('0x3b'),_0x3aa79c[_0x0798('0x2c')]);var _0x26e9cb=answerValidation['validate'](_0x3aa79c[_0x0798('0x2c')]);if(_0x26e9cb[_0x0798('0x26')]>0x0){return _0x11c5bf[_0x0798('0x19')](0x190)[_0x0798('0x32')](_0x26e9cb);}var _0x387450=_0x3aa79c[_0x0798('0x2c')][_0x0798('0x37')];var _0x10a50a=_0x3aa79c[_0x0798('0x2c')][_0x0798('0x25')];return getAgent(_0x387450)[_0x0798('0x1c')](function(_0x31a3cb){logger['info'](_0x0798('0x38'),_0x31a3cb[_0x0798('0x17')]);emit(util[_0x0798('0x3c')](_0x0798('0x30'),_0x31a3cb['name']),'webbar:answer',{'sessionId':_0x10a50a});return _0x11c5bf[_0x0798('0x19')](0xc8)[_0x0798('0x32')]({'error':![],'message':_0x0798('0x3d')});})[_0x0798('0x34')](handleError(_0x11c5bf));};exports['hold']=function(_0x21c28c,_0x4858e6){logger['info'](_0x0798('0x3e'),_0x21c28c[_0x0798('0x2c')]);var _0x42c5b8=holdValidation[_0x0798('0x2d')](_0x21c28c[_0x0798('0x2c')]);if(_0x42c5b8[_0x0798('0x26')]>0x0){return _0x4858e6[_0x0798('0x19')](0x190)[_0x0798('0x32')](_0x42c5b8);}var _0x182e3b=_0x21c28c['body'][_0x0798('0x37')];var _0x56d438=_0x21c28c[_0x0798('0x2c')][_0x0798('0x25')];return getAgent(_0x182e3b)[_0x0798('0x1c')](function(_0x54634d){logger[_0x0798('0x2a')](_0x0798('0x38'),_0x54634d[_0x0798('0x17')]);emit(util[_0x0798('0x3c')]('user:%s',_0x54634d[_0x0798('0x17')]),_0x0798('0x3f'),{'sessionId':_0x56d438});return _0x4858e6[_0x0798('0x19')](0xc8)[_0x0798('0x32')]({'error':![],'message':_0x0798('0x40')});})['catch'](handleError(_0x4858e6));};exports[_0x0798('0x41')]=function(_0x3e1c15,_0x2679b1){logger[_0x0798('0x2a')](_0x0798('0x42'),_0x3e1c15[_0x0798('0x2c')]);var _0x181757=unholdValidation[_0x0798('0x2d')](_0x3e1c15[_0x0798('0x2c')]);if(_0x181757['length']>0x0){return _0x2679b1['status'](0x190)[_0x0798('0x32')](_0x181757);}var _0x499073=_0x3e1c15[_0x0798('0x2c')][_0x0798('0x37')];var _0x40b3d6=_0x3e1c15[_0x0798('0x2c')][_0x0798('0x25')];return getAgent(_0x499073)['then'](function(_0x3cb0b4){logger['info'](_0x0798('0x38'),_0x3cb0b4[_0x0798('0x17')]);emit(util[_0x0798('0x3c')]('user:%s',_0x3cb0b4['name']),'webbar:unhold',{'sessionId':_0x40b3d6});return _0x2679b1[_0x0798('0x19')](0xc8)['json']({'error':![],'message':'unhold\x20executed!'});})[_0x0798('0x34')](handleError(_0x2679b1));};exports[_0x0798('0x43')]=function(_0x455d19,_0x499580){logger[_0x0798('0x2a')](_0x0798('0x44'),_0x499580[_0x0798('0x2c')]);var _0x743d26=callsValidation['validate'](_0x455d19['body']);if(_0x743d26[_0x0798('0x26')]>0x0){return _0x499580[_0x0798('0x19')](0x190)[_0x0798('0x32')](_0x743d26);}var _0x59ad6c=_0x455d19['body'][_0x0798('0x37')];var _0x82599=respondWithRpcPromise(_0x0798('0x22'));var _0x190467=getAgent(_0x59ad6c);return Promise[_0x0798('0x23')]([_0x82599,_0x190467])[_0x0798('0x1c')](function(_0x18c0fa){var _0x1a55c0=_0x18c0fa[0x0];var _0x4f35c7=_0x18c0fa[0x1];var _0x349f86=_[_0x0798('0x24')](_0x1a55c0['rows'],function(_0x3ab2cc){return _0x3ab2cc[_0x0798('0x45')]==_0x4f35c7['id'];});return _0x499580['status'](0xc8)[_0x0798('0x32')]({'count':_0x349f86[_0x0798('0x26')],'rows':_0x349f86});})[_0x0798('0x34')](handleError(_0x499580));};exports[_0x0798('0x46')]=function(_0x458a4e,_0x541669){logger[_0x0798('0x2a')](_0x0798('0x47'),_0x458a4e[_0x0798('0x2c')]);var _0x47cfc0=conferenceValidation[_0x0798('0x2d')](_0x458a4e['body']);if(_0x47cfc0[_0x0798('0x26')]>0x0){return _0x541669[_0x0798('0x19')](0x190)[_0x0798('0x32')](_0x47cfc0);}var _0x26b393=_0x458a4e[_0x0798('0x2c')][_0x0798('0x37')];return getAgent(_0x26b393)['then'](function(_0x3cc8bd){logger[_0x0798('0x2a')](_0x0798('0x38'),_0x3cc8bd[_0x0798('0x17')]);emit(util['format'](_0x0798('0x30'),_0x3cc8bd[_0x0798('0x17')]),_0x0798('0x48'));return _0x541669[_0x0798('0x19')](0xc8)[_0x0798('0x32')]({'error':![],'message':'conference\x20executed!'});})[_0x0798('0x34')](handleError(_0x541669));};exports[_0x0798('0x49')]=function(_0x5668b7,_0x48d1d1){logger[_0x0798('0x2a')](_0x0798('0x4a'),_0x5668b7['body']);var _0x2f336a=transferValidation[_0x0798('0x2d')](_0x5668b7[_0x0798('0x2c')]);if(_0x2f336a[_0x0798('0x26')]>0x0){return _0x48d1d1[_0x0798('0x19')](0x190)[_0x0798('0x32')](_0x2f336a);}var _0x21c156=_0x5668b7[_0x0798('0x2c')]['userId'];var _0x316762=_0x5668b7[_0x0798('0x2c')][_0x0798('0x25')];var _0xf5100e=_0x5668b7['body'][_0x0798('0x4b')];return getAgent(_0x21c156)[_0x0798('0x1c')](function(_0x11946d){logger[_0x0798('0x2a')](_0x0798('0x38'),_0x11946d[_0x0798('0x17')]);emit(util[_0x0798('0x3c')](_0x0798('0x30'),_0x11946d['name']),_0x0798('0x4c'),{'sessionId':_0x316762,'transferNumber':_0xf5100e});return _0x48d1d1['status'](0xc8)[_0x0798('0x32')]({'error':![],'message':_0x0798('0x4d')});})[_0x0798('0x34')](handleError(_0x48d1d1));};
\ No newline at end of file
+var _0x0a12=['send','code','result','agent','then','VoiceChannels','all','filter','rows','UserId','sessionId','length','sessionId\x20','\x20not\x20found!','originate','body','validate','json','callerId','callbackUrl','info','entityFound:','webbar:originate','originate\x20executed!','catch','hangup','hangup\x20fired:','userId','user:%s','hangup\x20executed!','answer','answer\x20fired:','format','webbar:answer','hold','hold\x20fired:','webbar:hold','hold\x20executed!','unhold','webbar:unhold','unhold\x20executed!','calls','calls\x20fired:','conference','conference\x20fired:','conference\x20executed!','transferNumber','webbar:transfer','lodash','bluebird','client','http','../../config/logger','webbarapi','ioredis','redis','defaults','socket.io-emitter','number','userId\x20is\x20required','string','callNumber\x20is\x20required','sessionId\x20is\x20required','transferNumber\x20is\x20required','error','stack','name','status'];(function(_0x1f31aa,_0x50b37d){var _0x333f10=function(_0x39f43a){while(--_0x39f43a){_0x1f31aa['push'](_0x1f31aa['shift']());}};_0x333f10(++_0x50b37d);}(_0x0a12,0xb8));var _0x20a1=function(_0xe66cf2,_0x32ba5f){_0xe66cf2=_0xe66cf2-0x0;var _0x2d84e7=_0x0a12[_0xe66cf2];return _0x2d84e7;};'use strict';var path=require('path');var fs=require('fs');var _=require(_0x20a1('0x0'));var db=require('../../mysqldb')['db'];var config=require('../../config/environment');var util=require('util');var BPromise=require(_0x20a1('0x1'));var jayson=require('jayson/promise');var amiClient=jayson[_0x20a1('0x2')][_0x20a1('0x3')]({'port':0x232a});var logger=require(_0x20a1('0x4'))(_0x20a1('0x5'));var Redis=require(_0x20a1('0x6'));config[_0x20a1('0x7')]=_[_0x20a1('0x8')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x20a1('0x9'))(new Redis(config['redis']));var Schema=require('validate');var originateValidation=new Schema({'userId':{'type':_0x20a1('0xa'),'required':[!![],_0x20a1('0xb')]},'callNumber':{'type':_0x20a1('0xc'),'required':[!![],_0x20a1('0xd')]},'callerId':{'type':_0x20a1('0xc')},'callbackUrl':{'type':_0x20a1('0xc')}});var hangupValidation=new Schema({'userId':{'type':_0x20a1('0xa'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0x20a1('0xc'),'required':![]}});var answerValidation=new Schema({'userId':{'type':_0x20a1('0xa'),'required':[!![],_0x20a1('0xb')]},'sessionId':{'type':_0x20a1('0xc'),'required':![]}});var transferValidation=new Schema({'userId':{'type':_0x20a1('0xa'),'required':[!![],_0x20a1('0xb')]},'sessionId':{'type':'string','required':[!![],_0x20a1('0xe')]},'transferNumber':{'type':_0x20a1('0xc'),'required':[!![],_0x20a1('0xf')]}});var holdValidation=new Schema({'userId':{'type':_0x20a1('0xa'),'required':[!![],_0x20a1('0xb')]},'sessionId':{'type':_0x20a1('0xc'),'required':![]}});var unholdValidation=new Schema({'userId':{'type':_0x20a1('0xa'),'required':[!![],_0x20a1('0xb')]},'sessionId':{'type':_0x20a1('0xc'),'required':![]}});var callsValidation=new Schema({'userId':{'type':_0x20a1('0xa'),'required':[!![],_0x20a1('0xb')]}});var conferenceValidation=new Schema({'userId':{'type':_0x20a1('0xa'),'required':[!![],_0x20a1('0xb')]}});function emit(_0xec799b,_0x559a97,_0x50d618){logger['info'](_0xec799b,_0x559a97,JSON['stringify'](_0x50d618));io['to'](_0xec799b)['emit'](_0x559a97,_0x50d618);}function handleError(_0x478974){return function(_0x5c00a6){console['log']('handleError:',_0x5c00a6,_0x5c00a6 instanceof RangeError);logger[_0x20a1('0x10')](_0x5c00a6[_0x20a1('0x11')]);if(_0x5c00a6 instanceof RangeError){if(_0x5c00a6[_0x20a1('0x12')]){delete _0x5c00a6[_0x20a1('0x12')];}_0x478974[_0x20a1('0x13')](0x194)[_0x20a1('0x14')](_0x5c00a6);}else{if(_0x5c00a6['name']){delete _0x5c00a6['name'];}_0x478974[_0x20a1('0x13')](0x1f4)[_0x20a1('0x14')](_0x5c00a6);}};}function checkError(){return function(_0x3720c2){if(!_0x3720c2){throw new RangeError('NotFound');}return _0x3720c2;};}function respondWithRpcPromise(_0x5dfb97,_0x1f6669){return new BPromise(function(_0x2969cd,_0x9089cc){var _0x16605d=amiClient;return _0x16605d['request'](_0x5dfb97,_0x1f6669)['then'](function(_0x4e0100){if(_0x4e0100['error']){if(_0x4e0100[_0x20a1('0x10')][_0x20a1('0x15')]===0x1f4){return _0x9089cc(_0x4e0100[_0x20a1('0x10')]['message']);}return _0x2969cd(_0x4e0100[_0x20a1('0x10')]['message']);}else{_0x2969cd(_0x4e0100[_0x20a1('0x16')]);}})['catch'](function(_0x4bed2d){_0x9089cc(_0x4bed2d);});});}function getAgent(_0x47dcab){return db['User']['findOne']({'where':{'id':_0x47dcab,'role':_0x20a1('0x17')}})[_0x20a1('0x18')](checkError());}function getAgentCheckSession(_0x24d1e2,_0xee9dd8){return new BPromise(function(_0x3927b2,_0x26bd09){var _0x5a1352=respondWithRpcPromise(_0x20a1('0x19'));var _0x47877f=getAgent(_0x24d1e2);Promise[_0x20a1('0x1a')]([_0x5a1352,_0x47877f])[_0x20a1('0x18')](function(_0x522a7b){var _0x1c48cf=_0x522a7b[0x0];var _0x5a7c8b=_0x522a7b[0x1];var _0x4148a0=_[_0x20a1('0x1b')](_0x1c48cf[_0x20a1('0x1c')],function(_0x1cdc2c){return _0x1cdc2c[_0x20a1('0x1d')]==_0x5a7c8b['id']&&_0x1cdc2c[_0x20a1('0x1e')]==_0xee9dd8;});if(_0x4148a0[_0x20a1('0x1f')]==0x1){_0x3927b2(_0x5a7c8b);}else{_0x26bd09(new RangeError(_0x20a1('0x20')+_0xee9dd8+_0x20a1('0x21')));}});});}exports[_0x20a1('0x22')]=function(_0x49e141,_0x1e6b14){logger['info']('originate\x20fired:',_0x49e141[_0x20a1('0x23')]);var _0x38503f=originateValidation[_0x20a1('0x24')](_0x49e141[_0x20a1('0x23')]);if(_0x38503f['length']>0x0){return _0x1e6b14[_0x20a1('0x13')](0x190)[_0x20a1('0x25')](_0x38503f);}var _0x308e15=_0x49e141[_0x20a1('0x23')]['userId'];var _0x4296be=_0x49e141['body']['callNumber'];var _0x2a65c4=_0x49e141[_0x20a1('0x23')][_0x20a1('0x26')];var _0x1a425f=_0x49e141['body'][_0x20a1('0x27')];return getAgent(_0x308e15)[_0x20a1('0x18')](function(_0x4989c1){logger[_0x20a1('0x28')](_0x20a1('0x29'),_0x4989c1[_0x20a1('0x12')]);emit(util['format']('user:%s',_0x4989c1[_0x20a1('0x12')]),_0x20a1('0x2a'),{'callNumber':_0x4296be,'callerId':_0x2a65c4,'callbackUrl':_0x1a425f});return _0x1e6b14[_0x20a1('0x13')](0xc8)[_0x20a1('0x25')]({'error':![],'message':_0x20a1('0x2b')});})[_0x20a1('0x2c')](handleError(_0x1e6b14));};exports[_0x20a1('0x2d')]=function(_0x27927a,_0x4a811d){logger[_0x20a1('0x28')](_0x20a1('0x2e'),_0x27927a[_0x20a1('0x23')]);var _0x2cbdc6=hangupValidation[_0x20a1('0x24')](_0x27927a['body']);if(_0x2cbdc6[_0x20a1('0x1f')]>0x0){return _0x4a811d['status'](0x190)[_0x20a1('0x25')](_0x2cbdc6);}var _0x21f8b7=_0x27927a['body'][_0x20a1('0x2f')];var _0x55120d=_0x27927a[_0x20a1('0x23')]['sessionId'];return getAgent(_0x21f8b7)['then'](function(_0xe1b39b){logger[_0x20a1('0x28')](_0x20a1('0x29'),_0xe1b39b[_0x20a1('0x12')]);emit(util['format'](_0x20a1('0x30'),_0xe1b39b[_0x20a1('0x12')]),'webbar:hangup',{'sessionId':_0x55120d});return _0x4a811d[_0x20a1('0x13')](0xc8)[_0x20a1('0x25')]({'error':![],'message':_0x20a1('0x31')});})[_0x20a1('0x2c')](handleError(_0x4a811d));};exports[_0x20a1('0x32')]=function(_0x51f8f2,_0x475c5d){logger[_0x20a1('0x28')](_0x20a1('0x33'),_0x51f8f2['body']);var _0x8fac61=answerValidation[_0x20a1('0x24')](_0x51f8f2['body']);if(_0x8fac61[_0x20a1('0x1f')]>0x0){return _0x475c5d['status'](0x190)['json'](_0x8fac61);}var _0x55133c=_0x51f8f2['body'][_0x20a1('0x2f')];var _0x29968a=_0x51f8f2['body']['sessionId'];return getAgent(_0x55133c)['then'](function(_0x37118d){logger[_0x20a1('0x28')](_0x20a1('0x29'),_0x37118d['name']);emit(util[_0x20a1('0x34')](_0x20a1('0x30'),_0x37118d[_0x20a1('0x12')]),_0x20a1('0x35'),{'sessionId':_0x29968a});return _0x475c5d[_0x20a1('0x13')](0xc8)['json']({'error':![],'message':'answer\x20executed!'});})['catch'](handleError(_0x475c5d));};exports[_0x20a1('0x36')]=function(_0x183507,_0x5c1fe3){logger[_0x20a1('0x28')](_0x20a1('0x37'),_0x183507[_0x20a1('0x23')]);var _0x49a6fe=holdValidation[_0x20a1('0x24')](_0x183507['body']);if(_0x49a6fe[_0x20a1('0x1f')]>0x0){return _0x5c1fe3[_0x20a1('0x13')](0x190)['json'](_0x49a6fe);}var _0x40fcf7=_0x183507[_0x20a1('0x23')]['userId'];var _0xb11b6f=_0x183507[_0x20a1('0x23')]['sessionId'];return getAgent(_0x40fcf7)[_0x20a1('0x18')](function(_0x85cbfd){logger[_0x20a1('0x28')]('entityFound:',_0x85cbfd[_0x20a1('0x12')]);emit(util[_0x20a1('0x34')](_0x20a1('0x30'),_0x85cbfd['name']),_0x20a1('0x38'),{'sessionId':_0xb11b6f});return _0x5c1fe3['status'](0xc8)[_0x20a1('0x25')]({'error':![],'message':_0x20a1('0x39')});})[_0x20a1('0x2c')](handleError(_0x5c1fe3));};exports[_0x20a1('0x3a')]=function(_0x19bb8d,_0x2c2363){logger[_0x20a1('0x28')]('unhold\x20fired:',_0x19bb8d[_0x20a1('0x23')]);var _0x2a4eb3=unholdValidation['validate'](_0x19bb8d[_0x20a1('0x23')]);if(_0x2a4eb3['length']>0x0){return _0x2c2363[_0x20a1('0x13')](0x190)[_0x20a1('0x25')](_0x2a4eb3);}var _0x57f1f9=_0x19bb8d[_0x20a1('0x23')][_0x20a1('0x2f')];var _0x1f988c=_0x19bb8d[_0x20a1('0x23')][_0x20a1('0x1e')];return getAgent(_0x57f1f9)[_0x20a1('0x18')](function(_0x1686d7){logger[_0x20a1('0x28')](_0x20a1('0x29'),_0x1686d7['name']);emit(util[_0x20a1('0x34')](_0x20a1('0x30'),_0x1686d7[_0x20a1('0x12')]),_0x20a1('0x3b'),{'sessionId':_0x1f988c});return _0x2c2363['status'](0xc8)[_0x20a1('0x25')]({'error':![],'message':_0x20a1('0x3c')});})['catch'](handleError(_0x2c2363));};exports[_0x20a1('0x3d')]=function(_0x57126d,_0xfbcadd){logger[_0x20a1('0x28')](_0x20a1('0x3e'),_0xfbcadd[_0x20a1('0x23')]);var _0x12c17c=callsValidation[_0x20a1('0x24')](_0x57126d[_0x20a1('0x23')]);if(_0x12c17c[_0x20a1('0x1f')]>0x0){return _0xfbcadd[_0x20a1('0x13')](0x190)[_0x20a1('0x25')](_0x12c17c);}var _0x283728=_0x57126d['body'][_0x20a1('0x2f')];var _0x4a12ac=respondWithRpcPromise(_0x20a1('0x19'));var _0x5cf3b4=getAgent(_0x283728);return Promise[_0x20a1('0x1a')]([_0x4a12ac,_0x5cf3b4])[_0x20a1('0x18')](function(_0x2a73cc){var _0x45f6da=_0x2a73cc[0x0];var _0x2fb198=_0x2a73cc[0x1];var _0x442410=_[_0x20a1('0x1b')](_0x45f6da['rows'],function(_0x436500){return _0x436500[_0x20a1('0x1d')]==_0x2fb198['id'];});return _0xfbcadd['status'](0xc8)[_0x20a1('0x25')]({'count':_0x442410[_0x20a1('0x1f')],'rows':_0x442410});})[_0x20a1('0x2c')](handleError(_0xfbcadd));};exports[_0x20a1('0x3f')]=function(_0x38efae,_0x6e85d){logger[_0x20a1('0x28')](_0x20a1('0x40'),_0x38efae[_0x20a1('0x23')]);var _0x4eae72=conferenceValidation[_0x20a1('0x24')](_0x38efae['body']);if(_0x4eae72[_0x20a1('0x1f')]>0x0){return _0x6e85d[_0x20a1('0x13')](0x190)[_0x20a1('0x25')](_0x4eae72);}var _0x1c3d8a=_0x38efae['body'][_0x20a1('0x2f')];return getAgent(_0x1c3d8a)[_0x20a1('0x18')](function(_0x3363a8){logger[_0x20a1('0x28')](_0x20a1('0x29'),_0x3363a8[_0x20a1('0x12')]);emit(util[_0x20a1('0x34')](_0x20a1('0x30'),_0x3363a8[_0x20a1('0x12')]),'webbar:conference');return _0x6e85d[_0x20a1('0x13')](0xc8)[_0x20a1('0x25')]({'error':![],'message':_0x20a1('0x41')});})[_0x20a1('0x2c')](handleError(_0x6e85d));};exports['transfer']=function(_0x4d3f32,_0x240044){logger[_0x20a1('0x28')]('transfer\x20fired:',_0x4d3f32[_0x20a1('0x23')]);var _0x1689f9=transferValidation[_0x20a1('0x24')](_0x4d3f32[_0x20a1('0x23')]);if(_0x1689f9[_0x20a1('0x1f')]>0x0){return _0x240044['status'](0x190)['json'](_0x1689f9);}var _0x221b0a=_0x4d3f32[_0x20a1('0x23')][_0x20a1('0x2f')];var _0x4cc007=_0x4d3f32[_0x20a1('0x23')][_0x20a1('0x1e')];var _0x1e8abe=_0x4d3f32[_0x20a1('0x23')][_0x20a1('0x42')];return getAgent(_0x221b0a)['then'](function(_0x1fb621){logger['info']('entityFound:',_0x1fb621[_0x20a1('0x12')]);emit(util[_0x20a1('0x34')]('user:%s',_0x1fb621[_0x20a1('0x12')]),_0x20a1('0x43'),{'sessionId':_0x4cc007,'transferNumber':_0x1e8abe});return _0x240044[_0x20a1('0x13')](0xc8)['json']({'error':![],'message':'transfer\x20executed!'});})[_0x20a1('0x2c')](handleError(_0x240044));};
\ No newline at end of file