2ce04741118346a2a3e954a2e18f3d957371215b
[motion-next.git] / server / services / ami / server / index.js
1 const a1132_0x4325=['toLowerCase','push','dialOriginateCallerIdNumber','listen','../../../config/environment','predictiveIntervalAvgHoldtime','predictiveIntervalAnsweredCalls','username','isNil','voicequeuechannelhangup','join','keys','erlangCalls','predictiveIntervalTotalCalls','isConnected','loggedInDb','faxAccounts','sumHoldTime','SIP','total','event','Trunk','moment','lodash','asterisk','emit','rec','outboundAnswerAgiCallsDay','startProgressive','outboundDropCallsDayTimeout','startPredictive','custom:','channel','YYYY-MM-DD\x20HH:mm:ss','content','uniqueid','map','status','predictiveIntervalAvailable','filename','callerid','../ami','dialOriginateTimeout','error','channels','length','active','outboundDropCallsDayACS','stop','abandoned','outboundNoAnswerCallsDay','mixmonitorid','outboundOriginateFailureCallsDay','predictiveIntervalDroppedCallsCallersExit','strategy','../properties','resolve','outboundDropCallsDayCallersExit','command','Reload','campaigns','dialMethod','erlangCallToSecond','message','RPC\x20listening\x20on\x20port:','outboundAnswerCallsDay','predictiveIntervalPauses','checkAfterSend','predictiveIntervalHitRate','name','find','values','send','agents','wav','monitors','format','run','voiceQueues','destinationchannel','context','originated','Interval','outboundUnknownCallsDay','dialActive','outboundChannels','dialPrefix','predictiveIntervalErlangCalls','answered','updateStatusRealtime','catch','talking','Hangup','MixMonitor\x20Success','type','pick','dialOriginateCallerIdName','Event\x20name\x20mandatory','Action','voicechannel','waiting','exten','log','%s.%s','erlangBusyFactor','outboundRejectCallsDay','outboundBusyCallsDay','outboundBlacklistCallsDay','action','updateAcw','outboundReCallsDay','erlangAbandonmentRate','outboundNoSuchCallsDay','timers','predictiveIntervalDroppedCallsTimeout','/var/spool/asterisk/monitor/','undefined','unmanaged','pause','StopMixMonitor','Channel\x20doesn\x27t\x20exist','pTalking','validate','util','then','predictiveIntervalErlangCallsDroppedCalls','QueuePause','predictiveIntervalAvgTalktime','available','queueChannels','ai(mixmonitorid)','MixMonitor','ami\x20disconnected'];(function(_0x2447c1,_0x432503){const _0x2ff544=function(_0x39c4a1){while(--_0x39c4a1){_0x2447c1['push'](_0x2447c1['shift']());}};_0x2ff544(++_0x432503);}(a1132_0x4325,0x1bf));const a1132_0x2ff5=function(_0x2447c1,_0x432503){_0x2447c1=_0x2447c1-0x0;let _0x2ff544=a1132_0x4325[_0x2447c1];return _0x2ff544;};const _0x5d81c6=a1132_0x2ff5;'use strict';const _=require(_0x5d81c6('0x6c')),util=require(_0x5d81c6('0x4b')),jayson=require('jayson/promise'),schema=require(_0x5d81c6('0x4a')),moment=require(_0x5d81c6('0x6b')),config=require(_0x5d81c6('0x59')),properties=require(_0x5d81c6('0x7')),ami=require(_0x5d81c6('0x7e'));exports[_0x5d81c6('0x58')]=function(_0x39c4a1,_0x5ee9a9,_0x666d41){return new Promise(function(_0x3d5bbe,_0x320a1e){const _0x5dcaae=a1132_0x2ff5,_0xf15e4e={'QueuePause':function(_0x146d33){return new Promise(function(_0x2af478){const _0x4af3f8=a1132_0x2ff5,_0x3ccd57=util[_0x4af3f8('0x1c')]('%s/%s',_0x4af3f8('0x67'),_0x146d33['name']);_0x39c4a1[_0x4af3f8('0x41')]&&_0x39c4a1[_0x4af3f8('0x41')][_0x3ccd57]&&_0x39c4a1[_0x4af3f8('0x41')][_0x3ccd57]['timer']&&_0x39c4a1['timers'][_0x3ccd57][_0x4af3f8('0x3d')](),_0x39c4a1[_0x4af3f8('0x19')][_0x3ccd57]&&_0x39c4a1[_0x4af3f8('0x19')][_0x3ccd57][_0x4af3f8('0x29')]({'statePause':_0x146d33[_0x4af3f8('0x46')]?!![]:![]}),_0x2af478({'code':0xc8,'message':_0x4af3f8('0x4e')});});},'Reload':function(_0x49df0f){const _0x8a2809=this;return new Promise(function(_0x570dad,_0x16b761){const _0x552ea2=a1132_0x2ff5;if(ami[_0x552ea2('0x63')]()==![])return _0x16b761(_0x8a2809[_0x552ea2('0x80')](0x1f4,[config[_0x552ea2('0x6d')]['ip'],config['asterisk'][_0x552ea2('0x5c')],_0x552ea2('0x54')][_0x552ea2('0x5f')]('\x20')));return _0x49df0f=_[_0x552ea2('0x2f')](_0x49df0f,_[_0x552ea2('0x60')](properties['module'])),_0x49df0f[_0x552ea2('0x3c')]=_0x552ea2('0xb'),ami[_0x552ea2('0x32')](_0x49df0f)[_0x552ea2('0x4c')](function(_0x58cdd2){const _0x5a16bf=_0x552ea2;_0x570dad({'code':0xc8,'message':_0x58cdd2[_0x5a16bf('0xf')]});})[_0x552ea2('0x2a')](function(_0x4a59d1){const _0x499a06=_0x552ea2;_0x16b761(_0x8a2809[_0x499a06('0x80')](0x1f5,_0x4a59d1['message']));});});},'Command':function(_0x53798f){const _0x1d56ae=this;return new Promise(function(_0x50e6f0,_0x2e149e){const _0x49119c=a1132_0x2ff5;if(ami[_0x49119c('0x63')]()==![])return _0x2e149e(_0x1d56ae[_0x49119c('0x80')](0x1f4,[config[_0x49119c('0x6d')]['ip'],config[_0x49119c('0x6d')][_0x49119c('0x5c')],_0x49119c('0x54')][_0x49119c('0x5f')]('\x20')));return _0x53798f=_[_0x49119c('0x2f')](_0x53798f,_0x49119c('0xa')),_0x53798f['action']='Command',ami[_0x49119c('0x32')](_0x53798f)[_0x49119c('0x4c')](function(_0x1e8602){const _0x5a28a2=_0x49119c;_0x50e6f0({'code':0xc8,'message':_0x1e8602[_0x5a28a2('0x77')]});})[_0x49119c('0x2a')](function(_0x109216){const _0x438c56=_0x49119c;_0x2e149e(_0x1d56ae['error'](0x1f5,_0x109216[_0x438c56('0xf')]));});});},'VoiceQueues':function(){return new Promise(function(_0x133304){const _0xdbfa24=a1132_0x2ff5,_0x2a22ed=[];for(const _0x264e84 in _0x39c4a1[_0xdbfa24('0x1e')]){if(typeof _0x39c4a1['voiceQueues'][_0x264e84]!==_0xdbfa24('0x44')){const _0x5b8fab=_0x39c4a1[_0xdbfa24('0x1e')][_0x264e84],_0x52951d={'id':_0x5b8fab['id'],'name':_0x5b8fab[_0xdbfa24('0x15')],'strategy':_0x5b8fab[_0xdbfa24('0x6')],'answered':_0x5b8fab[_0xdbfa24('0x28')],'available':_0x5b8fab[_0xdbfa24('0x50')],'loggedIn':_0x5b8fab['loggedIn'],'pTalking':_0x5b8fab[_0xdbfa24('0x49')],'sumBillable':_0x5b8fab['sumBillable'],'sumDuration':_0x5b8fab['sumDuration'],'sumHoldTime':_0x5b8fab[_0xdbfa24('0x66')]||0x0,'talking':_0x5b8fab[_0xdbfa24('0x2b')],'total':_0x5b8fab[_0xdbfa24('0x68')],'type':_0x5b8fab[_0xdbfa24('0x2e')],'unmanaged':_0x5b8fab[_0xdbfa24('0x45')],'abandoned':_0x5b8fab[_0xdbfa24('0x1')],'waiting':_0x5b8fab[_0xdbfa24('0x34')],'loggedInDb':_0x5b8fab[_0xdbfa24('0x64')]};_0x5b8fab[_0xdbfa24('0x2e')]==='outbound'&&(_0x52951d[_0xdbfa24('0x24')]=_0x5b8fab[_0xdbfa24('0x24')],_0x52951d[_0xdbfa24('0xd')]=_0x5b8fab[_0xdbfa24('0xd')],_0x52951d[_0xdbfa24('0x30')]=_0x5b8fab[_0xdbfa24('0x30')],_0x52951d['dialOriginateCallerIdNumber']=_0x5b8fab[_0xdbfa24('0x57')],_0x52951d[_0xdbfa24('0x7f')]=_0x5b8fab[_0xdbfa24('0x7f')],_0x52951d[_0xdbfa24('0x26')]=_0x5b8fab[_0xdbfa24('0x26')],_0x52951d['outboundAnswerAgiCallsDay']=_0x5b8fab[_0xdbfa24('0x70')],_0x52951d[_0xdbfa24('0x11')]=_0x5b8fab[_0xdbfa24('0x11')],_0x52951d[_0xdbfa24('0x3b')]=_0x5b8fab[_0xdbfa24('0x3b')],_0x52951d[_0xdbfa24('0x3a')]=_0x5b8fab[_0xdbfa24('0x3a')],_0x52951d['outboundCongestionCallsDay']=_0x5b8fab['outboundCongestionCallsDay'],_0x52951d['outboundDropCallsDayACS']=_0x5b8fab[_0xdbfa24('0x84')],_0x52951d[_0xdbfa24('0x9')]=_0x5b8fab[_0xdbfa24('0x9')],_0x52951d['outboundDropCallsDayTimeout']=_0x5b8fab[_0xdbfa24('0x72')],_0x52951d[_0xdbfa24('0x2')]=_0x5b8fab[_0xdbfa24('0x2')],_0x52951d[_0xdbfa24('0x40')]=_0x5b8fab['outboundNoSuchCallsDay'],_0x52951d[_0xdbfa24('0x4')]=_0x5b8fab['outboundOriginateFailureCallsDay'],_0x52951d['outboundReCallsDay']=_0x5b8fab[_0xdbfa24('0x3e')],_0x52951d['outboundRejectCallsDay']=_0x5b8fab[_0xdbfa24('0x39')],_0x52951d[_0xdbfa24('0x23')]=_0x5b8fab[_0xdbfa24('0x23')],_0x52951d['predictiveIntervalAnsweredCalls']=_0x5b8fab[_0xdbfa24('0x5b')],_0x52951d[_0xdbfa24('0x5a')]=_0x5b8fab[_0xdbfa24('0x5a')],_0x52951d[_0xdbfa24('0x4f')]=_0x5b8fab['predictiveIntervalAvgTalktime'],_0x52951d['predictiveIntervalDroppedCallsCallersExit']=_0x5b8fab[_0xdbfa24('0x5')],_0x52951d[_0xdbfa24('0x42')]=_0x5b8fab['predictiveIntervalDroppedCallsTimeout'],_0x52951d[_0xdbfa24('0x27')]=_0x5b8fab[_0xdbfa24('0x27')],_0x52951d[_0xdbfa24('0x4d')]=_0x5b8fab['predictiveIntervalErlangCallsDroppedCalls'],_0x52951d[_0xdbfa24('0x14')]=_0x5b8fab[_0xdbfa24('0x14')],_0x52951d['predictiveIntervalMultiplicativeFactor']=_0x5b8fab['predictiveIntervalMultiplicativeFactor'],_0x52951d[_0xdbfa24('0x12')]=_0x5b8fab[_0xdbfa24('0x12')],_0x52951d[_0xdbfa24('0x7b')]=_0x5b8fab[_0xdbfa24('0x7b')],_0x52951d['predictiveIntervalTotalCalls']=_0x5b8fab[_0xdbfa24('0x62')],_0x52951d[_0xdbfa24('0xf')]=_0x5b8fab[_0xdbfa24('0xf')],_0x52951d['originated']=_0x5b8fab[_0xdbfa24('0x21')],_0x52951d[_0xdbfa24('0x61')]=_0x5b8fab[_0xdbfa24('0x61')],_0x52951d[_0xdbfa24('0xe')]=_0x5b8fab['erlangCallToSecond'],_0x52951d[_0xdbfa24('0x3f')]=_0x5b8fab[_0xdbfa24('0x3f')],_0x52951d[_0xdbfa24('0x38')]=_0x5b8fab[_0xdbfa24('0x38')],_0x52951d[_0xdbfa24('0x73')]=_0x5b8fab['startPredictive'],_0x52951d[_0xdbfa24('0x71')]=_0x5b8fab[_0xdbfa24('0x71')]),_0x5b8fab[_0xdbfa24('0x6a')]&&(_0x52951d[_0xdbfa24('0x6a')]={'id':_0x5b8fab[_0xdbfa24('0x6a')]['id'],'name':_0x5b8fab[_0xdbfa24('0x6a')][_0xdbfa24('0x15')],'active':_0x5b8fab[_0xdbfa24('0x6a')][_0xdbfa24('0x83')],'callerid':_0x5b8fab[_0xdbfa24('0x6a')][_0xdbfa24('0x7d')]}),_0x5b8fab[_0xdbfa24('0x22')]&&(_0x52951d['Interval']={'id':_0x5b8fab[_0xdbfa24('0x22')]['id'],'name':_0x5b8fab[_0xdbfa24('0x22')]['name']}),_0x2a22ed['push'](_0x52951d);}}_0x133304({'count':_0x2a22ed[_0xdbfa24('0x82')],'rows':_0x2a22ed});});},'VoiceChannels':function(){return new Promise(function(_0x5a060e){const _0x50d060=a1132_0x2ff5,_0x5f35b8=_[_0x50d060('0x17')](_0x39c4a1['channels']);_0x5a060e({'count':_0x5f35b8[_0x50d060('0x82')],'rows':_0x5f35b8});});},'VoiceChannelMixMonitor':function(_0x151865){const _0x2d6bf7=this;return new Promise(function(_0x88750,_0x252385){const _0x5a7ff1=a1132_0x2ff5;if(ami[_0x5a7ff1('0x63')]()==![])return _0x252385(_0x2d6bf7[_0x5a7ff1('0x80')](0x1f4,[config[_0x5a7ff1('0x6d')]['ip'],config[_0x5a7ff1('0x6d')][_0x5a7ff1('0x5c')],_0x5a7ff1('0x54')]['join']('\x20')));const _0x5071f9=schema(properties[_0x5a7ff1('0x33')])['validate'](_0x151865);if(_0x5071f9[_0x5a7ff1('0x82')]>0x0)return _0x252385(_0x2d6bf7[_0x5a7ff1('0x80')](0x1f4,_['map'](_0x5071f9,_0x5a7ff1('0xf'))[_0x5a7ff1('0x5f')](',\x20')));const _0x2f4648=_[_0x5a7ff1('0x16')](_0x39c4a1['channels'],{'uniqueid':_0x151865[_0x5a7ff1('0x78')]});if(_0x2f4648&&_0x2f4648[_0x5a7ff1('0x75')]){const _0x46300c=util[_0x5a7ff1('0x1c')](_0x5a7ff1('0x37'),_0x151865[_0x5a7ff1('0x7c')]||_0x151865[_0x5a7ff1('0x78')],_0x151865[_0x5a7ff1('0x1c')]||_0x5a7ff1('0x1a'));return ami[_0x5a7ff1('0x32')]({'action':_0x5a7ff1('0x53'),'channel':_0x2f4648[_0x5a7ff1('0x75')],'file':_0x46300c,'options':_0x5a7ff1('0x52')})[_0x5a7ff1('0x4c')](function(_0x1b1e21){const _0x570208=_0x5a7ff1,_0x220910=_[_0x570208('0x16')](_0x2f4648[_0x570208('0x1b')],{'filename':_0x570208('0x43')+_0x46300c[_0x570208('0x55')]()});_[_0x570208('0x5d')](_0x220910)?_0x2f4648[_0x570208('0x1b')][_0x570208('0x56')]({'filename':'/var/spool/asterisk/monitor/'+_0x46300c[_0x570208('0x55')](),'createdAt':moment()[_0x570208('0x1c')](_0x570208('0x76')),'mixmonitorid':_0x1b1e21['mixmonitorid'],'status':_0x570208('0x6f')}):(_0x220910[_0x570208('0x3')]=_0x1b1e21['mixmonitorid'],_0x220910[_0x570208('0x7a')]='rec'),_0x88750({'code':0xc8,'message':[_0x151865[_0x570208('0x78')],_0x570208('0x2d'),_0x1b1e21[_0x570208('0x3')]]['join']('\x20'),'mixmonitorid':_0x1b1e21[_0x570208('0x3')]});})[_0x5a7ff1('0x2a')](function(_0x190ded){const _0x235ada=_0x5a7ff1;_0x252385(_0x2d6bf7[_0x235ada('0x80')](0x1f5,[_0x151865['uniqueid'],_0x190ded[_0x235ada('0xf')]['toLowerCase']()]['join']('\x20')));});}else return _0x252385(_0x2d6bf7[_0x5a7ff1('0x80')](0x1f5,_0x5a7ff1('0x48')));});},'VoiceChannelStopMixMonitor':function(_0x129588){const _0x7055c7=this;return new Promise(function(_0x506c09,_0x160e27){const _0x48d347=a1132_0x2ff5;if(ami[_0x48d347('0x63')]()==![])return _0x160e27(_0x7055c7[_0x48d347('0x80')](0x1f4,[config['asterisk']['ip'],config[_0x48d347('0x6d')][_0x48d347('0x5c')],_0x48d347('0x54')]['join']('\x20')));const _0x407b38=schema(properties['voicechannel'])[_0x48d347('0x4a')](_0x129588);if(_0x407b38[_0x48d347('0x82')]>0x0)return _0x160e27(_0x7055c7[_0x48d347('0x80')](0x1f4,_[_0x48d347('0x79')](_0x407b38,_0x48d347('0xf'))[_0x48d347('0x5f')](',\x20')));const _0x13ed14=_['find'](_0x39c4a1[_0x48d347('0x81')],{'uniqueid':_0x129588[_0x48d347('0x78')]});return _0x13ed14?Promise[_0x48d347('0x8')]()[_0x48d347('0x4c')](function(){const _0x4d0449=_0x48d347;if(_0x13ed14[_0x4d0449('0x75')])return ami[_0x4d0449('0x32')]({'action':'StopMixMonitor','channel':_0x13ed14[_0x4d0449('0x75')],'mixmonitorid':_0x129588['mixmonitorid']})['catch'](function(){});})[_0x48d347('0x4c')](function(){const _0x550316=_0x48d347;if(_0x13ed14['destinationchannel'])return ami[_0x550316('0x32')]({'action':_0x550316('0x47'),'channel':_0x13ed14[_0x550316('0x1f')],'mixmonitorid':_0x129588[_0x550316('0x3')]})[_0x550316('0x2a')](function(){});})[_0x48d347('0x4c')](function(){const _0x1205dd=_0x48d347,_0x25efc7=_['find'](_0x13ed14[_0x1205dd('0x1b')],{'mixmonitorid':_0x129588[_0x1205dd('0x3')]});_0x25efc7&&(_0x25efc7[_0x1205dd('0x7a')]=_0x1205dd('0x0'));})[_0x48d347('0x4c')](function(){const _0x3c7c2f=_0x48d347,_0x1c4989=util['format'](_0x3c7c2f('0x37'),_0x129588[_0x3c7c2f('0x7c')]||_0x129588[_0x3c7c2f('0x78')],_0x129588[_0x3c7c2f('0x1c')]||_0x3c7c2f('0x1a')),_0x39fc82=_[_0x3c7c2f('0x16')](_0x13ed14[_0x3c7c2f('0x1b')],{'filename':_0x3c7c2f('0x43')+_0x1c4989[_0x3c7c2f('0x55')]()});_0x39fc82&&(_0x39fc82[_0x3c7c2f('0x7a')]=_0x3c7c2f('0x0'));})[_0x48d347('0x4c')](function(){const _0xed0075=_0x48d347;_0x506c09({'code':0xc8,'message':[_0x129588[_0xed0075('0x78')],'StopMixMonitor\x20Success']['join']('\x20')});})[_0x48d347('0x2a')](function(_0x542327){const _0x45880e=_0x48d347;_0x160e27(_0x7055c7[_0x45880e('0x80')](0x1f5,[_0x129588['uniqueid'],_0x542327['message']['toLowerCase']()][_0x45880e('0x5f')]('\x20')));}):_0x160e27(_0x7055c7[_0x48d347('0x80')](0x1f5,'Channel\x20doesn\x27t\x20exist'));});},'VoiceQueuesChannels':function(){return new Promise(function(_0x13bbc7){const _0x474834=a1132_0x2ff5,_0x78855e=_[_0x474834('0x17')](_0x39c4a1[_0x474834('0x51')]);_0x13bbc7({'count':_0x78855e['length'],'rows':_0x78855e});});},'VoiceQueuesChannel':function(_0x42078f){const _0x58fb34=this;return new Promise(function(_0x41f83f,_0x3b8544){const _0x5a960f=a1132_0x2ff5,_0x59808b=schema(properties['voicequeuechannel'])[_0x5a960f('0x4a')](_0x42078f);if(_0x59808b[_0x5a960f('0x82')]>0x0)return _0x3b8544(_0x58fb34[_0x5a960f('0x80')](0x1f4,_[_0x5a960f('0x79')](_0x59808b,_0x5a960f('0xf'))[_0x5a960f('0x5f')](',\x20')));const _0x1cc972=_['find'](_0x39c4a1[_0x5a960f('0x51')],{'uniqueid':_0x42078f[_0x5a960f('0x78')]});if(_0x1cc972)_0x41f83f(_0x1cc972);else return _0x3b8544(_0x58fb34['error'](0x1f5,'Channel\x20doesn\x27t\x20exist'));});},'VoiceQueuesChannelHangup':function(_0x1ce223){const _0x41949c=this;return new Promise(function(_0x139095,_0x57a7d8){const _0x1ee364=a1132_0x2ff5;if(ami['isConnected']()==![])return _0x57a7d8(_0x41949c[_0x1ee364('0x80')](0x1f4,[config[_0x1ee364('0x6d')]['ip'],config[_0x1ee364('0x6d')][_0x1ee364('0x5c')],'ami\x20disconnected'][_0x1ee364('0x5f')]('\x20')));const _0x3309b8=schema(properties[_0x1ee364('0x5e')])[_0x1ee364('0x4a')](_0x1ce223);if(_0x3309b8[_0x1ee364('0x82')]>0x0)return _0x57a7d8(_0x41949c[_0x1ee364('0x80')](0x1f4,_[_0x1ee364('0x79')](_0x3309b8,_0x1ee364('0xf'))[_0x1ee364('0x5f')](',\x20')));const _0x1a8b7c=_[_0x1ee364('0x16')](_0x39c4a1[_0x1ee364('0x51')],{'uniqueid':_0x1ce223['uniqueid']});return _0x1a8b7c&&_0x1a8b7c[_0x1ee364('0x75')]?ami['Action']({'action':_0x1ee364('0x2c'),'channel':_0x1a8b7c[_0x1ee364('0x75')]})['then'](function(_0x5d0a16){const _0x10da51=_0x1ee364;_0x139095({'code':0xc8,'message':[_0x1ce223[_0x10da51('0x78')],_0x5d0a16[_0x10da51('0xf')][_0x10da51('0x55')]()][_0x10da51('0x5f')]('\x20')});})[_0x1ee364('0x2a')](function(_0x22fe81){const _0x3dc83b=_0x1ee364;_0x57a7d8(_0x41949c[_0x3dc83b('0x80')](0x1f5,[_0x1ce223[_0x3dc83b('0x78')],_0x22fe81['message'][_0x3dc83b('0x55')]()][_0x3dc83b('0x5f')]('\x20')));}):_0x57a7d8(_0x41949c[_0x1ee364('0x80')](0x1f5,'Channel\x20doesn\x27t\x20exist'));});},'VoiceQueuesChannelRedirect':function(_0x502dc2){const _0x33f5c8=this;return new Promise(function(_0x53b2de,_0x340e08){const _0x425837=a1132_0x2ff5;if(ami[_0x425837('0x63')]()==![])return _0x340e08(_0x33f5c8[_0x425837('0x80')](0x1f4,[config[_0x425837('0x6d')]['ip'],config[_0x425837('0x6d')]['username'],'ami\x20disconnected'][_0x425837('0x5f')]('\x20')));const _0x2c1372=schema(properties['voicequeuechannelredirect'])[_0x425837('0x4a')](_0x502dc2);if(_0x2c1372[_0x425837('0x82')]>0x0)return _0x340e08(_0x33f5c8['error'](0x1f4,_[_0x425837('0x79')](_0x2c1372,_0x425837('0xf'))[_0x425837('0x5f')](',\x20')));const _0x20afce=_[_0x425837('0x16')](_0x39c4a1[_0x425837('0x51')],{'uniqueid':_0x502dc2['uniqueid']});return _0x20afce&&_0x20afce['channel']?ami[_0x425837('0x32')]({'action':'Redirect','channel':_0x20afce['channel'],'exten':_0x502dc2[_0x425837('0x35')],'context':_0x502dc2[_0x425837('0x20')]||_0x20afce[_0x425837('0x20')],'priority':0x1})[_0x425837('0x4c')](function(_0x20a78e){const _0x4656f3=_0x425837;_0x53b2de({'code':0xc8,'message':[_0x502dc2[_0x4656f3('0x78')],_0x20a78e[_0x4656f3('0xf')][_0x4656f3('0x55')]()][_0x4656f3('0x5f')]('\x20')});})[_0x425837('0x2a')](function(_0x49cb69){const _0x14c8ed=_0x425837;_0x340e08(_0x33f5c8[_0x14c8ed('0x80')](0x1f5,[_0x502dc2['uniqueid'],_0x49cb69[_0x14c8ed('0xf')][_0x14c8ed('0x55')]()][_0x14c8ed('0x5f')]('\x20')));}):_0x340e08(_0x33f5c8[_0x425837('0x80')](0x1f5,_0x425837('0x48')));});},'Agents':function(){return new Promise(function(_0xa2fe17){const _0x53239f=a1132_0x2ff5,_0x43dc9a=_[_0x53239f('0x17')](_0x39c4a1['agents']);_0xa2fe17({'count':_0x43dc9a[_0x53239f('0x82')],'rows':_0x43dc9a});});},'Telephones':function(){return new Promise(function(_0x150683){const _0xfc0ac=a1132_0x2ff5,_0xa16baf=_[_0xfc0ac('0x17')](_0x39c4a1['telephones']);_0x150683({'count':_0xa16baf[_0xfc0ac('0x82')],'rows':_0xa16baf});});},'Trunks':function(){return new Promise(function(_0x561d09){const _0x1321d0=a1132_0x2ff5,_0x483918=_[_0x1321d0('0x17')](_0x39c4a1['trunks']);_0x561d09({'count':_0x483918[_0x1321d0('0x82')],'rows':_0x483918});});},'OutboundChannels':function(){return new Promise(function(_0x5900f7){const _0x3ef899=a1132_0x2ff5,_0x222154=_[_0x3ef899('0x17')](_0x39c4a1[_0x3ef899('0x25')]);_0x5900f7({'count':_0x222154[_0x3ef899('0x82')],'rows':_0x222154});});},'Outbound':function(){return new Promise(function(_0xe718cf){_0xe718cf(_0x39c4a1['outbound']);});},'Campaigns':function(){return new Promise(function(_0x5a7fe7){const _0x4d1916=a1132_0x2ff5,_0x5238d4=_[_0x4d1916('0x17')](_0x39c4a1[_0x4d1916('0xc')]);_0x5a7fe7({'count':_0x5238d4[_0x4d1916('0x82')],'rows':_0x5238d4});});},'VoiceQueuesPreview':function(_0x16a541){const _0x50f47c=this;return new Promise(function(_0x377508,_0x5c2848){const _0x1293a3=a1132_0x2ff5;_0x5ee9a9[_0x1293a3('0x1d')](_0x16a541['id'])['then'](function(_0x3316e3){_0x377508({'code':0xc8,'message':_0x3316e3['message']});})[_0x1293a3('0x2a')](function(_0x2c3616){const _0x1bc4fe=_0x1293a3;_0x5c2848(_0x50f47c[_0x1bc4fe('0x80')](0x1f4,_0x2c3616[_0x1bc4fe('0xf')]));});});},'EventManager':function(_0x523621){const _0x9bee53=this;return new Promise(function(_0x4ab909,_0x4795f0){const _0x48cccb=a1132_0x2ff5;if(!_0x523621['event'])return _0x4795f0(_0x9bee53['error'](0x1f4,_0x48cccb('0x31')));ami[_0x48cccb('0x6e')](_0x48cccb('0x74')+_0x523621[_0x48cccb('0x69')],_0x523621['message']),_0x4ab909({'code':0xc8,'message':_0x523621});});},'FaxAccounts':function(){return new Promise(function(_0x134c95){const _0x2b75f7=a1132_0x2ff5,_0x2fc0f8=_[_0x2b75f7('0x17')](_0x39c4a1[_0x2b75f7('0x65')]);_0x134c95({'count':_0x2fc0f8[_0x2b75f7('0x82')],'rows':_0x2fc0f8});});},'SendFax':function(_0x4b430a){const _0x13f223=this;return new Promise(function(_0x4adb72,_0xc63f3d){const _0x2f4d95=a1132_0x2ff5;_0x666d41[_0x2f4d95('0x18')](_0x4b430a)[_0x2f4d95('0x4c')](function(_0x483352){const _0x257dd0=_0x2f4d95;_0x4adb72({'code':0xc8,'message':_0x483352[_0x257dd0('0xf')]});})[_0x2f4d95('0x2a')](function(_0x3f0920){const _0x4c94b2=_0x2f4d95;_0xc63f3d(_0x13f223[_0x4c94b2('0x80')](0x1f4,_0x3f0920[_0x4c94b2('0xf')]));});});},'CheckAfterSend':function(_0x4b3039){const _0x5a0ee8=this;return new Promise(function(_0x4832dd,_0x284350){const _0x35909d=a1132_0x2ff5;_0x666d41[_0x35909d('0x13')](_0x4b3039)[_0x35909d('0x4c')](function(_0x31947d){const _0xfe7a57=_0x35909d;_0x4832dd({'code':0xc8,'message':_0x31947d[_0xfe7a57('0xf')]});})['catch'](function(_0x1501da){const _0x179f87=_0x35909d;_0x284350(_0x5a0ee8[_0x179f87('0x80')](0x1f4,_0x1501da[_0x179f87('0xf')]));});});}},_0x2ab4d6=jayson['server'](_0xf15e4e)['http']();_0x2ab4d6['on'](_0x5dcaae('0x80'),function(_0x75eb7a){return _0x320a1e(_0x75eb7a);}),_0x2ab4d6[_0x5dcaae('0x58')](0x232a,'127.0.0.1',function(){const _0x434cf2=_0x5dcaae;return console[_0x434cf2('0x36')]('AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!',0x232a),_0x3d5bbe(_0x434cf2('0x10')+0x232a);});});};