c3fc1b1dca129a7c7bc1a9a28e415aebdf6200e3
[motion2.git] / server / services / ami / server / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xa92a=['name','timers','timer','updateAcw','agents','updateStatusRealtime','QueuePause','isConnected','error','asterisk','username','ami\x20disconnected','join','pick','keys','module','Reload','Action','then','catch','message','action','Command','voiceQueues','hasOwnProperty','strategy','loggedIn','pTalking','sumBillable','sumDuration','sumHoldTime','talking','total','abandoned','dialActive','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialPrefix','temp','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundReCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','originated','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','startPredictive','startProgressive','Trunk','active','callerid','Interval','push','length','omit','undefined','channels','voicechannel','map','find','uniqueid','channel','%s.%s','filename','wav','MixMonitor','ai(mixmonitorid)','monitors','isNil','/var/spool/asterisk/monitor/','toLowerCase','YYYY-MM-DD\x20HH:mm:ss','mixmonitorid','rec','status','MixMonitor\x20Success','Channel\x20doesn\x27t\x20exist','StopMixMonitor','destinationchannel','stop','StopMixMonitor\x20Success','values','queueChannels','voicequeuechannelhangup','Hangup','voicequeuechannelredirect','Redirect','context','telephones','trunks','outboundChannels','run','event','Event\x20name\x20mandatory','emit','custom:','faxAccounts','send','checkAfterSend','server','listen','log','AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','lodash','jayson/promise','validate','bluebird','moment','../properties','format','%s/%s','SIP'];(function(_0x42245d,_0x51758f){var _0x4b211a=function(_0x2634e){while(--_0x2634e){_0x42245d['push'](_0x42245d['shift']());}};_0x4b211a(++_0x51758f);}(_0xa92a,0x18c));var _0xaa92=function(_0x2f3848,_0x48564d){_0x2f3848=_0x2f3848-0x0;var _0x102668=_0xa92a[_0x2f3848];return _0x102668;};'use strict';var _=require(_0xaa92('0x0'));var util=require('util');var jayson=require(_0xaa92('0x1'));var schema=require(_0xaa92('0x2'));var BPromise=require(_0xaa92('0x3'));var moment=require(_0xaa92('0x4'));var config=require('../../../config/environment');var properties=require(_0xaa92('0x5'));var ami=require('../ami');exports['listen']=function(_0x4cbfb6,_0x56dc82,_0x32469b){return new BPromise(function(_0x1b206e,_0x29d9ad){var _0x45693a={'QueuePause':function(_0x2592e0){return new Promise(function(_0x418b1b,_0x1e8b19){var _0x391bf9=util[_0xaa92('0x6')](_0xaa92('0x7'),_0xaa92('0x8'),_0x2592e0[_0xaa92('0x9')]);if(_0x4cbfb6[_0xaa92('0xa')]&&_0x4cbfb6['timers'][_0x391bf9]&&_0x4cbfb6['timers'][_0x391bf9][_0xaa92('0xb')]){_0x4cbfb6['timers'][_0x391bf9][_0xaa92('0xc')]();}if(_0x4cbfb6[_0xaa92('0xd')][_0x391bf9]){_0x4cbfb6[_0xaa92('0xd')][_0x391bf9][_0xaa92('0xe')]({'statePause':_0x2592e0['pause']?!![]:![]});}_0x418b1b({'code':0xc8,'message':_0xaa92('0xf')});});},'Reload':function(_0x41c57f){var _0x11d2a7=this;return new Promise(function(_0x504e82,_0x58636c){if(ami[_0xaa92('0x10')]()==![]){return _0x58636c(_0x11d2a7[_0xaa92('0x11')](0x1f4,[config[_0xaa92('0x12')]['ip'],config[_0xaa92('0x12')][_0xaa92('0x13')],_0xaa92('0x14')][_0xaa92('0x15')]('\x20')));}_0x41c57f=_[_0xaa92('0x16')](_0x41c57f,_[_0xaa92('0x17')](properties[_0xaa92('0x18')]));_0x41c57f['action']=_0xaa92('0x19');return ami[_0xaa92('0x1a')](_0x41c57f)[_0xaa92('0x1b')](function(_0x151f98){_0x504e82({'code':0xc8,'message':_0x151f98['message']});})[_0xaa92('0x1c')](function(_0x3a5c3e){_0x58636c(_0x11d2a7['error'](0x1f5,_0x3a5c3e[_0xaa92('0x1d')]));});});},'Command':function(_0x57809a){var _0x544c15=this;return new Promise(function(_0x4beec8,_0x449c46){if(ami[_0xaa92('0x10')]()==![]){return _0x449c46(_0x544c15['error'](0x1f4,[config[_0xaa92('0x12')]['ip'],config[_0xaa92('0x12')]['username'],'ami\x20disconnected'][_0xaa92('0x15')]('\x20')));}_0x57809a=_[_0xaa92('0x16')](_0x57809a,'command');_0x57809a[_0xaa92('0x1e')]=_0xaa92('0x1f');return ami[_0xaa92('0x1a')](_0x57809a)[_0xaa92('0x1b')](function(_0x53dbbb){_0x4beec8({'code':0xc8,'message':_0x53dbbb['content']});})[_0xaa92('0x1c')](function(_0x440bfe){_0x449c46(_0x544c15[_0xaa92('0x11')](0x1f5,_0x440bfe[_0xaa92('0x1d')]));});});},'VoiceQueues':function(_0x104cb9){return new Promise(function(_0x5870d3,_0x1427b5){var _0x52648b=[];for(var _0x484c64 in _0x4cbfb6[_0xaa92('0x20')]){if(_0x4cbfb6[_0xaa92('0x20')][_0xaa92('0x21')](_0x484c64)){var _0x23752f=_0x4cbfb6[_0xaa92('0x20')][_0x484c64];var _0x2dc545={'id':_0x23752f['id'],'name':_0x23752f['name'],'strategy':_0x23752f[_0xaa92('0x22')],'answered':_0x23752f['answered'],'available':_0x23752f['available'],'loggedIn':_0x23752f[_0xaa92('0x23')],'pTalking':_0x23752f[_0xaa92('0x24')],'sumBillable':_0x23752f[_0xaa92('0x25')],'sumDuration':_0x23752f[_0xaa92('0x26')],'sumHoldTime':_0x23752f[_0xaa92('0x27')]||0x0,'talking':_0x23752f[_0xaa92('0x28')],'total':_0x23752f[_0xaa92('0x29')],'type':_0x23752f['type'],'unmanaged':_0x23752f['unmanaged'],'abandoned':_0x23752f[_0xaa92('0x2a')],'waiting':_0x23752f['waiting'],'loggedInDb':_0x23752f['loggedInDb']};if(_0x23752f['type']==='outbound'){_0x2dc545[_0xaa92('0x2b')]=_0x23752f[_0xaa92('0x2b')];_0x2dc545[_0xaa92('0x2c')]=_0x23752f[_0xaa92('0x2c')];_0x2dc545[_0xaa92('0x2d')]=_0x23752f['dialOriginateCallerIdName'];_0x2dc545[_0xaa92('0x2e')]=_0x23752f[_0xaa92('0x2e')];_0x2dc545[_0xaa92('0x2f')]=_0x23752f[_0xaa92('0x2f')];_0x2dc545[_0xaa92('0x30')]=_0x23752f[_0xaa92('0x30')];_0x2dc545['temp']=_0x23752f[_0xaa92('0x31')];_0x2dc545[_0xaa92('0x32')]=_0x23752f['outboundAnswerAgiCallsDay'];_0x2dc545['outboundAnswerCallsDay']=_0x23752f[_0xaa92('0x33')];_0x2dc545[_0xaa92('0x34')]=_0x23752f[_0xaa92('0x34')];_0x2dc545['outboundBusyCallsDay']=_0x23752f['outboundBusyCallsDay'];_0x2dc545['outboundCongestionCallsDay']=_0x23752f[_0xaa92('0x35')];_0x2dc545[_0xaa92('0x36')]=_0x23752f[_0xaa92('0x36')];_0x2dc545[_0xaa92('0x37')]=_0x23752f[_0xaa92('0x37')];_0x2dc545['outboundDropCallsDayTimeout']=_0x23752f['outboundDropCallsDayTimeout'];_0x2dc545['outboundNoAnswerCallsDay']=_0x23752f['outboundNoAnswerCallsDay'];_0x2dc545[_0xaa92('0x38')]=_0x23752f[_0xaa92('0x38')];_0x2dc545[_0xaa92('0x39')]=_0x23752f[_0xaa92('0x39')];_0x2dc545[_0xaa92('0x3a')]=_0x23752f[_0xaa92('0x3a')];_0x2dc545[_0xaa92('0x3b')]=_0x23752f[_0xaa92('0x3b')];_0x2dc545[_0xaa92('0x3c')]=_0x23752f['outboundUnknownCallsDay'];_0x2dc545[_0xaa92('0x3d')]=_0x23752f[_0xaa92('0x3d')];_0x2dc545[_0xaa92('0x3e')]=_0x23752f['predictiveIntervalAvgHoldtime'];_0x2dc545[_0xaa92('0x3f')]=_0x23752f[_0xaa92('0x3f')];_0x2dc545[_0xaa92('0x40')]=_0x23752f[_0xaa92('0x40')];_0x2dc545[_0xaa92('0x41')]=_0x23752f['predictiveIntervalDroppedCallsTimeout'];_0x2dc545['predictiveIntervalErlangCalls']=_0x23752f[_0xaa92('0x42')];_0x2dc545['predictiveIntervalErlangCallsDroppedCalls']=_0x23752f[_0xaa92('0x43')];_0x2dc545[_0xaa92('0x44')]=_0x23752f[_0xaa92('0x44')];_0x2dc545[_0xaa92('0x45')]=_0x23752f['predictiveIntervalMultiplicativeFactor'];_0x2dc545['predictiveIntervalPauses']=_0x23752f[_0xaa92('0x46')];_0x2dc545[_0xaa92('0x47')]=_0x23752f[_0xaa92('0x47')];_0x2dc545[_0xaa92('0x48')]=_0x23752f[_0xaa92('0x48')];_0x2dc545[_0xaa92('0x1d')]=_0x23752f[_0xaa92('0x1d')];_0x2dc545[_0xaa92('0x49')]=_0x23752f[_0xaa92('0x49')];_0x2dc545[_0xaa92('0x4a')]=_0x23752f[_0xaa92('0x4a')];_0x2dc545[_0xaa92('0x4b')]=_0x23752f['erlangCallToSecond'];_0x2dc545[_0xaa92('0x4c')]=_0x23752f[_0xaa92('0x4c')];_0x2dc545['erlangBusyFactor']=_0x23752f[_0xaa92('0x4d')];_0x2dc545['startPredictive']=_0x23752f[_0xaa92('0x4e')];_0x2dc545['startProgressive']=_0x23752f[_0xaa92('0x4f')];}if(_0x23752f[_0xaa92('0x50')]){_0x2dc545['Trunk']={'id':_0x23752f[_0xaa92('0x50')]['id'],'name':_0x23752f[_0xaa92('0x50')][_0xaa92('0x9')],'active':_0x23752f[_0xaa92('0x50')][_0xaa92('0x51')],'callerid':_0x23752f[_0xaa92('0x50')][_0xaa92('0x52')]};}if(_0x23752f['Interval']){_0x2dc545['Interval']={'id':_0x23752f[_0xaa92('0x53')]['id'],'name':_0x23752f[_0xaa92('0x53')]['name']};}_0x52648b[_0xaa92('0x54')](_0x2dc545);}}_0x5870d3({'count':_0x52648b[_0xaa92('0x55')],'rows':_0x52648b});});},'UpdateVoiceQueue':function(_0x46caed){return new Promise(function(_0x5d85e7,_0x4906f6){var _0x2353fc=_['find'](_0x4cbfb6['voiceQueues'],{'id':parseInt(_0x46caed['id'])});var _0xe11acd=_[_0xaa92('0x56')](_0x46caed,['id']);if(_0x2353fc){for(var _0x4438c6 in _0xe11acd){if(typeof _0xe11acd[_0x4438c6]!==_0xaa92('0x57')&&typeof _0x2353fc[_0x4438c6]!=='undefined'){_0x2353fc[_0x4438c6]=_0xe11acd[_0x4438c6];}}_0x5d85e7(_0x2353fc);}else{_0x4906f6();}});},'VoiceChannels':function(_0x2beacf){return new Promise(function(_0x42dd8e,_0x44b749){var _0x2ff6cb=_['values'](_0x4cbfb6[_0xaa92('0x58')]);_0x42dd8e({'count':_0x2ff6cb['length'],'rows':_0x2ff6cb});});},'VoiceChannelMixMonitor':function(_0x11ddc1){var _0x5d07e6=this;return new Promise(function(_0x553820,_0x3ad9a5){if(ami[_0xaa92('0x10')]()==![]){return _0x3ad9a5(_0x5d07e6['error'](0x1f4,[config[_0xaa92('0x12')]['ip'],config[_0xaa92('0x12')]['username'],'ami\x20disconnected']['join']('\x20')));}var _0x135d1e=schema(properties[_0xaa92('0x59')])[_0xaa92('0x2')](_0x11ddc1);if(_0x135d1e[_0xaa92('0x55')]>0x0){return _0x3ad9a5(_0x5d07e6[_0xaa92('0x11')](0x1f4,_[_0xaa92('0x5a')](_0x135d1e,_0xaa92('0x1d'))[_0xaa92('0x15')](',\x20')));}var _0x3e67a4=_[_0xaa92('0x5b')](_0x4cbfb6['channels'],{'uniqueid':_0x11ddc1[_0xaa92('0x5c')]});if(_0x3e67a4&&_0x3e67a4[_0xaa92('0x5d')]){var _0x3149d6=util[_0xaa92('0x6')](_0xaa92('0x5e'),_0x11ddc1[_0xaa92('0x5f')]||_0x11ddc1[_0xaa92('0x5c')],_0x11ddc1['format']||_0xaa92('0x60'));return ami[_0xaa92('0x1a')]({'action':_0xaa92('0x61'),'channel':_0x3e67a4[_0xaa92('0x5d')],'file':_0x3149d6,'options':_0xaa92('0x62')})['then'](function(_0x5c6ed0){var _0x55e0d7=_['find'](_0x3e67a4[_0xaa92('0x63')],{'filename':'/var/spool/asterisk/monitor/'+_0x3149d6['toLowerCase']()});if(_[_0xaa92('0x64')](_0x55e0d7)){_0x3e67a4[_0xaa92('0x63')][_0xaa92('0x54')]({'filename':_0xaa92('0x65')+_0x3149d6[_0xaa92('0x66')](),'createdAt':moment()[_0xaa92('0x6')](_0xaa92('0x67')),'mixmonitorid':_0x5c6ed0[_0xaa92('0x68')],'status':_0xaa92('0x69')});}else{_0x55e0d7[_0xaa92('0x68')]=_0x5c6ed0[_0xaa92('0x68')];_0x55e0d7[_0xaa92('0x6a')]=_0xaa92('0x69');}_0x553820({'code':0xc8,'message':[_0x11ddc1[_0xaa92('0x5c')],_0xaa92('0x6b'),_0x5c6ed0[_0xaa92('0x68')]]['join']('\x20'),'mixmonitorid':_0x5c6ed0[_0xaa92('0x68')]});})[_0xaa92('0x1c')](function(_0x121ad7){_0x3ad9a5(_0x5d07e6[_0xaa92('0x11')](0x1f5,[_0x11ddc1[_0xaa92('0x5c')],_0x121ad7[_0xaa92('0x1d')][_0xaa92('0x66')]()][_0xaa92('0x15')]('\x20')));});}else{return _0x3ad9a5(_0x5d07e6[_0xaa92('0x11')](0x1f5,_0xaa92('0x6c')));}});},'VoiceChannelStopMixMonitor':function(_0x8a791d){var _0x4fc073=this;return new Promise(function(_0x3fb2be,_0x1ac913){if(ami[_0xaa92('0x10')]()==![]){return _0x1ac913(_0x4fc073[_0xaa92('0x11')](0x1f4,[config['asterisk']['ip'],config['asterisk'][_0xaa92('0x13')],_0xaa92('0x14')][_0xaa92('0x15')]('\x20')));}var _0x34afd1=schema(properties[_0xaa92('0x59')])[_0xaa92('0x2')](_0x8a791d);if(_0x34afd1[_0xaa92('0x55')]>0x0){return _0x1ac913(_0x4fc073[_0xaa92('0x11')](0x1f4,_[_0xaa92('0x5a')](_0x34afd1,_0xaa92('0x1d'))[_0xaa92('0x15')](',\x20')));}var _0x3a5430=_['find'](_0x4cbfb6[_0xaa92('0x58')],{'uniqueid':_0x8a791d[_0xaa92('0x5c')]});if(_0x3a5430){return BPromise['resolve']()[_0xaa92('0x1b')](function(){if(_0x3a5430[_0xaa92('0x5d')]){return ami['Action']({'action':_0xaa92('0x6d'),'channel':_0x3a5430[_0xaa92('0x5d')],'mixmonitorid':_0x8a791d[_0xaa92('0x68')]})[_0xaa92('0x1c')](function(_0x4d2435){});}})[_0xaa92('0x1b')](function(){if(_0x3a5430[_0xaa92('0x6e')]){return ami[_0xaa92('0x1a')]({'action':_0xaa92('0x6d'),'channel':_0x3a5430[_0xaa92('0x6e')],'mixmonitorid':_0x8a791d['mixmonitorid']})[_0xaa92('0x1c')](function(_0x19c2c3){});}})[_0xaa92('0x1b')](function(_0x1a3f21){var _0x37f1df=_[_0xaa92('0x5b')](_0x3a5430[_0xaa92('0x63')],{'mixmonitorid':_0x8a791d[_0xaa92('0x68')]});if(_0x37f1df){_0x37f1df[_0xaa92('0x6a')]=_0xaa92('0x6f');}})[_0xaa92('0x1b')](function(){var _0x307f3b=util['format'](_0xaa92('0x5e'),_0x8a791d[_0xaa92('0x5f')]||_0x8a791d['uniqueid'],_0x8a791d[_0xaa92('0x6')]||'wav');var _0xa6d9d8=_[_0xaa92('0x5b')](_0x3a5430[_0xaa92('0x63')],{'filename':_0xaa92('0x65')+_0x307f3b[_0xaa92('0x66')]()});if(_0xa6d9d8){_0xa6d9d8[_0xaa92('0x6a')]=_0xaa92('0x6f');}})[_0xaa92('0x1b')](function(){_0x3fb2be({'code':0xc8,'message':[_0x8a791d['uniqueid'],_0xaa92('0x70')][_0xaa92('0x15')]('\x20')});})[_0xaa92('0x1c')](function(_0x23989d){_0x1ac913(_0x4fc073[_0xaa92('0x11')](0x1f5,[_0x8a791d[_0xaa92('0x5c')],_0x23989d[_0xaa92('0x1d')][_0xaa92('0x66')]()]['join']('\x20')));});}else{return _0x1ac913(_0x4fc073[_0xaa92('0x11')](0x1f5,_0xaa92('0x6c')));}});},'VoiceQueuesChannels':function(_0x521e03){return new Promise(function(_0x2fd9e8,_0xe75c0f){var _0x27aade=_[_0xaa92('0x71')](_0x4cbfb6[_0xaa92('0x72')]);_0x2fd9e8({'count':_0x27aade[_0xaa92('0x55')],'rows':_0x27aade});});},'VoiceQueuesChannel':function(_0x35861b){var _0x719102=this;return new Promise(function(_0x233785,_0x29da75){var _0xd3801f=schema(properties['voicequeuechannel'])[_0xaa92('0x2')](_0x35861b);if(_0xd3801f['length']>0x0){return _0x29da75(_0x719102[_0xaa92('0x11')](0x1f4,_[_0xaa92('0x5a')](_0xd3801f,_0xaa92('0x1d'))['join'](',\x20')));}var _0x591e0f=_[_0xaa92('0x5b')](_0x4cbfb6[_0xaa92('0x72')],{'uniqueid':_0x35861b['uniqueid']});if(_0x591e0f){_0x233785(_0x591e0f);}else{return _0x29da75(_0x719102['error'](0x1f5,_0xaa92('0x6c')));}});},'VoiceQueuesChannelHangup':function(_0x51eeff){var _0x511df1=this;return new Promise(function(_0x260563,_0x588d0d){if(ami[_0xaa92('0x10')]()==![]){return _0x588d0d(_0x511df1[_0xaa92('0x11')](0x1f4,[config[_0xaa92('0x12')]['ip'],config[_0xaa92('0x12')][_0xaa92('0x13')],'ami\x20disconnected'][_0xaa92('0x15')]('\x20')));}var _0x52b3f8=schema(properties[_0xaa92('0x73')])['validate'](_0x51eeff);if(_0x52b3f8[_0xaa92('0x55')]>0x0){return _0x588d0d(_0x511df1[_0xaa92('0x11')](0x1f4,_[_0xaa92('0x5a')](_0x52b3f8,_0xaa92('0x1d'))['join'](',\x20')));}var _0x6f64=_[_0xaa92('0x5b')](_0x4cbfb6[_0xaa92('0x72')],{'uniqueid':_0x51eeff['uniqueid']});if(_0x6f64&&_0x6f64[_0xaa92('0x5d')]){return ami[_0xaa92('0x1a')]({'action':_0xaa92('0x74'),'channel':_0x6f64[_0xaa92('0x5d')]})[_0xaa92('0x1b')](function(_0x54f627){_0x260563({'code':0xc8,'message':[_0x51eeff[_0xaa92('0x5c')],_0x54f627[_0xaa92('0x1d')][_0xaa92('0x66')]()]['join']('\x20')});})[_0xaa92('0x1c')](function(_0x54327b){_0x588d0d(_0x511df1[_0xaa92('0x11')](0x1f5,[_0x51eeff[_0xaa92('0x5c')],_0x54327b[_0xaa92('0x1d')]['toLowerCase']()]['join']('\x20')));});}else{return _0x588d0d(_0x511df1[_0xaa92('0x11')](0x1f5,_0xaa92('0x6c')));}});},'VoiceQueuesChannelRedirect':function(_0x27b236){var _0x42aec5=this;return new Promise(function(_0x139380,_0x504260){if(ami['isConnected']()==![]){return _0x504260(_0x42aec5['error'](0x1f4,[config[_0xaa92('0x12')]['ip'],config[_0xaa92('0x12')][_0xaa92('0x13')],_0xaa92('0x14')][_0xaa92('0x15')]('\x20')));}var _0x3cf36b=schema(properties[_0xaa92('0x75')])[_0xaa92('0x2')](_0x27b236);if(_0x3cf36b[_0xaa92('0x55')]>0x0){return _0x504260(_0x42aec5[_0xaa92('0x11')](0x1f4,_[_0xaa92('0x5a')](_0x3cf36b,_0xaa92('0x1d'))[_0xaa92('0x15')](',\x20')));}var _0x43771f=_['find'](_0x4cbfb6['queueChannels'],{'uniqueid':_0x27b236['uniqueid']});if(_0x43771f&&_0x43771f[_0xaa92('0x5d')]){return ami['Action']({'action':_0xaa92('0x76'),'channel':_0x43771f['channel'],'exten':_0x27b236['exten'],'context':_0x27b236['context']||_0x43771f[_0xaa92('0x77')],'priority':0x1})[_0xaa92('0x1b')](function(_0x565610){_0x139380({'code':0xc8,'message':[_0x27b236[_0xaa92('0x5c')],_0x565610[_0xaa92('0x1d')][_0xaa92('0x66')]()][_0xaa92('0x15')]('\x20')});})[_0xaa92('0x1c')](function(_0xabb665){_0x504260(_0x42aec5['error'](0x1f5,[_0x27b236[_0xaa92('0x5c')],_0xabb665[_0xaa92('0x1d')][_0xaa92('0x66')]()][_0xaa92('0x15')]('\x20')));});}else{return _0x504260(_0x42aec5[_0xaa92('0x11')](0x1f5,_0xaa92('0x6c')));}});},'Agents':function(_0x31572f){return new Promise(function(_0x1da967,_0x280de1){var _0x232ea4=_[_0xaa92('0x71')](_0x4cbfb6[_0xaa92('0xd')]);_0x1da967({'count':_0x232ea4[_0xaa92('0x55')],'rows':_0x232ea4});});},'Telephones':function(_0x1a759d){return new Promise(function(_0x2def25,_0x3f7c1b){var _0x196df6=_[_0xaa92('0x71')](_0x4cbfb6[_0xaa92('0x78')]);_0x2def25({'count':_0x196df6[_0xaa92('0x55')],'rows':_0x196df6});});},'Trunks':function(_0x4427bb){return new Promise(function(_0xd5155f,_0x545cd0){var _0x55d69e=_[_0xaa92('0x71')](_0x4cbfb6[_0xaa92('0x79')]);_0xd5155f({'count':_0x55d69e[_0xaa92('0x55')],'rows':_0x55d69e});});},'OutboundChannels':function(_0x55e48c){return new Promise(function(_0x504f3a,_0x229a52){var _0x397a43=_[_0xaa92('0x71')](_0x4cbfb6[_0xaa92('0x7a')]);_0x504f3a({'count':_0x397a43[_0xaa92('0x55')],'rows':_0x397a43});});},'Outbound':function(_0x2715c9){return new Promise(function(_0x470fb0,_0x5a767b){_0x470fb0(_0x4cbfb6['outbound']);});},'Campaigns':function(_0x1c142d){return new Promise(function(_0x16aea0,_0x5b4afc){var _0xd6b3c5=_[_0xaa92('0x71')](_0x4cbfb6['campaigns']);_0x16aea0({'count':_0xd6b3c5['length'],'rows':_0xd6b3c5});});},'VoiceQueuesPreview':function(_0x4b323d){var _0x39c481=this;return new Promise(function(_0x337a5c,_0xb2d694){_0x56dc82[_0xaa92('0x7b')](_0x4b323d['id'])[_0xaa92('0x1b')](function(_0x31cb19){_0x337a5c({'code':0xc8,'message':_0x31cb19[_0xaa92('0x1d')]});})[_0xaa92('0x1c')](function(_0x32d507){_0xb2d694(_0x39c481[_0xaa92('0x11')](0x1f4,_0x32d507[_0xaa92('0x1d')]));});});},'EventManager':function(_0x463f13){var _0x47120d=this;return new Promise(function(_0x2fb1bc,_0x271689){if(!_0x463f13[_0xaa92('0x7c')]){return _0x271689(_0x47120d[_0xaa92('0x11')](0x1f4,_0xaa92('0x7d')));}ami[_0xaa92('0x7e')](_0xaa92('0x7f')+_0x463f13[_0xaa92('0x7c')],_0x463f13[_0xaa92('0x1d')]);_0x2fb1bc({'code':0xc8,'message':_0x463f13});});},'FaxAccounts':function(_0x55ce8b){return new Promise(function(_0x509a2d,_0x31a2a3){var _0x250fcd=_['values'](_0x4cbfb6[_0xaa92('0x80')]);_0x509a2d({'count':_0x250fcd[_0xaa92('0x55')],'rows':_0x250fcd});});},'SendFax':function(_0x348319){var _0x389a07=this;return new Promise(function(_0xb53a88,_0x3edeb6){_0x32469b[_0xaa92('0x81')](_0x348319)['then'](function(_0x15c538){_0xb53a88({'code':0xc8,'message':_0x15c538[_0xaa92('0x1d')]});})[_0xaa92('0x1c')](function(_0x481e09){_0x3edeb6(_0x389a07[_0xaa92('0x11')](0x1f4,_0x481e09[_0xaa92('0x1d')]));});});},'CheckAfterSend':function(_0x515cb9){var _0x418fd6=this;return new Promise(function(_0x5c81e7,_0x24a3c6){_0x32469b[_0xaa92('0x82')](_0x515cb9)[_0xaa92('0x1b')](function(_0x7c848e){_0x5c81e7({'code':0xc8,'message':_0x7c848e['message']});})[_0xaa92('0x1c')](function(_0x1e13c1){_0x24a3c6(_0x418fd6['error'](0x1f4,_0x1e13c1[_0xaa92('0x1d')]));});});}};var _0x177f43=jayson[_0xaa92('0x83')](_0x45693a)['http']();_0x177f43['on']('error',function(_0x4986a2){return _0x29d9ad(_0x4986a2);});_0x177f43[_0xaa92('0x84')](0x232a,'127.0.0.1',function(){console[_0xaa92('0x85')](_0xaa92('0x86'),0x232a);return _0x1b206e('RPC\x20listening\x20on\x20port:'+0x232a);});});};