Built motion from commit da617fac.|2.6.6
[motion2.git] / server / services / agi / project.js
index 7b83ac1..d54ea7d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf80a=['uniqueid','traverseBFS','clear','vertex','agicommand','gotoc','info','context','extension','priority','response','code','result','evtHangup','isUndefined','toString','finally','[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','[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','close','Project\x20%s\x20not\x20found','Project\x20%s\x20not\x20published','lodash','xml2json','../../config/logger','./graph','./vertices','catch','error','Unable\x20to\x20download\x20CallySquare\x20projects','stack','retry','maxRetry','mxCell','hasOwnProperty','isArray','length','addEdge','source','value','toJson','mxGraphModel','root','production','start','debug','stringify','joinAt','YYYY-MM-DD\x20HH:mm:ss','omit','format','arg_1','calleridname','callerid','dnid'];(function(_0x365e54,_0x44be74){var _0x13317a=function(_0x2d917f){while(--_0x2d917f){_0x365e54['push'](_0x365e54['shift']());}};_0x13317a(++_0x44be74);}(_0xf80a,0x8a));var _0xaf80=function(_0x592bbf,_0x592f2a){_0x592bbf=_0x592bbf-0x0;var _0x6b3377=_0xf80a[_0x592bbf];return _0x6b3377;};'use strict';var _=require(_0xaf80('0x0'));var moment=require('moment');var parser=require(_0xaf80('0x1'));var util=require('util');var logger=require(_0xaf80('0x2'))('agi');var rpc=require('./rpc');var mailRpc=require('./mailRpc');var Graph=require(_0xaf80('0x3'));var Vertices=require(_0xaf80('0x4'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc['getSquareProjects']()[_0xaf80('0x5')](function(_0x4be301){logger[_0xaf80('0x6')](_0xaf80('0x7'),_0x4be301[_0xaf80('0x8')]);return[];});}function addVertex(_0x27df09,_0x3d2ee8,_0x29f061){_0x3d2ee8['agicommand']=_0x29f061;if(_0x3d2ee8['hasOwnProperty'](_0xaf80('0x9'))){_0x3d2ee8[_0xaf80('0xa')]=parseInt(_0x3d2ee8[_0xaf80('0x9')],0xa);}_0x27df09['addVertex'](_['omit'](_0x3d2ee8,_0xaf80('0xb')));}function initGraph(_0x1b36e0,_0x31ed3e){var _0x29020d=new Graph();for(var _0x15f258 in _0x1b36e0){if(_0x1b36e0[_0xaf80('0xc')](_0x15f258)){if(_[_0xaf80('0xd')](_0x1b36e0[_0x15f258])){for(var _0x2ca8b0=0x0;_0x2ca8b0<_0x1b36e0[_0x15f258][_0xaf80('0xe')];_0x2ca8b0+=0x1){addVertex(_0x29020d,_0x1b36e0[_0x15f258][_0x2ca8b0],_0x15f258);}}else{addVertex(_0x29020d,_0x1b36e0[_0x15f258],_0x15f258);}}}for(var _0x2730f8=0x0;_0x2730f8<_0x31ed3e[_0xaf80('0xe')];_0x2730f8+=0x1){if(_0x31ed3e[_0x2730f8]['source']&&_0x31ed3e[_0x2730f8]['target']){_0x29020d[_0xaf80('0xf')](_0x31ed3e[_0x2730f8][_0xaf80('0x10')],_0x31ed3e[_0x2730f8]['target'],_0x31ed3e[_0x2730f8][_0xaf80('0x11')]);}}return _0x29020d;}function getRoot(_0x5ab053){return parser[_0xaf80('0x12')](_0x5ab053,{'object':!![]})[_0xaf80('0x13')][_0xaf80('0x14')];}function inspect(_0x503a55){return util['inspect'](_0x503a55,{'showHidden':![],'depth':null});}function initialize(_0x28bf71,_0x37f66d){var _0x11536b=getRoot(_0x28bf71[_0xaf80('0x15')]);if(!_0x11536b||!_0x11536b[_0xaf80('0x16')])return;var _0x8ca47,_0x568c37,_0x462b7;logger[_0xaf80('0x17')](_0xaf80('0x14'),JSON[_0xaf80('0x18')](_0x11536b,null,0x2));_0x37f66d[_0xaf80('0x19')]=moment()['format'](_0xaf80('0x1a'));_0x8ca47=initGraph(_[_0xaf80('0x1b')](_0x11536b,_0xaf80('0xb')),_0x11536b['mxCell']);_0x568c37=new Vertices(_0x37f66d,rpc,mailRpc);logger['info'](util[_0xaf80('0x1c')]('[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x37f66d[_0xaf80('0x1d')],_0x37f66d[_0xaf80('0x1e')],_0x37f66d[_0xaf80('0x1f')],_0x37f66d[_0xaf80('0x20')],_0x37f66d[_0xaf80('0x21')]));_0x8ca47[_0xaf80('0x22')](_0x11536b[_0xaf80('0x16')]['id'],function(_0x1b057c){try{_0x1b057c=_0x568c37[_0xaf80('0x23')](_0x1b057c);logger[_0xaf80('0x17')](_0xaf80('0x24'),JSON[_0xaf80('0x18')](_0x1b057c,null,0x2));if(_0x1b057c[_0xaf80('0x25')]===_0xaf80('0x26')){logger[_0xaf80('0x27')]('gotoc\x20block\x20stop\x20traverse\x20BFS');_0x37f66d[_0xaf80('0x28')]=_0x1b057c['context']||_0x37f66d[_0xaf80('0x28')];_0x37f66d[_0xaf80('0x29')]=_0x1b057c[_0xaf80('0x29')];_0x37f66d[_0xaf80('0x2a')]=_0x1b057c[_0xaf80('0x2a')]?_0x1b057c[_0xaf80('0x2a')]-0x1:0x1;return null;}else if(_0x1b057c&&_0x568c37[_0x1b057c[_0xaf80('0x25')]]){_0x462b7=_0x568c37[_0x1b057c[_0xaf80('0x25')]](_0x1b057c);logger[_0xaf80('0x27')](_0xaf80('0x2b'),JSON['stringify'](_0x462b7,null,0x2));if(_0x462b7&&_0x462b7[_0xaf80('0x2c')]===AGI_CODE_SUCCESS&&_0x462b7[_0xaf80('0x2d')]!==AGI_RESULT_ERROR&&!_0x37f66d[_0xaf80('0x2e')]){logger[_0xaf80('0x17')](_0xaf80('0x2b'),inspect(_0x462b7));return _[_0xaf80('0x2f')](_0x462b7[_0xaf80('0x2d')])?null:_0x462b7[_0xaf80('0x2d')][_0xaf80('0x30')]();}else{logger[_0xaf80('0x6')](_0xaf80('0x2b'),inspect(_0x462b7));return null;}}else{logger[_0xaf80('0x6')]('agicommand\x20not\x20found');return null;}}catch(_0x4a86ff){logger[_0xaf80('0x6')](_0x4a86ff[_0xaf80('0x8')]);return null;}});if(_0x11536b[_0xaf80('0x31')]){logger[_0xaf80('0x27')](util['format'](_0xaf80('0x32'),_0x37f66d[_0xaf80('0x1d')],_0x37f66d[_0xaf80('0x1e')],_0x37f66d['callerid'],_0x37f66d['dnid'],_0x37f66d[_0xaf80('0x21')]));_0x8ca47[_0xaf80('0x22')](_0x11536b[_0xaf80('0x31')]['id'],function(_0x4c4d00){try{_0x4c4d00=_0x568c37[_0xaf80('0x23')](_0x4c4d00);logger[_0xaf80('0x17')](_0xaf80('0x24'),JSON[_0xaf80('0x18')](_0x4c4d00,null,0x2));if(_0x4c4d00&&_0x568c37[_0x4c4d00['agicommand']]){_0x462b7=_0x568c37[_0x4c4d00['agicommand']](_0x4c4d00);if(_0x462b7){logger[_0xaf80('0x17')](_0xaf80('0x2b'),inspect(_0x462b7));return _[_0xaf80('0x2f')](_0x462b7[_0xaf80('0x2d')])?null:_0x462b7[_0xaf80('0x2d')][_0xaf80('0x30')]();}else{logger[_0xaf80('0x6')]('response',inspect(_0x462b7));return null;}}else{logger[_0xaf80('0x6')]('agicommand\x20not\x20found');return null;}}catch(_0x3282f1){logger[_0xaf80('0x6')](_0x3282f1[_0xaf80('0x8')]);return null;}});}logger[_0xaf80('0x27')](util['format'](_0xaf80('0x33'),_0x37f66d[_0xaf80('0x1d')],_0x37f66d[_0xaf80('0x1e')],_0x37f66d[_0xaf80('0x1f')],_0x37f66d[_0xaf80('0x20')],_0x37f66d[_0xaf80('0x21')]));logger['info'](util[_0xaf80('0x1c')](_0xaf80('0x34'),_0x37f66d[_0xaf80('0x28')],_0x37f66d[_0xaf80('0x29')],parseInt(_0x37f66d[_0xaf80('0x2a')],0xa)+0x1));_0x37f66d[_0xaf80('0x35')](_0x37f66d[_0xaf80('0x28')],_0x37f66d[_0xaf80('0x29')],parseInt(_0x37f66d[_0xaf80('0x2a')],0xa)+0x1);_0x37f66d[_0xaf80('0x36')]();}function handleNotFound(_0x4016cc){logger[_0xaf80('0x6')](util['format'](_0xaf80('0x37'),_0x4016cc[_0xaf80('0x1d')]));_0x4016cc[_0xaf80('0x35')](_0x4016cc[_0xaf80('0x28')],_0x4016cc['extension'],parseInt(_0x4016cc['priority'],0xa)+0x1);_0x4016cc[_0xaf80('0x36')]();}function handleUnpublished(_0x51077a){logger[_0xaf80('0x6')](util[_0xaf80('0x1c')](_0xaf80('0x38'),_0x51077a[_0xaf80('0x1d')]));_0x51077a[_0xaf80('0x35')](_0x51077a[_0xaf80('0x28')],_0x51077a['extension'],parseInt(_0x51077a[_0xaf80('0x2a')],0xa)+0x1);_0x51077a[_0xaf80('0x36')]();}module['exports']={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file
+var _0xb931=['code','result','evtHangup','toString','response','agicommand\x20not\x20found','traverseBFS','finally','isUndefined','[END]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','continueAt','close','Project\x20%s\x20not\x20found','Project\x20%s\x20not\x20published','exports','lodash','moment','xml2json','util','../../config/logger','./rpc','./mailRpc','./vertices','catch','error','stack','agicommand','hasOwnProperty','retry','maxRetry','addVertex','omit','mxCell','isArray','length','source','target','addEdge','value','toJson','mxGraphModel','inspect','production','start','root','stringify','format','YYYY-MM-DD\x20HH:mm:ss','info','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','calleridname','callerid','dnid','uniqueid','clear','debug','vertex','gotoc','gotoc\x20block\x20stop\x20traverse\x20BFS','context','extension','priority'];(function(_0x493588,_0x196836){var _0x4a38c5=function(_0x282082){while(--_0x282082){_0x493588['push'](_0x493588['shift']());}};_0x4a38c5(++_0x196836);}(_0xb931,0x189));var _0x1b93=function(_0x4a19c7,_0x6cfd4c){_0x4a19c7=_0x4a19c7-0x0;var _0x98b6c8=_0xb931[_0x4a19c7];return _0x98b6c8;};'use strict';var _=require(_0x1b93('0x0'));var moment=require(_0x1b93('0x1'));var parser=require(_0x1b93('0x2'));var util=require(_0x1b93('0x3'));var logger=require(_0x1b93('0x4'))('agi');var rpc=require(_0x1b93('0x5'));var mailRpc=require(_0x1b93('0x6'));var Graph=require('./graph');var Vertices=require(_0x1b93('0x7'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc['getSquareProjects']()[_0x1b93('0x8')](function(_0x3daf4f){logger[_0x1b93('0x9')]('Unable\x20to\x20download\x20CallySquare\x20projects',_0x3daf4f[_0x1b93('0xa')]);return[];});}function addVertex(_0x42f568,_0x344f76,_0x513664){_0x344f76[_0x1b93('0xb')]=_0x513664;if(_0x344f76[_0x1b93('0xc')](_0x1b93('0xd'))){_0x344f76[_0x1b93('0xe')]=parseInt(_0x344f76[_0x1b93('0xd')],0xa);}_0x42f568[_0x1b93('0xf')](_[_0x1b93('0x10')](_0x344f76,_0x1b93('0x11')));}function initGraph(_0x2567b4,_0x27513d){var _0x445276=new Graph();for(var _0xa2fb02 in _0x2567b4){if(_0x2567b4[_0x1b93('0xc')](_0xa2fb02)){if(_[_0x1b93('0x12')](_0x2567b4[_0xa2fb02])){for(var _0xbde4bc=0x0;_0xbde4bc<_0x2567b4[_0xa2fb02][_0x1b93('0x13')];_0xbde4bc+=0x1){addVertex(_0x445276,_0x2567b4[_0xa2fb02][_0xbde4bc],_0xa2fb02);}}else{addVertex(_0x445276,_0x2567b4[_0xa2fb02],_0xa2fb02);}}}for(var _0x413277=0x0;_0x413277<_0x27513d[_0x1b93('0x13')];_0x413277+=0x1){if(_0x27513d[_0x413277][_0x1b93('0x14')]&&_0x27513d[_0x413277][_0x1b93('0x15')]){_0x445276[_0x1b93('0x16')](_0x27513d[_0x413277][_0x1b93('0x14')],_0x27513d[_0x413277][_0x1b93('0x15')],_0x27513d[_0x413277][_0x1b93('0x17')]);}}return _0x445276;}function getRoot(_0xb1925d){return parser[_0x1b93('0x18')](_0xb1925d,{'object':!![]})[_0x1b93('0x19')]['root'];}function inspect(_0x2e4401){return util[_0x1b93('0x1a')](_0x2e4401,{'showHidden':![],'depth':null});}function initialize(_0x328758,_0x1f8064){var _0x1b10db=getRoot(_0x328758[_0x1b93('0x1b')]);if(!_0x1b10db||!_0x1b10db[_0x1b93('0x1c')])return;var _0x2dda05,_0x36d49f,_0x1d76e6;logger['debug'](_0x1b93('0x1d'),JSON[_0x1b93('0x1e')](_0x1b10db,null,0x2));_0x1f8064['joinAt']=moment()[_0x1b93('0x1f')](_0x1b93('0x20'));_0x2dda05=initGraph(_[_0x1b93('0x10')](_0x1b10db,'mxCell'),_0x1b10db[_0x1b93('0x11')]);_0x36d49f=new Vertices(_0x1f8064,rpc,mailRpc);logger[_0x1b93('0x21')](util[_0x1b93('0x1f')](_0x1b93('0x22'),_0x1f8064[_0x1b93('0x23')],_0x1f8064[_0x1b93('0x24')],_0x1f8064[_0x1b93('0x25')],_0x1f8064[_0x1b93('0x26')],_0x1f8064[_0x1b93('0x27')]));_0x2dda05['traverseBFS'](_0x1b10db['start']['id'],function(_0x2abe89){try{_0x2abe89=_0x36d49f[_0x1b93('0x28')](_0x2abe89);logger[_0x1b93('0x29')](_0x1b93('0x2a'),JSON[_0x1b93('0x1e')](_0x2abe89,null,0x2));if(_0x2abe89[_0x1b93('0xb')]===_0x1b93('0x2b')){logger['info'](_0x1b93('0x2c'));_0x1f8064[_0x1b93('0x2d')]=_0x2abe89[_0x1b93('0x2d')]||_0x1f8064[_0x1b93('0x2d')];_0x1f8064[_0x1b93('0x2e')]=_0x2abe89[_0x1b93('0x2e')];_0x1f8064['priority']=_0x2abe89['priority']?_0x2abe89[_0x1b93('0x2f')]-0x1:0x1;return null;}else if(_0x2abe89&&_0x36d49f[_0x2abe89[_0x1b93('0xb')]]){_0x1d76e6=_0x36d49f[_0x2abe89['agicommand']](_0x2abe89);logger[_0x1b93('0x21')]('response',JSON[_0x1b93('0x1e')](_0x1d76e6,null,0x2));if(_0x1d76e6&&_0x1d76e6[_0x1b93('0x30')]===AGI_CODE_SUCCESS&&_0x1d76e6[_0x1b93('0x31')]!==AGI_RESULT_ERROR&&!_0x1f8064[_0x1b93('0x32')]){logger[_0x1b93('0x29')]('response',inspect(_0x1d76e6));return _['isUndefined'](_0x1d76e6[_0x1b93('0x31')])?null:_0x1d76e6[_0x1b93('0x31')][_0x1b93('0x33')]();}else{logger[_0x1b93('0x9')](_0x1b93('0x34'),inspect(_0x1d76e6));return null;}}else{logger[_0x1b93('0x9')](_0x1b93('0x35'));return null;}}catch(_0x40c98e){logger[_0x1b93('0x9')](_0x40c98e[_0x1b93('0xa')]);return null;}});if(_0x1b10db['finally']){logger[_0x1b93('0x21')](util['format']('[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x1f8064[_0x1b93('0x23')],_0x1f8064[_0x1b93('0x24')],_0x1f8064[_0x1b93('0x25')],_0x1f8064[_0x1b93('0x26')],_0x1f8064['uniqueid']));_0x2dda05[_0x1b93('0x36')](_0x1b10db[_0x1b93('0x37')]['id'],function(_0x22abe6){try{_0x22abe6=_0x36d49f[_0x1b93('0x28')](_0x22abe6);logger[_0x1b93('0x29')](_0x1b93('0x2a'),JSON[_0x1b93('0x1e')](_0x22abe6,null,0x2));if(_0x22abe6&&_0x36d49f[_0x22abe6[_0x1b93('0xb')]]){_0x1d76e6=_0x36d49f[_0x22abe6[_0x1b93('0xb')]](_0x22abe6);if(_0x1d76e6){logger['debug'](_0x1b93('0x34'),inspect(_0x1d76e6));return _[_0x1b93('0x38')](_0x1d76e6[_0x1b93('0x31')])?null:_0x1d76e6['result'][_0x1b93('0x33')]();}else{logger[_0x1b93('0x9')](_0x1b93('0x34'),inspect(_0x1d76e6));return null;}}else{logger['error'](_0x1b93('0x35'));return null;}}catch(_0x1ac75b){logger[_0x1b93('0x9')](_0x1ac75b['stack']);return null;}});}logger['info'](util[_0x1b93('0x1f')](_0x1b93('0x39'),_0x1f8064[_0x1b93('0x23')],_0x1f8064['calleridname'],_0x1f8064[_0x1b93('0x25')],_0x1f8064[_0x1b93('0x26')],_0x1f8064[_0x1b93('0x27')]));logger['info'](util['format']('[GOTO]\x20context:\x20%s\x20extension:\x20%s\x20priority:\x20%s',_0x1f8064[_0x1b93('0x2d')],_0x1f8064['extension'],parseInt(_0x1f8064[_0x1b93('0x2f')],0xa)+0x1));_0x1f8064[_0x1b93('0x3a')](_0x1f8064[_0x1b93('0x2d')],_0x1f8064[_0x1b93('0x2e')],parseInt(_0x1f8064[_0x1b93('0x2f')],0xa)+0x1);_0x1f8064[_0x1b93('0x3b')]();}function handleNotFound(_0x5415db){logger[_0x1b93('0x9')](util[_0x1b93('0x1f')](_0x1b93('0x3c'),_0x5415db[_0x1b93('0x23')]));_0x5415db[_0x1b93('0x3a')](_0x5415db[_0x1b93('0x2d')],_0x5415db['extension'],parseInt(_0x5415db[_0x1b93('0x2f')],0xa)+0x1);_0x5415db['close']();}function handleUnpublished(_0x4ed343){logger[_0x1b93('0x9')](util[_0x1b93('0x1f')](_0x1b93('0x3d'),_0x4ed343[_0x1b93('0x23')]));_0x4ed343[_0x1b93('0x3a')](_0x4ed343[_0x1b93('0x2d')],_0x4ed343[_0x1b93('0x2e')],parseInt(_0x4ed343[_0x1b93('0x2f')],0xa)+0x1);_0x4ed343[_0x1b93('0x3b')]();}module[_0x1b93('0x3e')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file