047044fba87c9f448284fdc0c11a2781867b05a6
[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 _0xea22=['dialOriginateTimeout','dialPrefix','temp','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','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','callerid','Interval','push','length','omit','undefined','ami\x20disconnected','find','channels','uniqueid','%s.%s','filename','wav','MixMonitor','channel','monitors','/var/spool/asterisk/monitor/','toLowerCase','isNil','mixmonitorid','rec','MixMonitor\x20Success','Channel\x20doesn\x27t\x20exist','voicechannel','StopMixMonitor','destinationchannel','stop','status','values','voicequeuechannel','map','queueChannels','voicequeuechannelhangup','Hangup','Redirect','context','trunks','outboundChannels','campaigns','run','event','Event\x20name\x20mandatory','custom:','faxAccounts','send','checkAfterSend','http','listen','127.0.0.1','log','AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','util','validate','bluebird','moment','../../../config/environment','../ami','format','%s/%s','SIP','name','timers','timer','updateAcw','agents','updateStatusRealtime','pause','QueuePause','isConnected','error','asterisk','username','join','pick','module','action','Reload','Action','message','catch','command','Command','then','voiceQueues','hasOwnProperty','strategy','available','loggedIn','sumBillable','sumDuration','sumHoldTime','talking','total','type','unmanaged','abandoned','waiting','loggedInDb','outbound','dialActive','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber'];(function(_0x5e0870,_0x4b5b79){var _0x28a114=function(_0x4261b8){while(--_0x4261b8){_0x5e0870['push'](_0x5e0870['shift']());}};_0x28a114(++_0x4b5b79);}(_0xea22,0x16d));var _0x2ea2=function(_0x397342,_0x39f297){_0x397342=_0x397342-0x0;var _0x197051=_0xea22[_0x397342];return _0x197051;};'use strict';var _=require('lodash');var util=require(_0x2ea2('0x0'));var jayson=require('jayson/promise');var schema=require(_0x2ea2('0x1'));var BPromise=require(_0x2ea2('0x2'));var moment=require(_0x2ea2('0x3'));var config=require(_0x2ea2('0x4'));var properties=require('../properties');var ami=require(_0x2ea2('0x5'));exports['listen']=function(_0x4b926c,_0xcff7ab,_0x1656b9){return new BPromise(function(_0xa7fa31,_0x5652c2){var _0xeb9ec4={'QueuePause':function(_0x453999){return new Promise(function(_0x32a536,_0x46a4db){var _0xb94303=util[_0x2ea2('0x6')](_0x2ea2('0x7'),_0x2ea2('0x8'),_0x453999[_0x2ea2('0x9')]);if(_0x4b926c['timers']&&_0x4b926c['timers'][_0xb94303]&&_0x4b926c[_0x2ea2('0xa')][_0xb94303][_0x2ea2('0xb')]){_0x4b926c[_0x2ea2('0xa')][_0xb94303][_0x2ea2('0xc')]();}if(_0x4b926c[_0x2ea2('0xd')][_0xb94303]){_0x4b926c[_0x2ea2('0xd')][_0xb94303][_0x2ea2('0xe')]({'statePause':_0x453999[_0x2ea2('0xf')]?!![]:![]});}_0x32a536({'code':0xc8,'message':_0x2ea2('0x10')});});},'Reload':function(_0x2ba4e3){var _0x426e06=this;return new Promise(function(_0x166566,_0x4047e2){if(ami[_0x2ea2('0x11')]()==![]){return _0x4047e2(_0x426e06[_0x2ea2('0x12')](0x1f4,[config[_0x2ea2('0x13')]['ip'],config[_0x2ea2('0x13')][_0x2ea2('0x14')],'ami\x20disconnected'][_0x2ea2('0x15')]('\x20')));}_0x2ba4e3=_[_0x2ea2('0x16')](_0x2ba4e3,_['keys'](properties[_0x2ea2('0x17')]));_0x2ba4e3[_0x2ea2('0x18')]=_0x2ea2('0x19');return ami[_0x2ea2('0x1a')](_0x2ba4e3)['then'](function(_0x1f822c){_0x166566({'code':0xc8,'message':_0x1f822c[_0x2ea2('0x1b')]});})[_0x2ea2('0x1c')](function(_0x559dc8){_0x4047e2(_0x426e06[_0x2ea2('0x12')](0x1f5,_0x559dc8[_0x2ea2('0x1b')]));});});},'Command':function(_0x58dddc){var _0x2bffa5=this;return new Promise(function(_0x555688,_0x5e31c0){if(ami[_0x2ea2('0x11')]()==![]){return _0x5e31c0(_0x2bffa5[_0x2ea2('0x12')](0x1f4,[config[_0x2ea2('0x13')]['ip'],config['asterisk'][_0x2ea2('0x14')],'ami\x20disconnected']['join']('\x20')));}_0x58dddc=_['pick'](_0x58dddc,_0x2ea2('0x1d'));_0x58dddc['action']=_0x2ea2('0x1e');return ami[_0x2ea2('0x1a')](_0x58dddc)[_0x2ea2('0x1f')](function(_0x34630b){_0x555688({'code':0xc8,'message':_0x34630b['content']});})[_0x2ea2('0x1c')](function(_0xdb5d33){_0x5e31c0(_0x2bffa5['error'](0x1f5,_0xdb5d33['message']));});});},'VoiceQueues':function(_0x52ce63){return new Promise(function(_0x58818e,_0x22a2b0){var _0x3d4095=[];for(var _0x5ad5cd in _0x4b926c[_0x2ea2('0x20')]){if(_0x4b926c[_0x2ea2('0x20')][_0x2ea2('0x21')](_0x5ad5cd)){var _0x56d748=_0x4b926c[_0x2ea2('0x20')][_0x5ad5cd];var _0x1c991a={'id':_0x56d748['id'],'name':_0x56d748[_0x2ea2('0x9')],'strategy':_0x56d748[_0x2ea2('0x22')],'answered':_0x56d748['answered'],'available':_0x56d748[_0x2ea2('0x23')],'loggedIn':_0x56d748[_0x2ea2('0x24')],'pTalking':_0x56d748['pTalking'],'sumBillable':_0x56d748[_0x2ea2('0x25')],'sumDuration':_0x56d748[_0x2ea2('0x26')],'sumHoldTime':_0x56d748[_0x2ea2('0x27')]||0x0,'talking':_0x56d748[_0x2ea2('0x28')],'total':_0x56d748[_0x2ea2('0x29')],'type':_0x56d748[_0x2ea2('0x2a')],'unmanaged':_0x56d748[_0x2ea2('0x2b')],'abandoned':_0x56d748[_0x2ea2('0x2c')],'waiting':_0x56d748[_0x2ea2('0x2d')],'loggedInDb':_0x56d748[_0x2ea2('0x2e')]};if(_0x56d748['type']===_0x2ea2('0x2f')){_0x1c991a[_0x2ea2('0x30')]=_0x56d748['dialActive'];_0x1c991a[_0x2ea2('0x31')]=_0x56d748[_0x2ea2('0x31')];_0x1c991a['dialOriginateCallerIdName']=_0x56d748[_0x2ea2('0x32')];_0x1c991a[_0x2ea2('0x33')]=_0x56d748[_0x2ea2('0x33')];_0x1c991a[_0x2ea2('0x34')]=_0x56d748[_0x2ea2('0x34')];_0x1c991a[_0x2ea2('0x35')]=_0x56d748[_0x2ea2('0x35')];_0x1c991a[_0x2ea2('0x36')]=_0x56d748[_0x2ea2('0x36')];_0x1c991a[_0x2ea2('0x37')]=_0x56d748[_0x2ea2('0x37')];_0x1c991a[_0x2ea2('0x38')]=_0x56d748[_0x2ea2('0x38')];_0x1c991a['outboundBlacklistCallsDay']=_0x56d748[_0x2ea2('0x39')];_0x1c991a[_0x2ea2('0x3a')]=_0x56d748[_0x2ea2('0x3a')];_0x1c991a[_0x2ea2('0x3b')]=_0x56d748['outboundCongestionCallsDay'];_0x1c991a[_0x2ea2('0x3c')]=_0x56d748[_0x2ea2('0x3c')];_0x1c991a['outboundDropCallsDayCallersExit']=_0x56d748['outboundDropCallsDayCallersExit'];_0x1c991a[_0x2ea2('0x3d')]=_0x56d748[_0x2ea2('0x3d')];_0x1c991a[_0x2ea2('0x3e')]=_0x56d748['outboundNoAnswerCallsDay'];_0x1c991a['outboundNoSuchCallsDay']=_0x56d748[_0x2ea2('0x3f')];_0x1c991a[_0x2ea2('0x40')]=_0x56d748[_0x2ea2('0x40')];_0x1c991a[_0x2ea2('0x41')]=_0x56d748['outboundReCallsDay'];_0x1c991a[_0x2ea2('0x42')]=_0x56d748[_0x2ea2('0x42')];_0x1c991a[_0x2ea2('0x43')]=_0x56d748['outboundUnknownCallsDay'];_0x1c991a['predictiveIntervalAnsweredCalls']=_0x56d748[_0x2ea2('0x44')];_0x1c991a[_0x2ea2('0x45')]=_0x56d748[_0x2ea2('0x45')];_0x1c991a[_0x2ea2('0x46')]=_0x56d748['predictiveIntervalAvgTalktime'];_0x1c991a[_0x2ea2('0x47')]=_0x56d748[_0x2ea2('0x47')];_0x1c991a['predictiveIntervalDroppedCallsTimeout']=_0x56d748[_0x2ea2('0x48')];_0x1c991a[_0x2ea2('0x49')]=_0x56d748[_0x2ea2('0x49')];_0x1c991a[_0x2ea2('0x4a')]=_0x56d748[_0x2ea2('0x4a')];_0x1c991a[_0x2ea2('0x4b')]=_0x56d748[_0x2ea2('0x4b')];_0x1c991a[_0x2ea2('0x4c')]=_0x56d748[_0x2ea2('0x4c')];_0x1c991a[_0x2ea2('0x4d')]=_0x56d748[_0x2ea2('0x4d')];_0x1c991a[_0x2ea2('0x4e')]=_0x56d748['predictiveIntervalAvailable'];_0x1c991a[_0x2ea2('0x4f')]=_0x56d748['predictiveIntervalTotalCalls'];_0x1c991a[_0x2ea2('0x1b')]=_0x56d748[_0x2ea2('0x1b')];_0x1c991a[_0x2ea2('0x50')]=_0x56d748[_0x2ea2('0x50')];_0x1c991a[_0x2ea2('0x51')]=_0x56d748[_0x2ea2('0x51')];_0x1c991a[_0x2ea2('0x52')]=_0x56d748['erlangCallToSecond'];_0x1c991a[_0x2ea2('0x53')]=_0x56d748[_0x2ea2('0x53')];_0x1c991a['erlangBusyFactor']=_0x56d748[_0x2ea2('0x54')];_0x1c991a[_0x2ea2('0x55')]=_0x56d748[_0x2ea2('0x55')];_0x1c991a['startProgressive']=_0x56d748[_0x2ea2('0x56')];}if(_0x56d748[_0x2ea2('0x57')]){_0x1c991a['Trunk']={'id':_0x56d748[_0x2ea2('0x57')]['id'],'name':_0x56d748[_0x2ea2('0x57')]['name'],'active':_0x56d748[_0x2ea2('0x57')]['active'],'callerid':_0x56d748['Trunk'][_0x2ea2('0x58')]};}if(_0x56d748[_0x2ea2('0x59')]){_0x1c991a['Interval']={'id':_0x56d748[_0x2ea2('0x59')]['id'],'name':_0x56d748[_0x2ea2('0x59')][_0x2ea2('0x9')]};}_0x3d4095[_0x2ea2('0x5a')](_0x1c991a);}}_0x58818e({'count':_0x3d4095[_0x2ea2('0x5b')],'rows':_0x3d4095});});},'UpdateVoiceQueue':function(_0x58f68f){return new Promise(function(_0x24226e,_0x309f1c){var _0x2c1948=_['find'](_0x4b926c[_0x2ea2('0x20')],{'id':parseInt(_0x58f68f['id'])});var _0x3fc44a=_[_0x2ea2('0x5c')](_0x58f68f,['id']);if(_0x2c1948){for(var _0x3b7e34 in _0x3fc44a){if(typeof _0x3fc44a[_0x3b7e34]!==_0x2ea2('0x5d')&&typeof _0x2c1948[_0x3b7e34]!=='undefined'){_0x2c1948[_0x3b7e34]=_0x3fc44a[_0x3b7e34];}}_0x24226e(_0x2c1948);}else{_0x309f1c();}});},'VoiceChannels':function(_0x29c3f2){return new Promise(function(_0x1089e7,_0x26525f){var _0x441944=_['values'](_0x4b926c['channels']);_0x1089e7({'count':_0x441944['length'],'rows':_0x441944});});},'VoiceChannelMixMonitor':function(_0x40668a){var _0x290d10=this;return new Promise(function(_0x2ffd48,_0xca6eb7){if(ami[_0x2ea2('0x11')]()==![]){return _0xca6eb7(_0x290d10[_0x2ea2('0x12')](0x1f4,[config['asterisk']['ip'],config[_0x2ea2('0x13')][_0x2ea2('0x14')],_0x2ea2('0x5e')][_0x2ea2('0x15')]('\x20')));}var _0x5310b4=schema(properties['voicechannel'])['validate'](_0x40668a);if(_0x5310b4[_0x2ea2('0x5b')]>0x0){return _0xca6eb7(_0x290d10[_0x2ea2('0x12')](0x1f4,_['map'](_0x5310b4,'message')[_0x2ea2('0x15')](',\x20')));}var _0x437989=_[_0x2ea2('0x5f')](_0x4b926c[_0x2ea2('0x60')],{'uniqueid':_0x40668a[_0x2ea2('0x61')]});if(_0x437989&&_0x437989['channel']){var _0x60ed6b=util[_0x2ea2('0x6')](_0x2ea2('0x62'),_0x40668a[_0x2ea2('0x63')]||_0x40668a[_0x2ea2('0x61')],_0x40668a[_0x2ea2('0x6')]||_0x2ea2('0x64'));return ami['Action']({'action':_0x2ea2('0x65'),'channel':_0x437989[_0x2ea2('0x66')],'file':_0x60ed6b,'options':'ai(mixmonitorid)'})[_0x2ea2('0x1f')](function(_0x52b6c3){var _0x23825f=_['find'](_0x437989[_0x2ea2('0x67')],{'filename':_0x2ea2('0x68')+_0x60ed6b[_0x2ea2('0x69')]()});if(_[_0x2ea2('0x6a')](_0x23825f)){_0x437989[_0x2ea2('0x67')][_0x2ea2('0x5a')]({'filename':_0x2ea2('0x68')+_0x60ed6b[_0x2ea2('0x69')](),'createdAt':moment()[_0x2ea2('0x6')]('YYYY-MM-DD\x20HH:mm:ss'),'mixmonitorid':_0x52b6c3['mixmonitorid'],'status':'rec'});}else{_0x23825f[_0x2ea2('0x6b')]=_0x52b6c3[_0x2ea2('0x6b')];_0x23825f['status']=_0x2ea2('0x6c');}_0x2ffd48({'code':0xc8,'message':[_0x40668a[_0x2ea2('0x61')],_0x2ea2('0x6d'),_0x52b6c3[_0x2ea2('0x6b')]][_0x2ea2('0x15')]('\x20'),'mixmonitorid':_0x52b6c3['mixmonitorid']});})[_0x2ea2('0x1c')](function(_0x44d844){_0xca6eb7(_0x290d10['error'](0x1f5,[_0x40668a['uniqueid'],_0x44d844[_0x2ea2('0x1b')][_0x2ea2('0x69')]()][_0x2ea2('0x15')]('\x20')));});}else{return _0xca6eb7(_0x290d10[_0x2ea2('0x12')](0x1f5,_0x2ea2('0x6e')));}});},'VoiceChannelStopMixMonitor':function(_0x7e8d03){var _0x3aec83=this;return new Promise(function(_0x1875fe,_0x379859){if(ami['isConnected']()==![]){return _0x379859(_0x3aec83['error'](0x1f4,[config[_0x2ea2('0x13')]['ip'],config[_0x2ea2('0x13')][_0x2ea2('0x14')],'ami\x20disconnected'][_0x2ea2('0x15')]('\x20')));}var _0x2eec99=schema(properties[_0x2ea2('0x6f')])[_0x2ea2('0x1')](_0x7e8d03);if(_0x2eec99['length']>0x0){return _0x379859(_0x3aec83['error'](0x1f4,_['map'](_0x2eec99,_0x2ea2('0x1b'))[_0x2ea2('0x15')](',\x20')));}var _0x253c5c=_['find'](_0x4b926c[_0x2ea2('0x60')],{'uniqueid':_0x7e8d03[_0x2ea2('0x61')]});if(_0x253c5c){return BPromise['resolve']()['then'](function(){if(_0x253c5c[_0x2ea2('0x66')]){return ami[_0x2ea2('0x1a')]({'action':_0x2ea2('0x70'),'channel':_0x253c5c['channel'],'mixmonitorid':_0x7e8d03['mixmonitorid']})[_0x2ea2('0x1c')](function(_0x3b67b9){});}})['then'](function(){if(_0x253c5c[_0x2ea2('0x71')]){return ami[_0x2ea2('0x1a')]({'action':'StopMixMonitor','channel':_0x253c5c[_0x2ea2('0x71')],'mixmonitorid':_0x7e8d03[_0x2ea2('0x6b')]})[_0x2ea2('0x1c')](function(_0x6485c7){});}})[_0x2ea2('0x1f')](function(_0x45c2da){var _0x124a66=_[_0x2ea2('0x5f')](_0x253c5c[_0x2ea2('0x67')],{'mixmonitorid':_0x7e8d03['mixmonitorid']});if(_0x124a66){_0x124a66['status']=_0x2ea2('0x72');}})[_0x2ea2('0x1f')](function(){var _0x475a7b=util[_0x2ea2('0x6')](_0x2ea2('0x62'),_0x7e8d03[_0x2ea2('0x63')]||_0x7e8d03[_0x2ea2('0x61')],_0x7e8d03[_0x2ea2('0x6')]||_0x2ea2('0x64'));var _0x56a279=_[_0x2ea2('0x5f')](_0x253c5c['monitors'],{'filename':_0x2ea2('0x68')+_0x475a7b[_0x2ea2('0x69')]()});if(_0x56a279){_0x56a279[_0x2ea2('0x73')]=_0x2ea2('0x72');}})[_0x2ea2('0x1f')](function(){_0x1875fe({'code':0xc8,'message':[_0x7e8d03[_0x2ea2('0x61')],'StopMixMonitor\x20Success'][_0x2ea2('0x15')]('\x20')});})['catch'](function(_0x2d1d1c){_0x379859(_0x3aec83[_0x2ea2('0x12')](0x1f5,[_0x7e8d03[_0x2ea2('0x61')],_0x2d1d1c[_0x2ea2('0x1b')]['toLowerCase']()][_0x2ea2('0x15')]('\x20')));});}else{return _0x379859(_0x3aec83['error'](0x1f5,_0x2ea2('0x6e')));}});},'VoiceQueuesChannels':function(_0x21d09b){return new Promise(function(_0x4ce835,_0x4656d1){var _0x56ed70=_[_0x2ea2('0x74')](_0x4b926c['queueChannels']);_0x4ce835({'count':_0x56ed70[_0x2ea2('0x5b')],'rows':_0x56ed70});});},'VoiceQueuesChannel':function(_0x42b2d9){var _0xedce41=this;return new Promise(function(_0x2ed440,_0x17cfe0){var _0x37b0da=schema(properties[_0x2ea2('0x75')])[_0x2ea2('0x1')](_0x42b2d9);if(_0x37b0da[_0x2ea2('0x5b')]>0x0){return _0x17cfe0(_0xedce41[_0x2ea2('0x12')](0x1f4,_[_0x2ea2('0x76')](_0x37b0da,'message')[_0x2ea2('0x15')](',\x20')));}var _0x48e67b=_['find'](_0x4b926c[_0x2ea2('0x77')],{'uniqueid':_0x42b2d9[_0x2ea2('0x61')]});if(_0x48e67b){_0x2ed440(_0x48e67b);}else{return _0x17cfe0(_0xedce41[_0x2ea2('0x12')](0x1f5,_0x2ea2('0x6e')));}});},'VoiceQueuesChannelHangup':function(_0x130646){var _0x5ca705=this;return new Promise(function(_0x1a034f,_0x3bd1c6){if(ami[_0x2ea2('0x11')]()==![]){return _0x3bd1c6(_0x5ca705[_0x2ea2('0x12')](0x1f4,[config[_0x2ea2('0x13')]['ip'],config[_0x2ea2('0x13')][_0x2ea2('0x14')],_0x2ea2('0x5e')][_0x2ea2('0x15')]('\x20')));}var _0x257b22=schema(properties[_0x2ea2('0x78')])[_0x2ea2('0x1')](_0x130646);if(_0x257b22[_0x2ea2('0x5b')]>0x0){return _0x3bd1c6(_0x5ca705['error'](0x1f4,_[_0x2ea2('0x76')](_0x257b22,_0x2ea2('0x1b'))['join'](',\x20')));}var _0x1f956f=_['find'](_0x4b926c[_0x2ea2('0x77')],{'uniqueid':_0x130646[_0x2ea2('0x61')]});if(_0x1f956f&&_0x1f956f[_0x2ea2('0x66')]){return ami[_0x2ea2('0x1a')]({'action':_0x2ea2('0x79'),'channel':_0x1f956f[_0x2ea2('0x66')]})[_0x2ea2('0x1f')](function(_0x2b4815){_0x1a034f({'code':0xc8,'message':[_0x130646['uniqueid'],_0x2b4815[_0x2ea2('0x1b')][_0x2ea2('0x69')]()][_0x2ea2('0x15')]('\x20')});})[_0x2ea2('0x1c')](function(_0x1e2f18){_0x3bd1c6(_0x5ca705[_0x2ea2('0x12')](0x1f5,[_0x130646[_0x2ea2('0x61')],_0x1e2f18['message'][_0x2ea2('0x69')]()][_0x2ea2('0x15')]('\x20')));});}else{return _0x3bd1c6(_0x5ca705[_0x2ea2('0x12')](0x1f5,_0x2ea2('0x6e')));}});},'VoiceQueuesChannelRedirect':function(_0x1d72ff){var _0x5b179f=this;return new Promise(function(_0x5f5d68,_0xcf6fd3){if(ami[_0x2ea2('0x11')]()==![]){return _0xcf6fd3(_0x5b179f['error'](0x1f4,[config['asterisk']['ip'],config[_0x2ea2('0x13')][_0x2ea2('0x14')],_0x2ea2('0x5e')][_0x2ea2('0x15')]('\x20')));}var _0x241604=schema(properties['voicequeuechannelredirect'])[_0x2ea2('0x1')](_0x1d72ff);if(_0x241604[_0x2ea2('0x5b')]>0x0){return _0xcf6fd3(_0x5b179f[_0x2ea2('0x12')](0x1f4,_[_0x2ea2('0x76')](_0x241604,_0x2ea2('0x1b'))['join'](',\x20')));}var _0x1651bb=_[_0x2ea2('0x5f')](_0x4b926c[_0x2ea2('0x77')],{'uniqueid':_0x1d72ff['uniqueid']});if(_0x1651bb&&_0x1651bb[_0x2ea2('0x66')]){return ami['Action']({'action':_0x2ea2('0x7a'),'channel':_0x1651bb['channel'],'exten':_0x1d72ff['exten'],'context':_0x1d72ff[_0x2ea2('0x7b')]||_0x1651bb['context'],'priority':0x1})[_0x2ea2('0x1f')](function(_0x7a9c2f){_0x5f5d68({'code':0xc8,'message':[_0x1d72ff[_0x2ea2('0x61')],_0x7a9c2f[_0x2ea2('0x1b')][_0x2ea2('0x69')]()][_0x2ea2('0x15')]('\x20')});})[_0x2ea2('0x1c')](function(_0x58f2b4){_0xcf6fd3(_0x5b179f[_0x2ea2('0x12')](0x1f5,[_0x1d72ff[_0x2ea2('0x61')],_0x58f2b4[_0x2ea2('0x1b')][_0x2ea2('0x69')]()]['join']('\x20')));});}else{return _0xcf6fd3(_0x5b179f['error'](0x1f5,_0x2ea2('0x6e')));}});},'Agents':function(_0x9c04ad){return new Promise(function(_0x5e40fd,_0x5e7034){var _0xc2f67f=_[_0x2ea2('0x74')](_0x4b926c['agents']);_0x5e40fd({'count':_0xc2f67f[_0x2ea2('0x5b')],'rows':_0xc2f67f});});},'Telephones':function(_0x2be333){return new Promise(function(_0x46e597,_0x30cfca){var _0x185869=_[_0x2ea2('0x74')](_0x4b926c['telephones']);_0x46e597({'count':_0x185869[_0x2ea2('0x5b')],'rows':_0x185869});});},'Trunks':function(_0x3d18d9){return new Promise(function(_0x2b8348,_0x5525e8){var _0x1fe3b0=_['values'](_0x4b926c[_0x2ea2('0x7c')]);_0x2b8348({'count':_0x1fe3b0[_0x2ea2('0x5b')],'rows':_0x1fe3b0});});},'OutboundChannels':function(_0x2d999e){return new Promise(function(_0x5cd2ee,_0x450be4){var _0x1cbdfa=_[_0x2ea2('0x74')](_0x4b926c[_0x2ea2('0x7d')]);_0x5cd2ee({'count':_0x1cbdfa[_0x2ea2('0x5b')],'rows':_0x1cbdfa});});},'Outbound':function(_0x236663){return new Promise(function(_0x7453c3,_0x8207cf){_0x7453c3(_0x4b926c[_0x2ea2('0x2f')]);});},'Campaigns':function(_0x398756){return new Promise(function(_0x33fcec,_0x21f9e8){var _0x337d49=_['values'](_0x4b926c[_0x2ea2('0x7e')]);_0x33fcec({'count':_0x337d49[_0x2ea2('0x5b')],'rows':_0x337d49});});},'VoiceQueuesPreview':function(_0x220585){var _0x125f86=this;return new Promise(function(_0x4f4f7e,_0x44b62b){_0xcff7ab[_0x2ea2('0x7f')](_0x220585['id'])['then'](function(_0x3a2945){_0x4f4f7e({'code':0xc8,'message':_0x3a2945['message']});})[_0x2ea2('0x1c')](function(_0x7d2e7f){_0x44b62b(_0x125f86[_0x2ea2('0x12')](0x1f4,_0x7d2e7f['message']));});});},'EventManager':function(_0x500f7a){var _0x364d77=this;return new Promise(function(_0x293d6a,_0x2cedd1){if(!_0x500f7a[_0x2ea2('0x80')]){return _0x2cedd1(_0x364d77[_0x2ea2('0x12')](0x1f4,_0x2ea2('0x81')));}ami['emit'](_0x2ea2('0x82')+_0x500f7a[_0x2ea2('0x80')],_0x500f7a[_0x2ea2('0x1b')]);_0x293d6a({'code':0xc8,'message':_0x500f7a});});},'FaxAccounts':function(_0x47d218){return new Promise(function(_0x2f8dd8,_0x11047f){var _0x50b25e=_[_0x2ea2('0x74')](_0x4b926c[_0x2ea2('0x83')]);_0x2f8dd8({'count':_0x50b25e[_0x2ea2('0x5b')],'rows':_0x50b25e});});},'SendFax':function(_0x2d373c){var _0x473ab1=this;return new Promise(function(_0x13e643,_0x2860c0){_0x1656b9[_0x2ea2('0x84')](_0x2d373c)['then'](function(_0x1ba35c){_0x13e643({'code':0xc8,'message':_0x1ba35c[_0x2ea2('0x1b')]});})['catch'](function(_0x5980ac){_0x2860c0(_0x473ab1['error'](0x1f4,_0x5980ac[_0x2ea2('0x1b')]));});});},'CheckAfterSend':function(_0x596984){var _0xfacbef=this;return new Promise(function(_0x1691cf,_0xac3740){_0x1656b9[_0x2ea2('0x85')](_0x596984)[_0x2ea2('0x1f')](function(_0x3575c9){_0x1691cf({'code':0xc8,'message':_0x3575c9[_0x2ea2('0x1b')]});})[_0x2ea2('0x1c')](function(_0x163871){_0xac3740(_0xfacbef['error'](0x1f4,_0x163871['message']));});});}};var _0x8e2d2e=jayson['server'](_0xeb9ec4)[_0x2ea2('0x86')]();_0x8e2d2e['on'](_0x2ea2('0x12'),function(_0x4e0ee0){return _0x5652c2(_0x4e0ee0);});_0x8e2d2e[_0x2ea2('0x87')](0x232a,_0x2ea2('0x88'),function(){console[_0x2ea2('0x89')](_0x2ea2('0x8a'),0x232a);return _0xa7fa31('RPC\x20listening\x20on\x20port:'+0x232a);});});};