e67f9835f8e96bab2fa68296c6c03923ce4112d8
[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 _0xa264=['answered','available','loggedIn','pTalking','sumBillable','sumHoldTime','total','type','unmanaged','abandoned','waiting','dialActive','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialPrefix','temp','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundReCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','originated','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','startPredictive','startProgressive','Trunk','callerid','Interval','push','find','omit','undefined','values','channels','voicechannel','validate','length','map','uniqueid','%s.%s','filename','format','wav','channel','ai(mixmonitorid)','monitors','/var/spool/asterisk/monitor/','toLowerCase','isNil','YYYY-MM-DD\x20HH:mm:ss','mixmonitorid','rec','status','StopMixMonitor','destinationchannel','stop','queueChannels','voicequeuechannel','Channel\x20doesn\x27t\x20exist','voicequeuechannelhangup','voicequeuechannelredirect','Redirect','exten','agents','outboundChannels','campaigns','run','event','custom:','faxAccounts','send','checkAfterSend','http','listen','127.0.0.1','AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','util','jayson/promise','moment','../../../config/environment','../properties','%s/%s','timers','timer','updateAcw','updateStatusRealtime','pause','isConnected','error','asterisk','username','ami\x20disconnected','join','pick','keys','module','action','Reload','Action','then','message','catch','command','Command','content','voiceQueues','name'];(function(_0x5ecf84,_0x23a6e9){var _0x43488c=function(_0x2b09e6){while(--_0x2b09e6){_0x5ecf84['push'](_0x5ecf84['shift']());}};_0x43488c(++_0x23a6e9);}(_0xa264,0x170));var _0x4a26=function(_0x34ad72,_0x1e43f6){_0x34ad72=_0x34ad72-0x0;var _0x5c9aa8=_0xa264[_0x34ad72];return _0x5c9aa8;};'use strict';var _=require('lodash');var util=require(_0x4a26('0x0'));var jayson=require(_0x4a26('0x1'));var schema=require('validate');var BPromise=require('bluebird');var moment=require(_0x4a26('0x2'));var config=require(_0x4a26('0x3'));var properties=require(_0x4a26('0x4'));var ami=require('../ami');exports['listen']=function(_0x2b311f,_0x447891,_0x4d66a8){return new BPromise(function(_0xafa3c2,_0x4c6e35){var _0x47acf4={'QueuePause':function(_0x39cf64){return new Promise(function(_0x5e3e6f,_0x2d482c){var _0x173fdd=util['format'](_0x4a26('0x5'),'SIP',_0x39cf64['name']);if(_0x2b311f[_0x4a26('0x6')]&&_0x2b311f[_0x4a26('0x6')][_0x173fdd]&&_0x2b311f[_0x4a26('0x6')][_0x173fdd][_0x4a26('0x7')]){_0x2b311f[_0x4a26('0x6')][_0x173fdd][_0x4a26('0x8')]();}if(_0x2b311f['agents'][_0x173fdd]){_0x2b311f['agents'][_0x173fdd][_0x4a26('0x9')]({'statePause':_0x39cf64[_0x4a26('0xa')]?!![]:![]});}_0x5e3e6f({'code':0xc8,'message':'QueuePause'});});},'Reload':function(_0x155ad3){var _0x1082c6=this;return new Promise(function(_0x4ac3c2,_0x3a3064){if(ami[_0x4a26('0xb')]()==![]){return _0x3a3064(_0x1082c6[_0x4a26('0xc')](0x1f4,[config[_0x4a26('0xd')]['ip'],config[_0x4a26('0xd')][_0x4a26('0xe')],_0x4a26('0xf')][_0x4a26('0x10')]('\x20')));}_0x155ad3=_[_0x4a26('0x11')](_0x155ad3,_[_0x4a26('0x12')](properties[_0x4a26('0x13')]));_0x155ad3[_0x4a26('0x14')]=_0x4a26('0x15');return ami[_0x4a26('0x16')](_0x155ad3)[_0x4a26('0x17')](function(_0x27e197){_0x4ac3c2({'code':0xc8,'message':_0x27e197[_0x4a26('0x18')]});})[_0x4a26('0x19')](function(_0x15e377){_0x3a3064(_0x1082c6[_0x4a26('0xc')](0x1f5,_0x15e377[_0x4a26('0x18')]));});});},'Command':function(_0x468cf7){var _0x474474=this;return new Promise(function(_0x5a3966,_0x51adf0){if(ami['isConnected']()==![]){return _0x51adf0(_0x474474['error'](0x1f4,[config[_0x4a26('0xd')]['ip'],config['asterisk'][_0x4a26('0xe')],_0x4a26('0xf')]['join']('\x20')));}_0x468cf7=_[_0x4a26('0x11')](_0x468cf7,_0x4a26('0x1a'));_0x468cf7[_0x4a26('0x14')]=_0x4a26('0x1b');return ami[_0x4a26('0x16')](_0x468cf7)['then'](function(_0x2e82a3){_0x5a3966({'code':0xc8,'message':_0x2e82a3[_0x4a26('0x1c')]});})[_0x4a26('0x19')](function(_0x3cdf0a){_0x51adf0(_0x474474[_0x4a26('0xc')](0x1f5,_0x3cdf0a[_0x4a26('0x18')]));});});},'VoiceQueues':function(_0x2a7ed0){return new Promise(function(_0x2d26c6,_0x22ec7e){var _0x1a4878=[];for(var _0x2ab3fa in _0x2b311f[_0x4a26('0x1d')]){if(_0x2b311f[_0x4a26('0x1d')]['hasOwnProperty'](_0x2ab3fa)){var _0x220fe5=_0x2b311f[_0x4a26('0x1d')][_0x2ab3fa];var _0x5381d9={'id':_0x220fe5['id'],'name':_0x220fe5[_0x4a26('0x1e')],'strategy':_0x220fe5['strategy'],'answered':_0x220fe5[_0x4a26('0x1f')],'available':_0x220fe5[_0x4a26('0x20')],'loggedIn':_0x220fe5[_0x4a26('0x21')],'pTalking':_0x220fe5[_0x4a26('0x22')],'sumBillable':_0x220fe5[_0x4a26('0x23')],'sumDuration':_0x220fe5['sumDuration'],'sumHoldTime':_0x220fe5[_0x4a26('0x24')]||0x0,'talking':_0x220fe5['talking'],'total':_0x220fe5[_0x4a26('0x25')],'type':_0x220fe5[_0x4a26('0x26')],'unmanaged':_0x220fe5[_0x4a26('0x27')],'abandoned':_0x220fe5[_0x4a26('0x28')],'waiting':_0x220fe5[_0x4a26('0x29')],'loggedInDb':_0x220fe5['loggedInDb']};if(_0x220fe5[_0x4a26('0x26')]==='outbound'){_0x5381d9[_0x4a26('0x2a')]=_0x220fe5[_0x4a26('0x2a')];_0x5381d9[_0x4a26('0x2b')]=_0x220fe5['dialMethod'];_0x5381d9[_0x4a26('0x2c')]=_0x220fe5[_0x4a26('0x2c')];_0x5381d9[_0x4a26('0x2d')]=_0x220fe5[_0x4a26('0x2d')];_0x5381d9['dialOriginateTimeout']=_0x220fe5[_0x4a26('0x2e')];_0x5381d9[_0x4a26('0x2f')]=_0x220fe5[_0x4a26('0x2f')];_0x5381d9[_0x4a26('0x30')]=_0x220fe5[_0x4a26('0x30')];_0x5381d9[_0x4a26('0x31')]=_0x220fe5[_0x4a26('0x31')];_0x5381d9['outboundAnswerCallsDay']=_0x220fe5[_0x4a26('0x32')];_0x5381d9[_0x4a26('0x33')]=_0x220fe5[_0x4a26('0x33')];_0x5381d9[_0x4a26('0x34')]=_0x220fe5[_0x4a26('0x34')];_0x5381d9[_0x4a26('0x35')]=_0x220fe5[_0x4a26('0x35')];_0x5381d9[_0x4a26('0x36')]=_0x220fe5[_0x4a26('0x36')];_0x5381d9[_0x4a26('0x37')]=_0x220fe5[_0x4a26('0x37')];_0x5381d9[_0x4a26('0x38')]=_0x220fe5['outboundDropCallsDayTimeout'];_0x5381d9[_0x4a26('0x39')]=_0x220fe5[_0x4a26('0x39')];_0x5381d9[_0x4a26('0x3a')]=_0x220fe5[_0x4a26('0x3a')];_0x5381d9[_0x4a26('0x3b')]=_0x220fe5[_0x4a26('0x3b')];_0x5381d9[_0x4a26('0x3c')]=_0x220fe5[_0x4a26('0x3c')];_0x5381d9[_0x4a26('0x3d')]=_0x220fe5['outboundRejectCallsDay'];_0x5381d9['outboundUnknownCallsDay']=_0x220fe5[_0x4a26('0x3e')];_0x5381d9[_0x4a26('0x3f')]=_0x220fe5[_0x4a26('0x3f')];_0x5381d9[_0x4a26('0x40')]=_0x220fe5['predictiveIntervalAvgHoldtime'];_0x5381d9['predictiveIntervalAvgTalktime']=_0x220fe5[_0x4a26('0x41')];_0x5381d9['predictiveIntervalDroppedCallsCallersExit']=_0x220fe5[_0x4a26('0x42')];_0x5381d9[_0x4a26('0x43')]=_0x220fe5[_0x4a26('0x43')];_0x5381d9[_0x4a26('0x44')]=_0x220fe5[_0x4a26('0x44')];_0x5381d9[_0x4a26('0x45')]=_0x220fe5[_0x4a26('0x45')];_0x5381d9[_0x4a26('0x46')]=_0x220fe5[_0x4a26('0x46')];_0x5381d9['predictiveIntervalMultiplicativeFactor']=_0x220fe5[_0x4a26('0x47')];_0x5381d9['predictiveIntervalPauses']=_0x220fe5[_0x4a26('0x48')];_0x5381d9[_0x4a26('0x49')]=_0x220fe5['predictiveIntervalAvailable'];_0x5381d9[_0x4a26('0x4a')]=_0x220fe5[_0x4a26('0x4a')];_0x5381d9[_0x4a26('0x18')]=_0x220fe5[_0x4a26('0x18')];_0x5381d9[_0x4a26('0x4b')]=_0x220fe5[_0x4a26('0x4b')];_0x5381d9[_0x4a26('0x4c')]=_0x220fe5[_0x4a26('0x4c')];_0x5381d9[_0x4a26('0x4d')]=_0x220fe5['erlangCallToSecond'];_0x5381d9[_0x4a26('0x4e')]=_0x220fe5['erlangAbandonmentRate'];_0x5381d9['erlangBusyFactor']=_0x220fe5['erlangBusyFactor'];_0x5381d9['startPredictive']=_0x220fe5[_0x4a26('0x4f')];_0x5381d9[_0x4a26('0x50')]=_0x220fe5[_0x4a26('0x50')];}if(_0x220fe5[_0x4a26('0x51')]){_0x5381d9[_0x4a26('0x51')]={'id':_0x220fe5[_0x4a26('0x51')]['id'],'name':_0x220fe5[_0x4a26('0x51')][_0x4a26('0x1e')],'active':_0x220fe5[_0x4a26('0x51')]['active'],'callerid':_0x220fe5[_0x4a26('0x51')][_0x4a26('0x52')]};}if(_0x220fe5[_0x4a26('0x53')]){_0x5381d9[_0x4a26('0x53')]={'id':_0x220fe5[_0x4a26('0x53')]['id'],'name':_0x220fe5['Interval']['name']};}_0x1a4878[_0x4a26('0x54')](_0x5381d9);}}_0x2d26c6({'count':_0x1a4878['length'],'rows':_0x1a4878});});},'UpdateVoiceQueue':function(_0x5564fe){return new Promise(function(_0xf8251b,_0x181e0c){var _0x16050a=_[_0x4a26('0x55')](_0x2b311f['voiceQueues'],{'id':parseInt(_0x5564fe['id'])});var _0x24c8d7=_[_0x4a26('0x56')](_0x5564fe,['id']);if(_0x16050a){for(var _0x59783c in _0x24c8d7){if(typeof _0x24c8d7[_0x59783c]!==_0x4a26('0x57')&&typeof _0x16050a[_0x59783c]!=='undefined'){_0x16050a[_0x59783c]=_0x24c8d7[_0x59783c];}}_0xf8251b(_0x16050a);}else{_0x181e0c();}});},'VoiceChannels':function(_0x5622b8){return new Promise(function(_0x1e9359,_0x3949a0){var _0x38173f=_[_0x4a26('0x58')](_0x2b311f[_0x4a26('0x59')]);_0x1e9359({'count':_0x38173f['length'],'rows':_0x38173f});});},'VoiceChannelMixMonitor':function(_0x23d3f0){var _0x1a1912=this;return new Promise(function(_0x4a969c,_0x2595a0){if(ami[_0x4a26('0xb')]()==![]){return _0x2595a0(_0x1a1912['error'](0x1f4,[config[_0x4a26('0xd')]['ip'],config[_0x4a26('0xd')][_0x4a26('0xe')],_0x4a26('0xf')]['join']('\x20')));}var _0x1f95ea=schema(properties[_0x4a26('0x5a')])[_0x4a26('0x5b')](_0x23d3f0);if(_0x1f95ea[_0x4a26('0x5c')]>0x0){return _0x2595a0(_0x1a1912['error'](0x1f4,_[_0x4a26('0x5d')](_0x1f95ea,_0x4a26('0x18'))['join'](',\x20')));}var _0x5a9496=_[_0x4a26('0x55')](_0x2b311f[_0x4a26('0x59')],{'uniqueid':_0x23d3f0[_0x4a26('0x5e')]});if(_0x5a9496&&_0x5a9496['channel']){var _0x3ef002=util['format'](_0x4a26('0x5f'),_0x23d3f0[_0x4a26('0x60')]||_0x23d3f0[_0x4a26('0x5e')],_0x23d3f0[_0x4a26('0x61')]||_0x4a26('0x62'));return ami[_0x4a26('0x16')]({'action':'MixMonitor','channel':_0x5a9496[_0x4a26('0x63')],'file':_0x3ef002,'options':_0x4a26('0x64')})[_0x4a26('0x17')](function(_0xbf67c4){var _0x260ab7=_['find'](_0x5a9496[_0x4a26('0x65')],{'filename':_0x4a26('0x66')+_0x3ef002[_0x4a26('0x67')]()});if(_[_0x4a26('0x68')](_0x260ab7)){_0x5a9496[_0x4a26('0x65')][_0x4a26('0x54')]({'filename':_0x4a26('0x66')+_0x3ef002[_0x4a26('0x67')](),'createdAt':moment()['format'](_0x4a26('0x69')),'mixmonitorid':_0xbf67c4[_0x4a26('0x6a')],'status':_0x4a26('0x6b')});}else{_0x260ab7[_0x4a26('0x6a')]=_0xbf67c4[_0x4a26('0x6a')];_0x260ab7[_0x4a26('0x6c')]=_0x4a26('0x6b');}_0x4a969c({'code':0xc8,'message':[_0x23d3f0[_0x4a26('0x5e')],'MixMonitor\x20Success',_0xbf67c4[_0x4a26('0x6a')]][_0x4a26('0x10')]('\x20'),'mixmonitorid':_0xbf67c4['mixmonitorid']});})[_0x4a26('0x19')](function(_0x188bdb){_0x2595a0(_0x1a1912[_0x4a26('0xc')](0x1f5,[_0x23d3f0[_0x4a26('0x5e')],_0x188bdb[_0x4a26('0x18')][_0x4a26('0x67')]()][_0x4a26('0x10')]('\x20')));});}else{return _0x2595a0(_0x1a1912[_0x4a26('0xc')](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'VoiceChannelStopMixMonitor':function(_0x400fbb){var _0x27cc0e=this;return new Promise(function(_0x4a8d01,_0x3a5ec2){if(ami['isConnected']()==![]){return _0x3a5ec2(_0x27cc0e[_0x4a26('0xc')](0x1f4,[config[_0x4a26('0xd')]['ip'],config[_0x4a26('0xd')][_0x4a26('0xe')],_0x4a26('0xf')]['join']('\x20')));}var _0x4709d5=schema(properties[_0x4a26('0x5a')])['validate'](_0x400fbb);if(_0x4709d5[_0x4a26('0x5c')]>0x0){return _0x3a5ec2(_0x27cc0e['error'](0x1f4,_[_0x4a26('0x5d')](_0x4709d5,_0x4a26('0x18'))['join'](',\x20')));}var _0x5e7bf8=_['find'](_0x2b311f[_0x4a26('0x59')],{'uniqueid':_0x400fbb[_0x4a26('0x5e')]});if(_0x5e7bf8){return BPromise['resolve']()[_0x4a26('0x17')](function(){if(_0x5e7bf8[_0x4a26('0x63')]){return ami[_0x4a26('0x16')]({'action':_0x4a26('0x6d'),'channel':_0x5e7bf8[_0x4a26('0x63')],'mixmonitorid':_0x400fbb[_0x4a26('0x6a')]})[_0x4a26('0x19')](function(_0x2a8bea){});}})[_0x4a26('0x17')](function(){if(_0x5e7bf8[_0x4a26('0x6e')]){return ami[_0x4a26('0x16')]({'action':_0x4a26('0x6d'),'channel':_0x5e7bf8[_0x4a26('0x6e')],'mixmonitorid':_0x400fbb[_0x4a26('0x6a')]})[_0x4a26('0x19')](function(_0x23d019){});}})[_0x4a26('0x17')](function(_0x5b40e9){var _0x44b4c8=_['find'](_0x5e7bf8[_0x4a26('0x65')],{'mixmonitorid':_0x400fbb[_0x4a26('0x6a')]});if(_0x44b4c8){_0x44b4c8[_0x4a26('0x6c')]=_0x4a26('0x6f');}})[_0x4a26('0x17')](function(){var _0x404b28=util['format']('%s.%s',_0x400fbb[_0x4a26('0x60')]||_0x400fbb[_0x4a26('0x5e')],_0x400fbb[_0x4a26('0x61')]||_0x4a26('0x62'));var _0x4427f7=_[_0x4a26('0x55')](_0x5e7bf8[_0x4a26('0x65')],{'filename':_0x4a26('0x66')+_0x404b28[_0x4a26('0x67')]()});if(_0x4427f7){_0x4427f7[_0x4a26('0x6c')]=_0x4a26('0x6f');}})[_0x4a26('0x17')](function(){_0x4a8d01({'code':0xc8,'message':[_0x400fbb['uniqueid'],'StopMixMonitor\x20Success'][_0x4a26('0x10')]('\x20')});})['catch'](function(_0x199be8){_0x3a5ec2(_0x27cc0e[_0x4a26('0xc')](0x1f5,[_0x400fbb['uniqueid'],_0x199be8[_0x4a26('0x18')][_0x4a26('0x67')]()]['join']('\x20')));});}else{return _0x3a5ec2(_0x27cc0e['error'](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'VoiceQueuesChannels':function(_0xe5a78b){return new Promise(function(_0x532198,_0x544479){var _0x1044ba=_[_0x4a26('0x58')](_0x2b311f[_0x4a26('0x70')]);_0x532198({'count':_0x1044ba['length'],'rows':_0x1044ba});});},'VoiceQueuesChannel':function(_0x32af29){var _0x4e1051=this;return new Promise(function(_0x404253,_0x3c3af8){var _0x96bbf2=schema(properties[_0x4a26('0x71')])[_0x4a26('0x5b')](_0x32af29);if(_0x96bbf2['length']>0x0){return _0x3c3af8(_0x4e1051['error'](0x1f4,_[_0x4a26('0x5d')](_0x96bbf2,'message')['join'](',\x20')));}var _0x6f7335=_['find'](_0x2b311f[_0x4a26('0x70')],{'uniqueid':_0x32af29[_0x4a26('0x5e')]});if(_0x6f7335){_0x404253(_0x6f7335);}else{return _0x3c3af8(_0x4e1051[_0x4a26('0xc')](0x1f5,_0x4a26('0x72')));}});},'VoiceQueuesChannelHangup':function(_0x5851fb){var _0x461f3b=this;return new Promise(function(_0x1b6203,_0x31816f){if(ami[_0x4a26('0xb')]()==![]){return _0x31816f(_0x461f3b['error'](0x1f4,[config[_0x4a26('0xd')]['ip'],config[_0x4a26('0xd')][_0x4a26('0xe')],_0x4a26('0xf')][_0x4a26('0x10')]('\x20')));}var _0x1f1a4f=schema(properties[_0x4a26('0x73')])[_0x4a26('0x5b')](_0x5851fb);if(_0x1f1a4f[_0x4a26('0x5c')]>0x0){return _0x31816f(_0x461f3b[_0x4a26('0xc')](0x1f4,_[_0x4a26('0x5d')](_0x1f1a4f,_0x4a26('0x18'))[_0x4a26('0x10')](',\x20')));}var _0x42c42b=_[_0x4a26('0x55')](_0x2b311f[_0x4a26('0x70')],{'uniqueid':_0x5851fb[_0x4a26('0x5e')]});if(_0x42c42b&&_0x42c42b[_0x4a26('0x63')]){return ami[_0x4a26('0x16')]({'action':'Hangup','channel':_0x42c42b[_0x4a26('0x63')]})[_0x4a26('0x17')](function(_0x2b19f5){_0x1b6203({'code':0xc8,'message':[_0x5851fb[_0x4a26('0x5e')],_0x2b19f5['message'][_0x4a26('0x67')]()][_0x4a26('0x10')]('\x20')});})[_0x4a26('0x19')](function(_0x1ee3dc){_0x31816f(_0x461f3b[_0x4a26('0xc')](0x1f5,[_0x5851fb[_0x4a26('0x5e')],_0x1ee3dc[_0x4a26('0x18')][_0x4a26('0x67')]()][_0x4a26('0x10')]('\x20')));});}else{return _0x31816f(_0x461f3b[_0x4a26('0xc')](0x1f5,_0x4a26('0x72')));}});},'VoiceQueuesChannelRedirect':function(_0x2a0223){var _0x4dbcd7=this;return new Promise(function(_0x5eecb4,_0x4ff592){if(ami[_0x4a26('0xb')]()==![]){return _0x4ff592(_0x4dbcd7[_0x4a26('0xc')](0x1f4,[config['asterisk']['ip'],config[_0x4a26('0xd')][_0x4a26('0xe')],_0x4a26('0xf')][_0x4a26('0x10')]('\x20')));}var _0x1ee58d=schema(properties[_0x4a26('0x74')])[_0x4a26('0x5b')](_0x2a0223);if(_0x1ee58d[_0x4a26('0x5c')]>0x0){return _0x4ff592(_0x4dbcd7['error'](0x1f4,_[_0x4a26('0x5d')](_0x1ee58d,_0x4a26('0x18'))[_0x4a26('0x10')](',\x20')));}var _0x418347=_[_0x4a26('0x55')](_0x2b311f[_0x4a26('0x70')],{'uniqueid':_0x2a0223['uniqueid']});if(_0x418347&&_0x418347[_0x4a26('0x63')]){return ami[_0x4a26('0x16')]({'action':_0x4a26('0x75'),'channel':_0x418347[_0x4a26('0x63')],'exten':_0x2a0223[_0x4a26('0x76')],'context':_0x2a0223['context']||_0x418347['context'],'priority':0x1})['then'](function(_0x529374){_0x5eecb4({'code':0xc8,'message':[_0x2a0223[_0x4a26('0x5e')],_0x529374[_0x4a26('0x18')]['toLowerCase']()]['join']('\x20')});})[_0x4a26('0x19')](function(_0x4a018f){_0x4ff592(_0x4dbcd7[_0x4a26('0xc')](0x1f5,[_0x2a0223[_0x4a26('0x5e')],_0x4a018f[_0x4a26('0x18')]['toLowerCase']()][_0x4a26('0x10')]('\x20')));});}else{return _0x4ff592(_0x4dbcd7[_0x4a26('0xc')](0x1f5,_0x4a26('0x72')));}});},'Agents':function(_0x357592){return new Promise(function(_0x3325b4,_0x289533){var _0x42f9ed=_['values'](_0x2b311f[_0x4a26('0x77')]);_0x3325b4({'count':_0x42f9ed[_0x4a26('0x5c')],'rows':_0x42f9ed});});},'Telephones':function(_0x3cbcd3){return new Promise(function(_0x253cf5,_0x4f5680){var _0xdede46=_[_0x4a26('0x58')](_0x2b311f['telephones']);_0x253cf5({'count':_0xdede46[_0x4a26('0x5c')],'rows':_0xdede46});});},'Trunks':function(_0x390ec5){return new Promise(function(_0x240413,_0x3f1d53){var _0x4e11d1=_[_0x4a26('0x58')](_0x2b311f['trunks']);_0x240413({'count':_0x4e11d1['length'],'rows':_0x4e11d1});});},'OutboundChannels':function(_0x545050){return new Promise(function(_0x2b1ac3,_0x513cbf){var _0x31256c=_[_0x4a26('0x58')](_0x2b311f[_0x4a26('0x78')]);_0x2b1ac3({'count':_0x31256c[_0x4a26('0x5c')],'rows':_0x31256c});});},'Outbound':function(_0x20c5c4){return new Promise(function(_0x137618,_0x37e70b){_0x137618(_0x2b311f['outbound']);});},'Campaigns':function(_0x1e3eee){return new Promise(function(_0x4631e9,_0x4c2eaf){var _0x54e210=_['values'](_0x2b311f[_0x4a26('0x79')]);_0x4631e9({'count':_0x54e210[_0x4a26('0x5c')],'rows':_0x54e210});});},'VoiceQueuesPreview':function(_0x4a0c2d){var _0x5650cc=this;return new Promise(function(_0x6d2e1c,_0x1ccc33){_0x447891[_0x4a26('0x7a')](_0x4a0c2d['id'])[_0x4a26('0x17')](function(_0x164189){_0x6d2e1c({'code':0xc8,'message':_0x164189[_0x4a26('0x18')]});})[_0x4a26('0x19')](function(_0x2ee7cc){_0x1ccc33(_0x5650cc[_0x4a26('0xc')](0x1f4,_0x2ee7cc[_0x4a26('0x18')]));});});},'EventManager':function(_0x1758b9){var _0x2760d4=this;return new Promise(function(_0x17f763,_0x3afd2a){if(!_0x1758b9[_0x4a26('0x7b')]){return _0x3afd2a(_0x2760d4[_0x4a26('0xc')](0x1f4,'Event\x20name\x20mandatory'));}ami['emit'](_0x4a26('0x7c')+_0x1758b9[_0x4a26('0x7b')],_0x1758b9[_0x4a26('0x18')]);_0x17f763({'code':0xc8,'message':_0x1758b9});});},'FaxAccounts':function(_0x478bcf){return new Promise(function(_0xe62757,_0x2d4c27){var _0x3debbe=_[_0x4a26('0x58')](_0x2b311f[_0x4a26('0x7d')]);_0xe62757({'count':_0x3debbe[_0x4a26('0x5c')],'rows':_0x3debbe});});},'SendFax':function(_0x566cfe){var _0x4e2bfa=this;return new Promise(function(_0x4ddc62,_0x59b149){_0x4d66a8[_0x4a26('0x7e')](_0x566cfe)[_0x4a26('0x17')](function(_0x498372){_0x4ddc62({'code':0xc8,'message':_0x498372[_0x4a26('0x18')]});})['catch'](function(_0x555536){_0x59b149(_0x4e2bfa[_0x4a26('0xc')](0x1f4,_0x555536[_0x4a26('0x18')]));});});},'CheckAfterSend':function(_0x2f3ea7){var _0x3b536a=this;return new Promise(function(_0x4566a9,_0x1b3095){_0x4d66a8[_0x4a26('0x7f')](_0x2f3ea7)['then'](function(_0x488bf3){_0x4566a9({'code':0xc8,'message':_0x488bf3[_0x4a26('0x18')]});})['catch'](function(_0x5c17dd){_0x1b3095(_0x3b536a['error'](0x1f4,_0x5c17dd[_0x4a26('0x18')]));});});}};var _0x447a07=jayson['server'](_0x47acf4)[_0x4a26('0x80')]();_0x447a07['on'](_0x4a26('0xc'),function(_0x5ea637){return _0x4c6e35(_0x5ea637);});_0x447a07[_0x4a26('0x81')](0x232a,_0x4a26('0x82'),function(){console['log'](_0x4a26('0x83'),0x232a);return _0xafa3c2(_0x4a26('0x84')+0x232a);});});};