bdb62dfad1109b8e1eeff6c30ed44d73d551ca4e
[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 _0x7b84=['QueuePause','isConnected','error','asterisk','username','ami\x20disconnected','join','pick','keys','module','action','Action','catch','command','Command','then','message','voiceQueues','hasOwnProperty','strategy','answered','available','loggedIn','sumBillable','sumHoldTime','talking','total','type','abandoned','waiting','loggedInDb','outbound','dialActive','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialPrefix','temp','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundCongestionCallsDay','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundReCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','originated','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','startPredictive','startProgressive','Trunk','active','callerid','Interval','push','length','find','omit','undefined','values','channels','voicechannel','map','uniqueid','%s.%s','wav','channel','ai(mixmonitorid)','monitors','/var/spool/asterisk/monitor/','toLowerCase','YYYY-MM-DD\x20HH:mm:ss','rec','mixmonitorid','MixMonitor\x20Success','Channel\x20doesn\x27t\x20exist','resolve','StopMixMonitor','destinationchannel','status','stop','filename','queueChannels','voicequeuechannel','voicequeuechannelhangup','Hangup','context','trunks','outboundChannels','campaigns','run','event','Event\x20name\x20mandatory','custom:','faxAccounts','send','checkAfterSend','server','http','127.0.0.1','log','lodash','util','jayson/promise','validate','bluebird','moment','../../../config/environment','../ami','listen','format','%s/%s','SIP','name','timers','timer','updateAcw','agents','updateStatusRealtime','pause'];(function(_0x4855e3,_0x215372){var _0x28e3c0=function(_0x1bf819){while(--_0x1bf819){_0x4855e3['push'](_0x4855e3['shift']());}};_0x28e3c0(++_0x215372);}(_0x7b84,0x17c));var _0x47b8=function(_0x5c54ba,_0x3670ad){_0x5c54ba=_0x5c54ba-0x0;var _0x3c5355=_0x7b84[_0x5c54ba];return _0x3c5355;};'use strict';var _=require(_0x47b8('0x0'));var util=require(_0x47b8('0x1'));var jayson=require(_0x47b8('0x2'));var schema=require(_0x47b8('0x3'));var BPromise=require(_0x47b8('0x4'));var moment=require(_0x47b8('0x5'));var config=require(_0x47b8('0x6'));var properties=require('../properties');var ami=require(_0x47b8('0x7'));exports[_0x47b8('0x8')]=function(_0x2279ea,_0x7013d7,_0x2e6853){return new BPromise(function(_0xafe88a,_0x53e656){var _0x3867ca={'QueuePause':function(_0x3ce846){return new Promise(function(_0x46245a,_0xb845c9){var _0x2289d5=util[_0x47b8('0x9')](_0x47b8('0xa'),_0x47b8('0xb'),_0x3ce846[_0x47b8('0xc')]);if(_0x2279ea[_0x47b8('0xd')]&&_0x2279ea[_0x47b8('0xd')][_0x2289d5]&&_0x2279ea[_0x47b8('0xd')][_0x2289d5][_0x47b8('0xe')]){_0x2279ea[_0x47b8('0xd')][_0x2289d5][_0x47b8('0xf')]();}if(_0x2279ea[_0x47b8('0x10')][_0x2289d5]){_0x2279ea[_0x47b8('0x10')][_0x2289d5][_0x47b8('0x11')]({'statePause':_0x3ce846[_0x47b8('0x12')]?!![]:![]});}_0x46245a({'code':0xc8,'message':_0x47b8('0x13')});});},'Reload':function(_0x1edb4b){var _0x127d42=this;return new Promise(function(_0x2d1aaf,_0x268440){if(ami[_0x47b8('0x14')]()==![]){return _0x268440(_0x127d42[_0x47b8('0x15')](0x1f4,[config[_0x47b8('0x16')]['ip'],config['asterisk'][_0x47b8('0x17')],_0x47b8('0x18')][_0x47b8('0x19')]('\x20')));}_0x1edb4b=_[_0x47b8('0x1a')](_0x1edb4b,_[_0x47b8('0x1b')](properties[_0x47b8('0x1c')]));_0x1edb4b[_0x47b8('0x1d')]='Reload';return ami[_0x47b8('0x1e')](_0x1edb4b)['then'](function(_0x525fd6){_0x2d1aaf({'code':0xc8,'message':_0x525fd6['message']});})[_0x47b8('0x1f')](function(_0x36faf1){_0x268440(_0x127d42[_0x47b8('0x15')](0x1f5,_0x36faf1['message']));});});},'Command':function(_0x502a23){var _0x4f6716=this;return new Promise(function(_0x1c5bfd,_0x5531a2){if(ami[_0x47b8('0x14')]()==![]){return _0x5531a2(_0x4f6716[_0x47b8('0x15')](0x1f4,[config[_0x47b8('0x16')]['ip'],config[_0x47b8('0x16')]['username'],_0x47b8('0x18')][_0x47b8('0x19')]('\x20')));}_0x502a23=_[_0x47b8('0x1a')](_0x502a23,_0x47b8('0x20'));_0x502a23[_0x47b8('0x1d')]=_0x47b8('0x21');return ami['Action'](_0x502a23)[_0x47b8('0x22')](function(_0x2a22e3){_0x1c5bfd({'code':0xc8,'message':_0x2a22e3['content']});})[_0x47b8('0x1f')](function(_0x247429){_0x5531a2(_0x4f6716[_0x47b8('0x15')](0x1f5,_0x247429[_0x47b8('0x23')]));});});},'VoiceQueues':function(_0x5604c9){return new Promise(function(_0x35b327,_0x332c23){var _0x319d17=[];for(var _0x3e3de0 in _0x2279ea[_0x47b8('0x24')]){if(_0x2279ea[_0x47b8('0x24')][_0x47b8('0x25')](_0x3e3de0)){var _0x568c1e=_0x2279ea[_0x47b8('0x24')][_0x3e3de0];var _0x1f719a={'id':_0x568c1e['id'],'name':_0x568c1e['name'],'strategy':_0x568c1e[_0x47b8('0x26')],'answered':_0x568c1e[_0x47b8('0x27')],'available':_0x568c1e[_0x47b8('0x28')],'loggedIn':_0x568c1e[_0x47b8('0x29')],'pTalking':_0x568c1e['pTalking'],'sumBillable':_0x568c1e[_0x47b8('0x2a')],'sumDuration':_0x568c1e['sumDuration'],'sumHoldTime':_0x568c1e[_0x47b8('0x2b')]||0x0,'talking':_0x568c1e[_0x47b8('0x2c')],'total':_0x568c1e[_0x47b8('0x2d')],'type':_0x568c1e[_0x47b8('0x2e')],'unmanaged':_0x568c1e['unmanaged'],'abandoned':_0x568c1e[_0x47b8('0x2f')],'waiting':_0x568c1e[_0x47b8('0x30')],'loggedInDb':_0x568c1e[_0x47b8('0x31')]};if(_0x568c1e[_0x47b8('0x2e')]===_0x47b8('0x32')){_0x1f719a[_0x47b8('0x33')]=_0x568c1e['dialActive'];_0x1f719a['dialMethod']=_0x568c1e['dialMethod'];_0x1f719a[_0x47b8('0x34')]=_0x568c1e[_0x47b8('0x34')];_0x1f719a[_0x47b8('0x35')]=_0x568c1e['dialOriginateCallerIdNumber'];_0x1f719a['dialOriginateTimeout']=_0x568c1e['dialOriginateTimeout'];_0x1f719a['dialPrefix']=_0x568c1e[_0x47b8('0x36')];_0x1f719a[_0x47b8('0x37')]=_0x568c1e[_0x47b8('0x37')];_0x1f719a[_0x47b8('0x38')]=_0x568c1e[_0x47b8('0x38')];_0x1f719a[_0x47b8('0x39')]=_0x568c1e[_0x47b8('0x39')];_0x1f719a[_0x47b8('0x3a')]=_0x568c1e[_0x47b8('0x3a')];_0x1f719a['outboundBusyCallsDay']=_0x568c1e['outboundBusyCallsDay'];_0x1f719a[_0x47b8('0x3b')]=_0x568c1e[_0x47b8('0x3b')];_0x1f719a['outboundDropCallsDayACS']=_0x568c1e['outboundDropCallsDayACS'];_0x1f719a[_0x47b8('0x3c')]=_0x568c1e[_0x47b8('0x3c')];_0x1f719a[_0x47b8('0x3d')]=_0x568c1e['outboundDropCallsDayTimeout'];_0x1f719a[_0x47b8('0x3e')]=_0x568c1e[_0x47b8('0x3e')];_0x1f719a['outboundNoSuchCallsDay']=_0x568c1e['outboundNoSuchCallsDay'];_0x1f719a['outboundOriginateFailureCallsDay']=_0x568c1e['outboundOriginateFailureCallsDay'];_0x1f719a[_0x47b8('0x3f')]=_0x568c1e[_0x47b8('0x3f')];_0x1f719a[_0x47b8('0x40')]=_0x568c1e[_0x47b8('0x40')];_0x1f719a[_0x47b8('0x41')]=_0x568c1e[_0x47b8('0x41')];_0x1f719a['predictiveIntervalAnsweredCalls']=_0x568c1e['predictiveIntervalAnsweredCalls'];_0x1f719a[_0x47b8('0x42')]=_0x568c1e[_0x47b8('0x42')];_0x1f719a[_0x47b8('0x43')]=_0x568c1e['predictiveIntervalAvgTalktime'];_0x1f719a['predictiveIntervalDroppedCallsCallersExit']=_0x568c1e[_0x47b8('0x44')];_0x1f719a[_0x47b8('0x45')]=_0x568c1e['predictiveIntervalDroppedCallsTimeout'];_0x1f719a[_0x47b8('0x46')]=_0x568c1e[_0x47b8('0x46')];_0x1f719a['predictiveIntervalErlangCallsDroppedCalls']=_0x568c1e['predictiveIntervalErlangCallsDroppedCalls'];_0x1f719a['predictiveIntervalHitRate']=_0x568c1e['predictiveIntervalHitRate'];_0x1f719a[_0x47b8('0x47')]=_0x568c1e[_0x47b8('0x47')];_0x1f719a[_0x47b8('0x48')]=_0x568c1e[_0x47b8('0x48')];_0x1f719a[_0x47b8('0x49')]=_0x568c1e['predictiveIntervalAvailable'];_0x1f719a[_0x47b8('0x4a')]=_0x568c1e['predictiveIntervalTotalCalls'];_0x1f719a[_0x47b8('0x23')]=_0x568c1e[_0x47b8('0x23')];_0x1f719a[_0x47b8('0x4b')]=_0x568c1e['originated'];_0x1f719a[_0x47b8('0x4c')]=_0x568c1e[_0x47b8('0x4c')];_0x1f719a[_0x47b8('0x4d')]=_0x568c1e[_0x47b8('0x4d')];_0x1f719a[_0x47b8('0x4e')]=_0x568c1e[_0x47b8('0x4e')];_0x1f719a[_0x47b8('0x4f')]=_0x568c1e['erlangBusyFactor'];_0x1f719a[_0x47b8('0x50')]=_0x568c1e['startPredictive'];_0x1f719a[_0x47b8('0x51')]=_0x568c1e[_0x47b8('0x51')];}if(_0x568c1e[_0x47b8('0x52')]){_0x1f719a[_0x47b8('0x52')]={'id':_0x568c1e[_0x47b8('0x52')]['id'],'name':_0x568c1e[_0x47b8('0x52')]['name'],'active':_0x568c1e['Trunk'][_0x47b8('0x53')],'callerid':_0x568c1e[_0x47b8('0x52')][_0x47b8('0x54')]};}if(_0x568c1e['Interval']){_0x1f719a[_0x47b8('0x55')]={'id':_0x568c1e['Interval']['id'],'name':_0x568c1e[_0x47b8('0x55')][_0x47b8('0xc')]};}_0x319d17[_0x47b8('0x56')](_0x1f719a);}}_0x35b327({'count':_0x319d17[_0x47b8('0x57')],'rows':_0x319d17});});},'UpdateVoiceQueue':function(_0x3f13ae){return new Promise(function(_0x5c26c7,_0x40ff24){var _0xfb8041=_[_0x47b8('0x58')](_0x2279ea[_0x47b8('0x24')],{'id':parseInt(_0x3f13ae['id'])});var _0x1dce38=_[_0x47b8('0x59')](_0x3f13ae,['id']);if(_0xfb8041){for(var _0x46e648 in _0x1dce38){if(typeof _0x1dce38[_0x46e648]!=='undefined'&&typeof _0xfb8041[_0x46e648]!==_0x47b8('0x5a')){_0xfb8041[_0x46e648]=_0x1dce38[_0x46e648];}}_0x5c26c7(_0xfb8041);}else{_0x40ff24();}});},'VoiceChannels':function(_0x4bc93d){return new Promise(function(_0x4020f2,_0x2b46da){var _0x4a46eb=_[_0x47b8('0x5b')](_0x2279ea[_0x47b8('0x5c')]);_0x4020f2({'count':_0x4a46eb[_0x47b8('0x57')],'rows':_0x4a46eb});});},'VoiceChannelMixMonitor':function(_0x33ae87){var _0x223443=this;return new Promise(function(_0x167f24,_0x1b1733){if(ami[_0x47b8('0x14')]()==![]){return _0x1b1733(_0x223443['error'](0x1f4,[config[_0x47b8('0x16')]['ip'],config[_0x47b8('0x16')][_0x47b8('0x17')],'ami\x20disconnected'][_0x47b8('0x19')]('\x20')));}var _0x5645e6=schema(properties[_0x47b8('0x5d')])[_0x47b8('0x3')](_0x33ae87);if(_0x5645e6['length']>0x0){return _0x1b1733(_0x223443[_0x47b8('0x15')](0x1f4,_[_0x47b8('0x5e')](_0x5645e6,'message')[_0x47b8('0x19')](',\x20')));}var _0x263698=_[_0x47b8('0x58')](_0x2279ea['channels'],{'uniqueid':_0x33ae87[_0x47b8('0x5f')]});if(_0x263698&&_0x263698['channel']){var _0x178427=util['format'](_0x47b8('0x60'),_0x33ae87['filename']||_0x33ae87[_0x47b8('0x5f')],_0x33ae87[_0x47b8('0x9')]||_0x47b8('0x61'));return ami[_0x47b8('0x1e')]({'action':'MixMonitor','channel':_0x263698[_0x47b8('0x62')],'file':_0x178427,'options':_0x47b8('0x63')})[_0x47b8('0x22')](function(_0x115da1){var _0x586cf6=_[_0x47b8('0x58')](_0x263698[_0x47b8('0x64')],{'filename':_0x47b8('0x65')+_0x178427['toLowerCase']()});if(_['isNil'](_0x586cf6)){_0x263698[_0x47b8('0x64')]['push']({'filename':_0x47b8('0x65')+_0x178427[_0x47b8('0x66')](),'createdAt':moment()[_0x47b8('0x9')](_0x47b8('0x67')),'mixmonitorid':_0x115da1['mixmonitorid'],'status':_0x47b8('0x68')});}else{_0x586cf6[_0x47b8('0x69')]=_0x115da1[_0x47b8('0x69')];_0x586cf6['status']='rec';}_0x167f24({'code':0xc8,'message':[_0x33ae87[_0x47b8('0x5f')],_0x47b8('0x6a'),_0x115da1[_0x47b8('0x69')]]['join']('\x20'),'mixmonitorid':_0x115da1[_0x47b8('0x69')]});})[_0x47b8('0x1f')](function(_0x23a759){_0x1b1733(_0x223443[_0x47b8('0x15')](0x1f5,[_0x33ae87['uniqueid'],_0x23a759[_0x47b8('0x23')][_0x47b8('0x66')]()][_0x47b8('0x19')]('\x20')));});}else{return _0x1b1733(_0x223443['error'](0x1f5,_0x47b8('0x6b')));}});},'VoiceChannelStopMixMonitor':function(_0x480d8c){var _0x1311aa=this;return new Promise(function(_0x4fc8ac,_0x447ff7){if(ami[_0x47b8('0x14')]()==![]){return _0x447ff7(_0x1311aa[_0x47b8('0x15')](0x1f4,[config['asterisk']['ip'],config[_0x47b8('0x16')][_0x47b8('0x17')],'ami\x20disconnected'][_0x47b8('0x19')]('\x20')));}var _0x4e1aa7=schema(properties['voicechannel'])['validate'](_0x480d8c);if(_0x4e1aa7[_0x47b8('0x57')]>0x0){return _0x447ff7(_0x1311aa['error'](0x1f4,_[_0x47b8('0x5e')](_0x4e1aa7,'message')[_0x47b8('0x19')](',\x20')));}var _0x4be9dc=_[_0x47b8('0x58')](_0x2279ea[_0x47b8('0x5c')],{'uniqueid':_0x480d8c[_0x47b8('0x5f')]});if(_0x4be9dc){return BPromise[_0x47b8('0x6c')]()[_0x47b8('0x22')](function(){if(_0x4be9dc['channel']){return ami[_0x47b8('0x1e')]({'action':_0x47b8('0x6d'),'channel':_0x4be9dc[_0x47b8('0x62')],'mixmonitorid':_0x480d8c[_0x47b8('0x69')]})[_0x47b8('0x1f')](function(_0x4ada28){});}})[_0x47b8('0x22')](function(){if(_0x4be9dc[_0x47b8('0x6e')]){return ami['Action']({'action':_0x47b8('0x6d'),'channel':_0x4be9dc[_0x47b8('0x6e')],'mixmonitorid':_0x480d8c[_0x47b8('0x69')]})[_0x47b8('0x1f')](function(_0x5f3771){});}})[_0x47b8('0x22')](function(_0x226d29){var _0x44b461=_[_0x47b8('0x58')](_0x4be9dc[_0x47b8('0x64')],{'mixmonitorid':_0x480d8c[_0x47b8('0x69')]});if(_0x44b461){_0x44b461[_0x47b8('0x6f')]=_0x47b8('0x70');}})[_0x47b8('0x22')](function(){var _0xd55e85=util[_0x47b8('0x9')](_0x47b8('0x60'),_0x480d8c[_0x47b8('0x71')]||_0x480d8c[_0x47b8('0x5f')],_0x480d8c[_0x47b8('0x9')]||_0x47b8('0x61'));var _0x5e4b95=_[_0x47b8('0x58')](_0x4be9dc['monitors'],{'filename':_0x47b8('0x65')+_0xd55e85['toLowerCase']()});if(_0x5e4b95){_0x5e4b95[_0x47b8('0x6f')]=_0x47b8('0x70');}})[_0x47b8('0x22')](function(){_0x4fc8ac({'code':0xc8,'message':[_0x480d8c[_0x47b8('0x5f')],'StopMixMonitor\x20Success'][_0x47b8('0x19')]('\x20')});})[_0x47b8('0x1f')](function(_0x5a7cbe){_0x447ff7(_0x1311aa[_0x47b8('0x15')](0x1f5,[_0x480d8c[_0x47b8('0x5f')],_0x5a7cbe[_0x47b8('0x23')][_0x47b8('0x66')]()][_0x47b8('0x19')]('\x20')));});}else{return _0x447ff7(_0x1311aa[_0x47b8('0x15')](0x1f5,_0x47b8('0x6b')));}});},'VoiceQueuesChannels':function(_0x1a38fe){return new Promise(function(_0x56545b,_0x355d01){var _0x1246f9=_[_0x47b8('0x5b')](_0x2279ea[_0x47b8('0x72')]);_0x56545b({'count':_0x1246f9[_0x47b8('0x57')],'rows':_0x1246f9});});},'VoiceQueuesChannel':function(_0x3cf1b6){var _0x547df3=this;return new Promise(function(_0x578a3e,_0x1829f8){var _0xe2c20c=schema(properties[_0x47b8('0x73')])['validate'](_0x3cf1b6);if(_0xe2c20c['length']>0x0){return _0x1829f8(_0x547df3[_0x47b8('0x15')](0x1f4,_[_0x47b8('0x5e')](_0xe2c20c,_0x47b8('0x23'))['join'](',\x20')));}var _0x6ed009=_[_0x47b8('0x58')](_0x2279ea[_0x47b8('0x72')],{'uniqueid':_0x3cf1b6[_0x47b8('0x5f')]});if(_0x6ed009){_0x578a3e(_0x6ed009);}else{return _0x1829f8(_0x547df3[_0x47b8('0x15')](0x1f5,_0x47b8('0x6b')));}});},'VoiceQueuesChannelHangup':function(_0xbac225){var _0x4ad83a=this;return new Promise(function(_0xde73a6,_0x2930cc){if(ami['isConnected']()==![]){return _0x2930cc(_0x4ad83a[_0x47b8('0x15')](0x1f4,[config[_0x47b8('0x16')]['ip'],config['asterisk'][_0x47b8('0x17')],_0x47b8('0x18')]['join']('\x20')));}var _0xdf662d=schema(properties[_0x47b8('0x74')])['validate'](_0xbac225);if(_0xdf662d[_0x47b8('0x57')]>0x0){return _0x2930cc(_0x4ad83a['error'](0x1f4,_['map'](_0xdf662d,_0x47b8('0x23'))[_0x47b8('0x19')](',\x20')));}var _0x2ded9a=_[_0x47b8('0x58')](_0x2279ea[_0x47b8('0x72')],{'uniqueid':_0xbac225[_0x47b8('0x5f')]});if(_0x2ded9a&&_0x2ded9a[_0x47b8('0x62')]){return ami[_0x47b8('0x1e')]({'action':_0x47b8('0x75'),'channel':_0x2ded9a['channel']})['then'](function(_0x341bf5){_0xde73a6({'code':0xc8,'message':[_0xbac225[_0x47b8('0x5f')],_0x341bf5['message'][_0x47b8('0x66')]()]['join']('\x20')});})[_0x47b8('0x1f')](function(_0x116691){_0x2930cc(_0x4ad83a[_0x47b8('0x15')](0x1f5,[_0xbac225[_0x47b8('0x5f')],_0x116691[_0x47b8('0x23')][_0x47b8('0x66')]()][_0x47b8('0x19')]('\x20')));});}else{return _0x2930cc(_0x4ad83a[_0x47b8('0x15')](0x1f5,_0x47b8('0x6b')));}});},'VoiceQueuesChannelRedirect':function(_0x5e4b92){var _0x437cc5=this;return new Promise(function(_0x590577,_0x22f163){if(ami[_0x47b8('0x14')]()==![]){return _0x22f163(_0x437cc5['error'](0x1f4,[config[_0x47b8('0x16')]['ip'],config[_0x47b8('0x16')][_0x47b8('0x17')],_0x47b8('0x18')][_0x47b8('0x19')]('\x20')));}var _0x1dc765=schema(properties['voicequeuechannelredirect'])[_0x47b8('0x3')](_0x5e4b92);if(_0x1dc765[_0x47b8('0x57')]>0x0){return _0x22f163(_0x437cc5[_0x47b8('0x15')](0x1f4,_[_0x47b8('0x5e')](_0x1dc765,_0x47b8('0x23'))[_0x47b8('0x19')](',\x20')));}var _0x398d44=_['find'](_0x2279ea['queueChannels'],{'uniqueid':_0x5e4b92[_0x47b8('0x5f')]});if(_0x398d44&&_0x398d44[_0x47b8('0x62')]){return ami['Action']({'action':'Redirect','channel':_0x398d44[_0x47b8('0x62')],'exten':_0x5e4b92['exten'],'context':_0x5e4b92[_0x47b8('0x76')]||_0x398d44['context'],'priority':0x1})['then'](function(_0x438fc1){_0x590577({'code':0xc8,'message':[_0x5e4b92['uniqueid'],_0x438fc1['message'][_0x47b8('0x66')]()][_0x47b8('0x19')]('\x20')});})['catch'](function(_0x83c650){_0x22f163(_0x437cc5[_0x47b8('0x15')](0x1f5,[_0x5e4b92[_0x47b8('0x5f')],_0x83c650['message']['toLowerCase']()][_0x47b8('0x19')]('\x20')));});}else{return _0x22f163(_0x437cc5[_0x47b8('0x15')](0x1f5,_0x47b8('0x6b')));}});},'Agents':function(_0x19354e){return new Promise(function(_0x23bf13,_0x5237c3){var _0x41e4a7=_[_0x47b8('0x5b')](_0x2279ea[_0x47b8('0x10')]);_0x23bf13({'count':_0x41e4a7['length'],'rows':_0x41e4a7});});},'Telephones':function(_0x50cd3d){return new Promise(function(_0x2dab51,_0x182d57){var _0x37effe=_['values'](_0x2279ea['telephones']);_0x2dab51({'count':_0x37effe[_0x47b8('0x57')],'rows':_0x37effe});});},'Trunks':function(_0x5baf1a){return new Promise(function(_0x9d58bc,_0x45c6e0){var _0x5ab3be=_[_0x47b8('0x5b')](_0x2279ea[_0x47b8('0x77')]);_0x9d58bc({'count':_0x5ab3be['length'],'rows':_0x5ab3be});});},'OutboundChannels':function(_0x57e1f8){return new Promise(function(_0x398685,_0x4ef77b){var _0x4aa570=_[_0x47b8('0x5b')](_0x2279ea[_0x47b8('0x78')]);_0x398685({'count':_0x4aa570[_0x47b8('0x57')],'rows':_0x4aa570});});},'Outbound':function(_0x5703e3){return new Promise(function(_0x3559f4,_0x36e455){_0x3559f4(_0x2279ea[_0x47b8('0x32')]);});},'Campaigns':function(_0xe6cc93){return new Promise(function(_0x2faf37,_0x43c5ce){var _0x34e2cb=_['values'](_0x2279ea[_0x47b8('0x79')]);_0x2faf37({'count':_0x34e2cb[_0x47b8('0x57')],'rows':_0x34e2cb});});},'VoiceQueuesPreview':function(_0x347240){var _0x3c784e=this;return new Promise(function(_0x4281be,_0x289fa7){_0x7013d7[_0x47b8('0x7a')](_0x347240['id'])[_0x47b8('0x22')](function(_0x2136d0){_0x4281be({'code':0xc8,'message':_0x2136d0[_0x47b8('0x23')]});})[_0x47b8('0x1f')](function(_0x1b646e){_0x289fa7(_0x3c784e[_0x47b8('0x15')](0x1f4,_0x1b646e[_0x47b8('0x23')]));});});},'EventManager':function(_0x3df892){var _0x199933=this;return new Promise(function(_0x1524e6,_0x4690a5){if(!_0x3df892[_0x47b8('0x7b')]){return _0x4690a5(_0x199933[_0x47b8('0x15')](0x1f4,_0x47b8('0x7c')));}ami['emit'](_0x47b8('0x7d')+_0x3df892[_0x47b8('0x7b')],_0x3df892['message']);_0x1524e6({'code':0xc8,'message':_0x3df892});});},'FaxAccounts':function(_0xc2596d){return new Promise(function(_0xca5d3d,_0x349cc4){var _0x4dbf55=_[_0x47b8('0x5b')](_0x2279ea[_0x47b8('0x7e')]);_0xca5d3d({'count':_0x4dbf55[_0x47b8('0x57')],'rows':_0x4dbf55});});},'SendFax':function(_0xe0e869){var _0x3565ec=this;return new Promise(function(_0xd0a81a,_0xa7efe3){_0x2e6853[_0x47b8('0x7f')](_0xe0e869)[_0x47b8('0x22')](function(_0x37aa38){_0xd0a81a({'code':0xc8,'message':_0x37aa38[_0x47b8('0x23')]});})['catch'](function(_0x2ce472){_0xa7efe3(_0x3565ec[_0x47b8('0x15')](0x1f4,_0x2ce472[_0x47b8('0x23')]));});});},'CheckAfterSend':function(_0x3ed98e){var _0x3e1971=this;return new Promise(function(_0xc10a53,_0x579df5){_0x2e6853[_0x47b8('0x80')](_0x3ed98e)[_0x47b8('0x22')](function(_0x2db02c){_0xc10a53({'code':0xc8,'message':_0x2db02c['message']});})[_0x47b8('0x1f')](function(_0x542c38){_0x579df5(_0x3e1971[_0x47b8('0x15')](0x1f4,_0x542c38[_0x47b8('0x23')]));});});}};var _0x258f13=jayson[_0x47b8('0x81')](_0x3867ca)[_0x47b8('0x82')]();_0x258f13['on'](_0x47b8('0x15'),function(_0x74851f){return _0x53e656(_0x74851f);});_0x258f13['listen'](0x232a,_0x47b8('0x83'),function(){console[_0x47b8('0x84')]('AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!',0x232a);return _0xafe88a('RPC\x20listening\x20on\x20port:'+0x232a);});});};