Built motion from commit ff78e754.|2.6.29
[motion2.git] / server / services / agi / index.js
index e22342c..535b496 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x92f6=['handleUnpublished','initialize','getLicense','voice','callysquare','[LICENSE]\x20CHANNELS:\x20%s','[LICENSE]\x20CHANNELS:\x20UNLIMITED','[LICENSE]\x20VOICE\x20IS\x20DISABLED','getAll','[LICENSE]','./server','listening','connection','close','lodash','syncho','util','../../config/environment','agi','./project','./events','EventEmitter','defaults','127.0.0.1','projectUpdate','stack','findIndex','deleted','splice','error','log','Cally\x20Square\x20server\x20listening\x20on\x20port\x20%d!','port','info','format','[LISTENING]\x20Cally\x20Square\x20listening\x20%s:%d','name','message','[%s]\x20%s','[CLOSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','calleridname','callerid','dnid','uniqueid','[TIMEOUT]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','[HANGUP]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','evtHangup','then','catch','hasOwnProperty','indexOf','agi_','substring','debug','variables','stringify','timeout','find','handleNotFound','production'];(function(_0x1ac595,_0x5d2081){var _0x455fff=function(_0x3043ee){while(--_0x3043ee){_0x1ac595['push'](_0x1ac595['shift']());}};_0x455fff(++_0x5d2081);}(_0x92f6,0x13f));var _0x692f=function(_0x473e36,_0x3835f0){_0x473e36=_0x473e36-0x0;var _0x32cd5a=_0x92f6[_0x473e36];return _0x32cd5a;};'use strict';var _=require(_0x692f('0x0'));var syncho=require(_0x692f('0x1'));var util=require(_0x692f('0x2'));var config=require(_0x692f('0x3'));var logger=require('../../config/logger')(_0x692f('0x4'));var utilLicense=require('../../config/license/util');var rpc=require('./rpc');var Project=require(_0x692f('0x5'));var AGIEmitter=require(_0x692f('0x6'))[_0x692f('0x7')];var projects=[];config[_0x692f('0x4')]=_[_0x692f('0x8')](config[_0x692f('0x4')],{'ip':_0x692f('0x9'),'port':0x11dd});AGIEmitter['on'](_0x692f('0xa'),projectUpdateHandler);function connectionHandler(_0x54400b){process['nextTick'](function(){syncho(function(){try{setChannelVariables(_0x54400b);agiHandler(_0x54400b);}catch(_0x2ce90d){logger['error'](_0x2ce90d[_0x692f('0xb')]);}});});}function projectUpdateHandler(_0x548699){try{var _0x41c53d=_[_0x692f('0xc')](projects,['id',_0x548699['id']]);if(_0x41c53d>-0x1){if(_0x548699[_0x692f('0xd')]===!![]){projects[_0x692f('0xe')](_0x41c53d,0x1);}else{projects[_0x41c53d]=_0x548699;}}else{projects['push'](_0x548699);}}catch(_0x4cc49a){logger[_0x692f('0xf')](_0x4cc49a[_0x692f('0xb')]);}}function listeningHandler(){console[_0x692f('0x10')](_0x692f('0x11'),config[_0x692f('0x4')][_0x692f('0x12')]);logger[_0x692f('0x13')](util[_0x692f('0x14')](_0x692f('0x15'),config['agi']['ip'],config['agi'][_0x692f('0x12')]));}function errorHandler(_0x1e3346){if(_0x1e3346&&_0x1e3346[_0x692f('0x16')]&&_0x1e3346[_0x692f('0x17')]){logger[_0x692f('0xf')](util[_0x692f('0x14')](_0x692f('0x18'),_0x1e3346[_0x692f('0x16')],_0x1e3346[_0x692f('0x17')]));}else{logger[_0x692f('0xf')](util[_0x692f('0x14')]('[ERROR]\x20%s',_0x1e3346[_0x692f('0xb')]));}}function closeHandler(){logger[_0x692f('0x13')](util[_0x692f('0x14')](_0x692f('0x19'),this[_0x692f('0x1a')],this[_0x692f('0x1b')],this[_0x692f('0x1c')],this[_0x692f('0x1d')],this[_0x692f('0x1e')]));try{createSquareReport(this);}catch(_0x18e9a5){logger[_0x692f('0xf')](_0x18e9a5[_0x692f('0xb')]);}}function timeoutHandler(){logger['info'](util[_0x692f('0x14')](_0x692f('0x1f'),this[_0x692f('0x1a')],this[_0x692f('0x1b')],this[_0x692f('0x1c')],this[_0x692f('0x1d')],this[_0x692f('0x1e')]));}function hangupHandler(){logger['info'](util[_0x692f('0x14')](_0x692f('0x20'),this[_0x692f('0x1a')],this['calleridname'],this['callerid'],this[_0x692f('0x1d')],this[_0x692f('0x1e')]));this[_0x692f('0x21')]=!![];}function createSquareReport(_0x5dda29,_0x161690){rpc['createSquareReport'](_0x5dda29)[_0x692f('0x22')](function(_0x54deb1){if(_0x161690){_0x161690(null,_0x54deb1);}})[_0x692f('0x23')](function(_0x48c962){if(_0x161690){_0x161690(null,_0x48c962);}});}function setChannelVariables(_0x245b12){for(var _0x1371f7 in _0x245b12){if(_0x245b12[_0x692f('0x24')](_0x1371f7)){if(_0x1371f7[_0x692f('0x25')](_0x692f('0x26'))===0x0){_0x245b12[_0x1371f7[_0x692f('0x27')](0x4)]=_0x245b12[_0x1371f7];delete _0x245b12[_0x1371f7];}}}}function agiHandler(_0xbf34ca){logger[_0x692f('0x28')](_0x692f('0x29'),JSON[_0x692f('0x2a')](_0xbf34ca,null,0x2));logger[_0x692f('0x13')](util[_0x692f('0x14')]('[START]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0xbf34ca[_0x692f('0x1a')],_0xbf34ca[_0x692f('0x1b')],_0xbf34ca[_0x692f('0x1c')],_0xbf34ca['dnid'],_0xbf34ca['uniqueid']));_0xbf34ca['on'](_0x692f('0xf'),errorHandler);_0xbf34ca['on']('close',closeHandler);_0xbf34ca['on'](_0x692f('0x2b'),timeoutHandler);_0xbf34ca[_0x692f('0x21')]=![];_0xbf34ca['on']('hangup',hangupHandler);var _0x400090=_[_0x692f('0x2c')](projects,[_0x692f('0x16'),_0xbf34ca[_0x692f('0x1a')]]);if(!_0x400090)return Project[_0x692f('0x2d')](_0xbf34ca);if(!_0x400090[_0x692f('0x2e')])return Project[_0x692f('0x2f')](_0xbf34ca);return Project[_0x692f('0x30')](_0x400090,_0xbf34ca);}function main(){var _0x326857;return utilLicense[_0x692f('0x31')]()[_0x692f('0x22')](function(_0x34671e){if(!_0x34671e)return;if(_0x34671e[_0x692f('0x32')]){if(_0x34671e['callysquare']&&_0x34671e[_0x692f('0x33')]>0x0){logger['info'](util[_0x692f('0x14')](_0x692f('0x34'),_0x34671e[_0x692f('0x33')]));_0x326857=_0x34671e[_0x692f('0x33')];}else{logger[_0x692f('0x13')](_0x692f('0x35'));}}else{logger[_0x692f('0x13')](_0x692f('0x36'));_0x326857=-0x1;}})[_0x692f('0x22')](function(){return Project[_0x692f('0x37')]();})[_0x692f('0x22')](function(_0x3de9cb){projects=_0x3de9cb;return;})[_0x692f('0x23')](function(_0x2b801b){logger['error'](_0x692f('0x38'),_0x2b801b[_0x692f('0xb')]);})['finally'](function(){var _0x47b1fe=require(_0x692f('0x39'))(config[_0x692f('0x4')][_0x692f('0x12')],config[_0x692f('0x4')]['ip'],_0x326857);_0x47b1fe['on'](_0x692f('0xf'),errorHandler);_0x47b1fe['on'](_0x692f('0x3a'),listeningHandler);_0x47b1fe['on'](_0x692f('0x3b'),connectionHandler);_0x47b1fe['on'](_0x692f('0x3c'),closeHandler);});}main();
\ No newline at end of file
+var _0x5a1b=['projectUpdate','nextTick','error','stack','splice','push','Cally\x20Square\x20server\x20listening\x20on\x20port\x20%d!','port','info','format','name','message','[CLOSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','calleridname','callerid','uniqueid','dnid','evtHangup','createSquareReport','then','catch','hasOwnProperty','indexOf','agi_','substring','debug','variables','stringify','[START]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','timeout','hangup','find','handleNotFound','production','handleUnpublished','getLicense','voice','callysquare','[LICENSE]\x20CHANNELS:\x20%s','[LICENSE]\x20CHANNELS:\x20UNLIMITED','[LICENSE]\x20VOICE\x20IS\x20DISABLED','[LICENSE]','finally','listening','connection','close','lodash','syncho','util','agi','../../config/license/util','./rpc','./project','./events','EventEmitter','127.0.0.1'];(function(_0x35a9db,_0x444a01){var _0x35a528=function(_0x30a44b){while(--_0x30a44b){_0x35a9db['push'](_0x35a9db['shift']());}};_0x35a528(++_0x444a01);}(_0x5a1b,0x68));var _0xb5a1=function(_0x12f3f4,_0x5ea95f){_0x12f3f4=_0x12f3f4-0x0;var _0x41d2f6=_0x5a1b[_0x12f3f4];return _0x41d2f6;};'use strict';var _=require(_0xb5a1('0x0'));var syncho=require(_0xb5a1('0x1'));var util=require(_0xb5a1('0x2'));var config=require('../../config/environment');var logger=require('../../config/logger')(_0xb5a1('0x3'));var utilLicense=require(_0xb5a1('0x4'));var rpc=require(_0xb5a1('0x5'));var Project=require(_0xb5a1('0x6'));var AGIEmitter=require(_0xb5a1('0x7'))[_0xb5a1('0x8')];var projects=[];config[_0xb5a1('0x3')]=_['defaults'](config['agi'],{'ip':_0xb5a1('0x9'),'port':0x11dd});AGIEmitter['on'](_0xb5a1('0xa'),projectUpdateHandler);function connectionHandler(_0x3a346d){process[_0xb5a1('0xb')](function(){syncho(function(){try{setChannelVariables(_0x3a346d);agiHandler(_0x3a346d);}catch(_0x542dda){logger[_0xb5a1('0xc')](_0x542dda[_0xb5a1('0xd')]);}});});}function projectUpdateHandler(_0x36fffa){try{var _0x26a087=_['findIndex'](projects,['id',_0x36fffa['id']]);if(_0x26a087>-0x1){if(_0x36fffa['deleted']===!![]){projects[_0xb5a1('0xe')](_0x26a087,0x1);}else{projects[_0x26a087]=_0x36fffa;}}else{projects[_0xb5a1('0xf')](_0x36fffa);}}catch(_0x5235f7){logger[_0xb5a1('0xc')](_0x5235f7[_0xb5a1('0xd')]);}}function listeningHandler(){console['log'](_0xb5a1('0x10'),config['agi'][_0xb5a1('0x11')]);logger[_0xb5a1('0x12')](util[_0xb5a1('0x13')]('[LISTENING]\x20Cally\x20Square\x20listening\x20%s:%d',config['agi']['ip'],config[_0xb5a1('0x3')][_0xb5a1('0x11')]));}function errorHandler(_0x4ffead){if(_0x4ffead&&_0x4ffead[_0xb5a1('0x14')]&&_0x4ffead[_0xb5a1('0x15')]){logger[_0xb5a1('0xc')](util[_0xb5a1('0x13')]('[%s]\x20%s',_0x4ffead[_0xb5a1('0x14')],_0x4ffead[_0xb5a1('0x15')]));}else{logger[_0xb5a1('0xc')](util[_0xb5a1('0x13')]('[ERROR]\x20%s',_0x4ffead[_0xb5a1('0xd')]));}}function closeHandler(){logger['info'](util['format'](_0xb5a1('0x16'),this[_0xb5a1('0x17')],this[_0xb5a1('0x18')],this[_0xb5a1('0x19')],this['dnid'],this[_0xb5a1('0x1a')]));try{createSquareReport(this);}catch(_0xde5e48){logger[_0xb5a1('0xc')](_0xde5e48['stack']);}}function timeoutHandler(){logger['info'](util[_0xb5a1('0x13')]('[TIMEOUT]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this['arg_1'],this[_0xb5a1('0x18')],this['callerid'],this[_0xb5a1('0x1b')],this[_0xb5a1('0x1a')]));}function hangupHandler(){logger[_0xb5a1('0x12')](util[_0xb5a1('0x13')]('[HANGUP]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this[_0xb5a1('0x17')],this[_0xb5a1('0x18')],this[_0xb5a1('0x19')],this[_0xb5a1('0x1b')],this['uniqueid']));this[_0xb5a1('0x1c')]=!![];}function createSquareReport(_0x594614,_0x3ab7ec){rpc[_0xb5a1('0x1d')](_0x594614)[_0xb5a1('0x1e')](function(_0x1f3070){if(_0x3ab7ec){_0x3ab7ec(null,_0x1f3070);}})[_0xb5a1('0x1f')](function(_0x83a241){if(_0x3ab7ec){_0x3ab7ec(null,_0x83a241);}});}function setChannelVariables(_0x1c4e3e){for(var _0x34e001 in _0x1c4e3e){if(_0x1c4e3e[_0xb5a1('0x20')](_0x34e001)){if(_0x34e001[_0xb5a1('0x21')](_0xb5a1('0x22'))===0x0){_0x1c4e3e[_0x34e001[_0xb5a1('0x23')](0x4)]=_0x1c4e3e[_0x34e001];delete _0x1c4e3e[_0x34e001];}}}}function agiHandler(_0x316059){logger[_0xb5a1('0x24')](_0xb5a1('0x25'),JSON[_0xb5a1('0x26')](_0x316059,null,0x2));logger[_0xb5a1('0x12')](util[_0xb5a1('0x13')](_0xb5a1('0x27'),_0x316059[_0xb5a1('0x17')],_0x316059[_0xb5a1('0x18')],_0x316059[_0xb5a1('0x19')],_0x316059[_0xb5a1('0x1b')],_0x316059[_0xb5a1('0x1a')]));_0x316059['on']('error',errorHandler);_0x316059['on']('close',closeHandler);_0x316059['on'](_0xb5a1('0x28'),timeoutHandler);_0x316059[_0xb5a1('0x1c')]=![];_0x316059['on'](_0xb5a1('0x29'),hangupHandler);var _0x9b571e=_[_0xb5a1('0x2a')](projects,[_0xb5a1('0x14'),_0x316059[_0xb5a1('0x17')]]);if(!_0x9b571e)return Project[_0xb5a1('0x2b')](_0x316059);if(!_0x9b571e[_0xb5a1('0x2c')])return Project[_0xb5a1('0x2d')](_0x316059);return Project['initialize'](_0x9b571e,_0x316059);}function main(){var _0x192a47;return utilLicense[_0xb5a1('0x2e')]()[_0xb5a1('0x1e')](function(_0x232194){if(!_0x232194)return;if(_0x232194[_0xb5a1('0x2f')]){if(_0x232194[_0xb5a1('0x30')]&&_0x232194[_0xb5a1('0x30')]>0x0){logger[_0xb5a1('0x12')](util['format'](_0xb5a1('0x31'),_0x232194[_0xb5a1('0x30')]));_0x192a47=_0x232194[_0xb5a1('0x30')];}else{logger[_0xb5a1('0x12')](_0xb5a1('0x32'));}}else{logger[_0xb5a1('0x12')](_0xb5a1('0x33'));_0x192a47=-0x1;}})[_0xb5a1('0x1e')](function(){return Project['getAll']();})[_0xb5a1('0x1e')](function(_0x18050b){projects=_0x18050b;return;})['catch'](function(_0x31d64a){logger['error'](_0xb5a1('0x34'),_0x31d64a[_0xb5a1('0xd')]);})[_0xb5a1('0x35')](function(){var _0x1f1f8d=require('./server')(config[_0xb5a1('0x3')]['port'],config[_0xb5a1('0x3')]['ip'],_0x192a47);_0x1f1f8d['on'](_0xb5a1('0xc'),errorHandler);_0x1f1f8d['on'](_0xb5a1('0x36'),listeningHandler);_0x1f1f8d['on'](_0xb5a1('0x37'),connectionHandler);_0x1f1f8d['on'](_0xb5a1('0x38'),closeHandler);});}main();
\ No newline at end of file