3493aff9bee44f47f3059e70147c72ce4f4b4287
[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 _0xc9c3=['exten','context','trunks','outboundChannels','run','event','Event\x20name\x20mandatory','custom:','faxAccounts','send','checkAfterSend','http','log','AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','jayson/promise','bluebird','moment','../../../config/environment','../properties','../ami','listen','format','%s/%s','SIP','name','timers','agents','updateStatusRealtime','pause','asterisk','username','ami\x20disconnected','join','pick','module','then','message','catch','error','command','action','Command','Action','content','voiceQueues','hasOwnProperty','strategy','loggedIn','pTalking','sumBillable','sumDuration','sumHoldTime','total','unmanaged','abandoned','waiting','loggedInDb','outbound','dialActive','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialPrefix','temp','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','originated','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','startPredictive','startProgressive','Trunk','active','Interval','find','omit','undefined','values','channels','length','isConnected','voicechannel','validate','map','uniqueid','channel','wav','monitors','/var/spool/asterisk/monitor/','toLowerCase','isNil','push','YYYY-MM-DD\x20HH:mm:ss','mixmonitorid','rec','MixMonitor\x20Success','Channel\x20doesn\x27t\x20exist','resolve','destinationchannel','StopMixMonitor','status','stop','%s.%s','filename','StopMixMonitor\x20Success','voicequeuechannel','voicequeuechannelhangup','queueChannels','Redirect'];(function(_0x3051e5,_0x159597){var _0x2afeab=function(_0x2e9632){while(--_0x2e9632){_0x3051e5['push'](_0x3051e5['shift']());}};_0x2afeab(++_0x159597);}(_0xc9c3,0x96));var _0x3c9c=function(_0x25dd68,_0x4f806a){_0x25dd68=_0x25dd68-0x0;var _0x64ad9f=_0xc9c3[_0x25dd68];return _0x64ad9f;};'use strict';var _=require('lodash');var util=require('util');var jayson=require(_0x3c9c('0x0'));var schema=require('validate');var BPromise=require(_0x3c9c('0x1'));var moment=require(_0x3c9c('0x2'));var config=require(_0x3c9c('0x3'));var properties=require(_0x3c9c('0x4'));var ami=require(_0x3c9c('0x5'));exports[_0x3c9c('0x6')]=function(_0x143bfe,_0x512e80,_0x48b219){return new BPromise(function(_0x5c86bd,_0x5a2836){var _0x3ca0ce={'QueuePause':function(_0xc35e75){return new Promise(function(_0x2eb946,_0x3e5ccb){var _0x355ef3=util[_0x3c9c('0x7')](_0x3c9c('0x8'),_0x3c9c('0x9'),_0xc35e75[_0x3c9c('0xa')]);if(_0x143bfe['timers']&&_0x143bfe[_0x3c9c('0xb')][_0x355ef3]&&_0x143bfe[_0x3c9c('0xb')][_0x355ef3]['timer']){_0x143bfe[_0x3c9c('0xb')][_0x355ef3]['updateAcw']();}if(_0x143bfe[_0x3c9c('0xc')][_0x355ef3]){_0x143bfe[_0x3c9c('0xc')][_0x355ef3][_0x3c9c('0xd')]({'statePause':_0xc35e75[_0x3c9c('0xe')]?!![]:![]});}_0x2eb946({'code':0xc8,'message':'QueuePause'});});},'Reload':function(_0x50cf96){var _0x4a60d9=this;return new Promise(function(_0x857b1f,_0x59bbc6){if(ami['isConnected']()==![]){return _0x59bbc6(_0x4a60d9['error'](0x1f4,[config[_0x3c9c('0xf')]['ip'],config['asterisk'][_0x3c9c('0x10')],_0x3c9c('0x11')][_0x3c9c('0x12')]('\x20')));}_0x50cf96=_[_0x3c9c('0x13')](_0x50cf96,_['keys'](properties[_0x3c9c('0x14')]));_0x50cf96['action']='Reload';return ami['Action'](_0x50cf96)[_0x3c9c('0x15')](function(_0x32d94a){_0x857b1f({'code':0xc8,'message':_0x32d94a[_0x3c9c('0x16')]});})[_0x3c9c('0x17')](function(_0x3e63e0){_0x59bbc6(_0x4a60d9[_0x3c9c('0x18')](0x1f5,_0x3e63e0[_0x3c9c('0x16')]));});});},'Command':function(_0x56fa79){var _0x15a90a=this;return new Promise(function(_0x4c7122,_0x461711){if(ami['isConnected']()==![]){return _0x461711(_0x15a90a[_0x3c9c('0x18')](0x1f4,[config[_0x3c9c('0xf')]['ip'],config['asterisk'][_0x3c9c('0x10')],_0x3c9c('0x11')][_0x3c9c('0x12')]('\x20')));}_0x56fa79=_['pick'](_0x56fa79,_0x3c9c('0x19'));_0x56fa79[_0x3c9c('0x1a')]=_0x3c9c('0x1b');return ami[_0x3c9c('0x1c')](_0x56fa79)[_0x3c9c('0x15')](function(_0x3bc5c4){_0x4c7122({'code':0xc8,'message':_0x3bc5c4[_0x3c9c('0x1d')]});})[_0x3c9c('0x17')](function(_0x509bf7){_0x461711(_0x15a90a[_0x3c9c('0x18')](0x1f5,_0x509bf7['message']));});});},'VoiceQueues':function(_0x497145){return new Promise(function(_0xe04fca,_0x4ca078){var _0x527bb9=[];for(var _0x379880 in _0x143bfe[_0x3c9c('0x1e')]){if(_0x143bfe[_0x3c9c('0x1e')][_0x3c9c('0x1f')](_0x379880)){var _0x4c283d=_0x143bfe[_0x3c9c('0x1e')][_0x379880];var _0x65b831={'id':_0x4c283d['id'],'name':_0x4c283d['name'],'strategy':_0x4c283d[_0x3c9c('0x20')],'answered':_0x4c283d['answered'],'available':_0x4c283d['available'],'loggedIn':_0x4c283d[_0x3c9c('0x21')],'pTalking':_0x4c283d[_0x3c9c('0x22')],'sumBillable':_0x4c283d[_0x3c9c('0x23')],'sumDuration':_0x4c283d[_0x3c9c('0x24')],'sumHoldTime':_0x4c283d[_0x3c9c('0x25')]||0x0,'talking':_0x4c283d['talking'],'total':_0x4c283d[_0x3c9c('0x26')],'type':_0x4c283d['type'],'unmanaged':_0x4c283d[_0x3c9c('0x27')],'abandoned':_0x4c283d[_0x3c9c('0x28')],'waiting':_0x4c283d[_0x3c9c('0x29')],'loggedInDb':_0x4c283d[_0x3c9c('0x2a')]};if(_0x4c283d['type']===_0x3c9c('0x2b')){_0x65b831[_0x3c9c('0x2c')]=_0x4c283d[_0x3c9c('0x2c')];_0x65b831[_0x3c9c('0x2d')]=_0x4c283d[_0x3c9c('0x2d')];_0x65b831[_0x3c9c('0x2e')]=_0x4c283d[_0x3c9c('0x2e')];_0x65b831[_0x3c9c('0x2f')]=_0x4c283d['dialOriginateCallerIdNumber'];_0x65b831[_0x3c9c('0x30')]=_0x4c283d[_0x3c9c('0x30')];_0x65b831[_0x3c9c('0x31')]=_0x4c283d[_0x3c9c('0x31')];_0x65b831[_0x3c9c('0x32')]=_0x4c283d[_0x3c9c('0x32')];_0x65b831[_0x3c9c('0x33')]=_0x4c283d[_0x3c9c('0x33')];_0x65b831[_0x3c9c('0x34')]=_0x4c283d[_0x3c9c('0x34')];_0x65b831[_0x3c9c('0x35')]=_0x4c283d[_0x3c9c('0x35')];_0x65b831[_0x3c9c('0x36')]=_0x4c283d[_0x3c9c('0x36')];_0x65b831['outboundCongestionCallsDay']=_0x4c283d[_0x3c9c('0x37')];_0x65b831[_0x3c9c('0x38')]=_0x4c283d[_0x3c9c('0x38')];_0x65b831['outboundDropCallsDayCallersExit']=_0x4c283d[_0x3c9c('0x39')];_0x65b831[_0x3c9c('0x3a')]=_0x4c283d[_0x3c9c('0x3a')];_0x65b831[_0x3c9c('0x3b')]=_0x4c283d['outboundNoAnswerCallsDay'];_0x65b831['outboundNoSuchCallsDay']=_0x4c283d[_0x3c9c('0x3c')];_0x65b831[_0x3c9c('0x3d')]=_0x4c283d[_0x3c9c('0x3d')];_0x65b831['outboundReCallsDay']=_0x4c283d['outboundReCallsDay'];_0x65b831[_0x3c9c('0x3e')]=_0x4c283d['outboundRejectCallsDay'];_0x65b831['outboundUnknownCallsDay']=_0x4c283d[_0x3c9c('0x3f')];_0x65b831[_0x3c9c('0x40')]=_0x4c283d[_0x3c9c('0x40')];_0x65b831['predictiveIntervalAvgHoldtime']=_0x4c283d[_0x3c9c('0x41')];_0x65b831[_0x3c9c('0x42')]=_0x4c283d[_0x3c9c('0x42')];_0x65b831['predictiveIntervalDroppedCallsCallersExit']=_0x4c283d['predictiveIntervalDroppedCallsCallersExit'];_0x65b831['predictiveIntervalDroppedCallsTimeout']=_0x4c283d[_0x3c9c('0x43')];_0x65b831[_0x3c9c('0x44')]=_0x4c283d[_0x3c9c('0x44')];_0x65b831[_0x3c9c('0x45')]=_0x4c283d[_0x3c9c('0x45')];_0x65b831[_0x3c9c('0x46')]=_0x4c283d['predictiveIntervalHitRate'];_0x65b831['predictiveIntervalMultiplicativeFactor']=_0x4c283d[_0x3c9c('0x47')];_0x65b831[_0x3c9c('0x48')]=_0x4c283d[_0x3c9c('0x48')];_0x65b831['predictiveIntervalAvailable']=_0x4c283d[_0x3c9c('0x49')];_0x65b831[_0x3c9c('0x4a')]=_0x4c283d[_0x3c9c('0x4a')];_0x65b831['message']=_0x4c283d['message'];_0x65b831[_0x3c9c('0x4b')]=_0x4c283d[_0x3c9c('0x4b')];_0x65b831[_0x3c9c('0x4c')]=_0x4c283d['erlangCalls'];_0x65b831[_0x3c9c('0x4d')]=_0x4c283d[_0x3c9c('0x4d')];_0x65b831[_0x3c9c('0x4e')]=_0x4c283d[_0x3c9c('0x4e')];_0x65b831['erlangBusyFactor']=_0x4c283d[_0x3c9c('0x4f')];_0x65b831[_0x3c9c('0x50')]=_0x4c283d['startPredictive'];_0x65b831['startProgressive']=_0x4c283d[_0x3c9c('0x51')];}if(_0x4c283d[_0x3c9c('0x52')]){_0x65b831['Trunk']={'id':_0x4c283d[_0x3c9c('0x52')]['id'],'name':_0x4c283d[_0x3c9c('0x52')][_0x3c9c('0xa')],'active':_0x4c283d[_0x3c9c('0x52')][_0x3c9c('0x53')],'callerid':_0x4c283d[_0x3c9c('0x52')]['callerid']};}if(_0x4c283d[_0x3c9c('0x54')]){_0x65b831[_0x3c9c('0x54')]={'id':_0x4c283d[_0x3c9c('0x54')]['id'],'name':_0x4c283d[_0x3c9c('0x54')][_0x3c9c('0xa')]};}_0x527bb9['push'](_0x65b831);}}_0xe04fca({'count':_0x527bb9['length'],'rows':_0x527bb9});});},'UpdateVoiceQueue':function(_0x55a6ba){return new Promise(function(_0x3ff47a,_0x1da3e7){var _0x25285d=_[_0x3c9c('0x55')](_0x143bfe['voiceQueues'],{'id':parseInt(_0x55a6ba['id'])});var _0x798651=_[_0x3c9c('0x56')](_0x55a6ba,['id']);if(_0x25285d){for(var _0x27a013 in _0x798651){if(typeof _0x798651[_0x27a013]!==_0x3c9c('0x57')&&typeof _0x25285d[_0x27a013]!==_0x3c9c('0x57')){_0x25285d[_0x27a013]=_0x798651[_0x27a013];}}_0x3ff47a(_0x25285d);}else{_0x1da3e7();}});},'VoiceChannels':function(_0x58f6b7){return new Promise(function(_0x184c22,_0x1177b3){var _0x1804e3=_[_0x3c9c('0x58')](_0x143bfe[_0x3c9c('0x59')]);_0x184c22({'count':_0x1804e3[_0x3c9c('0x5a')],'rows':_0x1804e3});});},'VoiceChannelMixMonitor':function(_0x475fd6){var _0x5a74ce=this;return new Promise(function(_0x260d3b,_0x3a59f9){if(ami[_0x3c9c('0x5b')]()==![]){return _0x3a59f9(_0x5a74ce[_0x3c9c('0x18')](0x1f4,[config[_0x3c9c('0xf')]['ip'],config[_0x3c9c('0xf')]['username'],_0x3c9c('0x11')][_0x3c9c('0x12')]('\x20')));}var _0x2b0691=schema(properties[_0x3c9c('0x5c')])[_0x3c9c('0x5d')](_0x475fd6);if(_0x2b0691[_0x3c9c('0x5a')]>0x0){return _0x3a59f9(_0x5a74ce[_0x3c9c('0x18')](0x1f4,_[_0x3c9c('0x5e')](_0x2b0691,_0x3c9c('0x16'))[_0x3c9c('0x12')](',\x20')));}var _0x39b9d8=_[_0x3c9c('0x55')](_0x143bfe[_0x3c9c('0x59')],{'uniqueid':_0x475fd6[_0x3c9c('0x5f')]});if(_0x39b9d8&&_0x39b9d8[_0x3c9c('0x60')]){var _0x2b022f=util['format']('%s.%s',_0x475fd6['filename']||_0x475fd6[_0x3c9c('0x5f')],_0x475fd6[_0x3c9c('0x7')]||_0x3c9c('0x61'));return ami[_0x3c9c('0x1c')]({'action':'MixMonitor','channel':_0x39b9d8[_0x3c9c('0x60')],'file':_0x2b022f,'options':'ai(mixmonitorid)'})['then'](function(_0x34cd84){var _0x2849c6=_[_0x3c9c('0x55')](_0x39b9d8[_0x3c9c('0x62')],{'filename':_0x3c9c('0x63')+_0x2b022f[_0x3c9c('0x64')]()});if(_[_0x3c9c('0x65')](_0x2849c6)){_0x39b9d8[_0x3c9c('0x62')][_0x3c9c('0x66')]({'filename':'/var/spool/asterisk/monitor/'+_0x2b022f[_0x3c9c('0x64')](),'createdAt':moment()[_0x3c9c('0x7')](_0x3c9c('0x67')),'mixmonitorid':_0x34cd84[_0x3c9c('0x68')],'status':_0x3c9c('0x69')});}else{_0x2849c6[_0x3c9c('0x68')]=_0x34cd84[_0x3c9c('0x68')];_0x2849c6['status']='rec';}_0x260d3b({'code':0xc8,'message':[_0x475fd6[_0x3c9c('0x5f')],_0x3c9c('0x6a'),_0x34cd84[_0x3c9c('0x68')]][_0x3c9c('0x12')]('\x20'),'mixmonitorid':_0x34cd84[_0x3c9c('0x68')]});})[_0x3c9c('0x17')](function(_0x287ca1){_0x3a59f9(_0x5a74ce[_0x3c9c('0x18')](0x1f5,[_0x475fd6[_0x3c9c('0x5f')],_0x287ca1[_0x3c9c('0x16')][_0x3c9c('0x64')]()][_0x3c9c('0x12')]('\x20')));});}else{return _0x3a59f9(_0x5a74ce[_0x3c9c('0x18')](0x1f5,_0x3c9c('0x6b')));}});},'VoiceChannelStopMixMonitor':function(_0x581523){var _0x423891=this;return new Promise(function(_0x4306fe,_0x1b6f0a){if(ami[_0x3c9c('0x5b')]()==![]){return _0x1b6f0a(_0x423891[_0x3c9c('0x18')](0x1f4,[config['asterisk']['ip'],config[_0x3c9c('0xf')][_0x3c9c('0x10')],'ami\x20disconnected']['join']('\x20')));}var _0x1d810d=schema(properties[_0x3c9c('0x5c')])['validate'](_0x581523);if(_0x1d810d[_0x3c9c('0x5a')]>0x0){return _0x1b6f0a(_0x423891[_0x3c9c('0x18')](0x1f4,_[_0x3c9c('0x5e')](_0x1d810d,_0x3c9c('0x16'))[_0x3c9c('0x12')](',\x20')));}var _0x2264b7=_[_0x3c9c('0x55')](_0x143bfe[_0x3c9c('0x59')],{'uniqueid':_0x581523[_0x3c9c('0x5f')]});if(_0x2264b7){return BPromise[_0x3c9c('0x6c')]()[_0x3c9c('0x15')](function(){if(_0x2264b7['channel']){return ami[_0x3c9c('0x1c')]({'action':'StopMixMonitor','channel':_0x2264b7['channel'],'mixmonitorid':_0x581523[_0x3c9c('0x68')]})[_0x3c9c('0x17')](function(_0x1a1485){});}})[_0x3c9c('0x15')](function(){if(_0x2264b7[_0x3c9c('0x6d')]){return ami[_0x3c9c('0x1c')]({'action':_0x3c9c('0x6e'),'channel':_0x2264b7['destinationchannel'],'mixmonitorid':_0x581523[_0x3c9c('0x68')]})[_0x3c9c('0x17')](function(_0x31fb57){});}})[_0x3c9c('0x15')](function(_0x1cfaea){var _0x4fb887=_['find'](_0x2264b7[_0x3c9c('0x62')],{'mixmonitorid':_0x581523[_0x3c9c('0x68')]});if(_0x4fb887){_0x4fb887[_0x3c9c('0x6f')]=_0x3c9c('0x70');}})[_0x3c9c('0x15')](function(){var _0x990934=util[_0x3c9c('0x7')](_0x3c9c('0x71'),_0x581523[_0x3c9c('0x72')]||_0x581523[_0x3c9c('0x5f')],_0x581523[_0x3c9c('0x7')]||_0x3c9c('0x61'));var _0x4311c0=_[_0x3c9c('0x55')](_0x2264b7[_0x3c9c('0x62')],{'filename':_0x3c9c('0x63')+_0x990934[_0x3c9c('0x64')]()});if(_0x4311c0){_0x4311c0['status']=_0x3c9c('0x70');}})['then'](function(){_0x4306fe({'code':0xc8,'message':[_0x581523['uniqueid'],_0x3c9c('0x73')][_0x3c9c('0x12')]('\x20')});})[_0x3c9c('0x17')](function(_0x4b1b16){_0x1b6f0a(_0x423891[_0x3c9c('0x18')](0x1f5,[_0x581523[_0x3c9c('0x5f')],_0x4b1b16['message'][_0x3c9c('0x64')]()][_0x3c9c('0x12')]('\x20')));});}else{return _0x1b6f0a(_0x423891['error'](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'VoiceQueuesChannels':function(_0x5e4146){return new Promise(function(_0x1e93d7,_0x2fc65b){var _0xbc5b78=_[_0x3c9c('0x58')](_0x143bfe['queueChannels']);_0x1e93d7({'count':_0xbc5b78['length'],'rows':_0xbc5b78});});},'VoiceQueuesChannel':function(_0x2f2628){var _0x2dc609=this;return new Promise(function(_0x260a90,_0x94bc44){var _0x4342a9=schema(properties[_0x3c9c('0x74')])[_0x3c9c('0x5d')](_0x2f2628);if(_0x4342a9[_0x3c9c('0x5a')]>0x0){return _0x94bc44(_0x2dc609[_0x3c9c('0x18')](0x1f4,_['map'](_0x4342a9,'message')[_0x3c9c('0x12')](',\x20')));}var _0x5cf82a=_['find'](_0x143bfe['queueChannels'],{'uniqueid':_0x2f2628[_0x3c9c('0x5f')]});if(_0x5cf82a){_0x260a90(_0x5cf82a);}else{return _0x94bc44(_0x2dc609[_0x3c9c('0x18')](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'VoiceQueuesChannelHangup':function(_0x56effa){var _0x53ccaf=this;return new Promise(function(_0x482612,_0x77afb5){if(ami['isConnected']()==![]){return _0x77afb5(_0x53ccaf[_0x3c9c('0x18')](0x1f4,[config[_0x3c9c('0xf')]['ip'],config[_0x3c9c('0xf')]['username'],'ami\x20disconnected'][_0x3c9c('0x12')]('\x20')));}var _0x5ca292=schema(properties[_0x3c9c('0x75')])[_0x3c9c('0x5d')](_0x56effa);if(_0x5ca292[_0x3c9c('0x5a')]>0x0){return _0x77afb5(_0x53ccaf[_0x3c9c('0x18')](0x1f4,_['map'](_0x5ca292,_0x3c9c('0x16'))[_0x3c9c('0x12')](',\x20')));}var _0x5c1a13=_[_0x3c9c('0x55')](_0x143bfe[_0x3c9c('0x76')],{'uniqueid':_0x56effa['uniqueid']});if(_0x5c1a13&&_0x5c1a13[_0x3c9c('0x60')]){return ami[_0x3c9c('0x1c')]({'action':'Hangup','channel':_0x5c1a13[_0x3c9c('0x60')]})[_0x3c9c('0x15')](function(_0xab562a){_0x482612({'code':0xc8,'message':[_0x56effa['uniqueid'],_0xab562a['message'][_0x3c9c('0x64')]()][_0x3c9c('0x12')]('\x20')});})['catch'](function(_0x386197){_0x77afb5(_0x53ccaf[_0x3c9c('0x18')](0x1f5,[_0x56effa[_0x3c9c('0x5f')],_0x386197['message'][_0x3c9c('0x64')]()][_0x3c9c('0x12')]('\x20')));});}else{return _0x77afb5(_0x53ccaf['error'](0x1f5,_0x3c9c('0x6b')));}});},'VoiceQueuesChannelRedirect':function(_0x2cb21d){var _0xc4b7c9=this;return new Promise(function(_0x3caddb,_0x1ecabd){if(ami[_0x3c9c('0x5b')]()==![]){return _0x1ecabd(_0xc4b7c9[_0x3c9c('0x18')](0x1f4,[config[_0x3c9c('0xf')]['ip'],config[_0x3c9c('0xf')][_0x3c9c('0x10')],'ami\x20disconnected'][_0x3c9c('0x12')]('\x20')));}var _0x150a27=schema(properties['voicequeuechannelredirect'])[_0x3c9c('0x5d')](_0x2cb21d);if(_0x150a27[_0x3c9c('0x5a')]>0x0){return _0x1ecabd(_0xc4b7c9['error'](0x1f4,_[_0x3c9c('0x5e')](_0x150a27,_0x3c9c('0x16'))[_0x3c9c('0x12')](',\x20')));}var _0x17d23e=_[_0x3c9c('0x55')](_0x143bfe['queueChannels'],{'uniqueid':_0x2cb21d[_0x3c9c('0x5f')]});if(_0x17d23e&&_0x17d23e[_0x3c9c('0x60')]){return ami[_0x3c9c('0x1c')]({'action':_0x3c9c('0x77'),'channel':_0x17d23e[_0x3c9c('0x60')],'exten':_0x2cb21d[_0x3c9c('0x78')],'context':_0x2cb21d[_0x3c9c('0x79')]||_0x17d23e[_0x3c9c('0x79')],'priority':0x1})[_0x3c9c('0x15')](function(_0x36018f){_0x3caddb({'code':0xc8,'message':[_0x2cb21d[_0x3c9c('0x5f')],_0x36018f[_0x3c9c('0x16')][_0x3c9c('0x64')]()]['join']('\x20')});})[_0x3c9c('0x17')](function(_0x296e46){_0x1ecabd(_0xc4b7c9['error'](0x1f5,[_0x2cb21d[_0x3c9c('0x5f')],_0x296e46[_0x3c9c('0x16')][_0x3c9c('0x64')]()]['join']('\x20')));});}else{return _0x1ecabd(_0xc4b7c9[_0x3c9c('0x18')](0x1f5,_0x3c9c('0x6b')));}});},'Agents':function(_0x21c7c3){return new Promise(function(_0x285ebc,_0x478572){var _0x773eea=_['values'](_0x143bfe[_0x3c9c('0xc')]);_0x285ebc({'count':_0x773eea['length'],'rows':_0x773eea});});},'Telephones':function(_0x2265e8){return new Promise(function(_0x48a57f,_0x4950c3){var _0x263270=_['values'](_0x143bfe['telephones']);_0x48a57f({'count':_0x263270[_0x3c9c('0x5a')],'rows':_0x263270});});},'Trunks':function(_0x2f3a98){return new Promise(function(_0x14ccbc,_0x9b3118){var _0x2f4e79=_[_0x3c9c('0x58')](_0x143bfe[_0x3c9c('0x7a')]);_0x14ccbc({'count':_0x2f4e79[_0x3c9c('0x5a')],'rows':_0x2f4e79});});},'OutboundChannels':function(_0x2e6b96){return new Promise(function(_0x13e236,_0x1528a6){var _0x570ae6=_['values'](_0x143bfe[_0x3c9c('0x7b')]);_0x13e236({'count':_0x570ae6['length'],'rows':_0x570ae6});});},'Outbound':function(_0x552ec1){return new Promise(function(_0x3bb0c1,_0x1838d7){_0x3bb0c1(_0x143bfe[_0x3c9c('0x2b')]);});},'Campaigns':function(_0x1748c7){return new Promise(function(_0x2dec50,_0x57746d){var _0x105e67=_[_0x3c9c('0x58')](_0x143bfe['campaigns']);_0x2dec50({'count':_0x105e67['length'],'rows':_0x105e67});});},'VoiceQueuesPreview':function(_0x308a24){var _0x5f42c1=this;return new Promise(function(_0x2e3cab,_0x1ceaa3){_0x512e80[_0x3c9c('0x7c')](_0x308a24['id'])[_0x3c9c('0x15')](function(_0x327e63){_0x2e3cab({'code':0xc8,'message':_0x327e63[_0x3c9c('0x16')]});})[_0x3c9c('0x17')](function(_0x18012e){_0x1ceaa3(_0x5f42c1[_0x3c9c('0x18')](0x1f4,_0x18012e[_0x3c9c('0x16')]));});});},'EventManager':function(_0x52af3a){var _0x32690f=this;return new Promise(function(_0x2f5738,_0xf6f1ea){if(!_0x52af3a[_0x3c9c('0x7d')]){return _0xf6f1ea(_0x32690f['error'](0x1f4,_0x3c9c('0x7e')));}ami['emit'](_0x3c9c('0x7f')+_0x52af3a[_0x3c9c('0x7d')],_0x52af3a['message']);_0x2f5738({'code':0xc8,'message':_0x52af3a});});},'FaxAccounts':function(_0x22d2bd){return new Promise(function(_0x4cd7b9,_0x49559f){var _0x3d34e3=_[_0x3c9c('0x58')](_0x143bfe[_0x3c9c('0x80')]);_0x4cd7b9({'count':_0x3d34e3[_0x3c9c('0x5a')],'rows':_0x3d34e3});});},'SendFax':function(_0x17e5ce){var _0x5c96ad=this;return new Promise(function(_0x3e2f73,_0x48c11d){_0x48b219[_0x3c9c('0x81')](_0x17e5ce)['then'](function(_0x12bb7b){_0x3e2f73({'code':0xc8,'message':_0x12bb7b[_0x3c9c('0x16')]});})[_0x3c9c('0x17')](function(_0x19db8a){_0x48c11d(_0x5c96ad[_0x3c9c('0x18')](0x1f4,_0x19db8a[_0x3c9c('0x16')]));});});},'CheckAfterSend':function(_0x1fe080){var _0x41c07b=this;return new Promise(function(_0x557dc6,_0xa1de30){_0x48b219[_0x3c9c('0x82')](_0x1fe080)[_0x3c9c('0x15')](function(_0x5614df){_0x557dc6({'code':0xc8,'message':_0x5614df[_0x3c9c('0x16')]});})[_0x3c9c('0x17')](function(_0x37d2b6){_0xa1de30(_0x41c07b[_0x3c9c('0x18')](0x1f4,_0x37d2b6[_0x3c9c('0x16')]));});});}};var _0xdfe4f7=jayson['server'](_0x3ca0ce)[_0x3c9c('0x83')]();_0xdfe4f7['on'](_0x3c9c('0x18'),function(_0x2e158c){return _0x5a2836(_0x2e158c);});_0xdfe4f7[_0x3c9c('0x6')](0x232a,'127.0.0.1',function(){console[_0x3c9c('0x84')](_0x3c9c('0x85'),0x232a);return _0x5c86bd(_0x3c9c('0x86')+0x232a);});});};