Built motion from commit a8c4dd89.|2.6.33
[motion2.git] / server / services / agi / project.js
index 35398f2..1725e15 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc2aa=['arg_1','callerid','dnid','uniqueid','traverseBFS','start','clear','debug','vertex','agicommand','gotoc','gotoc\x20block\x20stop\x20traverse\x20BFS','context','extension','priority','response','code','result','isUndefined','toString','agicommand\x20not\x20found','[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','calleridname','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\x20found','close','exports','moment','xml2json','util','../../config/logger','./mailRpc','./graph','./vertices','getSquareProjects','catch','error','Unable\x20to\x20download\x20CallySquare\x20projects','stack','hasOwnProperty','retry','maxRetry','addVertex','mxCell','isArray','length','source','target','addEdge','value','toJson','mxGraphModel','root','stringify','joinAt','format','info','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s'];(function(_0x50e7e0,_0x5affce){var _0x1a0307=function(_0x32d343){while(--_0x32d343){_0x50e7e0['push'](_0x50e7e0['shift']());}};_0x1a0307(++_0x5affce);}(_0xc2aa,0x18c));var _0xac2a=function(_0x361012,_0x395290){_0x361012=_0x361012-0x0;var _0x2e8840=_0xc2aa[_0x361012];return _0x2e8840;};'use strict';var _=require('lodash');var moment=require(_0xac2a('0x0'));var parser=require(_0xac2a('0x1'));var util=require(_0xac2a('0x2'));var logger=require(_0xac2a('0x3'))('agi');var rpc=require('./rpc');var mailRpc=require(_0xac2a('0x4'));var Graph=require(_0xac2a('0x5'));var Vertices=require(_0xac2a('0x6'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0xac2a('0x7')]()[_0xac2a('0x8')](function(_0x37f4e0){logger[_0xac2a('0x9')](_0xac2a('0xa'),_0x37f4e0[_0xac2a('0xb')]);return[];});}function addVertex(_0xec85bd,_0x5c06aa,_0x1e02e6){_0x5c06aa['agicommand']=_0x1e02e6;if(_0x5c06aa[_0xac2a('0xc')](_0xac2a('0xd'))){_0x5c06aa[_0xac2a('0xe')]=parseInt(_0x5c06aa[_0xac2a('0xd')],0xa);}_0xec85bd[_0xac2a('0xf')](_['omit'](_0x5c06aa,_0xac2a('0x10')));}function initGraph(_0x53d81e,_0x4a7989){var _0x5cd8d0=new Graph();for(var _0x113642 in _0x53d81e){if(_0x53d81e['hasOwnProperty'](_0x113642)){if(_[_0xac2a('0x11')](_0x53d81e[_0x113642])){for(var _0x2e8c01=0x0;_0x2e8c01<_0x53d81e[_0x113642][_0xac2a('0x12')];_0x2e8c01+=0x1){addVertex(_0x5cd8d0,_0x53d81e[_0x113642][_0x2e8c01],_0x113642);}}else{addVertex(_0x5cd8d0,_0x53d81e[_0x113642],_0x113642);}}}for(var _0x4b8383=0x0;_0x4b8383<_0x4a7989[_0xac2a('0x12')];_0x4b8383+=0x1){if(_0x4a7989[_0x4b8383][_0xac2a('0x13')]&&_0x4a7989[_0x4b8383][_0xac2a('0x14')]){_0x5cd8d0[_0xac2a('0x15')](_0x4a7989[_0x4b8383][_0xac2a('0x13')],_0x4a7989[_0x4b8383]['target'],_0x4a7989[_0x4b8383][_0xac2a('0x16')]);}}return _0x5cd8d0;}function getRoot(_0xd7a1db){return parser[_0xac2a('0x17')](_0xd7a1db,{'object':!![]})[_0xac2a('0x18')][_0xac2a('0x19')];}function inspect(_0x2d103e){return util['inspect'](_0x2d103e,{'showHidden':![],'depth':null});}function initialize(_0x2b2703,_0x1e7425){var _0x22e054=getRoot(_0x2b2703['production']);if(!_0x22e054||!_0x22e054['start'])return;var _0x287487,_0x3e67b6,_0x5d4748;logger['debug'](_0xac2a('0x19'),JSON[_0xac2a('0x1a')](_0x22e054,null,0x2));_0x1e7425[_0xac2a('0x1b')]=moment()[_0xac2a('0x1c')]('YYYY-MM-DD\x20HH:mm:ss');_0x287487=initGraph(_['omit'](_0x22e054,'mxCell'),_0x22e054[_0xac2a('0x10')]);_0x3e67b6=new Vertices(_0x1e7425,rpc,mailRpc);logger[_0xac2a('0x1d')](util[_0xac2a('0x1c')](_0xac2a('0x1e'),_0x1e7425[_0xac2a('0x1f')],_0x1e7425['calleridname'],_0x1e7425[_0xac2a('0x20')],_0x1e7425[_0xac2a('0x21')],_0x1e7425[_0xac2a('0x22')]));_0x287487[_0xac2a('0x23')](_0x22e054[_0xac2a('0x24')]['id'],function(_0x180646){try{_0x180646=_0x3e67b6[_0xac2a('0x25')](_0x180646);logger[_0xac2a('0x26')](_0xac2a('0x27'),JSON[_0xac2a('0x1a')](_0x180646,null,0x2));if(_0x180646[_0xac2a('0x28')]===_0xac2a('0x29')){logger[_0xac2a('0x1d')](_0xac2a('0x2a'));_0x1e7425[_0xac2a('0x2b')]=_0x180646[_0xac2a('0x2b')]||_0x1e7425[_0xac2a('0x2b')];_0x1e7425[_0xac2a('0x2c')]=_0x180646[_0xac2a('0x2c')];_0x1e7425[_0xac2a('0x2d')]=_0x180646['priority']?_0x180646[_0xac2a('0x2d')]-0x1:0x1;return null;}else if(_0x180646&&_0x3e67b6[_0x180646['agicommand']]){_0x5d4748=_0x3e67b6[_0x180646[_0xac2a('0x28')]](_0x180646);logger[_0xac2a('0x1d')](_0xac2a('0x2e'),JSON[_0xac2a('0x1a')](_0x5d4748,null,0x2));if(_0x5d4748&&_0x5d4748[_0xac2a('0x2f')]===AGI_CODE_SUCCESS&&_0x5d4748[_0xac2a('0x30')]!==AGI_RESULT_ERROR&&!_0x1e7425['evtHangup']){logger['debug'](_0xac2a('0x2e'),inspect(_0x5d4748));return _[_0xac2a('0x31')](_0x5d4748[_0xac2a('0x30')])?null:_0x5d4748[_0xac2a('0x30')][_0xac2a('0x32')]();}else{logger[_0xac2a('0x9')](_0xac2a('0x2e'),inspect(_0x5d4748));return null;}}else{logger[_0xac2a('0x9')](_0xac2a('0x33'));return null;}}catch(_0x88f628){logger[_0xac2a('0x9')](_0x88f628[_0xac2a('0xb')]);return null;}});if(_0x22e054['finally']){logger['info'](util[_0xac2a('0x1c')](_0xac2a('0x34'),_0x1e7425[_0xac2a('0x1f')],_0x1e7425[_0xac2a('0x35')],_0x1e7425[_0xac2a('0x20')],_0x1e7425[_0xac2a('0x21')],_0x1e7425[_0xac2a('0x22')]));_0x287487[_0xac2a('0x23')](_0x22e054[_0xac2a('0x36')]['id'],function(_0x142067){try{_0x142067=_0x3e67b6[_0xac2a('0x25')](_0x142067);logger[_0xac2a('0x26')](_0xac2a('0x27'),JSON[_0xac2a('0x1a')](_0x142067,null,0x2));if(_0x142067&&_0x3e67b6[_0x142067[_0xac2a('0x28')]]){_0x5d4748=_0x3e67b6[_0x142067[_0xac2a('0x28')]](_0x142067);if(_0x5d4748){logger[_0xac2a('0x26')]('response',inspect(_0x5d4748));return _[_0xac2a('0x31')](_0x5d4748['result'])?null:_0x5d4748[_0xac2a('0x30')][_0xac2a('0x32')]();}else{logger['error'](_0xac2a('0x2e'),inspect(_0x5d4748));return null;}}else{logger[_0xac2a('0x9')]('agicommand\x20not\x20found');return null;}}catch(_0x3b4895){logger[_0xac2a('0x9')](_0x3b4895[_0xac2a('0xb')]);return null;}});}logger[_0xac2a('0x1d')](util[_0xac2a('0x1c')](_0xac2a('0x37'),_0x1e7425['arg_1'],_0x1e7425[_0xac2a('0x35')],_0x1e7425[_0xac2a('0x20')],_0x1e7425[_0xac2a('0x21')],_0x1e7425[_0xac2a('0x22')]));logger['info'](util[_0xac2a('0x1c')](_0xac2a('0x38'),_0x1e7425[_0xac2a('0x2b')],_0x1e7425[_0xac2a('0x2c')],parseInt(_0x1e7425[_0xac2a('0x2d')],0xa)+0x1));_0x1e7425[_0xac2a('0x39')](_0x1e7425[_0xac2a('0x2b')],_0x1e7425[_0xac2a('0x2c')],parseInt(_0x1e7425[_0xac2a('0x2d')],0xa)+0x1);_0x1e7425['close']();}function handleNotFound(_0x5eab63){logger[_0xac2a('0x9')](util[_0xac2a('0x1c')](_0xac2a('0x3a'),_0x5eab63['arg_1']));_0x5eab63[_0xac2a('0x39')](_0x5eab63['context'],_0x5eab63['extension'],parseInt(_0x5eab63[_0xac2a('0x2d')],0xa)+0x1);_0x5eab63[_0xac2a('0x3b')]();}function handleUnpublished(_0x527698){logger[_0xac2a('0x9')](util[_0xac2a('0x1c')]('Project\x20%s\x20not\x20published',_0x527698[_0xac2a('0x1f')]));_0x527698[_0xac2a('0x39')](_0x527698[_0xac2a('0x2b')],_0x527698[_0xac2a('0x2c')],parseInt(_0x527698[_0xac2a('0x2d')],0xa)+0x1);_0x527698[_0xac2a('0x3b')]();}module[_0xac2a('0x3c')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file
+var _0xb0be=['target','value','mxGraphModel','inspect','start','root','joinAt','format','YYYY-MM-DD\x20HH:mm:ss','mxCell','info','arg_1','calleridname','dnid','traverseBFS','clear','debug','vertex','stringify','gotoc','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','uniqueid','[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','Project\x20%s\x20not\x20published','close','exports','moment','xml2json','agi','./mailRpc','./graph','./vertices','getSquareProjects','catch','error','Unable\x20to\x20download\x20CallySquare\x20projects','stack','agicommand','retry','maxRetry','addVertex','omit','hasOwnProperty','isArray','length','source'];(function(_0x5678b5,_0x1c4aa8){var _0x4c09a5=function(_0x2aa89a){while(--_0x2aa89a){_0x5678b5['push'](_0x5678b5['shift']());}};_0x4c09a5(++_0x1c4aa8);}(_0xb0be,0xa3));var _0xeb0b=function(_0x59c765,_0x1b14cb){_0x59c765=_0x59c765-0x0;var _0x731b6d=_0xb0be[_0x59c765];return _0x731b6d;};'use strict';var _=require('lodash');var moment=require(_0xeb0b('0x0'));var parser=require(_0xeb0b('0x1'));var util=require('util');var logger=require('../../config/logger')(_0xeb0b('0x2'));var rpc=require('./rpc');var mailRpc=require(_0xeb0b('0x3'));var Graph=require(_0xeb0b('0x4'));var Vertices=require(_0xeb0b('0x5'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0xeb0b('0x6')]()[_0xeb0b('0x7')](function(_0x14224e){logger[_0xeb0b('0x8')](_0xeb0b('0x9'),_0x14224e[_0xeb0b('0xa')]);return[];});}function addVertex(_0x11feb6,_0xd48e22,_0x2269e0){_0xd48e22[_0xeb0b('0xb')]=_0x2269e0;if(_0xd48e22['hasOwnProperty'](_0xeb0b('0xc'))){_0xd48e22[_0xeb0b('0xd')]=parseInt(_0xd48e22['retry'],0xa);}_0x11feb6[_0xeb0b('0xe')](_[_0xeb0b('0xf')](_0xd48e22,'mxCell'));}function initGraph(_0x8c49f3,_0x253d2f){var _0x5b4114=new Graph();for(var _0x16b992 in _0x8c49f3){if(_0x8c49f3[_0xeb0b('0x10')](_0x16b992)){if(_[_0xeb0b('0x11')](_0x8c49f3[_0x16b992])){for(var _0x3a80ef=0x0;_0x3a80ef<_0x8c49f3[_0x16b992]['length'];_0x3a80ef+=0x1){addVertex(_0x5b4114,_0x8c49f3[_0x16b992][_0x3a80ef],_0x16b992);}}else{addVertex(_0x5b4114,_0x8c49f3[_0x16b992],_0x16b992);}}}for(var _0x2b0ca4=0x0;_0x2b0ca4<_0x253d2f[_0xeb0b('0x12')];_0x2b0ca4+=0x1){if(_0x253d2f[_0x2b0ca4][_0xeb0b('0x13')]&&_0x253d2f[_0x2b0ca4]['target']){_0x5b4114['addEdge'](_0x253d2f[_0x2b0ca4][_0xeb0b('0x13')],_0x253d2f[_0x2b0ca4][_0xeb0b('0x14')],_0x253d2f[_0x2b0ca4][_0xeb0b('0x15')]);}}return _0x5b4114;}function getRoot(_0x2a75b0){return parser['toJson'](_0x2a75b0,{'object':!![]})[_0xeb0b('0x16')]['root'];}function inspect(_0x33a675){return util[_0xeb0b('0x17')](_0x33a675,{'showHidden':![],'depth':null});}function initialize(_0x460e10,_0x371608){var _0x1a1e81=getRoot(_0x460e10['production']);if(!_0x1a1e81||!_0x1a1e81[_0xeb0b('0x18')])return;var _0x231e1b,_0x59e913,_0x31351f;logger['debug'](_0xeb0b('0x19'),JSON['stringify'](_0x1a1e81,null,0x2));_0x371608[_0xeb0b('0x1a')]=moment()[_0xeb0b('0x1b')](_0xeb0b('0x1c'));_0x231e1b=initGraph(_['omit'](_0x1a1e81,_0xeb0b('0x1d')),_0x1a1e81[_0xeb0b('0x1d')]);_0x59e913=new Vertices(_0x371608,rpc,mailRpc);logger[_0xeb0b('0x1e')](util['format']('[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x371608[_0xeb0b('0x1f')],_0x371608[_0xeb0b('0x20')],_0x371608['callerid'],_0x371608[_0xeb0b('0x21')],_0x371608['uniqueid']));_0x231e1b[_0xeb0b('0x22')](_0x1a1e81[_0xeb0b('0x18')]['id'],function(_0x45a79e){try{_0x45a79e=_0x59e913[_0xeb0b('0x23')](_0x45a79e);logger[_0xeb0b('0x24')](_0xeb0b('0x25'),JSON[_0xeb0b('0x26')](_0x45a79e,null,0x2));if(_0x45a79e[_0xeb0b('0xb')]===_0xeb0b('0x27')){logger[_0xeb0b('0x1e')]('gotoc\x20block\x20stop\x20traverse\x20BFS');_0x371608[_0xeb0b('0x28')]=_0x45a79e[_0xeb0b('0x28')]||_0x371608[_0xeb0b('0x28')];_0x371608['extension']=_0x45a79e[_0xeb0b('0x29')];_0x371608['priority']=_0x45a79e['priority']?_0x45a79e[_0xeb0b('0x2a')]-0x1:0x1;return null;}else if(_0x45a79e&&_0x59e913[_0x45a79e['agicommand']]){_0x31351f=_0x59e913[_0x45a79e['agicommand']](_0x45a79e);logger['info']('response',JSON[_0xeb0b('0x26')](_0x31351f,null,0x2));if(_0x31351f&&_0x31351f[_0xeb0b('0x2b')]===AGI_CODE_SUCCESS&&_0x31351f[_0xeb0b('0x2c')]!==AGI_RESULT_ERROR&&!_0x371608[_0xeb0b('0x2d')]){logger[_0xeb0b('0x24')](_0xeb0b('0x2e'),inspect(_0x31351f));return _[_0xeb0b('0x2f')](_0x31351f[_0xeb0b('0x2c')])?null:_0x31351f[_0xeb0b('0x2c')][_0xeb0b('0x30')]();}else{logger[_0xeb0b('0x8')]('response',inspect(_0x31351f));return null;}}else{logger['error'](_0xeb0b('0x31'));return null;}}catch(_0x2d61a1){logger['error'](_0x2d61a1[_0xeb0b('0xa')]);return null;}});if(_0x1a1e81[_0xeb0b('0x32')]){logger[_0xeb0b('0x1e')](util['format'](_0xeb0b('0x33'),_0x371608[_0xeb0b('0x1f')],_0x371608[_0xeb0b('0x20')],_0x371608[_0xeb0b('0x34')],_0x371608[_0xeb0b('0x21')],_0x371608[_0xeb0b('0x35')]));_0x231e1b[_0xeb0b('0x22')](_0x1a1e81['finally']['id'],function(_0x46c72c){try{_0x46c72c=_0x59e913[_0xeb0b('0x23')](_0x46c72c);logger[_0xeb0b('0x24')](_0xeb0b('0x25'),JSON[_0xeb0b('0x26')](_0x46c72c,null,0x2));if(_0x46c72c&&_0x59e913[_0x46c72c[_0xeb0b('0xb')]]){_0x31351f=_0x59e913[_0x46c72c[_0xeb0b('0xb')]](_0x46c72c);if(_0x31351f){logger['debug'](_0xeb0b('0x2e'),inspect(_0x31351f));return _[_0xeb0b('0x2f')](_0x31351f['result'])?null:_0x31351f[_0xeb0b('0x2c')][_0xeb0b('0x30')]();}else{logger[_0xeb0b('0x8')]('response',inspect(_0x31351f));return null;}}else{logger[_0xeb0b('0x8')]('agicommand\x20not\x20found');return null;}}catch(_0xf6e576){logger[_0xeb0b('0x8')](_0xf6e576[_0xeb0b('0xa')]);return null;}});}logger[_0xeb0b('0x1e')](util['format'](_0xeb0b('0x36'),_0x371608['arg_1'],_0x371608[_0xeb0b('0x20')],_0x371608[_0xeb0b('0x34')],_0x371608['dnid'],_0x371608[_0xeb0b('0x35')]));logger[_0xeb0b('0x1e')](util[_0xeb0b('0x1b')](_0xeb0b('0x37'),_0x371608['context'],_0x371608[_0xeb0b('0x29')],parseInt(_0x371608[_0xeb0b('0x2a')],0xa)+0x1));_0x371608[_0xeb0b('0x38')](_0x371608[_0xeb0b('0x28')],_0x371608['extension'],parseInt(_0x371608['priority'],0xa)+0x1);_0x371608['close']();}function handleNotFound(_0x367195){logger[_0xeb0b('0x8')](util[_0xeb0b('0x1b')](_0xeb0b('0x39'),_0x367195[_0xeb0b('0x1f')]));_0x367195['continueAt'](_0x367195[_0xeb0b('0x28')],_0x367195[_0xeb0b('0x29')],parseInt(_0x367195[_0xeb0b('0x2a')],0xa)+0x1);_0x367195['close']();}function handleUnpublished(_0x58eda7){logger[_0xeb0b('0x8')](util[_0xeb0b('0x1b')](_0xeb0b('0x3a'),_0x58eda7['arg_1']));_0x58eda7[_0xeb0b('0x38')](_0x58eda7[_0xeb0b('0x28')],_0x58eda7[_0xeb0b('0x29')],parseInt(_0x58eda7[_0xeb0b('0x2a')],0xa)+0x1);_0x58eda7[_0xeb0b('0x3b')]();}module[_0xeb0b('0x3c')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file