Built motion from commit f67b3b02.|2.6.31
[motion2.git] / server / services / agi / index.js
index ba9b396..d1138c6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4cfe=['syncho','../../config/environment','../../config/logger','agi','../../config/license/util','./rpc','./project','./events','EventEmitter','defaults','127.0.0.1','projectUpdate','nextTick','error','stack','findIndex','splice','push','env','production','log','Cally\x20Square\x20server\x20listening\x20on\x20port\x20%d!','port','info','format','[LISTENING]\x20Cally\x20Square\x20listening\x20%s:%d','host.docker.internal','name','message','[ERROR]\x20%s','[CLOSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','calleridname','dnid','uniqueid','callerid','[HANGUP]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','evtHangup','createSquareReport','catch','hasOwnProperty','indexOf','debug','variables','stringify','[START]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','close','hangup','handleUnpublished','getLicense','then','voice','callysquare','[LICENSE]\x20CHANNELS:\x20%s','[LICENSE]\x20CHANNELS:\x20UNLIMITED','[LICENSE]\x20VOICE\x20IS\x20DISABLED','getAll','finally','./server','listening','connection','lodash'];(function(_0x5ae3dc,_0x473a1e){var _0x29272c=function(_0x15fde6){while(--_0x15fde6){_0x5ae3dc['push'](_0x5ae3dc['shift']());}};_0x29272c(++_0x473a1e);}(_0x4cfe,0x1b1));var _0xe4cf=function(_0x2eec65,_0x4e0fa3){_0x2eec65=_0x2eec65-0x0;var _0x1464e6=_0x4cfe[_0x2eec65];return _0x1464e6;};'use strict';var _=require(_0xe4cf('0x0'));var syncho=require(_0xe4cf('0x1'));var util=require('util');var config=require(_0xe4cf('0x2'));var logger=require(_0xe4cf('0x3'))(_0xe4cf('0x4'));var utilLicense=require(_0xe4cf('0x5'));var rpc=require(_0xe4cf('0x6'));var Project=require(_0xe4cf('0x7'));var AGIEmitter=require(_0xe4cf('0x8'))[_0xe4cf('0x9')];var projects=[];config[_0xe4cf('0x4')]=_[_0xe4cf('0xa')](config[_0xe4cf('0x4')],{'ip':_0xe4cf('0xb'),'port':0x11dd});AGIEmitter['on'](_0xe4cf('0xc'),projectUpdateHandler);function connectionHandler(_0x4ed292){process[_0xe4cf('0xd')](function(){syncho(function(){try{setChannelVariables(_0x4ed292);agiHandler(_0x4ed292);}catch(_0x347a9f){logger[_0xe4cf('0xe')](_0x347a9f[_0xe4cf('0xf')]);}});});}function projectUpdateHandler(_0x396063){try{var _0x47b363=_[_0xe4cf('0x10')](projects,['id',_0x396063['id']]);if(_0x47b363>-0x1){if(_0x396063['deleted']===!![]){projects[_0xe4cf('0x11')](_0x47b363,0x1);}else{projects[_0x47b363]=_0x396063;}}else{projects[_0xe4cf('0x12')](_0x396063);}}catch(_0x37bb7d){logger[_0xe4cf('0xe')](_0x37bb7d[_0xe4cf('0xf')]);}}function listeningHandler(){var _0x4d1283=config[_0xe4cf('0x13')]===_0xe4cf('0x14')||![];console[_0xe4cf('0x15')](_0xe4cf('0x16'),config[_0xe4cf('0x4')][_0xe4cf('0x17')]);logger[_0xe4cf('0x18')](util[_0xe4cf('0x19')](_0xe4cf('0x1a'),_0x4d1283?config[_0xe4cf('0x4')]['ip']:_0xe4cf('0x1b'),config[_0xe4cf('0x4')][_0xe4cf('0x17')]));}function errorHandler(_0x336006){if(_0x336006&&_0x336006[_0xe4cf('0x1c')]&&_0x336006[_0xe4cf('0x1d')]){logger['error'](util['format']('[%s]\x20%s',_0x336006['name'],_0x336006[_0xe4cf('0x1d')]));}else{logger[_0xe4cf('0xe')](util['format'](_0xe4cf('0x1e'),_0x336006[_0xe4cf('0xf')]));}}function closeHandler(){logger[_0xe4cf('0x18')](util[_0xe4cf('0x19')](_0xe4cf('0x1f'),this[_0xe4cf('0x20')],this[_0xe4cf('0x21')],this['callerid'],this[_0xe4cf('0x22')],this[_0xe4cf('0x23')]));try{createSquareReport(this);}catch(_0x386d5b){logger[_0xe4cf('0xe')](_0x386d5b[_0xe4cf('0xf')]);}}function timeoutHandler(){logger[_0xe4cf('0x18')](util[_0xe4cf('0x19')]('[TIMEOUT]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this[_0xe4cf('0x20')],this[_0xe4cf('0x21')],this[_0xe4cf('0x24')],this['dnid'],this[_0xe4cf('0x23')]));}function hangupHandler(){logger['info'](util[_0xe4cf('0x19')](_0xe4cf('0x25'),this[_0xe4cf('0x20')],this[_0xe4cf('0x21')],this[_0xe4cf('0x24')],this[_0xe4cf('0x22')],this[_0xe4cf('0x23')]));this[_0xe4cf('0x26')]=!![];}function createSquareReport(_0xd4b796,_0xec191b){rpc[_0xe4cf('0x27')](_0xd4b796)['then'](function(_0x312657){if(_0xec191b){_0xec191b(null,_0x312657);}})[_0xe4cf('0x28')](function(_0x24751c){if(_0xec191b){_0xec191b(null,_0x24751c);}});}function setChannelVariables(_0x2c116a){for(var _0x17a67b in _0x2c116a){if(_0x2c116a[_0xe4cf('0x29')](_0x17a67b)){if(_0x17a67b[_0xe4cf('0x2a')]('agi_')===0x0){_0x2c116a[_0x17a67b['substring'](0x4)]=_0x2c116a[_0x17a67b];delete _0x2c116a[_0x17a67b];}}}}function agiHandler(_0xd26ede){logger[_0xe4cf('0x2b')](_0xe4cf('0x2c'),JSON[_0xe4cf('0x2d')](_0xd26ede,null,0x2));logger['info'](util[_0xe4cf('0x19')](_0xe4cf('0x2e'),_0xd26ede[_0xe4cf('0x20')],_0xd26ede[_0xe4cf('0x21')],_0xd26ede[_0xe4cf('0x24')],_0xd26ede[_0xe4cf('0x22')],_0xd26ede[_0xe4cf('0x23')]));_0xd26ede['on'](_0xe4cf('0xe'),errorHandler);_0xd26ede['on'](_0xe4cf('0x2f'),closeHandler);_0xd26ede['on']('timeout',timeoutHandler);_0xd26ede[_0xe4cf('0x26')]=![];_0xd26ede['on'](_0xe4cf('0x30'),hangupHandler);var _0x2944d3=_['find'](projects,[_0xe4cf('0x1c'),_0xd26ede[_0xe4cf('0x20')]]);if(!_0x2944d3)return Project['handleNotFound'](_0xd26ede);if(!_0x2944d3[_0xe4cf('0x14')])return Project[_0xe4cf('0x31')](_0xd26ede);return Project['initialize'](_0x2944d3,_0xd26ede);}function main(){var _0x53672f;return utilLicense[_0xe4cf('0x32')]()[_0xe4cf('0x33')](function(_0x106f8e){if(!_0x106f8e)return;if(_0x106f8e[_0xe4cf('0x34')]){if(_0x106f8e[_0xe4cf('0x35')]&&_0x106f8e['callysquare']>0x0){logger[_0xe4cf('0x18')](util[_0xe4cf('0x19')](_0xe4cf('0x36'),_0x106f8e['callysquare']));_0x53672f=_0x106f8e[_0xe4cf('0x35')];}else{logger[_0xe4cf('0x18')](_0xe4cf('0x37'));}}else{logger[_0xe4cf('0x18')](_0xe4cf('0x38'));_0x53672f=-0x1;}})[_0xe4cf('0x33')](function(){return Project[_0xe4cf('0x39')]();})[_0xe4cf('0x33')](function(_0x2958b9){projects=_0x2958b9;return;})[_0xe4cf('0x28')](function(_0x3165a9){logger[_0xe4cf('0xe')]('[LICENSE]',_0x3165a9['stack']);})[_0xe4cf('0x3a')](function(){var _0x3729be=require(_0xe4cf('0x3b'))(config[_0xe4cf('0x4')][_0xe4cf('0x17')],config[_0xe4cf('0x4')]['ip'],_0x53672f);_0x3729be['on'](_0xe4cf('0xe'),errorHandler);_0x3729be['on'](_0xe4cf('0x3c'),listeningHandler);_0x3729be['on'](_0xe4cf('0x3d'),connectionHandler);_0x3729be['on'](_0xe4cf('0x2f'),closeHandler);});}main();
\ No newline at end of file
+var _0x29a5=['format','[ERROR]\x20%s','arg_1','calleridname','callerid','dnid','uniqueid','[HANGUP]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','evtHangup','createSquareReport','then','indexOf','agi_','substring','debug','variables','[START]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','close','timeout','hangup','find','handleNotFound','handleUnpublished','initialize','getLicense','callysquare','[LICENSE]\x20CHANNELS:\x20%s','[LICENSE]\x20CHANNELS:\x20UNLIMITED','[LICENSE]\x20VOICE\x20IS\x20DISABLED','getAll','catch','finally','./server','listening','connection','syncho','../../config/logger','agi','../../config/license/util','./rpc','./project','EventEmitter','defaults','127.0.0.1','projectUpdate','stack','findIndex','splice','push','error','env','production','log','port','info','[LISTENING]\x20Cally\x20Square\x20listening\x20%s:%d','host.docker.internal','name','message','[%s]\x20%s'];(function(_0x2704be,_0x2555d4){var _0x21d7b5=function(_0x5f2a1b){while(--_0x5f2a1b){_0x2704be['push'](_0x2704be['shift']());}};_0x21d7b5(++_0x2555d4);}(_0x29a5,0x113));var _0x529a=function(_0x10004e,_0xd701e6){_0x10004e=_0x10004e-0x0;var _0x5af990=_0x29a5[_0x10004e];return _0x5af990;};'use strict';var _=require('lodash');var syncho=require(_0x529a('0x0'));var util=require('util');var config=require('../../config/environment');var logger=require(_0x529a('0x1'))(_0x529a('0x2'));var utilLicense=require(_0x529a('0x3'));var rpc=require(_0x529a('0x4'));var Project=require(_0x529a('0x5'));var AGIEmitter=require('./events')[_0x529a('0x6')];var projects=[];config['agi']=_[_0x529a('0x7')](config[_0x529a('0x2')],{'ip':_0x529a('0x8'),'port':0x11dd});AGIEmitter['on'](_0x529a('0x9'),projectUpdateHandler);function connectionHandler(_0x4bca30){process['nextTick'](function(){syncho(function(){try{setChannelVariables(_0x4bca30);agiHandler(_0x4bca30);}catch(_0x4930a6){logger['error'](_0x4930a6[_0x529a('0xa')]);}});});}function projectUpdateHandler(_0x1c79fc){try{var _0x124503=_[_0x529a('0xb')](projects,['id',_0x1c79fc['id']]);if(_0x124503>-0x1){if(_0x1c79fc['deleted']===!![]){projects[_0x529a('0xc')](_0x124503,0x1);}else{projects[_0x124503]=_0x1c79fc;}}else{projects[_0x529a('0xd')](_0x1c79fc);}}catch(_0x41e268){logger[_0x529a('0xe')](_0x41e268['stack']);}}function listeningHandler(){var _0x348c29=config[_0x529a('0xf')]===_0x529a('0x10')||![];console[_0x529a('0x11')]('Cally\x20Square\x20server\x20listening\x20on\x20port\x20%d!',config[_0x529a('0x2')][_0x529a('0x12')]);logger[_0x529a('0x13')](util['format'](_0x529a('0x14'),_0x348c29?config[_0x529a('0x2')]['ip']:_0x529a('0x15'),config['agi'][_0x529a('0x12')]));}function errorHandler(_0x4dd0b0){if(_0x4dd0b0&&_0x4dd0b0[_0x529a('0x16')]&&_0x4dd0b0[_0x529a('0x17')]){logger['error'](util['format'](_0x529a('0x18'),_0x4dd0b0[_0x529a('0x16')],_0x4dd0b0[_0x529a('0x17')]));}else{logger[_0x529a('0xe')](util[_0x529a('0x19')](_0x529a('0x1a'),_0x4dd0b0[_0x529a('0xa')]));}}function closeHandler(){logger[_0x529a('0x13')](util['format']('[CLOSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this[_0x529a('0x1b')],this[_0x529a('0x1c')],this[_0x529a('0x1d')],this[_0x529a('0x1e')],this[_0x529a('0x1f')]));try{createSquareReport(this);}catch(_0x4d6342){logger[_0x529a('0xe')](_0x4d6342[_0x529a('0xa')]);}}function timeoutHandler(){logger[_0x529a('0x13')](util[_0x529a('0x19')]('[TIMEOUT]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',this[_0x529a('0x1b')],this[_0x529a('0x1c')],this[_0x529a('0x1d')],this['dnid'],this[_0x529a('0x1f')]));}function hangupHandler(){logger[_0x529a('0x13')](util[_0x529a('0x19')](_0x529a('0x20'),this[_0x529a('0x1b')],this[_0x529a('0x1c')],this[_0x529a('0x1d')],this[_0x529a('0x1e')],this['uniqueid']));this[_0x529a('0x21')]=!![];}function createSquareReport(_0x84ef7d,_0x5777cb){rpc[_0x529a('0x22')](_0x84ef7d)[_0x529a('0x23')](function(_0x41df20){if(_0x5777cb){_0x5777cb(null,_0x41df20);}})['catch'](function(_0x4d1920){if(_0x5777cb){_0x5777cb(null,_0x4d1920);}});}function setChannelVariables(_0x4ec134){for(var _0x5287ff in _0x4ec134){if(_0x4ec134['hasOwnProperty'](_0x5287ff)){if(_0x5287ff[_0x529a('0x24')](_0x529a('0x25'))===0x0){_0x4ec134[_0x5287ff[_0x529a('0x26')](0x4)]=_0x4ec134[_0x5287ff];delete _0x4ec134[_0x5287ff];}}}}function agiHandler(_0x45c437){logger[_0x529a('0x27')](_0x529a('0x28'),JSON['stringify'](_0x45c437,null,0x2));logger[_0x529a('0x13')](util[_0x529a('0x19')](_0x529a('0x29'),_0x45c437[_0x529a('0x1b')],_0x45c437[_0x529a('0x1c')],_0x45c437[_0x529a('0x1d')],_0x45c437[_0x529a('0x1e')],_0x45c437[_0x529a('0x1f')]));_0x45c437['on'](_0x529a('0xe'),errorHandler);_0x45c437['on'](_0x529a('0x2a'),closeHandler);_0x45c437['on'](_0x529a('0x2b'),timeoutHandler);_0x45c437[_0x529a('0x21')]=![];_0x45c437['on'](_0x529a('0x2c'),hangupHandler);var _0x41bf07=_[_0x529a('0x2d')](projects,[_0x529a('0x16'),_0x45c437['arg_1']]);if(!_0x41bf07)return Project[_0x529a('0x2e')](_0x45c437);if(!_0x41bf07['production'])return Project[_0x529a('0x2f')](_0x45c437);return Project[_0x529a('0x30')](_0x41bf07,_0x45c437);}function main(){var _0x537837;return utilLicense[_0x529a('0x31')]()[_0x529a('0x23')](function(_0xa83457){if(!_0xa83457)return;if(_0xa83457['voice']){if(_0xa83457[_0x529a('0x32')]&&_0xa83457[_0x529a('0x32')]>0x0){logger['info'](util[_0x529a('0x19')](_0x529a('0x33'),_0xa83457[_0x529a('0x32')]));_0x537837=_0xa83457[_0x529a('0x32')];}else{logger[_0x529a('0x13')](_0x529a('0x34'));}}else{logger[_0x529a('0x13')](_0x529a('0x35'));_0x537837=-0x1;}})[_0x529a('0x23')](function(){return Project[_0x529a('0x36')]();})[_0x529a('0x23')](function(_0x2a8ac6){projects=_0x2a8ac6;return;})[_0x529a('0x37')](function(_0x435baf){logger[_0x529a('0xe')]('[LICENSE]',_0x435baf[_0x529a('0xa')]);})[_0x529a('0x38')](function(){var _0x1ad9be=require(_0x529a('0x39'))(config[_0x529a('0x2')][_0x529a('0x12')],config[_0x529a('0x2')]['ip'],_0x537837);_0x1ad9be['on'](_0x529a('0xe'),errorHandler);_0x1ad9be['on'](_0x529a('0x3a'),listeningHandler);_0x1ad9be['on'](_0x529a('0x3b'),connectionHandler);_0x1ad9be['on'](_0x529a('0x2a'),closeHandler);});}main();
\ No newline at end of file