Built motion from commit (unavailable).|2.5.21
[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 _0x6d3d=['uniqueid','channel','%s.%s','filename','wav','MixMonitor','then','find','/var/spool/asterisk/monitor/','toLowerCase','isNil','monitors','push','YYYY-MM-DD\x20HH:mm:ss','mixmonitorid','status','rec','MixMonitor\x20Success','Channel\x20doesn\x27t\x20exist','voicechannel','resolve','StopMixMonitor','stop','StopMixMonitor\x20Success','queueChannels','voicequeuechannelhangup','voicequeuechannelredirect','Redirect','exten','context','values','telephones','outboundChannels','campaigns','run','Event\x20name\x20mandatory','emit','faxAccounts','send','checkAfterSend','server','127.0.0.1','log','RPC\x20listening\x20on\x20port:','util','jayson/promise','validate','bluebird','moment','../../../config/environment','../properties','../ami','listen','format','%s/%s','name','timers','agents','updateStatusRealtime','QueuePause','isConnected','error','asterisk','username','join','keys','action','Reload','Action','message','catch','ami\x20disconnected','pick','command','content','hasOwnProperty','voiceQueues','answered','available','loggedIn','pTalking','sumBillable','sumDuration','sumHoldTime','talking','total','type','waiting','outbound','dialActive','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialPrefix','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','active','Interval','length','channels','map'];(function(_0x29d94e,_0xf386d6){var _0x106237=function(_0x327501){while(--_0x327501){_0x29d94e['push'](_0x29d94e['shift']());}};_0x106237(++_0xf386d6);}(_0x6d3d,0x134));var _0xd6d3=function(_0xe6b23e,_0x25bafa){_0xe6b23e=_0xe6b23e-0x0;var _0x1f9428=_0x6d3d[_0xe6b23e];return _0x1f9428;};'use strict';var _=require('lodash');var util=require(_0xd6d3('0x0'));var jayson=require(_0xd6d3('0x1'));var schema=require(_0xd6d3('0x2'));var BPromise=require(_0xd6d3('0x3'));var moment=require(_0xd6d3('0x4'));var config=require(_0xd6d3('0x5'));var properties=require(_0xd6d3('0x6'));var ami=require(_0xd6d3('0x7'));exports[_0xd6d3('0x8')]=function(_0x5eec4d,_0x11f945,_0x11b54f){return new BPromise(function(_0x3d5565,_0x4b3232){var _0xd4332a={'QueuePause':function(_0x173a22){return new Promise(function(_0x3bc717,_0x98c598){var _0x1c1027=util[_0xd6d3('0x9')](_0xd6d3('0xa'),'SIP',_0x173a22[_0xd6d3('0xb')]);if(_0x5eec4d['timers']&&_0x5eec4d[_0xd6d3('0xc')][_0x1c1027]&&_0x5eec4d[_0xd6d3('0xc')][_0x1c1027]['timer']){_0x5eec4d[_0xd6d3('0xc')][_0x1c1027]['updateAcw']();}if(_0x5eec4d['agents'][_0x1c1027]){_0x5eec4d[_0xd6d3('0xd')][_0x1c1027][_0xd6d3('0xe')]({'statePause':_0x173a22['pause']?!![]:![]});}_0x3bc717({'code':0xc8,'message':_0xd6d3('0xf')});});},'Reload':function(_0x5de8ab){var _0x5c9649=this;return new Promise(function(_0x454d7a,_0x35306f){if(ami[_0xd6d3('0x10')]()==![]){return _0x35306f(_0x5c9649[_0xd6d3('0x11')](0x1f4,[config[_0xd6d3('0x12')]['ip'],config[_0xd6d3('0x12')][_0xd6d3('0x13')],'ami\x20disconnected'][_0xd6d3('0x14')]('\x20')));}_0x5de8ab=_['pick'](_0x5de8ab,_[_0xd6d3('0x15')](properties['module']));_0x5de8ab[_0xd6d3('0x16')]=_0xd6d3('0x17');return ami[_0xd6d3('0x18')](_0x5de8ab)['then'](function(_0x234e72){_0x454d7a({'code':0xc8,'message':_0x234e72[_0xd6d3('0x19')]});})[_0xd6d3('0x1a')](function(_0x2b7d0c){_0x35306f(_0x5c9649['error'](0x1f5,_0x2b7d0c[_0xd6d3('0x19')]));});});},'Command':function(_0x746322){var _0x378456=this;return new Promise(function(_0x4d606f,_0x30f74f){if(ami[_0xd6d3('0x10')]()==![]){return _0x30f74f(_0x378456[_0xd6d3('0x11')](0x1f4,[config['asterisk']['ip'],config[_0xd6d3('0x12')][_0xd6d3('0x13')],_0xd6d3('0x1b')][_0xd6d3('0x14')]('\x20')));}_0x746322=_[_0xd6d3('0x1c')](_0x746322,_0xd6d3('0x1d'));_0x746322[_0xd6d3('0x16')]='Command';return ami[_0xd6d3('0x18')](_0x746322)['then'](function(_0xcde34a){_0x4d606f({'code':0xc8,'message':_0xcde34a[_0xd6d3('0x1e')]});})[_0xd6d3('0x1a')](function(_0x34abb1){_0x30f74f(_0x378456[_0xd6d3('0x11')](0x1f5,_0x34abb1[_0xd6d3('0x19')]));});});},'VoiceQueues':function(_0x58db31){return new Promise(function(_0x245df4,_0x1feab6){var _0x2d6d34=[];for(var _0x5e67bc in _0x5eec4d['voiceQueues']){if(_0x5eec4d['voiceQueues'][_0xd6d3('0x1f')](_0x5e67bc)){var _0x42dd21=_0x5eec4d[_0xd6d3('0x20')][_0x5e67bc];var _0x34afdb={'id':_0x42dd21['id'],'name':_0x42dd21[_0xd6d3('0xb')],'strategy':_0x42dd21['strategy'],'answered':_0x42dd21[_0xd6d3('0x21')],'available':_0x42dd21[_0xd6d3('0x22')],'loggedIn':_0x42dd21[_0xd6d3('0x23')],'pTalking':_0x42dd21[_0xd6d3('0x24')],'sumBillable':_0x42dd21[_0xd6d3('0x25')],'sumDuration':_0x42dd21[_0xd6d3('0x26')],'sumHoldTime':_0x42dd21[_0xd6d3('0x27')]||0x0,'talking':_0x42dd21[_0xd6d3('0x28')],'total':_0x42dd21[_0xd6d3('0x29')],'type':_0x42dd21[_0xd6d3('0x2a')],'unmanaged':_0x42dd21['unmanaged'],'abandoned':_0x42dd21['abandoned'],'waiting':_0x42dd21[_0xd6d3('0x2b')],'loggedInDb':_0x42dd21['loggedInDb']};if(_0x42dd21[_0xd6d3('0x2a')]===_0xd6d3('0x2c')){_0x34afdb[_0xd6d3('0x2d')]=_0x42dd21[_0xd6d3('0x2d')];_0x34afdb[_0xd6d3('0x2e')]=_0x42dd21[_0xd6d3('0x2e')];_0x34afdb[_0xd6d3('0x2f')]=_0x42dd21['dialOriginateCallerIdName'];_0x34afdb[_0xd6d3('0x30')]=_0x42dd21[_0xd6d3('0x30')];_0x34afdb['dialOriginateTimeout']=_0x42dd21[_0xd6d3('0x31')];_0x34afdb[_0xd6d3('0x32')]=_0x42dd21[_0xd6d3('0x32')];_0x34afdb['outboundAnswerAgiCallsDay']=_0x42dd21['outboundAnswerAgiCallsDay'];_0x34afdb[_0xd6d3('0x33')]=_0x42dd21[_0xd6d3('0x33')];_0x34afdb[_0xd6d3('0x34')]=_0x42dd21[_0xd6d3('0x34')];_0x34afdb[_0xd6d3('0x35')]=_0x42dd21['outboundBusyCallsDay'];_0x34afdb[_0xd6d3('0x36')]=_0x42dd21['outboundCongestionCallsDay'];_0x34afdb['outboundDropCallsDayACS']=_0x42dd21[_0xd6d3('0x37')];_0x34afdb['outboundDropCallsDayCallersExit']=_0x42dd21['outboundDropCallsDayCallersExit'];_0x34afdb[_0xd6d3('0x38')]=_0x42dd21[_0xd6d3('0x38')];_0x34afdb[_0xd6d3('0x39')]=_0x42dd21[_0xd6d3('0x39')];_0x34afdb[_0xd6d3('0x3a')]=_0x42dd21[_0xd6d3('0x3a')];_0x34afdb[_0xd6d3('0x3b')]=_0x42dd21['outboundOriginateFailureCallsDay'];_0x34afdb[_0xd6d3('0x3c')]=_0x42dd21[_0xd6d3('0x3c')];_0x34afdb[_0xd6d3('0x3d')]=_0x42dd21[_0xd6d3('0x3d')];_0x34afdb[_0xd6d3('0x3e')]=_0x42dd21[_0xd6d3('0x3e')];_0x34afdb[_0xd6d3('0x3f')]=_0x42dd21['predictiveIntervalAnsweredCalls'];_0x34afdb[_0xd6d3('0x40')]=_0x42dd21[_0xd6d3('0x40')];_0x34afdb[_0xd6d3('0x41')]=_0x42dd21[_0xd6d3('0x41')];_0x34afdb['predictiveIntervalDroppedCallsCallersExit']=_0x42dd21[_0xd6d3('0x42')];_0x34afdb[_0xd6d3('0x43')]=_0x42dd21['predictiveIntervalDroppedCallsTimeout'];_0x34afdb['predictiveIntervalErlangCalls']=_0x42dd21[_0xd6d3('0x44')];_0x34afdb['predictiveIntervalErlangCallsDroppedCalls']=_0x42dd21[_0xd6d3('0x45')];_0x34afdb[_0xd6d3('0x46')]=_0x42dd21[_0xd6d3('0x46')];_0x34afdb['predictiveIntervalMultiplicativeFactor']=_0x42dd21[_0xd6d3('0x47')];_0x34afdb[_0xd6d3('0x48')]=_0x42dd21[_0xd6d3('0x48')];_0x34afdb[_0xd6d3('0x49')]=_0x42dd21[_0xd6d3('0x49')];_0x34afdb[_0xd6d3('0x4a')]=_0x42dd21[_0xd6d3('0x4a')];_0x34afdb['message']=_0x42dd21[_0xd6d3('0x19')];_0x34afdb[_0xd6d3('0x4b')]=_0x42dd21[_0xd6d3('0x4b')];_0x34afdb[_0xd6d3('0x4c')]=_0x42dd21[_0xd6d3('0x4c')];_0x34afdb['erlangCallToSecond']=_0x42dd21[_0xd6d3('0x4d')];_0x34afdb[_0xd6d3('0x4e')]=_0x42dd21['erlangAbandonmentRate'];_0x34afdb[_0xd6d3('0x4f')]=_0x42dd21[_0xd6d3('0x4f')];_0x34afdb['startPredictive']=_0x42dd21[_0xd6d3('0x50')];_0x34afdb[_0xd6d3('0x51')]=_0x42dd21[_0xd6d3('0x51')];}if(_0x42dd21['Trunk']){_0x34afdb['Trunk']={'id':_0x42dd21['Trunk']['id'],'name':_0x42dd21['Trunk']['name'],'active':_0x42dd21[_0xd6d3('0x52')][_0xd6d3('0x53')],'callerid':_0x42dd21[_0xd6d3('0x52')]['callerid']};}if(_0x42dd21[_0xd6d3('0x54')]){_0x34afdb[_0xd6d3('0x54')]={'id':_0x42dd21['Interval']['id'],'name':_0x42dd21['Interval'][_0xd6d3('0xb')]};}_0x2d6d34['push'](_0x34afdb);}}_0x245df4({'count':_0x2d6d34[_0xd6d3('0x55')],'rows':_0x2d6d34});});},'VoiceChannels':function(_0x300b55){return new Promise(function(_0x305616,_0xa51331){var _0x3a141c=_['values'](_0x5eec4d[_0xd6d3('0x56')]);_0x305616({'count':_0x3a141c[_0xd6d3('0x55')],'rows':_0x3a141c});});},'VoiceChannelMixMonitor':function(_0x50e60f){var _0x51a605=this;return new Promise(function(_0x1558b4,_0x47c13e){if(ami[_0xd6d3('0x10')]()==![]){return _0x47c13e(_0x51a605[_0xd6d3('0x11')](0x1f4,[config[_0xd6d3('0x12')]['ip'],config[_0xd6d3('0x12')][_0xd6d3('0x13')],_0xd6d3('0x1b')][_0xd6d3('0x14')]('\x20')));}var _0x48e838=schema(properties['voicechannel'])['validate'](_0x50e60f);if(_0x48e838[_0xd6d3('0x55')]>0x0){return _0x47c13e(_0x51a605[_0xd6d3('0x11')](0x1f4,_[_0xd6d3('0x57')](_0x48e838,'message')[_0xd6d3('0x14')](',\x20')));}var _0x1c49be=_['find'](_0x5eec4d[_0xd6d3('0x56')],{'uniqueid':_0x50e60f[_0xd6d3('0x58')]});if(_0x1c49be&&_0x1c49be[_0xd6d3('0x59')]){var _0x3dcb63=util['format'](_0xd6d3('0x5a'),_0x50e60f[_0xd6d3('0x5b')]||_0x50e60f[_0xd6d3('0x58')],_0x50e60f[_0xd6d3('0x9')]||_0xd6d3('0x5c'));return ami[_0xd6d3('0x18')]({'action':_0xd6d3('0x5d'),'channel':_0x1c49be[_0xd6d3('0x59')],'file':_0x3dcb63,'options':'ai(mixmonitorid)'})[_0xd6d3('0x5e')](function(_0x5d2703){var _0x4704f7=_[_0xd6d3('0x5f')](_0x1c49be['monitors'],{'filename':_0xd6d3('0x60')+_0x3dcb63[_0xd6d3('0x61')]()});if(_[_0xd6d3('0x62')](_0x4704f7)){_0x1c49be[_0xd6d3('0x63')][_0xd6d3('0x64')]({'filename':_0xd6d3('0x60')+_0x3dcb63[_0xd6d3('0x61')](),'createdAt':moment()[_0xd6d3('0x9')](_0xd6d3('0x65')),'mixmonitorid':_0x5d2703[_0xd6d3('0x66')],'status':'rec'});}else{_0x4704f7[_0xd6d3('0x66')]=_0x5d2703[_0xd6d3('0x66')];_0x4704f7[_0xd6d3('0x67')]=_0xd6d3('0x68');}_0x1558b4({'code':0xc8,'message':[_0x50e60f['uniqueid'],_0xd6d3('0x69'),_0x5d2703[_0xd6d3('0x66')]][_0xd6d3('0x14')]('\x20'),'mixmonitorid':_0x5d2703[_0xd6d3('0x66')]});})['catch'](function(_0x2d9bf9){_0x47c13e(_0x51a605['error'](0x1f5,[_0x50e60f[_0xd6d3('0x58')],_0x2d9bf9[_0xd6d3('0x19')]['toLowerCase']()][_0xd6d3('0x14')]('\x20')));});}else{return _0x47c13e(_0x51a605[_0xd6d3('0x11')](0x1f5,_0xd6d3('0x6a')));}});},'VoiceChannelStopMixMonitor':function(_0x1bdb24){var _0x27e22b=this;return new Promise(function(_0xd63624,_0x535a8b){if(ami[_0xd6d3('0x10')]()==![]){return _0x535a8b(_0x27e22b['error'](0x1f4,[config[_0xd6d3('0x12')]['ip'],config['asterisk'][_0xd6d3('0x13')],_0xd6d3('0x1b')][_0xd6d3('0x14')]('\x20')));}var _0x338aa5=schema(properties[_0xd6d3('0x6b')])[_0xd6d3('0x2')](_0x1bdb24);if(_0x338aa5[_0xd6d3('0x55')]>0x0){return _0x535a8b(_0x27e22b[_0xd6d3('0x11')](0x1f4,_[_0xd6d3('0x57')](_0x338aa5,_0xd6d3('0x19'))[_0xd6d3('0x14')](',\x20')));}var _0x486b48=_['find'](_0x5eec4d['channels'],{'uniqueid':_0x1bdb24[_0xd6d3('0x58')]});if(_0x486b48){return BPromise[_0xd6d3('0x6c')]()[_0xd6d3('0x5e')](function(){if(_0x486b48['channel']){return ami[_0xd6d3('0x18')]({'action':'StopMixMonitor','channel':_0x486b48[_0xd6d3('0x59')],'mixmonitorid':_0x1bdb24['mixmonitorid']})[_0xd6d3('0x1a')](function(_0x5a6e1e){});}})[_0xd6d3('0x5e')](function(){if(_0x486b48['destinationchannel']){return ami[_0xd6d3('0x18')]({'action':_0xd6d3('0x6d'),'channel':_0x486b48['destinationchannel'],'mixmonitorid':_0x1bdb24['mixmonitorid']})[_0xd6d3('0x1a')](function(_0x4f827f){});}})[_0xd6d3('0x5e')](function(_0x50722f){var _0x225788=_['find'](_0x486b48['monitors'],{'mixmonitorid':_0x1bdb24[_0xd6d3('0x66')]});if(_0x225788){_0x225788[_0xd6d3('0x67')]='stop';}})[_0xd6d3('0x5e')](function(){var _0x3243a0=util[_0xd6d3('0x9')](_0xd6d3('0x5a'),_0x1bdb24[_0xd6d3('0x5b')]||_0x1bdb24['uniqueid'],_0x1bdb24[_0xd6d3('0x9')]||_0xd6d3('0x5c'));var _0x41a8e3=_[_0xd6d3('0x5f')](_0x486b48['monitors'],{'filename':_0xd6d3('0x60')+_0x3243a0['toLowerCase']()});if(_0x41a8e3){_0x41a8e3[_0xd6d3('0x67')]=_0xd6d3('0x6e');}})['then'](function(){_0xd63624({'code':0xc8,'message':[_0x1bdb24[_0xd6d3('0x58')],_0xd6d3('0x6f')][_0xd6d3('0x14')]('\x20')});})[_0xd6d3('0x1a')](function(_0x3d2a8e){_0x535a8b(_0x27e22b[_0xd6d3('0x11')](0x1f5,[_0x1bdb24[_0xd6d3('0x58')],_0x3d2a8e[_0xd6d3('0x19')][_0xd6d3('0x61')]()][_0xd6d3('0x14')]('\x20')));});}else{return _0x535a8b(_0x27e22b['error'](0x1f5,_0xd6d3('0x6a')));}});},'VoiceQueuesChannels':function(_0x1404ac){return new Promise(function(_0x44db3a,_0x579ecb){var _0xbc656=_['values'](_0x5eec4d['queueChannels']);_0x44db3a({'count':_0xbc656[_0xd6d3('0x55')],'rows':_0xbc656});});},'VoiceQueuesChannel':function(_0x1251ce){var _0x30c01b=this;return new Promise(function(_0x2cff31,_0x51e1e2){var _0x397521=schema(properties['voicequeuechannel'])[_0xd6d3('0x2')](_0x1251ce);if(_0x397521[_0xd6d3('0x55')]>0x0){return _0x51e1e2(_0x30c01b[_0xd6d3('0x11')](0x1f4,_[_0xd6d3('0x57')](_0x397521,_0xd6d3('0x19'))[_0xd6d3('0x14')](',\x20')));}var _0xe9f6a9=_[_0xd6d3('0x5f')](_0x5eec4d[_0xd6d3('0x70')],{'uniqueid':_0x1251ce[_0xd6d3('0x58')]});if(_0xe9f6a9){_0x2cff31(_0xe9f6a9);}else{return _0x51e1e2(_0x30c01b['error'](0x1f5,_0xd6d3('0x6a')));}});},'VoiceQueuesChannelHangup':function(_0x298e50){var _0x13bcf3=this;return new Promise(function(_0x28f507,_0x67ff67){if(ami[_0xd6d3('0x10')]()==![]){return _0x67ff67(_0x13bcf3['error'](0x1f4,[config[_0xd6d3('0x12')]['ip'],config[_0xd6d3('0x12')][_0xd6d3('0x13')],_0xd6d3('0x1b')][_0xd6d3('0x14')]('\x20')));}var _0xb53100=schema(properties[_0xd6d3('0x71')])['validate'](_0x298e50);if(_0xb53100['length']>0x0){return _0x67ff67(_0x13bcf3[_0xd6d3('0x11')](0x1f4,_['map'](_0xb53100,_0xd6d3('0x19'))[_0xd6d3('0x14')](',\x20')));}var _0x55d148=_['find'](_0x5eec4d[_0xd6d3('0x70')],{'uniqueid':_0x298e50[_0xd6d3('0x58')]});if(_0x55d148&&_0x55d148[_0xd6d3('0x59')]){return ami['Action']({'action':'Hangup','channel':_0x55d148[_0xd6d3('0x59')]})[_0xd6d3('0x5e')](function(_0x44c1cb){_0x28f507({'code':0xc8,'message':[_0x298e50[_0xd6d3('0x58')],_0x44c1cb[_0xd6d3('0x19')][_0xd6d3('0x61')]()][_0xd6d3('0x14')]('\x20')});})[_0xd6d3('0x1a')](function(_0x15d9c0){_0x67ff67(_0x13bcf3[_0xd6d3('0x11')](0x1f5,[_0x298e50[_0xd6d3('0x58')],_0x15d9c0[_0xd6d3('0x19')][_0xd6d3('0x61')]()]['join']('\x20')));});}else{return _0x67ff67(_0x13bcf3[_0xd6d3('0x11')](0x1f5,_0xd6d3('0x6a')));}});},'VoiceQueuesChannelRedirect':function(_0xf9380e){var _0x4114fa=this;return new Promise(function(_0x2b25c1,_0x336e70){if(ami['isConnected']()==![]){return _0x336e70(_0x4114fa[_0xd6d3('0x11')](0x1f4,[config[_0xd6d3('0x12')]['ip'],config[_0xd6d3('0x12')][_0xd6d3('0x13')],_0xd6d3('0x1b')][_0xd6d3('0x14')]('\x20')));}var _0x176559=schema(properties[_0xd6d3('0x72')])['validate'](_0xf9380e);if(_0x176559[_0xd6d3('0x55')]>0x0){return _0x336e70(_0x4114fa[_0xd6d3('0x11')](0x1f4,_[_0xd6d3('0x57')](_0x176559,_0xd6d3('0x19'))[_0xd6d3('0x14')](',\x20')));}var _0x4e0a91=_[_0xd6d3('0x5f')](_0x5eec4d[_0xd6d3('0x70')],{'uniqueid':_0xf9380e[_0xd6d3('0x58')]});if(_0x4e0a91&&_0x4e0a91[_0xd6d3('0x59')]){return ami['Action']({'action':_0xd6d3('0x73'),'channel':_0x4e0a91[_0xd6d3('0x59')],'exten':_0xf9380e[_0xd6d3('0x74')],'context':_0xf9380e[_0xd6d3('0x75')]||_0x4e0a91[_0xd6d3('0x75')],'priority':0x1})['then'](function(_0x415a43){_0x2b25c1({'code':0xc8,'message':[_0xf9380e[_0xd6d3('0x58')],_0x415a43[_0xd6d3('0x19')][_0xd6d3('0x61')]()][_0xd6d3('0x14')]('\x20')});})[_0xd6d3('0x1a')](function(_0x488990){_0x336e70(_0x4114fa['error'](0x1f5,[_0xf9380e['uniqueid'],_0x488990['message']['toLowerCase']()]['join']('\x20')));});}else{return _0x336e70(_0x4114fa['error'](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'Agents':function(_0x402554){return new Promise(function(_0x165f85,_0x41ea8a){var _0x3456d8=_[_0xd6d3('0x76')](_0x5eec4d[_0xd6d3('0xd')]);_0x165f85({'count':_0x3456d8['length'],'rows':_0x3456d8});});},'Telephones':function(_0x55ff49){return new Promise(function(_0x30340b,_0x208eb1){var _0x1c04b4=_['values'](_0x5eec4d[_0xd6d3('0x77')]);_0x30340b({'count':_0x1c04b4[_0xd6d3('0x55')],'rows':_0x1c04b4});});},'Trunks':function(_0x1c48b8){return new Promise(function(_0x59279e,_0x20422e){var _0xbe2599=_[_0xd6d3('0x76')](_0x5eec4d['trunks']);_0x59279e({'count':_0xbe2599['length'],'rows':_0xbe2599});});},'OutboundChannels':function(_0x326387){return new Promise(function(_0x434df2,_0x2de1c2){var _0x17f8bf=_[_0xd6d3('0x76')](_0x5eec4d[_0xd6d3('0x78')]);_0x434df2({'count':_0x17f8bf[_0xd6d3('0x55')],'rows':_0x17f8bf});});},'Outbound':function(_0x5c36d7){return new Promise(function(_0x2b165b,_0x2698a9){_0x2b165b(_0x5eec4d[_0xd6d3('0x2c')]);});},'Campaigns':function(_0x565ae4){return new Promise(function(_0x23c4f1,_0x2a2d39){var _0x11f7a5=_[_0xd6d3('0x76')](_0x5eec4d[_0xd6d3('0x79')]);_0x23c4f1({'count':_0x11f7a5[_0xd6d3('0x55')],'rows':_0x11f7a5});});},'VoiceQueuesPreview':function(_0x4163a7){var _0x57107f=this;return new Promise(function(_0x5f302b,_0x5e813d){_0x11f945[_0xd6d3('0x7a')](_0x4163a7['id'])['then'](function(_0x30c9e8){_0x5f302b({'code':0xc8,'message':_0x30c9e8[_0xd6d3('0x19')]});})['catch'](function(_0x2e3e76){_0x5e813d(_0x57107f[_0xd6d3('0x11')](0x1f4,_0x2e3e76[_0xd6d3('0x19')]));});});},'EventManager':function(_0x51098e){var _0x17b33c=this;return new Promise(function(_0x568f23,_0x22826d){if(!_0x51098e['event']){return _0x22826d(_0x17b33c[_0xd6d3('0x11')](0x1f4,_0xd6d3('0x7b')));}ami[_0xd6d3('0x7c')]('custom:'+_0x51098e['event'],_0x51098e[_0xd6d3('0x19')]);_0x568f23({'code':0xc8,'message':_0x51098e});});},'FaxAccounts':function(_0x277a5d){return new Promise(function(_0x442169,_0x35ae9e){var _0x27a585=_['values'](_0x5eec4d[_0xd6d3('0x7d')]);_0x442169({'count':_0x27a585[_0xd6d3('0x55')],'rows':_0x27a585});});},'SendFax':function(_0x5407a7){var _0xcb895f=this;return new Promise(function(_0x9b7140,_0x5e0ab6){_0x11b54f[_0xd6d3('0x7e')](_0x5407a7)[_0xd6d3('0x5e')](function(_0x24c50){_0x9b7140({'code':0xc8,'message':_0x24c50[_0xd6d3('0x19')]});})[_0xd6d3('0x1a')](function(_0x1ed8a4){_0x5e0ab6(_0xcb895f[_0xd6d3('0x11')](0x1f4,_0x1ed8a4['message']));});});},'CheckAfterSend':function(_0x7af116){var _0x289a32=this;return new Promise(function(_0x177832,_0x109076){_0x11b54f[_0xd6d3('0x7f')](_0x7af116)[_0xd6d3('0x5e')](function(_0x536ad0){_0x177832({'code':0xc8,'message':_0x536ad0[_0xd6d3('0x19')]});})[_0xd6d3('0x1a')](function(_0x4d44d4){_0x109076(_0x289a32[_0xd6d3('0x11')](0x1f4,_0x4d44d4['message']));});});}};var _0xf34465=jayson[_0xd6d3('0x80')](_0xd4332a)['http']();_0xf34465['on'](_0xd6d3('0x11'),function(_0x38d356){return _0x4b3232(_0x38d356);});_0xf34465['listen'](0x232a,_0xd6d3('0x81'),function(){console[_0xd6d3('0x82')]('AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!',0x232a);return _0x3d5565(_0xd6d3('0x83')+0x232a);});});};