Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / services / agi / index.js
index 9e0beff..f9f0a6d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6f7f=['variables','stringify','[START]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','callerid','close','timeout','evtHangup','hangup','sync','production','start','joinAt','mxCell','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','traverseBFS','clear','agicommand','gotoc','gotoc\x20block\x20stop\x20traverse\x20BFS','context','extension','priority','result','response','toString','agicommand\x20not\x20found','finally','[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','isUndefined','Project\x20%s\x20not\x20published','continueAt','getLicense','voice','callysquare','[LICENSE]\x20CHANNELS:\x20UNLIMITED','[LICENSE]\x20VOICE\x20IS\x20DISABLED','[LICENSE]','./server','listening','lodash','syncho','util','moment','../../config/environment','agi','./rpc','./mailRpc','./graph','127.0.0.1','nextTick','error','log','info','format','[LISTENING]\x20Cally\x20Square\x20listening\x20%s:%d','port','message','[%s]\x20%s','[ERROR]\x20%s','[CLOSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','calleridname','dnid','uniqueid','stack','[HANGUP]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','mxGraphModel','root','hasOwnProperty','retry','maxRetry','addVertex','isArray','length','source','target','addEdge','then','createSquareReport','indexOf','agi_','substring','inspect','debug'];(function(_0x4a6fd0,_0x29621a){var _0x318b5a=function(_0x595e5a){while(--_0x595e5a){_0x4a6fd0['push'](_0x4a6fd0['shift']());}};_0x318b5a(++_0x29621a);}(_0x6f7f,0x177));var _0xf6f7=function(_0x4fa003,_0x42d436){_0x4fa003=_0x4fa003-0x0;var _0xfb4211=_0x6f7f[_0x4fa003];return _0xfb4211;};'use strict';var parser=require('xml2json');var _=require(_0xf6f7('0x0'));var syncho=require(_0xf6f7('0x1'));var util=require(_0xf6f7('0x2'));var moment=require(_0xf6f7('0x3'));var config=require(_0xf6f7('0x4'));var logger=require('../../config/logger')(_0xf6f7('0x5'));var utilLicense=require('../../config/license/util');var rpc=require(_0xf6f7('0x6'));var mailRpc=require(_0xf6f7('0x7'));var Graph=require(_0xf6f7('0x8'));var Vertices=require('./vertices');var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;config[_0xf6f7('0x5')]=_['defaults'](config[_0xf6f7('0x5')],{'ip':_0xf6f7('0x9'),'port':0x11dd});function connectionHandler(_0xe86f3a){process[_0xf6f7('0xa')](function(){syncho(function(){try{setChannelVariables(_0xe86f3a);agiHandler(_0xe86f3a);}catch(_0x2bf166){logger[_0xf6f7('0xb')](_0x2bf166['stack']);}});});}function listeningHandler(){console[_0xf6f7('0xc')]('Cally\x20Square\x20server\x20listening\x20on\x20port\x20%d!',config['agi']['port']);logger[_0xf6f7('0xd')](util[_0xf6f7('0xe')](_0xf6f7('0xf'),config[_0xf6f7('0x5')]['ip'],config[_0xf6f7('0x5')][_0xf6f7('0x10')]));}function errorHandler(_0x4def48){if(_0x4def48&&_0x4def48['name']&&_0x4def48[_0xf6f7('0x11')]){logger[_0xf6f7('0xb')](util[_0xf6f7('0xe')](_0xf6f7('0x12'),_0x4def48['name'],_0x4def48['message']));}else{logger[_0xf6f7('0xb')](util['format'](_0xf6f7('0x13'),_0x4def48['stack']));}}function closeHandler(){logger[_0xf6f7('0xd')](util[_0xf6f7('0xe')](_0xf6f7('0x14'),this[_0xf6f7('0x15')],this[_0xf6f7('0x16')],this['callerid'],this[_0xf6f7('0x17')],this[_0xf6f7('0x18')]));try{createSquareReport(this);}catch(_0x566589){logger[_0xf6f7('0xb')](_0x566589[_0xf6f7('0x19')]);}}function timeoutHandler(){logger[_0xf6f7('0xd')](util[_0xf6f7('0xe')]('[TIMEOUT]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this[_0xf6f7('0x15')],this[_0xf6f7('0x16')],this['callerid'],this[_0xf6f7('0x17')],this[_0xf6f7('0x18')]));}function hangupHandler(){logger[_0xf6f7('0xd')](util[_0xf6f7('0xe')](_0xf6f7('0x1a'),this[_0xf6f7('0x15')],this[_0xf6f7('0x16')],this['callerid'],this[_0xf6f7('0x17')],this['uniqueid']));this['evtHangup']=!![];}function getRoot(_0x66e5e4){return parser['toJson'](_0x66e5e4,{'object':!![]})[_0xf6f7('0x1b')][_0xf6f7('0x1c')];}function addVertex(_0x50b550,_0x3ce38d,_0x5ec44f){_0x3ce38d['agicommand']=_0x5ec44f;if(_0x3ce38d[_0xf6f7('0x1d')](_0xf6f7('0x1e'))){_0x3ce38d[_0xf6f7('0x1f')]=parseInt(_0x3ce38d[_0xf6f7('0x1e')],0xa);}_0x50b550[_0xf6f7('0x20')](_['omit'](_0x3ce38d,'mxCell'));}function initGraph(_0x3fecc1,_0x2620a4){var _0x277023=new Graph();for(var _0x1de269 in _0x3fecc1){if(_0x3fecc1[_0xf6f7('0x1d')](_0x1de269)){if(_[_0xf6f7('0x21')](_0x3fecc1[_0x1de269])){for(var _0x4b6e82=0x0;_0x4b6e82<_0x3fecc1[_0x1de269][_0xf6f7('0x22')];_0x4b6e82+=0x1){addVertex(_0x277023,_0x3fecc1[_0x1de269][_0x4b6e82],_0x1de269);}}else{addVertex(_0x277023,_0x3fecc1[_0x1de269],_0x1de269);}}}for(var _0x2c545c=0x0;_0x2c545c<_0x2620a4[_0xf6f7('0x22')];_0x2c545c+=0x1){if(_0x2620a4[_0x2c545c][_0xf6f7('0x23')]&&_0x2620a4[_0x2c545c][_0xf6f7('0x24')]){_0x277023[_0xf6f7('0x25')](_0x2620a4[_0x2c545c][_0xf6f7('0x23')],_0x2620a4[_0x2c545c]['target'],_0x2620a4[_0x2c545c]['value']);}}return _0x277023;}function getSquareProject(_0x4bd86c,_0x3bd11b){rpc['getSquareProject'](_0x4bd86c)[_0xf6f7('0x26')](function(_0x35b586){_0x3bd11b(null,_0x35b586);})['catch'](function(_0x50ef5b){_0x3bd11b(null,_0x50ef5b);});}function createSquareReport(_0x3b85db,_0x26610f){rpc[_0xf6f7('0x27')](_0x3b85db)['then'](function(_0x2fcb7c){if(_0x26610f){_0x26610f(null,_0x2fcb7c);}})['catch'](function(_0x34b223){if(_0x26610f){_0x26610f(null,_0x34b223);}});}function setChannelVariables(_0x2b0faf){for(var _0x958646 in _0x2b0faf){if(_0x2b0faf[_0xf6f7('0x1d')](_0x958646)){if(_0x958646[_0xf6f7('0x28')](_0xf6f7('0x29'))===0x0){_0x2b0faf[_0x958646[_0xf6f7('0x2a')](0x4)]=_0x2b0faf[_0x958646];delete _0x2b0faf[_0x958646];}}}}function getLogFromObject(_0x257af4){return util[_0xf6f7('0x2b')](_0x257af4,{'showHidden':![],'depth':null});}function agiHandler(_0x174730){var _0xd755e6,_0x4589c4,_0x5883e3,_0x3fbdb6,_0x55e336;logger[_0xf6f7('0x2c')](_0xf6f7('0x2d'),JSON[_0xf6f7('0x2e')](_0x174730,null,0x2));logger[_0xf6f7('0xd')](util[_0xf6f7('0xe')](_0xf6f7('0x2f'),_0x174730[_0xf6f7('0x15')],_0x174730[_0xf6f7('0x16')],_0x174730[_0xf6f7('0x30')],_0x174730['dnid'],_0x174730['uniqueid']));_0x174730['on'](_0xf6f7('0xb'),errorHandler);_0x174730['on'](_0xf6f7('0x31'),closeHandler);_0x174730['on'](_0xf6f7('0x32'),timeoutHandler);_0x174730[_0xf6f7('0x33')]=![];_0x174730['on'](_0xf6f7('0x34'),hangupHandler);var _0x41975f=getSquareProject[_0xf6f7('0x35')](null,_0x174730[_0xf6f7('0x15')]);if(_0x41975f){if(_0x41975f[_0xf6f7('0x36')]){_0xd755e6=getRoot(_0x41975f[_0xf6f7('0x36')]);if(_0xd755e6&&_0xd755e6[_0xf6f7('0x37')]){logger[_0xf6f7('0x2c')](_0xf6f7('0x1c'),JSON[_0xf6f7('0x2e')](_0xd755e6,null,0x2));_0x174730[_0xf6f7('0x38')]=moment()[_0xf6f7('0xe')]('YYYY-MM-DD\x20HH:mm:ss');_0x4589c4=initGraph(_['omit'](_0xd755e6,_0xf6f7('0x39')),_0xd755e6[_0xf6f7('0x39')]);_0x5883e3=new Vertices(_0x174730,rpc,mailRpc);logger[_0xf6f7('0xd')](util[_0xf6f7('0xe')](_0xf6f7('0x3a'),_0x174730[_0xf6f7('0x15')],_0x174730['calleridname'],_0x174730[_0xf6f7('0x30')],_0x174730[_0xf6f7('0x17')],_0x174730[_0xf6f7('0x18')]));_0x4589c4[_0xf6f7('0x3b')](_0xd755e6['start']['id'],function(_0x489c39){try{_0x489c39=_0x5883e3[_0xf6f7('0x3c')](_0x489c39);logger['debug']('vertex',JSON[_0xf6f7('0x2e')](_0x489c39,null,0x2));if(_0x489c39[_0xf6f7('0x3d')]===_0xf6f7('0x3e')){logger['info'](_0xf6f7('0x3f'));_0x174730[_0xf6f7('0x40')]=_0x489c39[_0xf6f7('0x40')]||_0x174730[_0xf6f7('0x40')];_0x174730['extension']=_0x489c39[_0xf6f7('0x41')];_0x174730[_0xf6f7('0x42')]=_0x489c39['priority']?_0x489c39['priority']-0x1:0x1;return null;}else if(_0x489c39&&_0x5883e3[_0x489c39[_0xf6f7('0x3d')]]){_0x55e336=_0x5883e3[_0x489c39['agicommand']](_0x489c39);logger[_0xf6f7('0xd')]('response',JSON['stringify'](_0x55e336,null,0x2));if(_0x55e336&&_0x55e336['code']===AGI_CODE_SUCCESS&&_0x55e336[_0xf6f7('0x43')]!==AGI_RESULT_ERROR&&!_0x174730[_0xf6f7('0x33')]){logger[_0xf6f7('0x2c')](_0xf6f7('0x44'),getLogFromObject(_0x55e336));return _['isUndefined'](_0x55e336[_0xf6f7('0x43')])?null:_0x55e336['result'][_0xf6f7('0x45')]();}else{logger['error']('response',getLogFromObject(_0x55e336));return null;}}else{logger[_0xf6f7('0xb')](_0xf6f7('0x46'));return null;}}catch(_0xff8a0f){logger['error'](_0xff8a0f[_0xf6f7('0x19')]);return null;}});if(_0xd755e6[_0xf6f7('0x47')]){logger['info'](util['format'](_0xf6f7('0x48'),_0x174730['arg_1'],_0x174730[_0xf6f7('0x16')],_0x174730['callerid'],_0x174730['dnid'],_0x174730[_0xf6f7('0x18')]));_0x4589c4['traverseBFS'](_0xd755e6[_0xf6f7('0x47')]['id'],function(_0x59b0fd){try{_0x59b0fd=_0x5883e3[_0xf6f7('0x3c')](_0x59b0fd);logger['debug']('vertex',JSON[_0xf6f7('0x2e')](_0x59b0fd,null,0x2));if(_0x59b0fd&&_0x5883e3[_0x59b0fd[_0xf6f7('0x3d')]]){_0x55e336=_0x5883e3[_0x59b0fd[_0xf6f7('0x3d')]](_0x59b0fd);if(_0x55e336){logger[_0xf6f7('0x2c')](_0xf6f7('0x44'),getLogFromObject(_0x55e336));return _[_0xf6f7('0x49')](_0x55e336[_0xf6f7('0x43')])?null:_0x55e336[_0xf6f7('0x43')][_0xf6f7('0x45')]();}else{logger[_0xf6f7('0xb')](_0xf6f7('0x44'),getLogFromObject(_0x55e336));return null;}}else{logger[_0xf6f7('0xb')]('agicommand\x20not\x20found');return null;}}catch(_0x4003b7){logger['error'](_0x4003b7[_0xf6f7('0x19')]);return null;}});}logger[_0xf6f7('0xd')](util[_0xf6f7('0xe')]('[END]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x174730[_0xf6f7('0x15')],_0x174730[_0xf6f7('0x16')],_0x174730[_0xf6f7('0x30')],_0x174730[_0xf6f7('0x17')],_0x174730[_0xf6f7('0x18')]));logger['info'](util[_0xf6f7('0xe')]('[GOTO]\x20context:\x20%s\x20extension:\x20%s\x20priority:\x20%s',_0x174730[_0xf6f7('0x40')],_0x174730[_0xf6f7('0x41')],parseInt(_0x174730[_0xf6f7('0x42')],0xa)+0x1));_0x174730['continueAt'](_0x174730['context'],_0x174730[_0xf6f7('0x41')],parseInt(_0x174730[_0xf6f7('0x42')],0xa)+0x1);_0x174730[_0xf6f7('0x31')]();}}else{logger['error'](util[_0xf6f7('0xe')](_0xf6f7('0x4a'),_0x174730[_0xf6f7('0x15')]));_0x174730[_0xf6f7('0x4b')](_0x174730[_0xf6f7('0x40')],_0x174730[_0xf6f7('0x41')],parseInt(_0x174730['priority'],0xa)+0x1);_0x174730[_0xf6f7('0x31')]();}}else{logger[_0xf6f7('0xb')](util['format']('Project\x20%s\x20not\x20found',_0x174730[_0xf6f7('0x15')]));_0x174730[_0xf6f7('0x4b')](_0x174730['context'],_0x174730[_0xf6f7('0x41')],parseInt(_0x174730['priority'],0xa)+0x1);_0x174730[_0xf6f7('0x31')]();}}function main(){var _0x41f083;return utilLicense[_0xf6f7('0x4c')]()[_0xf6f7('0x26')](function(_0x12ed5a){if(_0x12ed5a){if(_0x12ed5a[_0xf6f7('0x4d')]){if(_0x12ed5a[_0xf6f7('0x4e')]&&_0x12ed5a[_0xf6f7('0x4e')]>0x0){logger['info'](util['format']('[LICENSE]\x20CHANNELS:\x20%s',_0x12ed5a[_0xf6f7('0x4e')]));_0x41f083=_0x12ed5a[_0xf6f7('0x4e')];}else{logger[_0xf6f7('0xd')](_0xf6f7('0x4f'));}}else{logger['info'](_0xf6f7('0x50'));_0x41f083=-0x1;}}})['catch'](function(_0x117ec1){logger[_0xf6f7('0xb')](_0xf6f7('0x51'),_0x117ec1[_0xf6f7('0x19')]);})['finally'](function(){var _0x1e43c4=require(_0xf6f7('0x52'))(config[_0xf6f7('0x5')][_0xf6f7('0x10')],config[_0xf6f7('0x5')]['ip'],_0x41f083);_0x1e43c4['on'](_0xf6f7('0xb'),errorHandler);_0x1e43c4['on'](_0xf6f7('0x53'),listeningHandler);_0x1e43c4['on']('connection',connectionHandler);_0x1e43c4['on']('close',closeHandler);});}main();
\ No newline at end of file
+var _0x5ad3=['vertex','gotoc','gotoc\x20block\x20stop\x20traverse\x20BFS','context','extension','priority','response','code','isUndefined','result','toString','agicommand\x20not\x20found','[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','finally','[END]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','[GOTO]\x20context:\x20%s\x20extension:\x20%s\x20priority:\x20%s','continueAt','Project\x20%s\x20not\x20published','Project\x20%s\x20not\x20found','getLicense','voice','callysquare','[LICENSE]\x20CHANNELS:\x20%s','[LICENSE]\x20CHANNELS:\x20UNLIMITED','[LICENSE]\x20VOICE\x20IS\x20DISABLED','./server','connection','xml2json','lodash','syncho','util','../../config/environment','../../config/logger','agi','../../config/license/util','./rpc','./mailRpc','./graph','./vertices','defaults','127.0.0.1','nextTick','error','Cally\x20Square\x20server\x20listening\x20on\x20port\x20%d!','info','format','port','name','message','[%s]\x20%s','[ERROR]\x20%s','arg_1','calleridname','callerid','uniqueid','stack','[HANGUP]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','dnid','evtHangup','toJson','mxGraphModel','root','agicommand','hasOwnProperty','maxRetry','retry','addVertex','omit','mxCell','isArray','length','source','target','addEdge','then','indexOf','substring','inspect','stringify','[START]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','close','hangup','sync','production','start','debug','joinAt','YYYY-MM-DD\x20HH:mm:ss','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','traverseBFS','clear'];(function(_0x4d348c,_0x46445e){var _0x3a9837=function(_0x2cce6b){while(--_0x2cce6b){_0x4d348c['push'](_0x4d348c['shift']());}};_0x3a9837(++_0x46445e);}(_0x5ad3,0x1e2));var _0x35ad=function(_0x5257bf,_0xf39844){_0x5257bf=_0x5257bf-0x0;var _0x30f32b=_0x5ad3[_0x5257bf];return _0x30f32b;};'use strict';var parser=require(_0x35ad('0x0'));var _=require(_0x35ad('0x1'));var syncho=require(_0x35ad('0x2'));var util=require(_0x35ad('0x3'));var moment=require('moment');var config=require(_0x35ad('0x4'));var logger=require(_0x35ad('0x5'))(_0x35ad('0x6'));var utilLicense=require(_0x35ad('0x7'));var rpc=require(_0x35ad('0x8'));var mailRpc=require(_0x35ad('0x9'));var Graph=require(_0x35ad('0xa'));var Vertices=require(_0x35ad('0xb'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;config[_0x35ad('0x6')]=_[_0x35ad('0xc')](config['agi'],{'ip':_0x35ad('0xd'),'port':0x11dd});function connectionHandler(_0x3cec3e){process[_0x35ad('0xe')](function(){syncho(function(){try{setChannelVariables(_0x3cec3e);agiHandler(_0x3cec3e);}catch(_0x5400f3){logger[_0x35ad('0xf')](_0x5400f3['stack']);}});});}function listeningHandler(){console['log'](_0x35ad('0x10'),config[_0x35ad('0x6')]['port']);logger[_0x35ad('0x11')](util[_0x35ad('0x12')]('[LISTENING]\x20Cally\x20Square\x20listening\x20%s:%d',config['agi']['ip'],config[_0x35ad('0x6')][_0x35ad('0x13')]));}function errorHandler(_0x4cf6bd){if(_0x4cf6bd&&_0x4cf6bd[_0x35ad('0x14')]&&_0x4cf6bd[_0x35ad('0x15')]){logger['error'](util['format'](_0x35ad('0x16'),_0x4cf6bd[_0x35ad('0x14')],_0x4cf6bd[_0x35ad('0x15')]));}else{logger['error'](util[_0x35ad('0x12')](_0x35ad('0x17'),_0x4cf6bd['stack']));}}function closeHandler(){logger[_0x35ad('0x11')](util['format']('[CLOSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this[_0x35ad('0x18')],this[_0x35ad('0x19')],this[_0x35ad('0x1a')],this['dnid'],this[_0x35ad('0x1b')]));try{createSquareReport(this);}catch(_0x2f3f27){logger[_0x35ad('0xf')](_0x2f3f27[_0x35ad('0x1c')]);}}function timeoutHandler(){logger[_0x35ad('0x11')](util[_0x35ad('0x12')]('[TIMEOUT]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this[_0x35ad('0x18')],this[_0x35ad('0x19')],this['callerid'],this['dnid'],this[_0x35ad('0x1b')]));}function hangupHandler(){logger[_0x35ad('0x11')](util['format'](_0x35ad('0x1d'),this[_0x35ad('0x18')],this['calleridname'],this[_0x35ad('0x1a')],this[_0x35ad('0x1e')],this[_0x35ad('0x1b')]));this[_0x35ad('0x1f')]=!![];}function getRoot(_0x1be6d2){return parser[_0x35ad('0x20')](_0x1be6d2,{'object':!![]})[_0x35ad('0x21')][_0x35ad('0x22')];}function addVertex(_0x2fb296,_0xebc6c5,_0x4c5740){_0xebc6c5[_0x35ad('0x23')]=_0x4c5740;if(_0xebc6c5[_0x35ad('0x24')]('retry')){_0xebc6c5[_0x35ad('0x25')]=parseInt(_0xebc6c5[_0x35ad('0x26')],0xa);}_0x2fb296[_0x35ad('0x27')](_[_0x35ad('0x28')](_0xebc6c5,_0x35ad('0x29')));}function initGraph(_0x561cae,_0x37e9bd){var _0x226167=new Graph();for(var _0x3dc3c4 in _0x561cae){if(_0x561cae[_0x35ad('0x24')](_0x3dc3c4)){if(_[_0x35ad('0x2a')](_0x561cae[_0x3dc3c4])){for(var _0x20a682=0x0;_0x20a682<_0x561cae[_0x3dc3c4][_0x35ad('0x2b')];_0x20a682+=0x1){addVertex(_0x226167,_0x561cae[_0x3dc3c4][_0x20a682],_0x3dc3c4);}}else{addVertex(_0x226167,_0x561cae[_0x3dc3c4],_0x3dc3c4);}}}for(var _0xaf7237=0x0;_0xaf7237<_0x37e9bd['length'];_0xaf7237+=0x1){if(_0x37e9bd[_0xaf7237][_0x35ad('0x2c')]&&_0x37e9bd[_0xaf7237][_0x35ad('0x2d')]){_0x226167[_0x35ad('0x2e')](_0x37e9bd[_0xaf7237][_0x35ad('0x2c')],_0x37e9bd[_0xaf7237][_0x35ad('0x2d')],_0x37e9bd[_0xaf7237]['value']);}}return _0x226167;}function getSquareProject(_0x571ad6,_0x131d65){rpc['getSquareProject'](_0x571ad6)[_0x35ad('0x2f')](function(_0x4ccaea){_0x131d65(null,_0x4ccaea);})['catch'](function(_0x589e4a){_0x131d65(null,_0x589e4a);});}function createSquareReport(_0x5380e5,_0x55906e){rpc['createSquareReport'](_0x5380e5)['then'](function(_0x183037){if(_0x55906e){_0x55906e(null,_0x183037);}})['catch'](function(_0x3d5670){if(_0x55906e){_0x55906e(null,_0x3d5670);}});}function setChannelVariables(_0x51cf37){for(var _0x4005ad in _0x51cf37){if(_0x51cf37['hasOwnProperty'](_0x4005ad)){if(_0x4005ad[_0x35ad('0x30')]('agi_')===0x0){_0x51cf37[_0x4005ad[_0x35ad('0x31')](0x4)]=_0x51cf37[_0x4005ad];delete _0x51cf37[_0x4005ad];}}}}function getLogFromObject(_0x2766dd){return util[_0x35ad('0x32')](_0x2766dd,{'showHidden':![],'depth':null});}function agiHandler(_0x4b6ec2){var _0x2852e2,_0x2e5fcb,_0x129710,_0x31b591,_0x3cb239;logger['debug']('variables',JSON[_0x35ad('0x33')](_0x4b6ec2,null,0x2));logger[_0x35ad('0x11')](util[_0x35ad('0x12')](_0x35ad('0x34'),_0x4b6ec2['arg_1'],_0x4b6ec2[_0x35ad('0x19')],_0x4b6ec2[_0x35ad('0x1a')],_0x4b6ec2[_0x35ad('0x1e')],_0x4b6ec2[_0x35ad('0x1b')]));_0x4b6ec2['on'](_0x35ad('0xf'),errorHandler);_0x4b6ec2['on'](_0x35ad('0x35'),closeHandler);_0x4b6ec2['on']('timeout',timeoutHandler);_0x4b6ec2['evtHangup']=![];_0x4b6ec2['on'](_0x35ad('0x36'),hangupHandler);var _0x2800e7=getSquareProject[_0x35ad('0x37')](null,_0x4b6ec2[_0x35ad('0x18')]);if(_0x2800e7){if(_0x2800e7[_0x35ad('0x38')]){_0x2852e2=getRoot(_0x2800e7[_0x35ad('0x38')]);if(_0x2852e2&&_0x2852e2[_0x35ad('0x39')]){logger[_0x35ad('0x3a')](_0x35ad('0x22'),JSON['stringify'](_0x2852e2,null,0x2));_0x4b6ec2[_0x35ad('0x3b')]=moment()['format'](_0x35ad('0x3c'));_0x2e5fcb=initGraph(_[_0x35ad('0x28')](_0x2852e2,_0x35ad('0x29')),_0x2852e2[_0x35ad('0x29')]);_0x129710=new Vertices(_0x4b6ec2,rpc,mailRpc);logger[_0x35ad('0x11')](util[_0x35ad('0x12')](_0x35ad('0x3d'),_0x4b6ec2[_0x35ad('0x18')],_0x4b6ec2[_0x35ad('0x19')],_0x4b6ec2['callerid'],_0x4b6ec2[_0x35ad('0x1e')],_0x4b6ec2[_0x35ad('0x1b')]));_0x2e5fcb[_0x35ad('0x3e')](_0x2852e2['start']['id'],function(_0x19d82d){try{_0x19d82d=_0x129710[_0x35ad('0x3f')](_0x19d82d);logger[_0x35ad('0x3a')](_0x35ad('0x40'),JSON[_0x35ad('0x33')](_0x19d82d,null,0x2));if(_0x19d82d[_0x35ad('0x23')]===_0x35ad('0x41')){logger[_0x35ad('0x11')](_0x35ad('0x42'));_0x4b6ec2[_0x35ad('0x43')]=_0x19d82d[_0x35ad('0x43')]||_0x4b6ec2['context'];_0x4b6ec2[_0x35ad('0x44')]=_0x19d82d['extension'];_0x4b6ec2[_0x35ad('0x45')]=_0x19d82d[_0x35ad('0x45')]?_0x19d82d[_0x35ad('0x45')]-0x1:0x1;return null;}else if(_0x19d82d&&_0x129710[_0x19d82d[_0x35ad('0x23')]]){_0x3cb239=_0x129710[_0x19d82d[_0x35ad('0x23')]](_0x19d82d);logger[_0x35ad('0x11')](_0x35ad('0x46'),JSON[_0x35ad('0x33')](_0x3cb239,null,0x2));if(_0x3cb239&&_0x3cb239[_0x35ad('0x47')]===AGI_CODE_SUCCESS&&_0x3cb239['result']!==AGI_RESULT_ERROR&&!_0x4b6ec2[_0x35ad('0x1f')]){logger[_0x35ad('0x3a')](_0x35ad('0x46'),getLogFromObject(_0x3cb239));return _[_0x35ad('0x48')](_0x3cb239[_0x35ad('0x49')])?null:_0x3cb239['result'][_0x35ad('0x4a')]();}else{logger[_0x35ad('0xf')]('response',getLogFromObject(_0x3cb239));return null;}}else{logger['error'](_0x35ad('0x4b'));return null;}}catch(_0x228498){logger[_0x35ad('0xf')](_0x228498[_0x35ad('0x1c')]);return null;}});if(_0x2852e2['finally']){logger[_0x35ad('0x11')](util[_0x35ad('0x12')](_0x35ad('0x4c'),_0x4b6ec2[_0x35ad('0x18')],_0x4b6ec2[_0x35ad('0x19')],_0x4b6ec2[_0x35ad('0x1a')],_0x4b6ec2[_0x35ad('0x1e')],_0x4b6ec2['uniqueid']));_0x2e5fcb[_0x35ad('0x3e')](_0x2852e2[_0x35ad('0x4d')]['id'],function(_0x63ce47){try{_0x63ce47=_0x129710['clear'](_0x63ce47);logger['debug']('vertex',JSON[_0x35ad('0x33')](_0x63ce47,null,0x2));if(_0x63ce47&&_0x129710[_0x63ce47[_0x35ad('0x23')]]){_0x3cb239=_0x129710[_0x63ce47[_0x35ad('0x23')]](_0x63ce47);if(_0x3cb239){logger[_0x35ad('0x3a')]('response',getLogFromObject(_0x3cb239));return _[_0x35ad('0x48')](_0x3cb239[_0x35ad('0x49')])?null:_0x3cb239[_0x35ad('0x49')][_0x35ad('0x4a')]();}else{logger[_0x35ad('0xf')](_0x35ad('0x46'),getLogFromObject(_0x3cb239));return null;}}else{logger['error']('agicommand\x20not\x20found');return null;}}catch(_0x34a9a3){logger[_0x35ad('0xf')](_0x34a9a3['stack']);return null;}});}logger['info'](util[_0x35ad('0x12')](_0x35ad('0x4e'),_0x4b6ec2[_0x35ad('0x18')],_0x4b6ec2['calleridname'],_0x4b6ec2['callerid'],_0x4b6ec2[_0x35ad('0x1e')],_0x4b6ec2[_0x35ad('0x1b')]));logger[_0x35ad('0x11')](util['format'](_0x35ad('0x4f'),_0x4b6ec2[_0x35ad('0x43')],_0x4b6ec2[_0x35ad('0x44')],parseInt(_0x4b6ec2[_0x35ad('0x45')],0xa)+0x1));_0x4b6ec2[_0x35ad('0x50')](_0x4b6ec2[_0x35ad('0x43')],_0x4b6ec2['extension'],parseInt(_0x4b6ec2[_0x35ad('0x45')],0xa)+0x1);_0x4b6ec2[_0x35ad('0x35')]();}}else{logger[_0x35ad('0xf')](util['format'](_0x35ad('0x51'),_0x4b6ec2[_0x35ad('0x18')]));_0x4b6ec2[_0x35ad('0x50')](_0x4b6ec2[_0x35ad('0x43')],_0x4b6ec2['extension'],parseInt(_0x4b6ec2['priority'],0xa)+0x1);_0x4b6ec2[_0x35ad('0x35')]();}}else{logger[_0x35ad('0xf')](util[_0x35ad('0x12')](_0x35ad('0x52'),_0x4b6ec2[_0x35ad('0x18')]));_0x4b6ec2['continueAt'](_0x4b6ec2[_0x35ad('0x43')],_0x4b6ec2[_0x35ad('0x44')],parseInt(_0x4b6ec2[_0x35ad('0x45')],0xa)+0x1);_0x4b6ec2[_0x35ad('0x35')]();}}function main(){var _0x3b8004;return utilLicense[_0x35ad('0x53')]()['then'](function(_0x579090){if(_0x579090){if(_0x579090[_0x35ad('0x54')]){if(_0x579090[_0x35ad('0x55')]&&_0x579090[_0x35ad('0x55')]>0x0){logger[_0x35ad('0x11')](util[_0x35ad('0x12')](_0x35ad('0x56'),_0x579090[_0x35ad('0x55')]));_0x3b8004=_0x579090['callysquare'];}else{logger[_0x35ad('0x11')](_0x35ad('0x57'));}}else{logger[_0x35ad('0x11')](_0x35ad('0x58'));_0x3b8004=-0x1;}}})['catch'](function(_0x12735e){logger[_0x35ad('0xf')]('[LICENSE]',_0x12735e[_0x35ad('0x1c')]);})[_0x35ad('0x4d')](function(){var _0x1da9ca=require(_0x35ad('0x59'))(config[_0x35ad('0x6')][_0x35ad('0x13')],config[_0x35ad('0x6')]['ip'],_0x3b8004);_0x1da9ca['on'](_0x35ad('0xf'),errorHandler);_0x1da9ca['on']('listening',listeningHandler);_0x1da9ca['on'](_0x35ad('0x5a'),connectionHandler);_0x1da9ca['on'](_0x35ad('0x35'),closeHandler);});}main();
\ No newline at end of file