Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / webbar / webbar.controller.js
index b7a8ed0..89a817b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf4eb=['originate','body','userId','callNumber','callerId','callbackUrl','entityFound:','webbar:originate','json','originate\x20executed!','hangup','validate','format','user:%s','webbar:hangup','answer','answer\x20fired:','webbar:answer','answer\x20executed!','hold\x20fired:','webbar:hold','hold\x20executed!','unhold\x20fired:','calls','calls\x20fired:','VoiceChannels','conference','conference\x20executed!','transfer','transferNumber','webbar:transfer','transfer\x20executed!','path','bluebird','http','../../config/logger','webbarapi','ioredis','redis','defaults','socket.io-emitter','number','userId\x20is\x20required','string','callNumber\x20is\x20required','transferNumber\x20is\x20required','info','stringify','stack','name','status','send','NotFound','then','error','code','message','result','catch','User','all','filter','rows','UserId','sessionId','length','sessionId\x20','\x20not\x20found!'];(function(_0x3074f3,_0x4f2c03){var _0x53f112=function(_0x4a17af){while(--_0x4a17af){_0x3074f3['push'](_0x3074f3['shift']());}};_0x53f112(++_0x4f2c03);}(_0xf4eb,0xec));var _0xbf4e=function(_0x43a677,_0x5be2ba){_0x43a677=_0x43a677-0x0;var _0x2790d2=_0xf4eb[_0x43a677];return _0x2790d2;};'use strict';var path=require(_0xbf4e('0x0'));var fs=require('fs');var _=require('lodash');var db=require('../../mysqldb')['db'];var config=require('../../config/environment');var util=require('util');var BPromise=require(_0xbf4e('0x1'));var jayson=require('jayson/promise');var amiClient=jayson['client'][_0xbf4e('0x2')]({'port':0x232a});var logger=require(_0xbf4e('0x3'))(_0xbf4e('0x4'));var Redis=require(_0xbf4e('0x5'));config[_0xbf4e('0x6')]=_[_0xbf4e('0x7')](config[_0xbf4e('0x6')],{'host':'localhost','port':0x18eb});var io=require(_0xbf4e('0x8'))(new Redis(config['redis']));var Schema=require('validate');var originateValidation=new Schema({'userId':{'type':_0xbf4e('0x9'),'required':[!![],_0xbf4e('0xa')]},'callNumber':{'type':_0xbf4e('0xb'),'required':[!![],_0xbf4e('0xc')]},'callerId':{'type':_0xbf4e('0xb')},'callbackUrl':{'type':_0xbf4e('0xb')}});var hangupValidation=new Schema({'userId':{'type':_0xbf4e('0x9'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':'string','required':![]}});var answerValidation=new Schema({'userId':{'type':_0xbf4e('0x9'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0xbf4e('0xb'),'required':![]}});var transferValidation=new Schema({'userId':{'type':_0xbf4e('0x9'),'required':[!![],'userId\x20is\x20required']},'sessionId':{'type':_0xbf4e('0xb'),'required':[!![],'sessionId\x20is\x20required']},'transferNumber':{'type':'string','required':[!![],_0xbf4e('0xd')]}});var holdValidation=new Schema({'userId':{'type':_0xbf4e('0x9'),'required':[!![],_0xbf4e('0xa')]},'sessionId':{'type':_0xbf4e('0xb'),'required':![]}});var unholdValidation=new Schema({'userId':{'type':_0xbf4e('0x9'),'required':[!![],_0xbf4e('0xa')]},'sessionId':{'type':'string','required':![]}});var callsValidation=new Schema({'userId':{'type':'number','required':[!![],_0xbf4e('0xa')]}});var conferenceValidation=new Schema({'userId':{'type':_0xbf4e('0x9'),'required':[!![],_0xbf4e('0xa')]}});function emit(_0x542909,_0x14110b,_0x2c292c){logger[_0xbf4e('0xe')](_0x542909,_0x14110b,JSON[_0xbf4e('0xf')](_0x2c292c));io['to'](_0x542909)['emit'](_0x14110b,_0x2c292c);}function handleError(_0x247322){return function(_0x577c27){console['log']('handleError:',_0x577c27,_0x577c27 instanceof RangeError);logger['error'](_0x577c27[_0xbf4e('0x10')]);if(_0x577c27 instanceof RangeError){if(_0x577c27[_0xbf4e('0x11')]){delete _0x577c27[_0xbf4e('0x11')];}_0x247322['status'](0x194)['send'](_0x577c27);}else{if(_0x577c27[_0xbf4e('0x11')]){delete _0x577c27[_0xbf4e('0x11')];}_0x247322[_0xbf4e('0x12')](0x1f4)[_0xbf4e('0x13')](_0x577c27);}};}function checkError(){return function(_0x344727){if(!_0x344727){throw new RangeError(_0xbf4e('0x14'));}return _0x344727;};}function respondWithRpcPromise(_0x415963,_0x3d642a){return new BPromise(function(_0xd09e12,_0x376832){var _0x30539b=amiClient;return _0x30539b['request'](_0x415963,_0x3d642a)[_0xbf4e('0x15')](function(_0x2e7673){if(_0x2e7673['error']){if(_0x2e7673[_0xbf4e('0x16')][_0xbf4e('0x17')]===0x1f4){return _0x376832(_0x2e7673[_0xbf4e('0x16')][_0xbf4e('0x18')]);}return _0xd09e12(_0x2e7673[_0xbf4e('0x16')]['message']);}else{_0xd09e12(_0x2e7673[_0xbf4e('0x19')]);}})[_0xbf4e('0x1a')](function(_0x3d6863){_0x376832(_0x3d6863);});});}function getAgent(_0x5766d4){return db[_0xbf4e('0x1b')]['findOne']({'where':{'id':_0x5766d4,'role':'agent'}})[_0xbf4e('0x15')](checkError());}function getAgentCheckSession(_0x5a0a9b,_0x38c923){return new BPromise(function(_0x315df3,_0x4021a9){var _0x41f918=respondWithRpcPromise('VoiceChannels');var _0x2d4686=getAgent(_0x5a0a9b);Promise[_0xbf4e('0x1c')]([_0x41f918,_0x2d4686])[_0xbf4e('0x15')](function(_0x4cd4a1){var _0x681c3b=_0x4cd4a1[0x0];var _0x590c85=_0x4cd4a1[0x1];var _0x1dfa81=_[_0xbf4e('0x1d')](_0x681c3b[_0xbf4e('0x1e')],function(_0x498dbd){return _0x498dbd[_0xbf4e('0x1f')]==_0x590c85['id']&&_0x498dbd[_0xbf4e('0x20')]==_0x38c923;});if(_0x1dfa81[_0xbf4e('0x21')]==0x1){_0x315df3(_0x590c85);}else{_0x4021a9(new RangeError(_0xbf4e('0x22')+_0x38c923+_0xbf4e('0x23')));}});});}exports[_0xbf4e('0x24')]=function(_0x5a7c71,_0x35c82d){logger[_0xbf4e('0xe')]('originate\x20fired:',_0x5a7c71[_0xbf4e('0x25')]);var _0x26a375=originateValidation['validate'](_0x5a7c71[_0xbf4e('0x25')]);if(_0x26a375['length']>0x0){return _0x35c82d[_0xbf4e('0x12')](0x190)['json'](_0x26a375);}var _0x2f49d8=_0x5a7c71[_0xbf4e('0x25')][_0xbf4e('0x26')];var _0x5b3b28=_0x5a7c71[_0xbf4e('0x25')][_0xbf4e('0x27')];var _0x70c54f=_0x5a7c71[_0xbf4e('0x25')][_0xbf4e('0x28')];var _0x477873=_0x5a7c71['body'][_0xbf4e('0x29')];return getAgent(_0x2f49d8)[_0xbf4e('0x15')](function(_0x25b837){logger[_0xbf4e('0xe')](_0xbf4e('0x2a'),_0x25b837['name']);emit(util['format']('user:%s',_0x25b837['name']),_0xbf4e('0x2b'),{'callNumber':_0x5b3b28,'callerId':_0x70c54f,'callbackUrl':_0x477873});return _0x35c82d[_0xbf4e('0x12')](0xc8)[_0xbf4e('0x2c')]({'error':![],'message':_0xbf4e('0x2d')});})[_0xbf4e('0x1a')](handleError(_0x35c82d));};exports[_0xbf4e('0x2e')]=function(_0x355b42,_0x467b74){logger[_0xbf4e('0xe')]('hangup\x20fired:',_0x355b42['body']);var _0x303fd8=hangupValidation[_0xbf4e('0x2f')](_0x355b42[_0xbf4e('0x25')]);if(_0x303fd8['length']>0x0){return _0x467b74[_0xbf4e('0x12')](0x190)['json'](_0x303fd8);}var _0x370d90=_0x355b42[_0xbf4e('0x25')][_0xbf4e('0x26')];var _0xb30f90=_0x355b42['body'][_0xbf4e('0x20')];return getAgent(_0x370d90)[_0xbf4e('0x15')](function(_0x3aa308){logger[_0xbf4e('0xe')]('entityFound:',_0x3aa308[_0xbf4e('0x11')]);emit(util[_0xbf4e('0x30')](_0xbf4e('0x31'),_0x3aa308[_0xbf4e('0x11')]),_0xbf4e('0x32'),{'sessionId':_0xb30f90});return _0x467b74[_0xbf4e('0x12')](0xc8)[_0xbf4e('0x2c')]({'error':![],'message':'hangup\x20executed!'});})[_0xbf4e('0x1a')](handleError(_0x467b74));};exports[_0xbf4e('0x33')]=function(_0x518400,_0x47d6f2){logger[_0xbf4e('0xe')](_0xbf4e('0x34'),_0x518400['body']);var _0x5bfc4d=answerValidation[_0xbf4e('0x2f')](_0x518400[_0xbf4e('0x25')]);if(_0x5bfc4d[_0xbf4e('0x21')]>0x0){return _0x47d6f2[_0xbf4e('0x12')](0x190)[_0xbf4e('0x2c')](_0x5bfc4d);}var _0x3ad0a4=_0x518400['body'][_0xbf4e('0x26')];var _0x7bd91=_0x518400['body']['sessionId'];return getAgent(_0x3ad0a4)['then'](function(_0x53d7dd){logger[_0xbf4e('0xe')]('entityFound:',_0x53d7dd[_0xbf4e('0x11')]);emit(util[_0xbf4e('0x30')]('user:%s',_0x53d7dd['name']),_0xbf4e('0x35'),{'sessionId':_0x7bd91});return _0x47d6f2[_0xbf4e('0x12')](0xc8)[_0xbf4e('0x2c')]({'error':![],'message':_0xbf4e('0x36')});})[_0xbf4e('0x1a')](handleError(_0x47d6f2));};exports['hold']=function(_0x2b20d3,_0x3e8ade){logger[_0xbf4e('0xe')](_0xbf4e('0x37'),_0x2b20d3[_0xbf4e('0x25')]);var _0x1bc421=holdValidation[_0xbf4e('0x2f')](_0x2b20d3[_0xbf4e('0x25')]);if(_0x1bc421['length']>0x0){return _0x3e8ade[_0xbf4e('0x12')](0x190)[_0xbf4e('0x2c')](_0x1bc421);}var _0x1833c1=_0x2b20d3[_0xbf4e('0x25')][_0xbf4e('0x26')];var _0x1198e8=_0x2b20d3[_0xbf4e('0x25')][_0xbf4e('0x20')];return getAgent(_0x1833c1)[_0xbf4e('0x15')](function(_0x3447ab){logger[_0xbf4e('0xe')](_0xbf4e('0x2a'),_0x3447ab[_0xbf4e('0x11')]);emit(util[_0xbf4e('0x30')](_0xbf4e('0x31'),_0x3447ab[_0xbf4e('0x11')]),_0xbf4e('0x38'),{'sessionId':_0x1198e8});return _0x3e8ade['status'](0xc8)[_0xbf4e('0x2c')]({'error':![],'message':_0xbf4e('0x39')});})[_0xbf4e('0x1a')](handleError(_0x3e8ade));};exports['unhold']=function(_0x33ab9a,_0x5ed838){logger['info'](_0xbf4e('0x3a'),_0x33ab9a[_0xbf4e('0x25')]);var _0x4d32b3=unholdValidation[_0xbf4e('0x2f')](_0x33ab9a[_0xbf4e('0x25')]);if(_0x4d32b3[_0xbf4e('0x21')]>0x0){return _0x5ed838[_0xbf4e('0x12')](0x190)[_0xbf4e('0x2c')](_0x4d32b3);}var _0x2ac2c8=_0x33ab9a[_0xbf4e('0x25')][_0xbf4e('0x26')];var _0x3cd61b=_0x33ab9a[_0xbf4e('0x25')][_0xbf4e('0x20')];return getAgent(_0x2ac2c8)['then'](function(_0x5d6324){logger[_0xbf4e('0xe')](_0xbf4e('0x2a'),_0x5d6324[_0xbf4e('0x11')]);emit(util['format'](_0xbf4e('0x31'),_0x5d6324[_0xbf4e('0x11')]),'webbar:unhold',{'sessionId':_0x3cd61b});return _0x5ed838['status'](0xc8)[_0xbf4e('0x2c')]({'error':![],'message':'unhold\x20executed!'});})['catch'](handleError(_0x5ed838));};exports[_0xbf4e('0x3b')]=function(_0x3dd51a,_0x73ca86){logger[_0xbf4e('0xe')](_0xbf4e('0x3c'),_0x73ca86['body']);var _0x242a75=callsValidation['validate'](_0x3dd51a[_0xbf4e('0x25')]);if(_0x242a75['length']>0x0){return _0x73ca86[_0xbf4e('0x12')](0x190)['json'](_0x242a75);}var _0xab6991=_0x3dd51a[_0xbf4e('0x25')][_0xbf4e('0x26')];var _0x16592f=respondWithRpcPromise(_0xbf4e('0x3d'));var _0x52dfc4=getAgent(_0xab6991);return Promise['all']([_0x16592f,_0x52dfc4])['then'](function(_0x52ea6e){var _0x419a69=_0x52ea6e[0x0];var _0x453411=_0x52ea6e[0x1];var _0x5cfc26=_[_0xbf4e('0x1d')](_0x419a69[_0xbf4e('0x1e')],function(_0x458fea){return _0x458fea[_0xbf4e('0x1f')]==_0x453411['id'];});return _0x73ca86[_0xbf4e('0x12')](0xc8)[_0xbf4e('0x2c')]({'count':_0x5cfc26[_0xbf4e('0x21')],'rows':_0x5cfc26});})['catch'](handleError(_0x73ca86));};exports[_0xbf4e('0x3e')]=function(_0x137df1,_0x42e117){logger['info']('conference\x20fired:',_0x137df1[_0xbf4e('0x25')]);var _0x301d66=conferenceValidation[_0xbf4e('0x2f')](_0x137df1['body']);if(_0x301d66[_0xbf4e('0x21')]>0x0){return _0x42e117[_0xbf4e('0x12')](0x190)[_0xbf4e('0x2c')](_0x301d66);}var _0x4039a4=_0x137df1[_0xbf4e('0x25')][_0xbf4e('0x26')];return getAgent(_0x4039a4)[_0xbf4e('0x15')](function(_0x3ee848){logger[_0xbf4e('0xe')](_0xbf4e('0x2a'),_0x3ee848[_0xbf4e('0x11')]);emit(util[_0xbf4e('0x30')]('user:%s',_0x3ee848[_0xbf4e('0x11')]),'webbar:conference');return _0x42e117[_0xbf4e('0x12')](0xc8)[_0xbf4e('0x2c')]({'error':![],'message':_0xbf4e('0x3f')});})[_0xbf4e('0x1a')](handleError(_0x42e117));};exports[_0xbf4e('0x40')]=function(_0x2846ef,_0x13b0a6){logger[_0xbf4e('0xe')]('transfer\x20fired:',_0x2846ef[_0xbf4e('0x25')]);var _0x325d09=transferValidation[_0xbf4e('0x2f')](_0x2846ef[_0xbf4e('0x25')]);if(_0x325d09[_0xbf4e('0x21')]>0x0){return _0x13b0a6['status'](0x190)[_0xbf4e('0x2c')](_0x325d09);}var _0x753f25=_0x2846ef[_0xbf4e('0x25')][_0xbf4e('0x26')];var _0x12f19f=_0x2846ef[_0xbf4e('0x25')]['sessionId'];var _0x2246a2=_0x2846ef['body'][_0xbf4e('0x41')];return getAgent(_0x753f25)[_0xbf4e('0x15')](function(_0x9335f7){logger[_0xbf4e('0xe')]('entityFound:',_0x9335f7[_0xbf4e('0x11')]);emit(util['format']('user:%s',_0x9335f7[_0xbf4e('0x11')]),_0xbf4e('0x42'),{'sessionId':_0x12f19f,'transferNumber':_0x2246a2});return _0x13b0a6[_0xbf4e('0x12')](0xc8)['json']({'error':![],'message':_0xbf4e('0x43')});})[_0xbf4e('0x1a')](handleError(_0x13b0a6));};
\ 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