Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / services / agi / project.js
index 79258e9..8b428c8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x50a4=['dnid','continueAt','Project\x20%s\x20not\x20found','close','Project\x20%s\x20not\x20published','exports','lodash','moment','xml2json','util','../../config/logger','agi','./mailRpc','./vertices','getSquareProjects','error','Unable\x20to\x20download\x20CallySquare\x20projects','stack','hasOwnProperty','retry','addVertex','omit','mxCell','source','target','addEdge','value','mxGraphModel','inspect','production','debug','root','joinAt','YYYY-MM-DD\x20HH:mm:ss','info','format','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','calleridname','callerid','start','clear','vertex','agicommand','gotoc','context','extension','priority','stringify','result','evtHangup','response','toString','[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','uniqueid','finally','isUndefined','agicommand\x20not\x20found'];(function(_0x2514e2,_0x7490ad){var _0x28b546=function(_0x250a47){while(--_0x250a47){_0x2514e2['push'](_0x2514e2['shift']());}};_0x28b546(++_0x7490ad);}(_0x50a4,0xb4));var _0x450a=function(_0x5e0406,_0x21dfea){_0x5e0406=_0x5e0406-0x0;var _0x81d10=_0x50a4[_0x5e0406];return _0x81d10;};'use strict';var _=require(_0x450a('0x0'));var moment=require(_0x450a('0x1'));var parser=require(_0x450a('0x2'));var util=require(_0x450a('0x3'));var logger=require(_0x450a('0x4'))(_0x450a('0x5'));var rpc=require('./rpc');var mailRpc=require(_0x450a('0x6'));var Graph=require('./graph');var Vertices=require(_0x450a('0x7'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0x450a('0x8')]()['catch'](function(_0x396b75){logger[_0x450a('0x9')](_0x450a('0xa'),_0x396b75[_0x450a('0xb')]);return[];});}function addVertex(_0x30f5f2,_0x3e675b,_0x8d59ee){_0x3e675b['agicommand']=_0x8d59ee;if(_0x3e675b[_0x450a('0xc')](_0x450a('0xd'))){_0x3e675b['maxRetry']=parseInt(_0x3e675b[_0x450a('0xd')],0xa);}_0x30f5f2[_0x450a('0xe')](_[_0x450a('0xf')](_0x3e675b,_0x450a('0x10')));}function initGraph(_0x13253f,_0x5ed007){var _0x48e4be=new Graph();for(var _0x35d2f8 in _0x13253f){if(_0x13253f[_0x450a('0xc')](_0x35d2f8)){if(_['isArray'](_0x13253f[_0x35d2f8])){for(var _0x12a6b7=0x0;_0x12a6b7<_0x13253f[_0x35d2f8]['length'];_0x12a6b7+=0x1){addVertex(_0x48e4be,_0x13253f[_0x35d2f8][_0x12a6b7],_0x35d2f8);}}else{addVertex(_0x48e4be,_0x13253f[_0x35d2f8],_0x35d2f8);}}}for(var _0x215284=0x0;_0x215284<_0x5ed007['length'];_0x215284+=0x1){if(_0x5ed007[_0x215284][_0x450a('0x11')]&&_0x5ed007[_0x215284][_0x450a('0x12')]){_0x48e4be[_0x450a('0x13')](_0x5ed007[_0x215284][_0x450a('0x11')],_0x5ed007[_0x215284][_0x450a('0x12')],_0x5ed007[_0x215284][_0x450a('0x14')]);}}return _0x48e4be;}function getRoot(_0x1ed445){return parser['toJson'](_0x1ed445,{'object':!![]})[_0x450a('0x15')]['root'];}function inspect(_0x17a011){return util[_0x450a('0x16')](_0x17a011,{'showHidden':![],'depth':null});}function initialize(_0x51dac4,_0x451e22){var _0x60aead=getRoot(_0x51dac4[_0x450a('0x17')]);if(!_0x60aead||!_0x60aead['start'])return;var _0x209eb1,_0x2cb073,_0x2dc1ea;logger[_0x450a('0x18')](_0x450a('0x19'),JSON['stringify'](_0x60aead,null,0x2));_0x451e22[_0x450a('0x1a')]=moment()['format'](_0x450a('0x1b'));_0x209eb1=initGraph(_[_0x450a('0xf')](_0x60aead,_0x450a('0x10')),_0x60aead[_0x450a('0x10')]);_0x2cb073=new Vertices(_0x451e22,rpc,mailRpc);logger[_0x450a('0x1c')](util[_0x450a('0x1d')](_0x450a('0x1e'),_0x451e22[_0x450a('0x1f')],_0x451e22[_0x450a('0x20')],_0x451e22[_0x450a('0x21')],_0x451e22['dnid'],_0x451e22['uniqueid']));_0x209eb1['traverseBFS'](_0x60aead[_0x450a('0x22')]['id'],function(_0x1a0299){try{_0x1a0299=_0x2cb073[_0x450a('0x23')](_0x1a0299);logger[_0x450a('0x18')](_0x450a('0x24'),JSON['stringify'](_0x1a0299,null,0x2));if(_0x1a0299[_0x450a('0x25')]===_0x450a('0x26')){logger[_0x450a('0x1c')]('gotoc\x20block\x20stop\x20traverse\x20BFS');_0x451e22['context']=_0x1a0299[_0x450a('0x27')]||_0x451e22['context'];_0x451e22[_0x450a('0x28')]=_0x1a0299[_0x450a('0x28')];_0x451e22['priority']=_0x1a0299['priority']?_0x1a0299[_0x450a('0x29')]-0x1:0x1;return null;}else if(_0x1a0299&&_0x2cb073[_0x1a0299[_0x450a('0x25')]]){_0x2dc1ea=_0x2cb073[_0x1a0299[_0x450a('0x25')]](_0x1a0299);logger[_0x450a('0x1c')]('response',JSON[_0x450a('0x2a')](_0x2dc1ea,null,0x2));if(_0x2dc1ea&&_0x2dc1ea['code']===AGI_CODE_SUCCESS&&_0x2dc1ea[_0x450a('0x2b')]!==AGI_RESULT_ERROR&&!_0x451e22[_0x450a('0x2c')]){logger[_0x450a('0x18')](_0x450a('0x2d'),inspect(_0x2dc1ea));return _['isUndefined'](_0x2dc1ea[_0x450a('0x2b')])?null:_0x2dc1ea[_0x450a('0x2b')][_0x450a('0x2e')]();}else{logger['error'](_0x450a('0x2d'),inspect(_0x2dc1ea));return null;}}else{logger[_0x450a('0x9')]('agicommand\x20not\x20found');return null;}}catch(_0x1d2a9a){logger['error'](_0x1d2a9a['stack']);return null;}});if(_0x60aead['finally']){logger['info'](util[_0x450a('0x1d')](_0x450a('0x2f'),_0x451e22[_0x450a('0x1f')],_0x451e22['calleridname'],_0x451e22[_0x450a('0x21')],_0x451e22['dnid'],_0x451e22[_0x450a('0x30')]));_0x209eb1['traverseBFS'](_0x60aead[_0x450a('0x31')]['id'],function(_0x305a84){try{_0x305a84=_0x2cb073[_0x450a('0x23')](_0x305a84);logger[_0x450a('0x18')](_0x450a('0x24'),JSON[_0x450a('0x2a')](_0x305a84,null,0x2));if(_0x305a84&&_0x2cb073[_0x305a84['agicommand']]){_0x2dc1ea=_0x2cb073[_0x305a84[_0x450a('0x25')]](_0x305a84);if(_0x2dc1ea){logger[_0x450a('0x18')](_0x450a('0x2d'),inspect(_0x2dc1ea));return _[_0x450a('0x32')](_0x2dc1ea[_0x450a('0x2b')])?null:_0x2dc1ea[_0x450a('0x2b')]['toString']();}else{logger[_0x450a('0x9')]('response',inspect(_0x2dc1ea));return null;}}else{logger['error'](_0x450a('0x33'));return null;}}catch(_0x2e9480){logger[_0x450a('0x9')](_0x2e9480[_0x450a('0xb')]);return null;}});}logger['info'](util['format']('[END]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x451e22[_0x450a('0x1f')],_0x451e22['calleridname'],_0x451e22['callerid'],_0x451e22[_0x450a('0x34')],_0x451e22[_0x450a('0x30')]));logger[_0x450a('0x1c')](util[_0x450a('0x1d')]('[GOTO]\x20context:\x20%s\x20extension:\x20%s\x20priority:\x20%s',_0x451e22[_0x450a('0x27')],_0x451e22['extension'],parseInt(_0x451e22[_0x450a('0x29')],0xa)+0x1));_0x451e22[_0x450a('0x35')](_0x451e22[_0x450a('0x27')],_0x451e22['extension'],parseInt(_0x451e22['priority'],0xa)+0x1);_0x451e22['close']();}function handleNotFound(_0x49ec66){logger[_0x450a('0x9')](util[_0x450a('0x1d')](_0x450a('0x36'),_0x49ec66['arg_1']));_0x49ec66[_0x450a('0x35')](_0x49ec66[_0x450a('0x27')],_0x49ec66['extension'],parseInt(_0x49ec66[_0x450a('0x29')],0xa)+0x1);_0x49ec66[_0x450a('0x37')]();}function handleUnpublished(_0x39d535){logger['error'](util[_0x450a('0x1d')](_0x450a('0x38'),_0x39d535['arg_1']));_0x39d535[_0x450a('0x35')](_0x39d535[_0x450a('0x27')],_0x39d535['extension'],parseInt(_0x39d535['priority'],0xa)+0x1);_0x39d535[_0x450a('0x37')]();}module[_0x450a('0x39')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file
+var _0x7dc5=['mxGraphModel','root','inspect','start','debug','stringify','joinAt','format','YYYY-MM-DD\x20HH:mm:ss','info','arg_1','calleridname','dnid','uniqueid','traverseBFS','clear','vertex','gotoc','gotoc\x20block\x20stop\x20traverse\x20BFS','context','extension','priority','code','result','evtHangup','response','isUndefined','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','callerid','[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\x20found','close','Project\x20%s\x20not\x20published','exports','moment','util','agi','./rpc','./mailRpc','./graph','./vertices','getSquareProjects','error','Unable\x20to\x20download\x20CallySquare\x20projects','stack','agicommand','hasOwnProperty','retry','maxRetry','addVertex','omit','mxCell','isArray','length','source','addEdge','target','value','toJson'];(function(_0xf5d71c,_0x2613a6){var _0x5af672=function(_0x191f52){while(--_0x191f52){_0xf5d71c['push'](_0xf5d71c['shift']());}};_0x5af672(++_0x2613a6);}(_0x7dc5,0x167));var _0x57dc=function(_0xf9431c,_0x4754b5){_0xf9431c=_0xf9431c-0x0;var _0x53fc33=_0x7dc5[_0xf9431c];return _0x53fc33;};'use strict';var _=require('lodash');var moment=require(_0x57dc('0x0'));var parser=require('xml2json');var util=require(_0x57dc('0x1'));var logger=require('../../config/logger')(_0x57dc('0x2'));var rpc=require(_0x57dc('0x3'));var mailRpc=require(_0x57dc('0x4'));var Graph=require(_0x57dc('0x5'));var Vertices=require(_0x57dc('0x6'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0x57dc('0x7')]()['catch'](function(_0x2e4e54){logger[_0x57dc('0x8')](_0x57dc('0x9'),_0x2e4e54[_0x57dc('0xa')]);return[];});}function addVertex(_0x591792,_0x28308a,_0x199323){_0x28308a[_0x57dc('0xb')]=_0x199323;if(_0x28308a[_0x57dc('0xc')](_0x57dc('0xd'))){_0x28308a[_0x57dc('0xe')]=parseInt(_0x28308a[_0x57dc('0xd')],0xa);}_0x591792[_0x57dc('0xf')](_[_0x57dc('0x10')](_0x28308a,_0x57dc('0x11')));}function initGraph(_0x52b3d0,_0x3f45f5){var _0x2f41cc=new Graph();for(var _0xbc7493 in _0x52b3d0){if(_0x52b3d0[_0x57dc('0xc')](_0xbc7493)){if(_[_0x57dc('0x12')](_0x52b3d0[_0xbc7493])){for(var _0x4c1fcc=0x0;_0x4c1fcc<_0x52b3d0[_0xbc7493]['length'];_0x4c1fcc+=0x1){addVertex(_0x2f41cc,_0x52b3d0[_0xbc7493][_0x4c1fcc],_0xbc7493);}}else{addVertex(_0x2f41cc,_0x52b3d0[_0xbc7493],_0xbc7493);}}}for(var _0x269c1b=0x0;_0x269c1b<_0x3f45f5[_0x57dc('0x13')];_0x269c1b+=0x1){if(_0x3f45f5[_0x269c1b][_0x57dc('0x14')]&&_0x3f45f5[_0x269c1b]['target']){_0x2f41cc[_0x57dc('0x15')](_0x3f45f5[_0x269c1b]['source'],_0x3f45f5[_0x269c1b][_0x57dc('0x16')],_0x3f45f5[_0x269c1b][_0x57dc('0x17')]);}}return _0x2f41cc;}function getRoot(_0x4af601){return parser[_0x57dc('0x18')](_0x4af601,{'object':!![]})[_0x57dc('0x19')][_0x57dc('0x1a')];}function inspect(_0x28f21b){return util[_0x57dc('0x1b')](_0x28f21b,{'showHidden':![],'depth':null});}function initialize(_0x3ed0b2,_0x4f0821){var _0x238e1a=getRoot(_0x3ed0b2['production']);if(!_0x238e1a||!_0x238e1a[_0x57dc('0x1c')])return;var _0x1deeab,_0xdc47dc,_0x4e47f2;logger[_0x57dc('0x1d')](_0x57dc('0x1a'),JSON[_0x57dc('0x1e')](_0x238e1a,null,0x2));_0x4f0821[_0x57dc('0x1f')]=moment()[_0x57dc('0x20')](_0x57dc('0x21'));_0x1deeab=initGraph(_[_0x57dc('0x10')](_0x238e1a,'mxCell'),_0x238e1a['mxCell']);_0xdc47dc=new Vertices(_0x4f0821,rpc,mailRpc);logger[_0x57dc('0x22')](util[_0x57dc('0x20')]('[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x4f0821[_0x57dc('0x23')],_0x4f0821[_0x57dc('0x24')],_0x4f0821['callerid'],_0x4f0821[_0x57dc('0x25')],_0x4f0821[_0x57dc('0x26')]));_0x1deeab[_0x57dc('0x27')](_0x238e1a[_0x57dc('0x1c')]['id'],function(_0x23f46d){try{_0x23f46d=_0xdc47dc[_0x57dc('0x28')](_0x23f46d);logger[_0x57dc('0x1d')](_0x57dc('0x29'),JSON[_0x57dc('0x1e')](_0x23f46d,null,0x2));if(_0x23f46d[_0x57dc('0xb')]===_0x57dc('0x2a')){logger['info'](_0x57dc('0x2b'));_0x4f0821[_0x57dc('0x2c')]=_0x23f46d[_0x57dc('0x2c')]||_0x4f0821['context'];_0x4f0821[_0x57dc('0x2d')]=_0x23f46d[_0x57dc('0x2d')];_0x4f0821['priority']=_0x23f46d[_0x57dc('0x2e')]?_0x23f46d['priority']-0x1:0x1;return null;}else if(_0x23f46d&&_0xdc47dc[_0x23f46d[_0x57dc('0xb')]]){_0x4e47f2=_0xdc47dc[_0x23f46d['agicommand']](_0x23f46d);logger['info']('response',JSON[_0x57dc('0x1e')](_0x4e47f2,null,0x2));if(_0x4e47f2&&_0x4e47f2[_0x57dc('0x2f')]===AGI_CODE_SUCCESS&&_0x4e47f2[_0x57dc('0x30')]!==AGI_RESULT_ERROR&&!_0x4f0821[_0x57dc('0x31')]){logger['debug'](_0x57dc('0x32'),inspect(_0x4e47f2));return _[_0x57dc('0x33')](_0x4e47f2[_0x57dc('0x30')])?null:_0x4e47f2[_0x57dc('0x30')][_0x57dc('0x34')]();}else{logger[_0x57dc('0x8')]('response',inspect(_0x4e47f2));return null;}}else{logger[_0x57dc('0x8')](_0x57dc('0x35'));return null;}}catch(_0x1d7b53){logger[_0x57dc('0x8')](_0x1d7b53[_0x57dc('0xa')]);return null;}});if(_0x238e1a[_0x57dc('0x36')]){logger[_0x57dc('0x22')](util[_0x57dc('0x20')](_0x57dc('0x37'),_0x4f0821['arg_1'],_0x4f0821['calleridname'],_0x4f0821[_0x57dc('0x38')],_0x4f0821[_0x57dc('0x25')],_0x4f0821['uniqueid']));_0x1deeab[_0x57dc('0x27')](_0x238e1a[_0x57dc('0x36')]['id'],function(_0x33fc32){try{_0x33fc32=_0xdc47dc[_0x57dc('0x28')](_0x33fc32);logger[_0x57dc('0x1d')](_0x57dc('0x29'),JSON['stringify'](_0x33fc32,null,0x2));if(_0x33fc32&&_0xdc47dc[_0x33fc32[_0x57dc('0xb')]]){_0x4e47f2=_0xdc47dc[_0x33fc32[_0x57dc('0xb')]](_0x33fc32);if(_0x4e47f2){logger['debug']('response',inspect(_0x4e47f2));return _[_0x57dc('0x33')](_0x4e47f2[_0x57dc('0x30')])?null:_0x4e47f2[_0x57dc('0x30')]['toString']();}else{logger[_0x57dc('0x8')](_0x57dc('0x32'),inspect(_0x4e47f2));return null;}}else{logger[_0x57dc('0x8')](_0x57dc('0x35'));return null;}}catch(_0x48619c){logger[_0x57dc('0x8')](_0x48619c[_0x57dc('0xa')]);return null;}});}logger[_0x57dc('0x22')](util[_0x57dc('0x20')](_0x57dc('0x39'),_0x4f0821[_0x57dc('0x23')],_0x4f0821['calleridname'],_0x4f0821['callerid'],_0x4f0821[_0x57dc('0x25')],_0x4f0821[_0x57dc('0x26')]));logger[_0x57dc('0x22')](util[_0x57dc('0x20')](_0x57dc('0x3a'),_0x4f0821[_0x57dc('0x2c')],_0x4f0821[_0x57dc('0x2d')],parseInt(_0x4f0821['priority'],0xa)+0x1));_0x4f0821[_0x57dc('0x3b')](_0x4f0821[_0x57dc('0x2c')],_0x4f0821[_0x57dc('0x2d')],parseInt(_0x4f0821[_0x57dc('0x2e')],0xa)+0x1);_0x4f0821['close']();}function handleNotFound(_0x10b346){logger['error'](util[_0x57dc('0x20')](_0x57dc('0x3c'),_0x10b346[_0x57dc('0x23')]));_0x10b346[_0x57dc('0x3b')](_0x10b346[_0x57dc('0x2c')],_0x10b346['extension'],parseInt(_0x10b346[_0x57dc('0x2e')],0xa)+0x1);_0x10b346[_0x57dc('0x3d')]();}function handleUnpublished(_0x221388){logger[_0x57dc('0x8')](util['format'](_0x57dc('0x3e'),_0x221388[_0x57dc('0x23')]));_0x221388[_0x57dc('0x3b')](_0x221388['context'],_0x221388['extension'],parseInt(_0x221388[_0x57dc('0x2e')],0xa)+0x1);_0x221388[_0x57dc('0x3d')]();}module[_0x57dc('0x3f')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file