Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / services / ami / report / userReport.js
index 7599e88..d9bbc22 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6bc0=['actionSipShowRegistry','then','actionDeviceStateList','catch','error','inspect','actionSipPeerStatus','prototype','emit','isNotNull','find','stateRegistry','state','merge','omit','event','actionid','username','format','name','trunk:save','[syncRegistry][UserReport]','device','local','inuse','toLowerCase','stateTime','toNumber','updateStatusRealtime','telephone:%s','telephone:save','trunk:%s','startsWith','Queue','Local','substring','indexOf','mobile','phone','peer','registered','status','address','peerstatus','[syncPeerStatus][UserReport]','exports','lodash','util','ioredis','../../../config/logger','ami','defaults','redis','socket.io-emitter','trunks','agents','telephones','registryentry','syncRegistry','bind','devicestatechange','syncDeviceState','syncPeerStatus','loopSyncRealTimeShow','resolve'];(function(_0x1fa8f7,_0x5c13d6){var _0x43dc69=function(_0x567f73){while(--_0x567f73){_0x1fa8f7['push'](_0x1fa8f7['shift']());}};_0x43dc69(++_0x5c13d6);}(_0x6bc0,0xb0));var _0x06bc=function(_0x1c8762,_0x1991f8){_0x1c8762=_0x1c8762-0x0;var _0x9f4165=_0x6bc0[_0x1c8762];return _0x9f4165;};'use strict';var _=require(_0x06bc('0x0'));var moment=require('moment');var BPromise=require('bluebird');var util=require(_0x06bc('0x1'));var Redis=require(_0x06bc('0x2'));var config=require('../../../config/environment');var logger=require(_0x06bc('0x3'))(_0x06bc('0x4'));var ami=require('../ami');config['redis']=_[_0x06bc('0x5')](config[_0x06bc('0x6')],{'host':'localhost','port':0x18eb});var io=require(_0x06bc('0x7'))(new Redis(config[_0x06bc('0x6')]));function UserReport(_0x527e57){this[_0x06bc('0x8')]=_0x527e57['trunks'];this[_0x06bc('0x9')]=_0x527e57['agents'];this[_0x06bc('0xa')]=_0x527e57[_0x06bc('0xa')];ami['on'](_0x06bc('0xb'),this[_0x06bc('0xc')][_0x06bc('0xd')](this));ami['on']('registry',this[_0x06bc('0xc')]['bind'](this));ami['on'](_0x06bc('0xe'),this[_0x06bc('0xf')][_0x06bc('0xd')](this));ami['on']('peerstatus',this[_0x06bc('0x10')][_0x06bc('0xd')](this));this[_0x06bc('0x11')]();return BPromise[_0x06bc('0x12')]()['then'](ami[_0x06bc('0x13')]())[_0x06bc('0x14')](ami[_0x06bc('0x15')]())[_0x06bc('0x14')](ami['actionSipPeerStatus']())[_0x06bc('0x16')](loggerCatch('[loopSyncRealTimeShow]'));}function loggerCatch(_0x460e3e){return function(_0x500860){logger[_0x06bc('0x17')](_0x460e3e,util[_0x06bc('0x18')](_0x500860,{'showHidden':![],'depth':null}));};}UserReport['prototype']['loopSyncRealTimeShow']=function(){setInterval(function(){BPromise[_0x06bc('0x12')]()['then'](ami[_0x06bc('0x13')]())[_0x06bc('0x14')](ami['actionDeviceStateList']())[_0x06bc('0x14')](ami[_0x06bc('0x19')]())[_0x06bc('0x16')](loggerCatch('[loopSyncRealTimeShow]'));},0x32c8);};UserReport[_0x06bc('0x1a')]['isNotNull']=function(_0x2a416d){return _0x2a416d!==null&&!_['isUndefined'](_0x2a416d);};UserReport[_0x06bc('0x1a')][_0x06bc('0x1b')]=function(_0x55101d,_0x26be55,_0x330626){io['to'](_0x55101d)[_0x06bc('0x1b')](_0x26be55,_0x330626);};UserReport[_0x06bc('0x1a')][_0x06bc('0xc')]=function(_0x312458){try{if(this[_0x06bc('0x1c')](_0x312458)){var _0x4710d7=_[_0x06bc('0x1d')](this[_0x06bc('0x8')],{'registry':_0x312458['username']});if(_0x4710d7){_0x312458[_0x06bc('0x1e')]=_0x312458[_0x06bc('0x1f')];_[_0x06bc('0x20')](_0x4710d7,_[_0x06bc('0x21')](_0x312458,[_0x06bc('0x22'),_0x06bc('0x23'),_0x06bc('0x24'),_0x06bc('0x1f')]));this['emit'](util[_0x06bc('0x25')]('trunk:%s',_0x4710d7[_0x06bc('0x26')]),_0x06bc('0x27'),_0x4710d7);}}}catch(_0x1b05b7){logger[_0x06bc('0x17')](_0x06bc('0x28'),util[_0x06bc('0x18')](_0x1b05b7,{'showHidden':![],'depth':null}));}};UserReport[_0x06bc('0x1a')][_0x06bc('0xf')]=function(_0x1691c0){try{if(this[_0x06bc('0x1c')](_0x1691c0)){if(this[_0x06bc('0x9')][_0x1691c0[_0x06bc('0x29')]]){if(!this[_0x06bc('0x9')][_0x1691c0[_0x06bc('0x29')]][_0x06bc('0x2a')]||_0x1691c0['state']['toLowerCase']()==_0x06bc('0x2b')){this[_0x06bc('0x9')][_0x1691c0['device']][_0x06bc('0x2a')]=![];if(this[_0x06bc('0x9')][_0x1691c0[_0x06bc('0x29')]]['state']!==_0x1691c0[_0x06bc('0x1f')][_0x06bc('0x2c')]()){this['agents'][_0x1691c0[_0x06bc('0x29')]][_0x06bc('0x2d')]=_[_0x06bc('0x2e')](moment()['format']('x'));}this[_0x06bc('0x9')][_0x1691c0['device']][_0x06bc('0x1f')]=_0x1691c0[_0x06bc('0x1f')][_0x06bc('0x2c')]();this[_0x06bc('0x9')][_0x1691c0['device']][_0x06bc('0x2f')](_0x1691c0);}}else if(this[_0x06bc('0xa')][_0x1691c0['device']]){if(this[_0x06bc('0xa')][_0x1691c0[_0x06bc('0x29')]]['state']!==_0x1691c0[_0x06bc('0x1f')][_0x06bc('0x2c')]()){this['telephones'][_0x1691c0[_0x06bc('0x29')]][_0x06bc('0x2d')]=_[_0x06bc('0x2e')](moment()['format']('x'));}this[_0x06bc('0xa')][_0x1691c0[_0x06bc('0x29')]][_0x06bc('0x1f')]=_0x1691c0[_0x06bc('0x1f')][_0x06bc('0x2c')]();this[_0x06bc('0x1b')](util['format'](_0x06bc('0x30'),this[_0x06bc('0xa')][_0x1691c0[_0x06bc('0x29')]][_0x06bc('0x26')]),_0x06bc('0x31'),this[_0x06bc('0xa')][_0x1691c0[_0x06bc('0x29')]]);}else if(this[_0x06bc('0x8')][_0x1691c0[_0x06bc('0x29')]]){if(this['trunks'][_0x1691c0['device']][_0x06bc('0x1f')]!==_0x1691c0[_0x06bc('0x1f')][_0x06bc('0x2c')]()){this[_0x06bc('0x8')][_0x1691c0[_0x06bc('0x29')]][_0x06bc('0x2d')]=_['toNumber'](moment()[_0x06bc('0x25')]('x'));}this['trunks'][_0x1691c0[_0x06bc('0x29')]][_0x06bc('0x1f')]=_0x1691c0[_0x06bc('0x1f')]['toLowerCase']();this[_0x06bc('0x1b')](util[_0x06bc('0x25')](_0x06bc('0x32'),this[_0x06bc('0x8')][_0x1691c0[_0x06bc('0x29')]][_0x06bc('0x26')]),'trunk:save',this[_0x06bc('0x8')][_0x1691c0[_0x06bc('0x29')]]);}else if(_[_0x06bc('0x33')](_0x1691c0[_0x06bc('0x29')],_0x06bc('0x34'))){}else if(_[_0x06bc('0x33')](_0x1691c0[_0x06bc('0x29')],_0x06bc('0x35'))){var _0x168a52=_0x1691c0[_0x06bc('0x29')];var _0x407f49=_0x168a52[_0x06bc('0x36')](_0x168a52[_0x06bc('0x37')]('/')+0x1,_0x168a52[_0x06bc('0x37')]('@'));var _0x2e72dd=_['find'](this[_0x06bc('0x9')],function(_0x4a8206){return _0x4a8206[_0x06bc('0x38')]==_0x407f49||_0x4a8206[_0x06bc('0x39')]==_0x407f49||_0x4a8206['accountcode']==_0x407f49;});if(_0x2e72dd){if(_0x2e72dd['state']!==_0x1691c0[_0x06bc('0x1f')]['toLowerCase']()){_0x2e72dd[_0x06bc('0x2d')]=_['toNumber'](moment()[_0x06bc('0x25')]('x'));}_0x2e72dd['state']=_0x1691c0[_0x06bc('0x1f')][_0x06bc('0x2c')]();_0x2e72dd[_0x06bc('0x2a')]=!![];_0x2e72dd[_0x06bc('0x2f')](_0x1691c0);}}else{}}}catch(_0x2d7ac4){logger[_0x06bc('0x17')]('[syncDeviceState][UserReport]',util[_0x06bc('0x18')](_0x2d7ac4,{'showHidden':![],'depth':null}));}};UserReport[_0x06bc('0x1a')][_0x06bc('0x10')]=function(_0x195306){try{if(this[_0x06bc('0x1c')](_0x195306)&&this[_0x06bc('0x1c')](_0x195306['peerstatus'])){if(this['agents'][_0x195306[_0x06bc('0x3a')]]){if(!this[_0x06bc('0x9')][_0x195306[_0x06bc('0x3a')]]['local']||_0x195306['peerstatus'][_0x06bc('0x2c')]()==_0x06bc('0x3b')){this[_0x06bc('0x9')][_0x195306[_0x06bc('0x3a')]][_0x06bc('0x2a')]=![];this[_0x06bc('0x9')][_0x195306[_0x06bc('0x3a')]][_0x06bc('0x3c')]=_0x195306['peerstatus'][_0x06bc('0x2c')]();this[_0x06bc('0x9')][_0x195306['peer']][_0x06bc('0x3d')]=_0x195306['address'];this[_0x06bc('0x9')][_0x195306[_0x06bc('0x3a')]][_0x06bc('0x2f')](_0x195306);}}else if(this[_0x06bc('0xa')][_0x195306['peer']]){this[_0x06bc('0xa')][_0x195306[_0x06bc('0x3a')]][_0x06bc('0x3c')]=_0x195306['peerstatus']['toLowerCase']();this[_0x06bc('0xa')][_0x195306['peer']]['address']=_0x195306[_0x06bc('0x3d')];this[_0x06bc('0x1b')](util[_0x06bc('0x25')](_0x06bc('0x30'),this[_0x06bc('0xa')][_0x195306[_0x06bc('0x3a')]][_0x06bc('0x26')]),_0x06bc('0x31'),this['telephones'][_0x195306[_0x06bc('0x3a')]]);}else if(this[_0x06bc('0x8')][_0x195306[_0x06bc('0x3a')]]){this[_0x06bc('0x8')][_0x195306['peer']][_0x06bc('0x3c')]=_0x195306[_0x06bc('0x3e')][_0x06bc('0x2c')]();this[_0x06bc('0x8')][_0x195306[_0x06bc('0x3a')]]['address']=_0x195306[_0x06bc('0x3d')];this[_0x06bc('0x1b')](util[_0x06bc('0x25')](_0x06bc('0x32'),this[_0x06bc('0x8')][_0x195306[_0x06bc('0x3a')]][_0x06bc('0x26')]),_0x06bc('0x27'),this[_0x06bc('0x8')][_0x195306[_0x06bc('0x3a')]]);}else{}}}catch(_0x2e7090){logger[_0x06bc('0x17')](_0x06bc('0x3f'),util[_0x06bc('0x18')](_0x2e7090,{'showHidden':![],'depth':null}));}};module[_0x06bc('0x40')]=UserReport;
\ No newline at end of file
+var _0x1f37=['Local','substring','indexOf','find','mobile','phone','accountcode','[syncDeviceState][UserReport]','peer','status','address','telephone:save','exports','moment','bluebird','ioredis','../../../config/logger','../ami','redis','localhost','socket.io-emitter','trunks','agents','telephones','registryentry','syncRegistry','bind','registry','devicestatechange','syncDeviceState','peerstatus','syncPeerStatus','resolve','then','actionDeviceStateList','catch','[loopSyncRealTimeShow]','error','prototype','loopSyncRealTimeShow','actionSipShowRegistry','actionSipPeerStatus','isNotNull','isUndefined','emit','username','stateRegistry','merge','actionid','state','format','trunk:%s','name','trunk:save','[syncRegistry][UserReport]','inspect','local','toLowerCase','inuse','device','stateTime','toNumber','updateStatusRealtime','telephone:%s','startsWith'];(function(_0x8d6531,_0x5bce9d){var _0x1e43dd=function(_0x2593ec){while(--_0x2593ec){_0x8d6531['push'](_0x8d6531['shift']());}};_0x1e43dd(++_0x5bce9d);}(_0x1f37,0x152));var _0x71f3=function(_0x37a9d7,_0x2b6fde){_0x37a9d7=_0x37a9d7-0x0;var _0x1343d3=_0x1f37[_0x37a9d7];return _0x1343d3;};'use strict';var _=require('lodash');var moment=require(_0x71f3('0x0'));var BPromise=require(_0x71f3('0x1'));var util=require('util');var Redis=require(_0x71f3('0x2'));var config=require('../../../config/environment');var logger=require(_0x71f3('0x3'))('ami');var ami=require(_0x71f3('0x4'));config[_0x71f3('0x5')]=_['defaults'](config['redis'],{'host':_0x71f3('0x6'),'port':0x18eb});var io=require(_0x71f3('0x7'))(new Redis(config[_0x71f3('0x5')]));function UserReport(_0x5a6ee3){this[_0x71f3('0x8')]=_0x5a6ee3['trunks'];this[_0x71f3('0x9')]=_0x5a6ee3['agents'];this['telephones']=_0x5a6ee3[_0x71f3('0xa')];ami['on'](_0x71f3('0xb'),this[_0x71f3('0xc')][_0x71f3('0xd')](this));ami['on'](_0x71f3('0xe'),this[_0x71f3('0xc')][_0x71f3('0xd')](this));ami['on'](_0x71f3('0xf'),this[_0x71f3('0x10')][_0x71f3('0xd')](this));ami['on'](_0x71f3('0x11'),this[_0x71f3('0x12')][_0x71f3('0xd')](this));this['loopSyncRealTimeShow']();return BPromise[_0x71f3('0x13')]()[_0x71f3('0x14')](ami['actionSipShowRegistry']())[_0x71f3('0x14')](ami[_0x71f3('0x15')]())[_0x71f3('0x14')](ami['actionSipPeerStatus']())[_0x71f3('0x16')](loggerCatch(_0x71f3('0x17')));}function loggerCatch(_0x2f90d6){return function(_0x42a913){logger[_0x71f3('0x18')](_0x2f90d6,util['inspect'](_0x42a913,{'showHidden':![],'depth':null}));};}UserReport[_0x71f3('0x19')][_0x71f3('0x1a')]=function(){setInterval(function(){BPromise[_0x71f3('0x13')]()[_0x71f3('0x14')](ami[_0x71f3('0x1b')]())[_0x71f3('0x14')](ami[_0x71f3('0x15')]())[_0x71f3('0x14')](ami[_0x71f3('0x1c')]())['catch'](loggerCatch(_0x71f3('0x17')));},0x32c8);};UserReport['prototype'][_0x71f3('0x1d')]=function(_0xd48c2a){return _0xd48c2a!==null&&!_[_0x71f3('0x1e')](_0xd48c2a);};UserReport[_0x71f3('0x19')][_0x71f3('0x1f')]=function(_0x256c89,_0x3976d0,_0x32cd3f){io['to'](_0x256c89)['emit'](_0x3976d0,_0x32cd3f);};UserReport[_0x71f3('0x19')][_0x71f3('0xc')]=function(_0x384ef2){try{if(this[_0x71f3('0x1d')](_0x384ef2)){var _0x44eba9=_['find'](this[_0x71f3('0x8')],{'registry':_0x384ef2[_0x71f3('0x20')]});if(_0x44eba9){_0x384ef2[_0x71f3('0x21')]=_0x384ef2['state'];_[_0x71f3('0x22')](_0x44eba9,_['omit'](_0x384ef2,['event',_0x71f3('0x23'),_0x71f3('0x20'),_0x71f3('0x24')]));this[_0x71f3('0x1f')](util[_0x71f3('0x25')](_0x71f3('0x26'),_0x44eba9[_0x71f3('0x27')]),_0x71f3('0x28'),_0x44eba9);}}}catch(_0x2b357d){logger[_0x71f3('0x18')](_0x71f3('0x29'),util[_0x71f3('0x2a')](_0x2b357d,{'showHidden':![],'depth':null}));}};UserReport[_0x71f3('0x19')][_0x71f3('0x10')]=function(_0x42d039){try{if(this[_0x71f3('0x1d')](_0x42d039)){if(this['agents'][_0x42d039['device']]){if(!this[_0x71f3('0x9')][_0x42d039['device']][_0x71f3('0x2b')]||_0x42d039[_0x71f3('0x24')][_0x71f3('0x2c')]()==_0x71f3('0x2d')){this[_0x71f3('0x9')][_0x42d039[_0x71f3('0x2e')]][_0x71f3('0x2b')]=![];if(this['agents'][_0x42d039[_0x71f3('0x2e')]]['state']!==_0x42d039[_0x71f3('0x24')][_0x71f3('0x2c')]()){this[_0x71f3('0x9')][_0x42d039[_0x71f3('0x2e')]][_0x71f3('0x2f')]=_[_0x71f3('0x30')](moment()[_0x71f3('0x25')]('x'));}this[_0x71f3('0x9')][_0x42d039[_0x71f3('0x2e')]][_0x71f3('0x24')]=_0x42d039['state'][_0x71f3('0x2c')]();this[_0x71f3('0x9')][_0x42d039[_0x71f3('0x2e')]][_0x71f3('0x31')](_0x42d039);}}else if(this['telephones'][_0x42d039[_0x71f3('0x2e')]]){if(this[_0x71f3('0xa')][_0x42d039[_0x71f3('0x2e')]][_0x71f3('0x24')]!==_0x42d039['state'][_0x71f3('0x2c')]()){this[_0x71f3('0xa')][_0x42d039[_0x71f3('0x2e')]][_0x71f3('0x2f')]=_[_0x71f3('0x30')](moment()[_0x71f3('0x25')]('x'));}this[_0x71f3('0xa')][_0x42d039['device']][_0x71f3('0x24')]=_0x42d039['state'][_0x71f3('0x2c')]();this[_0x71f3('0x1f')](util[_0x71f3('0x25')](_0x71f3('0x32'),this[_0x71f3('0xa')][_0x42d039[_0x71f3('0x2e')]][_0x71f3('0x27')]),'telephone:save',this[_0x71f3('0xa')][_0x42d039['device']]);}else if(this[_0x71f3('0x8')][_0x42d039[_0x71f3('0x2e')]]){if(this[_0x71f3('0x8')][_0x42d039[_0x71f3('0x2e')]][_0x71f3('0x24')]!==_0x42d039['state'][_0x71f3('0x2c')]()){this['trunks'][_0x42d039[_0x71f3('0x2e')]]['stateTime']=_[_0x71f3('0x30')](moment()[_0x71f3('0x25')]('x'));}this[_0x71f3('0x8')][_0x42d039[_0x71f3('0x2e')]][_0x71f3('0x24')]=_0x42d039[_0x71f3('0x24')][_0x71f3('0x2c')]();this[_0x71f3('0x1f')](util['format'](_0x71f3('0x26'),this[_0x71f3('0x8')][_0x42d039[_0x71f3('0x2e')]]['name']),_0x71f3('0x28'),this[_0x71f3('0x8')][_0x42d039[_0x71f3('0x2e')]]);}else if(_[_0x71f3('0x33')](_0x42d039[_0x71f3('0x2e')],'Queue')){}else if(_['startsWith'](_0x42d039[_0x71f3('0x2e')],_0x71f3('0x34'))){var _0x179a6d=_0x42d039[_0x71f3('0x2e')];var _0x2f1ccd=_0x179a6d[_0x71f3('0x35')](_0x179a6d['indexOf']('/')+0x1,_0x179a6d[_0x71f3('0x36')]('@'));var _0x404797=_[_0x71f3('0x37')](this[_0x71f3('0x9')],function(_0x43edc9){return _0x43edc9[_0x71f3('0x38')]==_0x2f1ccd||_0x43edc9[_0x71f3('0x39')]==_0x2f1ccd||_0x43edc9[_0x71f3('0x3a')]==_0x2f1ccd;});if(_0x404797){if(_0x404797['state']!==_0x42d039[_0x71f3('0x24')][_0x71f3('0x2c')]()){_0x404797[_0x71f3('0x2f')]=_[_0x71f3('0x30')](moment()['format']('x'));}_0x404797[_0x71f3('0x24')]=_0x42d039[_0x71f3('0x24')]['toLowerCase']();_0x404797['local']=!![];_0x404797[_0x71f3('0x31')](_0x42d039);}}else{}}}catch(_0x2f35a1){logger[_0x71f3('0x18')](_0x71f3('0x3b'),util['inspect'](_0x2f35a1,{'showHidden':![],'depth':null}));}};UserReport[_0x71f3('0x19')][_0x71f3('0x12')]=function(_0x305cf5){try{if(this['isNotNull'](_0x305cf5)&&this[_0x71f3('0x1d')](_0x305cf5[_0x71f3('0x11')])){if(this['agents'][_0x305cf5[_0x71f3('0x3c')]]){if(!this['agents'][_0x305cf5['peer']][_0x71f3('0x2b')]||_0x305cf5['peerstatus'][_0x71f3('0x2c')]()=='registered'){this[_0x71f3('0x9')][_0x305cf5[_0x71f3('0x3c')]][_0x71f3('0x2b')]=![];this['agents'][_0x305cf5[_0x71f3('0x3c')]][_0x71f3('0x3d')]=_0x305cf5[_0x71f3('0x11')][_0x71f3('0x2c')]();this['agents'][_0x305cf5['peer']]['address']=_0x305cf5[_0x71f3('0x3e')];this[_0x71f3('0x9')][_0x305cf5['peer']][_0x71f3('0x31')](_0x305cf5);}}else if(this[_0x71f3('0xa')][_0x305cf5[_0x71f3('0x3c')]]){this[_0x71f3('0xa')][_0x305cf5['peer']]['status']=_0x305cf5[_0x71f3('0x11')][_0x71f3('0x2c')]();this[_0x71f3('0xa')][_0x305cf5['peer']][_0x71f3('0x3e')]=_0x305cf5['address'];this[_0x71f3('0x1f')](util[_0x71f3('0x25')](_0x71f3('0x32'),this[_0x71f3('0xa')][_0x305cf5[_0x71f3('0x3c')]][_0x71f3('0x27')]),_0x71f3('0x3f'),this[_0x71f3('0xa')][_0x305cf5[_0x71f3('0x3c')]]);}else if(this[_0x71f3('0x8')][_0x305cf5[_0x71f3('0x3c')]]){this[_0x71f3('0x8')][_0x305cf5[_0x71f3('0x3c')]][_0x71f3('0x3d')]=_0x305cf5['peerstatus']['toLowerCase']();this[_0x71f3('0x8')][_0x305cf5[_0x71f3('0x3c')]][_0x71f3('0x3e')]=_0x305cf5[_0x71f3('0x3e')];this[_0x71f3('0x1f')](util[_0x71f3('0x25')]('trunk:%s',this[_0x71f3('0x8')][_0x305cf5['peer']][_0x71f3('0x27')]),_0x71f3('0x28'),this[_0x71f3('0x8')][_0x305cf5[_0x71f3('0x3c')]]);}else{}}}catch(_0x568ae5){logger[_0x71f3('0x18')]('[syncPeerStatus][UserReport]',util['inspect'](_0x568ae5,{'showHidden':![],'depth':null}));}};module[_0x71f3('0x40')]=UserReport;
\ No newline at end of file