Built motion from commit f57cc866.|2.6.31
[motion2.git] / server / services / agi / index.js
index 7febedb..84c5b02 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb46f=['callerid','uniqueid','[HANGUP]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','indexOf','agi_','debug','stringify','[START]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','hangup','handleNotFound','handleUnpublished','initialize','getLicense','then','voice','callysquare','[LICENSE]\x20CHANNELS:\x20UNLIMITED','getAll','[LICENSE]','finally','listening','connection','close','syncho','util','../../config/environment','../../config/logger','agi','./rpc','./project','EventEmitter','127.0.0.1','projectUpdate','stack','findIndex','splice','push','production','log','Cally\x20Square\x20server\x20listening\x20on\x20port\x20%d!','port','info','format','[LISTENING]\x20Cally\x20Square\x20listening\x20%s:%d','name','error','[%s]\x20%s','[ERROR]\x20%s','arg_1','calleridname','dnid','[TIMEOUT]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s'];(function(_0x2e612b,_0x290af4){var _0x5aad14=function(_0x2cd899){while(--_0x2cd899){_0x2e612b['push'](_0x2e612b['shift']());}};_0x5aad14(++_0x290af4);}(_0xb46f,0xb3));var _0xfb46=function(_0x54125c,_0x1c9b8c){_0x54125c=_0x54125c-0x0;var _0x545c43=_0xb46f[_0x54125c];return _0x545c43;};'use strict';var _=require('lodash');var syncho=require(_0xfb46('0x0'));var util=require(_0xfb46('0x1'));var config=require(_0xfb46('0x2'));var logger=require(_0xfb46('0x3'))(_0xfb46('0x4'));var utilLicense=require('../../config/license/util');var rpc=require(_0xfb46('0x5'));var Project=require(_0xfb46('0x6'));var AGIEmitter=require('./events')[_0xfb46('0x7')];var projects=[];config['agi']=_['defaults'](config[_0xfb46('0x4')],{'ip':_0xfb46('0x8'),'port':0x11dd});AGIEmitter['on'](_0xfb46('0x9'),projectUpdateHandler);function connectionHandler(_0x5dcb8d){process['nextTick'](function(){syncho(function(){try{setChannelVariables(_0x5dcb8d);agiHandler(_0x5dcb8d);}catch(_0x44bfb0){logger['error'](_0x44bfb0[_0xfb46('0xa')]);}});});}function projectUpdateHandler(_0x44564c){try{var _0xfe4f69=_[_0xfb46('0xb')](projects,['id',_0x44564c['id']]);if(_0xfe4f69>-0x1){if(_0x44564c['deleted']===!![]){projects[_0xfb46('0xc')](_0xfe4f69,0x1);}else{projects[_0xfe4f69]=_0x44564c;}}else{projects[_0xfb46('0xd')](_0x44564c);}}catch(_0x52943b){logger['error'](_0x52943b[_0xfb46('0xa')]);}}function listeningHandler(){var _0x1064e6=config['env']===_0xfb46('0xe')||![];console[_0xfb46('0xf')](_0xfb46('0x10'),config[_0xfb46('0x4')][_0xfb46('0x11')]);logger[_0xfb46('0x12')](util[_0xfb46('0x13')](_0xfb46('0x14'),_0x1064e6?config[_0xfb46('0x4')]['ip']:'host.docker.internal',config[_0xfb46('0x4')][_0xfb46('0x11')]));}function errorHandler(_0x2c1a9e){if(_0x2c1a9e&&_0x2c1a9e[_0xfb46('0x15')]&&_0x2c1a9e['message']){logger[_0xfb46('0x16')](util[_0xfb46('0x13')](_0xfb46('0x17'),_0x2c1a9e[_0xfb46('0x15')],_0x2c1a9e['message']));}else{logger['error'](util[_0xfb46('0x13')](_0xfb46('0x18'),_0x2c1a9e[_0xfb46('0xa')]));}}function closeHandler(){logger[_0xfb46('0x12')](util[_0xfb46('0x13')]('[CLOSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this[_0xfb46('0x19')],this[_0xfb46('0x1a')],this['callerid'],this[_0xfb46('0x1b')],this['uniqueid']));try{createSquareReport(this);}catch(_0x398ce3){logger[_0xfb46('0x16')](_0x398ce3[_0xfb46('0xa')]);}}function timeoutHandler(){logger['info'](util['format'](_0xfb46('0x1c'),this['arg_1'],this[_0xfb46('0x1a')],this[_0xfb46('0x1d')],this[_0xfb46('0x1b')],this[_0xfb46('0x1e')]));}function hangupHandler(){logger['info'](util['format'](_0xfb46('0x1f'),this[_0xfb46('0x19')],this[_0xfb46('0x1a')],this['callerid'],this[_0xfb46('0x1b')],this['uniqueid']));this['evtHangup']=!![];}function createSquareReport(_0x55b30f,_0x38f08e){rpc['createSquareReport'](_0x55b30f)['then'](function(_0x44adca){if(_0x38f08e){_0x38f08e(null,_0x44adca);}})['catch'](function(_0x167fab){if(_0x38f08e){_0x38f08e(null,_0x167fab);}});}function setChannelVariables(_0x53b3b6){for(var _0x55f814 in _0x53b3b6){if(_0x53b3b6['hasOwnProperty'](_0x55f814)){if(_0x55f814[_0xfb46('0x20')](_0xfb46('0x21'))===0x0){_0x53b3b6[_0x55f814['substring'](0x4)]=_0x53b3b6[_0x55f814];delete _0x53b3b6[_0x55f814];}}}}function agiHandler(_0x56241a){logger[_0xfb46('0x22')]('variables',JSON[_0xfb46('0x23')](_0x56241a,null,0x2));logger[_0xfb46('0x12')](util['format'](_0xfb46('0x24'),_0x56241a['arg_1'],_0x56241a[_0xfb46('0x1a')],_0x56241a[_0xfb46('0x1d')],_0x56241a[_0xfb46('0x1b')],_0x56241a[_0xfb46('0x1e')]));_0x56241a['on']('error',errorHandler);_0x56241a['on']('close',closeHandler);_0x56241a['on']('timeout',timeoutHandler);_0x56241a['evtHangup']=![];_0x56241a['on'](_0xfb46('0x25'),hangupHandler);var _0x5a0d2e=_['find'](projects,['name',_0x56241a[_0xfb46('0x19')]]);if(!_0x5a0d2e)return Project[_0xfb46('0x26')](_0x56241a);if(!_0x5a0d2e[_0xfb46('0xe')])return Project[_0xfb46('0x27')](_0x56241a);return Project[_0xfb46('0x28')](_0x5a0d2e,_0x56241a);}function main(){var _0x3b57cf;return utilLicense[_0xfb46('0x29')]()[_0xfb46('0x2a')](function(_0x4b9ccf){if(!_0x4b9ccf)return;if(_0x4b9ccf[_0xfb46('0x2b')]){if(_0x4b9ccf[_0xfb46('0x2c')]&&_0x4b9ccf[_0xfb46('0x2c')]>0x0){logger[_0xfb46('0x12')](util[_0xfb46('0x13')]('[LICENSE]\x20CHANNELS:\x20%s',_0x4b9ccf['callysquare']));_0x3b57cf=_0x4b9ccf[_0xfb46('0x2c')];}else{logger[_0xfb46('0x12')](_0xfb46('0x2d'));}}else{logger[_0xfb46('0x12')]('[LICENSE]\x20VOICE\x20IS\x20DISABLED');_0x3b57cf=-0x1;}})[_0xfb46('0x2a')](function(){return Project[_0xfb46('0x2e')]();})[_0xfb46('0x2a')](function(_0xeebb8d){projects=_0xeebb8d;return;})['catch'](function(_0x1f6108){logger[_0xfb46('0x16')](_0xfb46('0x2f'),_0x1f6108[_0xfb46('0xa')]);})[_0xfb46('0x30')](function(){var _0x526d8a=require('./server')(config['agi']['port'],config[_0xfb46('0x4')]['ip'],_0x3b57cf);_0x526d8a['on'](_0xfb46('0x16'),errorHandler);_0x526d8a['on'](_0xfb46('0x31'),listeningHandler);_0x526d8a['on'](_0xfb46('0x32'),connectionHandler);_0x526d8a['on'](_0xfb46('0x33'),closeHandler);});}main();
\ No newline at end of file
+var _0x6fe0=['Cally\x20Square\x20server\x20listening\x20on\x20port\x20%d!','format','name','[%s]\x20%s','[ERROR]\x20%s','info','[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','createSquareReport','then','catch','indexOf','agi_','substring','debug','stringify','close','timeout','hangup','handleNotFound','handleUnpublished','initialize','getLicense','voice','callysquare','[LICENSE]\x20CHANNELS:\x20UNLIMITED','[LICENSE]\x20VOICE\x20IS\x20DISABLED','[LICENSE]','finally','./server','port','listening','connection','lodash','util','../../config/environment','../../config/license/util','./rpc','./events','EventEmitter','agi','defaults','127.0.0.1','projectUpdate','error','findIndex','deleted','splice','stack','production'];(function(_0x4f96ac,_0x18dc01){var _0x33bd52=function(_0x4081ee){while(--_0x4081ee){_0x4f96ac['push'](_0x4f96ac['shift']());}};_0x33bd52(++_0x18dc01);}(_0x6fe0,0x1b7));var _0x06fe=function(_0x5b8b97,_0x6b4dfa){_0x5b8b97=_0x5b8b97-0x0;var _0x1fdf84=_0x6fe0[_0x5b8b97];return _0x1fdf84;};'use strict';var _=require(_0x06fe('0x0'));var syncho=require('syncho');var util=require(_0x06fe('0x1'));var config=require(_0x06fe('0x2'));var logger=require('../../config/logger')('agi');var utilLicense=require(_0x06fe('0x3'));var rpc=require(_0x06fe('0x4'));var Project=require('./project');var AGIEmitter=require(_0x06fe('0x5'))[_0x06fe('0x6')];var projects=[];config[_0x06fe('0x7')]=_[_0x06fe('0x8')](config[_0x06fe('0x7')],{'ip':_0x06fe('0x9'),'port':0x11dd});AGIEmitter['on'](_0x06fe('0xa'),projectUpdateHandler);function connectionHandler(_0x1b6400){process['nextTick'](function(){syncho(function(){try{setChannelVariables(_0x1b6400);agiHandler(_0x1b6400);}catch(_0x2b7fbc){logger[_0x06fe('0xb')](_0x2b7fbc['stack']);}});});}function projectUpdateHandler(_0x1ceaf6){try{var _0x5f5a41=_[_0x06fe('0xc')](projects,['id',_0x1ceaf6['id']]);if(_0x5f5a41>-0x1){if(_0x1ceaf6[_0x06fe('0xd')]===!![]){projects[_0x06fe('0xe')](_0x5f5a41,0x1);}else{projects[_0x5f5a41]=_0x1ceaf6;}}else{projects['push'](_0x1ceaf6);}}catch(_0x32bc2b){logger[_0x06fe('0xb')](_0x32bc2b[_0x06fe('0xf')]);}}function listeningHandler(){var _0x493e58=config['env']===_0x06fe('0x10')||![];console['log'](_0x06fe('0x11'),config[_0x06fe('0x7')]['port']);logger['info'](util[_0x06fe('0x12')]('[LISTENING]\x20Cally\x20Square\x20listening\x20%s:%d',_0x493e58?config['agi']['ip']:'host.docker.internal',config['agi']['port']));}function errorHandler(_0x4852b3){if(_0x4852b3&&_0x4852b3[_0x06fe('0x13')]&&_0x4852b3['message']){logger[_0x06fe('0xb')](util[_0x06fe('0x12')](_0x06fe('0x14'),_0x4852b3[_0x06fe('0x13')],_0x4852b3['message']));}else{logger[_0x06fe('0xb')](util['format'](_0x06fe('0x15'),_0x4852b3[_0x06fe('0xf')]));}}function closeHandler(){logger[_0x06fe('0x16')](util[_0x06fe('0x12')](_0x06fe('0x17'),this[_0x06fe('0x18')],this[_0x06fe('0x19')],this[_0x06fe('0x1a')],this[_0x06fe('0x1b')],this[_0x06fe('0x1c')]));try{createSquareReport(this);}catch(_0x7b0d3a){logger[_0x06fe('0xb')](_0x7b0d3a[_0x06fe('0xf')]);}}function timeoutHandler(){logger['info'](util[_0x06fe('0x12')](_0x06fe('0x1d'),this[_0x06fe('0x18')],this[_0x06fe('0x19')],this[_0x06fe('0x1a')],this[_0x06fe('0x1b')],this['uniqueid']));}function hangupHandler(){logger[_0x06fe('0x16')](util[_0x06fe('0x12')](_0x06fe('0x1e'),this[_0x06fe('0x18')],this['calleridname'],this[_0x06fe('0x1a')],this[_0x06fe('0x1b')],this[_0x06fe('0x1c')]));this[_0x06fe('0x1f')]=!![];}function createSquareReport(_0x2e3441,_0x26bc9a){rpc[_0x06fe('0x20')](_0x2e3441)[_0x06fe('0x21')](function(_0x2cf4c4){if(_0x26bc9a){_0x26bc9a(null,_0x2cf4c4);}})[_0x06fe('0x22')](function(_0x203fe4){if(_0x26bc9a){_0x26bc9a(null,_0x203fe4);}});}function setChannelVariables(_0x338b11){for(var _0x4b6be7 in _0x338b11){if(_0x338b11['hasOwnProperty'](_0x4b6be7)){if(_0x4b6be7[_0x06fe('0x23')](_0x06fe('0x24'))===0x0){_0x338b11[_0x4b6be7[_0x06fe('0x25')](0x4)]=_0x338b11[_0x4b6be7];delete _0x338b11[_0x4b6be7];}}}}function agiHandler(_0x2adeff){logger[_0x06fe('0x26')]('variables',JSON[_0x06fe('0x27')](_0x2adeff,null,0x2));logger[_0x06fe('0x16')](util[_0x06fe('0x12')]('[START]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x2adeff['arg_1'],_0x2adeff['calleridname'],_0x2adeff[_0x06fe('0x1a')],_0x2adeff[_0x06fe('0x1b')],_0x2adeff[_0x06fe('0x1c')]));_0x2adeff['on']('error',errorHandler);_0x2adeff['on'](_0x06fe('0x28'),closeHandler);_0x2adeff['on'](_0x06fe('0x29'),timeoutHandler);_0x2adeff[_0x06fe('0x1f')]=![];_0x2adeff['on'](_0x06fe('0x2a'),hangupHandler);var _0x3b735b=_['find'](projects,[_0x06fe('0x13'),_0x2adeff[_0x06fe('0x18')]]);if(!_0x3b735b)return Project[_0x06fe('0x2b')](_0x2adeff);if(!_0x3b735b[_0x06fe('0x10')])return Project[_0x06fe('0x2c')](_0x2adeff);return Project[_0x06fe('0x2d')](_0x3b735b,_0x2adeff);}function main(){var _0x2ee66d;return utilLicense[_0x06fe('0x2e')]()[_0x06fe('0x21')](function(_0x231a0a){if(!_0x231a0a)return;if(_0x231a0a[_0x06fe('0x2f')]){if(_0x231a0a['callysquare']&&_0x231a0a[_0x06fe('0x30')]>0x0){logger[_0x06fe('0x16')](util[_0x06fe('0x12')]('[LICENSE]\x20CHANNELS:\x20%s',_0x231a0a[_0x06fe('0x30')]));_0x2ee66d=_0x231a0a['callysquare'];}else{logger[_0x06fe('0x16')](_0x06fe('0x31'));}}else{logger[_0x06fe('0x16')](_0x06fe('0x32'));_0x2ee66d=-0x1;}})[_0x06fe('0x21')](function(){return Project['getAll']();})[_0x06fe('0x21')](function(_0x2db100){projects=_0x2db100;return;})[_0x06fe('0x22')](function(_0x1f553f){logger[_0x06fe('0xb')](_0x06fe('0x33'),_0x1f553f[_0x06fe('0xf')]);})[_0x06fe('0x34')](function(){var _0x4a7408=require(_0x06fe('0x35'))(config[_0x06fe('0x7')][_0x06fe('0x36')],config[_0x06fe('0x7')]['ip'],_0x2ee66d);_0x4a7408['on'](_0x06fe('0xb'),errorHandler);_0x4a7408['on'](_0x06fe('0x37'),listeningHandler);_0x4a7408['on'](_0x06fe('0x38'),connectionHandler);_0x4a7408['on'](_0x06fe('0x28'),closeHandler);});}main();
\ No newline at end of file