Built motion from commit ff78e754.|2.6.29
[motion2.git] / server / services / agi / project.js
index ace0791..7d75e37 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb5f3=['length','source','target','addEdge','value','root','inspect','production','start','debug','stringify','format','omit','info','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','uniqueid','clear','vertex','gotoc','gotoc\x20block\x20stop\x20traverse\x20BFS','context','priority','response','code','result','evtHangup','isUndefined','toString','stack','[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','calleridname','agicommand','callerid','extension','continueAt','close','Project\x20%s\x20not\x20found','exports','lodash','moment','util','../../config/logger','./rpc','./mailRpc','./graph','getSquareProjects','error','Unable\x20to\x20download\x20CallySquare\x20projects','hasOwnProperty','retry','maxRetry','mxCell','isArray'];(function(_0x405326,_0x4c4eff){var _0xe5bd1f=function(_0x367ac8){while(--_0x367ac8){_0x405326['push'](_0x405326['shift']());}};_0xe5bd1f(++_0x4c4eff);}(_0xb5f3,0xc9));var _0x3b5f=function(_0x473ee7,_0x4dd754){_0x473ee7=_0x473ee7-0x0;var _0x30f0d4=_0xb5f3[_0x473ee7];return _0x30f0d4;};'use strict';var _=require(_0x3b5f('0x0'));var moment=require(_0x3b5f('0x1'));var parser=require('xml2json');var util=require(_0x3b5f('0x2'));var logger=require(_0x3b5f('0x3'))('agi');var rpc=require(_0x3b5f('0x4'));var mailRpc=require(_0x3b5f('0x5'));var Graph=require(_0x3b5f('0x6'));var Vertices=require('./vertices');var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0x3b5f('0x7')]()['catch'](function(_0x287feb){logger[_0x3b5f('0x8')](_0x3b5f('0x9'),_0x287feb['stack']);return[];});}function addVertex(_0x1d3ce0,_0x23b323,_0x7e0d00){_0x23b323['agicommand']=_0x7e0d00;if(_0x23b323[_0x3b5f('0xa')](_0x3b5f('0xb'))){_0x23b323[_0x3b5f('0xc')]=parseInt(_0x23b323['retry'],0xa);}_0x1d3ce0['addVertex'](_['omit'](_0x23b323,_0x3b5f('0xd')));}function initGraph(_0x44fbb8,_0x34d505){var _0x15a853=new Graph();for(var _0x3bfd42 in _0x44fbb8){if(_0x44fbb8[_0x3b5f('0xa')](_0x3bfd42)){if(_[_0x3b5f('0xe')](_0x44fbb8[_0x3bfd42])){for(var _0x151a0f=0x0;_0x151a0f<_0x44fbb8[_0x3bfd42]['length'];_0x151a0f+=0x1){addVertex(_0x15a853,_0x44fbb8[_0x3bfd42][_0x151a0f],_0x3bfd42);}}else{addVertex(_0x15a853,_0x44fbb8[_0x3bfd42],_0x3bfd42);}}}for(var _0xbc76c3=0x0;_0xbc76c3<_0x34d505[_0x3b5f('0xf')];_0xbc76c3+=0x1){if(_0x34d505[_0xbc76c3][_0x3b5f('0x10')]&&_0x34d505[_0xbc76c3][_0x3b5f('0x11')]){_0x15a853[_0x3b5f('0x12')](_0x34d505[_0xbc76c3][_0x3b5f('0x10')],_0x34d505[_0xbc76c3]['target'],_0x34d505[_0xbc76c3][_0x3b5f('0x13')]);}}return _0x15a853;}function getRoot(_0x131dfb){return parser['toJson'](_0x131dfb,{'object':!![]})['mxGraphModel'][_0x3b5f('0x14')];}function inspect(_0x27649b){return util[_0x3b5f('0x15')](_0x27649b,{'showHidden':![],'depth':null});}function initialize(_0x37850d,_0x4f37e8){var _0x1c83a0=getRoot(_0x37850d[_0x3b5f('0x16')]);if(!_0x1c83a0||!_0x1c83a0[_0x3b5f('0x17')])return;var _0x2118c0,_0x5e2b0e,_0x3121aa;logger[_0x3b5f('0x18')]('root',JSON[_0x3b5f('0x19')](_0x1c83a0,null,0x2));_0x4f37e8['joinAt']=moment()[_0x3b5f('0x1a')]('YYYY-MM-DD\x20HH:mm:ss');_0x2118c0=initGraph(_[_0x3b5f('0x1b')](_0x1c83a0,_0x3b5f('0xd')),_0x1c83a0[_0x3b5f('0xd')]);_0x5e2b0e=new Vertices(_0x4f37e8,rpc,mailRpc);logger[_0x3b5f('0x1c')](util['format'](_0x3b5f('0x1d'),_0x4f37e8[_0x3b5f('0x1e')],_0x4f37e8['calleridname'],_0x4f37e8['callerid'],_0x4f37e8['dnid'],_0x4f37e8[_0x3b5f('0x1f')]));_0x2118c0['traverseBFS'](_0x1c83a0[_0x3b5f('0x17')]['id'],function(_0x42a015){try{_0x42a015=_0x5e2b0e[_0x3b5f('0x20')](_0x42a015);logger[_0x3b5f('0x18')](_0x3b5f('0x21'),JSON[_0x3b5f('0x19')](_0x42a015,null,0x2));if(_0x42a015['agicommand']===_0x3b5f('0x22')){logger[_0x3b5f('0x1c')](_0x3b5f('0x23'));_0x4f37e8[_0x3b5f('0x24')]=_0x42a015[_0x3b5f('0x24')]||_0x4f37e8['context'];_0x4f37e8['extension']=_0x42a015['extension'];_0x4f37e8['priority']=_0x42a015['priority']?_0x42a015[_0x3b5f('0x25')]-0x1:0x1;return null;}else if(_0x42a015&&_0x5e2b0e[_0x42a015['agicommand']]){_0x3121aa=_0x5e2b0e[_0x42a015['agicommand']](_0x42a015);logger[_0x3b5f('0x1c')](_0x3b5f('0x26'),JSON['stringify'](_0x3121aa,null,0x2));if(_0x3121aa&&_0x3121aa[_0x3b5f('0x27')]===AGI_CODE_SUCCESS&&_0x3121aa[_0x3b5f('0x28')]!==AGI_RESULT_ERROR&&!_0x4f37e8[_0x3b5f('0x29')]){logger[_0x3b5f('0x18')](_0x3b5f('0x26'),inspect(_0x3121aa));return _[_0x3b5f('0x2a')](_0x3121aa[_0x3b5f('0x28')])?null:_0x3121aa['result'][_0x3b5f('0x2b')]();}else{logger[_0x3b5f('0x8')](_0x3b5f('0x26'),inspect(_0x3121aa));return null;}}else{logger[_0x3b5f('0x8')]('agicommand\x20not\x20found');return null;}}catch(_0x1cc968){logger[_0x3b5f('0x8')](_0x1cc968[_0x3b5f('0x2c')]);return null;}});if(_0x1c83a0['finally']){logger[_0x3b5f('0x1c')](util['format'](_0x3b5f('0x2d'),_0x4f37e8[_0x3b5f('0x1e')],_0x4f37e8[_0x3b5f('0x2e')],_0x4f37e8['callerid'],_0x4f37e8['dnid'],_0x4f37e8['uniqueid']));_0x2118c0['traverseBFS'](_0x1c83a0['finally']['id'],function(_0x3cf73a){try{_0x3cf73a=_0x5e2b0e[_0x3b5f('0x20')](_0x3cf73a);logger[_0x3b5f('0x18')](_0x3b5f('0x21'),JSON[_0x3b5f('0x19')](_0x3cf73a,null,0x2));if(_0x3cf73a&&_0x5e2b0e[_0x3cf73a[_0x3b5f('0x2f')]]){_0x3121aa=_0x5e2b0e[_0x3cf73a[_0x3b5f('0x2f')]](_0x3cf73a);if(_0x3121aa){logger['debug'](_0x3b5f('0x26'),inspect(_0x3121aa));return _[_0x3b5f('0x2a')](_0x3121aa['result'])?null:_0x3121aa[_0x3b5f('0x28')][_0x3b5f('0x2b')]();}else{logger[_0x3b5f('0x8')](_0x3b5f('0x26'),inspect(_0x3121aa));return null;}}else{logger[_0x3b5f('0x8')]('agicommand\x20not\x20found');return null;}}catch(_0x333fad){logger['error'](_0x333fad[_0x3b5f('0x2c')]);return null;}});}logger[_0x3b5f('0x1c')](util['format']('[END]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x4f37e8[_0x3b5f('0x1e')],_0x4f37e8[_0x3b5f('0x2e')],_0x4f37e8[_0x3b5f('0x30')],_0x4f37e8['dnid'],_0x4f37e8[_0x3b5f('0x1f')]));logger[_0x3b5f('0x1c')](util[_0x3b5f('0x1a')]('[GOTO]\x20context:\x20%s\x20extension:\x20%s\x20priority:\x20%s',_0x4f37e8[_0x3b5f('0x24')],_0x4f37e8[_0x3b5f('0x31')],parseInt(_0x4f37e8['priority'],0xa)+0x1));_0x4f37e8[_0x3b5f('0x32')](_0x4f37e8[_0x3b5f('0x24')],_0x4f37e8['extension'],parseInt(_0x4f37e8[_0x3b5f('0x25')],0xa)+0x1);_0x4f37e8[_0x3b5f('0x33')]();}function handleNotFound(_0x50461f){logger[_0x3b5f('0x8')](util[_0x3b5f('0x1a')](_0x3b5f('0x34'),_0x50461f[_0x3b5f('0x1e')]));_0x50461f[_0x3b5f('0x32')](_0x50461f['context'],_0x50461f[_0x3b5f('0x31')],parseInt(_0x50461f[_0x3b5f('0x25')],0xa)+0x1);_0x50461f[_0x3b5f('0x33')]();}function handleUnpublished(_0x208a5a){logger[_0x3b5f('0x8')](util[_0x3b5f('0x1a')]('Project\x20%s\x20not\x20published',_0x208a5a[_0x3b5f('0x1e')]));_0x208a5a[_0x3b5f('0x32')](_0x208a5a[_0x3b5f('0x24')],_0x208a5a[_0x3b5f('0x31')],parseInt(_0x208a5a[_0x3b5f('0x25')],0xa)+0x1);_0x208a5a[_0x3b5f('0x33')]();}module[_0x3b5f('0x35')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file
+var _0xa6bf=['response','stringify','code','result','evtHangup','toString','stack','[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','dnid','uniqueid','finally','clear','agicommand\x20not\x20found','[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','xml2json','util','../../config/logger','agi','./rpc','./mailRpc','./graph','./vertices','getSquareProjects','error','Unable\x20to\x20download\x20CallySquare\x20projects','agicommand','hasOwnProperty','retry','maxRetry','addVertex','omit','mxCell','length','source','target','addEdge','value','mxGraphModel','root','production','start','debug','joinAt','format','YYYY-MM-DD\x20HH:mm:ss','info','arg_1','calleridname','callerid','traverseBFS','vertex','gotoc','context','extension','priority'];(function(_0x17d9e3,_0x1f969c){var _0x14192d=function(_0x159745){while(--_0x159745){_0x17d9e3['push'](_0x17d9e3['shift']());}};_0x14192d(++_0x1f969c);}(_0xa6bf,0x188));var _0xfa6b=function(_0x30cbc4,_0x44ee82){_0x30cbc4=_0x30cbc4-0x0;var _0x208203=_0xa6bf[_0x30cbc4];return _0x208203;};'use strict';var _=require('lodash');var moment=require(_0xfa6b('0x0'));var parser=require(_0xfa6b('0x1'));var util=require(_0xfa6b('0x2'));var logger=require(_0xfa6b('0x3'))(_0xfa6b('0x4'));var rpc=require(_0xfa6b('0x5'));var mailRpc=require(_0xfa6b('0x6'));var Graph=require(_0xfa6b('0x7'));var Vertices=require(_0xfa6b('0x8'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0xfa6b('0x9')]()['catch'](function(_0x4e721d){logger[_0xfa6b('0xa')](_0xfa6b('0xb'),_0x4e721d['stack']);return[];});}function addVertex(_0x45f34c,_0x792605,_0x13d7b0){_0x792605[_0xfa6b('0xc')]=_0x13d7b0;if(_0x792605[_0xfa6b('0xd')](_0xfa6b('0xe'))){_0x792605[_0xfa6b('0xf')]=parseInt(_0x792605[_0xfa6b('0xe')],0xa);}_0x45f34c[_0xfa6b('0x10')](_[_0xfa6b('0x11')](_0x792605,_0xfa6b('0x12')));}function initGraph(_0x1eeada,_0x54bbc9){var _0x252214=new Graph();for(var _0x372b22 in _0x1eeada){if(_0x1eeada['hasOwnProperty'](_0x372b22)){if(_['isArray'](_0x1eeada[_0x372b22])){for(var _0x4a9fc6=0x0;_0x4a9fc6<_0x1eeada[_0x372b22][_0xfa6b('0x13')];_0x4a9fc6+=0x1){addVertex(_0x252214,_0x1eeada[_0x372b22][_0x4a9fc6],_0x372b22);}}else{addVertex(_0x252214,_0x1eeada[_0x372b22],_0x372b22);}}}for(var _0x2b709c=0x0;_0x2b709c<_0x54bbc9[_0xfa6b('0x13')];_0x2b709c+=0x1){if(_0x54bbc9[_0x2b709c][_0xfa6b('0x14')]&&_0x54bbc9[_0x2b709c][_0xfa6b('0x15')]){_0x252214[_0xfa6b('0x16')](_0x54bbc9[_0x2b709c][_0xfa6b('0x14')],_0x54bbc9[_0x2b709c][_0xfa6b('0x15')],_0x54bbc9[_0x2b709c][_0xfa6b('0x17')]);}}return _0x252214;}function getRoot(_0x2f0b95){return parser['toJson'](_0x2f0b95,{'object':!![]})[_0xfa6b('0x18')][_0xfa6b('0x19')];}function inspect(_0x24329c){return util['inspect'](_0x24329c,{'showHidden':![],'depth':null});}function initialize(_0x16bfe7,_0x10ca6e){var _0x20ad4b=getRoot(_0x16bfe7[_0xfa6b('0x1a')]);if(!_0x20ad4b||!_0x20ad4b[_0xfa6b('0x1b')])return;var _0x23c3b7,_0x5ad8ca,_0x53f614;logger[_0xfa6b('0x1c')](_0xfa6b('0x19'),JSON['stringify'](_0x20ad4b,null,0x2));_0x10ca6e[_0xfa6b('0x1d')]=moment()[_0xfa6b('0x1e')](_0xfa6b('0x1f'));_0x23c3b7=initGraph(_['omit'](_0x20ad4b,_0xfa6b('0x12')),_0x20ad4b['mxCell']);_0x5ad8ca=new Vertices(_0x10ca6e,rpc,mailRpc);logger[_0xfa6b('0x20')](util[_0xfa6b('0x1e')]('[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x10ca6e[_0xfa6b('0x21')],_0x10ca6e[_0xfa6b('0x22')],_0x10ca6e[_0xfa6b('0x23')],_0x10ca6e['dnid'],_0x10ca6e['uniqueid']));_0x23c3b7[_0xfa6b('0x24')](_0x20ad4b['start']['id'],function(_0x36e349){try{_0x36e349=_0x5ad8ca['clear'](_0x36e349);logger[_0xfa6b('0x1c')](_0xfa6b('0x25'),JSON['stringify'](_0x36e349,null,0x2));if(_0x36e349[_0xfa6b('0xc')]===_0xfa6b('0x26')){logger['info']('gotoc\x20block\x20stop\x20traverse\x20BFS');_0x10ca6e[_0xfa6b('0x27')]=_0x36e349[_0xfa6b('0x27')]||_0x10ca6e['context'];_0x10ca6e[_0xfa6b('0x28')]=_0x36e349['extension'];_0x10ca6e['priority']=_0x36e349[_0xfa6b('0x29')]?_0x36e349[_0xfa6b('0x29')]-0x1:0x1;return null;}else if(_0x36e349&&_0x5ad8ca[_0x36e349[_0xfa6b('0xc')]]){_0x53f614=_0x5ad8ca[_0x36e349['agicommand']](_0x36e349);logger['info'](_0xfa6b('0x2a'),JSON[_0xfa6b('0x2b')](_0x53f614,null,0x2));if(_0x53f614&&_0x53f614[_0xfa6b('0x2c')]===AGI_CODE_SUCCESS&&_0x53f614[_0xfa6b('0x2d')]!==AGI_RESULT_ERROR&&!_0x10ca6e[_0xfa6b('0x2e')]){logger[_0xfa6b('0x1c')](_0xfa6b('0x2a'),inspect(_0x53f614));return _['isUndefined'](_0x53f614[_0xfa6b('0x2d')])?null:_0x53f614[_0xfa6b('0x2d')][_0xfa6b('0x2f')]();}else{logger['error'](_0xfa6b('0x2a'),inspect(_0x53f614));return null;}}else{logger[_0xfa6b('0xa')]('agicommand\x20not\x20found');return null;}}catch(_0x6e0ade){logger[_0xfa6b('0xa')](_0x6e0ade[_0xfa6b('0x30')]);return null;}});if(_0x20ad4b['finally']){logger[_0xfa6b('0x20')](util[_0xfa6b('0x1e')](_0xfa6b('0x31'),_0x10ca6e['arg_1'],_0x10ca6e['calleridname'],_0x10ca6e[_0xfa6b('0x23')],_0x10ca6e[_0xfa6b('0x32')],_0x10ca6e[_0xfa6b('0x33')]));_0x23c3b7[_0xfa6b('0x24')](_0x20ad4b[_0xfa6b('0x34')]['id'],function(_0xf42b02){try{_0xf42b02=_0x5ad8ca[_0xfa6b('0x35')](_0xf42b02);logger['debug']('vertex',JSON[_0xfa6b('0x2b')](_0xf42b02,null,0x2));if(_0xf42b02&&_0x5ad8ca[_0xf42b02[_0xfa6b('0xc')]]){_0x53f614=_0x5ad8ca[_0xf42b02['agicommand']](_0xf42b02);if(_0x53f614){logger[_0xfa6b('0x1c')](_0xfa6b('0x2a'),inspect(_0x53f614));return _['isUndefined'](_0x53f614['result'])?null:_0x53f614[_0xfa6b('0x2d')][_0xfa6b('0x2f')]();}else{logger[_0xfa6b('0xa')]('response',inspect(_0x53f614));return null;}}else{logger[_0xfa6b('0xa')](_0xfa6b('0x36'));return null;}}catch(_0x4991f4){logger[_0xfa6b('0xa')](_0x4991f4[_0xfa6b('0x30')]);return null;}});}logger[_0xfa6b('0x20')](util[_0xfa6b('0x1e')](_0xfa6b('0x37'),_0x10ca6e[_0xfa6b('0x21')],_0x10ca6e[_0xfa6b('0x22')],_0x10ca6e[_0xfa6b('0x23')],_0x10ca6e[_0xfa6b('0x32')],_0x10ca6e[_0xfa6b('0x33')]));logger[_0xfa6b('0x20')](util[_0xfa6b('0x1e')](_0xfa6b('0x38'),_0x10ca6e[_0xfa6b('0x27')],_0x10ca6e['extension'],parseInt(_0x10ca6e['priority'],0xa)+0x1));_0x10ca6e[_0xfa6b('0x39')](_0x10ca6e['context'],_0x10ca6e['extension'],parseInt(_0x10ca6e[_0xfa6b('0x29')],0xa)+0x1);_0x10ca6e['close']();}function handleNotFound(_0x4389b0){logger[_0xfa6b('0xa')](util[_0xfa6b('0x1e')](_0xfa6b('0x3a'),_0x4389b0[_0xfa6b('0x21')]));_0x4389b0[_0xfa6b('0x39')](_0x4389b0[_0xfa6b('0x27')],_0x4389b0[_0xfa6b('0x28')],parseInt(_0x4389b0['priority'],0xa)+0x1);_0x4389b0[_0xfa6b('0x3b')]();}function handleUnpublished(_0x1abeea){logger['error'](util[_0xfa6b('0x1e')](_0xfa6b('0x3c'),_0x1abeea[_0xfa6b('0x21')]));_0x1abeea['continueAt'](_0x1abeea[_0xfa6b('0x27')],_0x1abeea['extension'],parseInt(_0x1abeea[_0xfa6b('0x29')],0xa)+0x1);_0x1abeea[_0xfa6b('0x3b')]();}module[_0xfa6b('0x3d')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file