Built motion from commit b51cdcb3f2cb46634587ce1d55ea1b8f32dacea6. Version 3.0.0...
[motion-next.git] / server / services / ami / report / userReport.js
1 const a1093_0xbcc4=['trunk:%s','state','toLowerCase','syncPeerStatus','trunks','emit','registry','substring','lodash','resolve','omit','[loopSyncRealTimeShow]','../../../config/logger','bind','moment','inspect','updateStatusRealtime','trunk:save','[syncRegistry][UserReport]','username','peerstatus','loopSyncRealTimeShow','actionSipShowRegistry','Local','telephones','peer','accountcode','name','telephone:save','actionid','../../../rediscache','device','event','registryentry','stateRegistry','Queue','isUndefined','prototype','indexOf','then','inuse','isNotNull','catch','startsWith','mobile','format','syncDeviceState','phone','actionDeviceStateList','error','telephone:%s','exports','agents','status','local','util','stateTime','address','actionSipPeerStatus','toNumber','ami','syncRegistry'];(function(_0x2bf4a7,_0xbcc4af){const _0x2d48dc=function(_0x1e5b13){while(--_0x1e5b13){_0x2bf4a7['push'](_0x2bf4a7['shift']());}};_0x2d48dc(++_0xbcc4af);}(a1093_0xbcc4,0x129));const a1093_0x2d48=function(_0x2bf4a7,_0xbcc4af){_0x2bf4a7=_0x2bf4a7-0x0;let _0x2d48dc=a1093_0xbcc4[_0x2bf4a7];return _0x2d48dc;};const _0x228619=a1093_0x2d48;'use strict';const _=require(_0x228619('0x15')),moment=require(_0x228619('0x1b')),util=require(_0x228619('0x6')),logger=require(_0x228619('0x19'))(_0x228619('0xb')),ami=require('../ami'),{getSocket}=require(_0x228619('0x2b')),io=getSocket();function UserReport(_0x1e5b13){const _0x51d133=_0x228619;return this[_0x51d133('0x11')]=_0x1e5b13[_0x51d133('0x11')],this['agents']=_0x1e5b13[_0x51d133('0x3')],this[_0x51d133('0x25')]=_0x1e5b13[_0x51d133('0x25')],ami['on'](_0x51d133('0x2e'),this[_0x51d133('0xc')][_0x51d133('0x1a')](this)),ami['on'](_0x51d133('0x13'),this['syncRegistry']['bind'](this)),ami['on']('devicestatechange',this[_0x51d133('0x3b')][_0x51d133('0x1a')](this)),ami['on'](_0x51d133('0x21'),this[_0x51d133('0x10')]['bind'](this)),this[_0x51d133('0x22')](),Promise[_0x51d133('0x16')]()['then'](ami['actionSipShowRegistry']())['then'](ami['actionDeviceStateList']())['then'](ami[_0x51d133('0x9')]())['catch'](loggerCatch(_0x51d133('0x18')));}function loggerCatch(_0x244a64){return function(_0x53ebbc){logger['error'](_0x244a64,util['inspect'](_0x53ebbc,{'showHidden':![],'depth':null}));};}UserReport['prototype']['loopSyncRealTimeShow']=function(){setInterval(function(){const _0x2adf3a=a1093_0x2d48;Promise[_0x2adf3a('0x16')]()[_0x2adf3a('0x34')](ami[_0x2adf3a('0x23')]())['then'](ami[_0x2adf3a('0x3d')]())[_0x2adf3a('0x34')](ami['actionSipPeerStatus']())[_0x2adf3a('0x37')](loggerCatch(_0x2adf3a('0x18')));},0x32c8);},UserReport['prototype']['isNotNull']=function(_0x59c44e){const _0x4a8335=_0x228619;return _0x59c44e!==null&&!_[_0x4a8335('0x31')](_0x59c44e);},UserReport[_0x228619('0x32')]['emit']=function(_0x123cc3,_0x328027,_0x48daf8){io['to'](_0x123cc3)['emit'](_0x328027,_0x48daf8);},UserReport[_0x228619('0x32')][_0x228619('0xc')]=function(_0x47080a){const _0x180a3b=_0x228619;try{if(this[_0x180a3b('0x36')](_0x47080a)){const _0xdd5079=_['find'](this[_0x180a3b('0x11')],{'registry':_0x47080a[_0x180a3b('0x20')]});_0xdd5079&&(_0x47080a[_0x180a3b('0x2f')]=_0x47080a['state'],_['merge'](_0xdd5079,_[_0x180a3b('0x17')](_0x47080a,[_0x180a3b('0x2d'),_0x180a3b('0x2a'),_0x180a3b('0x20'),_0x180a3b('0xe')])),this[_0x180a3b('0x12')](util[_0x180a3b('0x3a')]('trunk:%s',_0xdd5079[_0x180a3b('0x28')]),_0x180a3b('0x1e'),_0xdd5079));}}catch(_0x2e62f3){logger[_0x180a3b('0x0')](_0x180a3b('0x1f'),util[_0x180a3b('0x1c')](_0x2e62f3,{'showHidden':![],'depth':null}));}},UserReport[_0x228619('0x32')]['syncDeviceState']=function(_0x34b848){const _0x159377=_0x228619;try{if(this[_0x159377('0x36')](_0x34b848)){if(this[_0x159377('0x3')][_0x34b848['device']])(!this[_0x159377('0x3')][_0x34b848[_0x159377('0x2c')]][_0x159377('0x5')]||_0x34b848[_0x159377('0xe')]['toLowerCase']()==_0x159377('0x35'))&&(this['agents'][_0x34b848[_0x159377('0x2c')]][_0x159377('0x5')]=![],this[_0x159377('0x3')][_0x34b848['device']]['state']!==_0x34b848['state'][_0x159377('0xf')]()&&(this[_0x159377('0x3')][_0x34b848[_0x159377('0x2c')]][_0x159377('0x7')]=_['toNumber'](moment()[_0x159377('0x3a')]('x'))),this[_0x159377('0x3')][_0x34b848[_0x159377('0x2c')]][_0x159377('0xe')]=_0x34b848[_0x159377('0xe')]['toLowerCase'](),this[_0x159377('0x3')][_0x34b848[_0x159377('0x2c')]][_0x159377('0x1d')](_0x34b848));else{if(this[_0x159377('0x25')][_0x34b848[_0x159377('0x2c')]])this['telephones'][_0x34b848['device']][_0x159377('0xe')]!==_0x34b848[_0x159377('0xe')][_0x159377('0xf')]()&&(this[_0x159377('0x25')][_0x34b848[_0x159377('0x2c')]]['stateTime']=_[_0x159377('0xa')](moment()['format']('x'))),this[_0x159377('0x25')][_0x34b848[_0x159377('0x2c')]][_0x159377('0xe')]=_0x34b848['state'][_0x159377('0xf')](),this[_0x159377('0x12')](util[_0x159377('0x3a')](_0x159377('0x1'),this[_0x159377('0x25')][_0x34b848[_0x159377('0x2c')]][_0x159377('0x28')]),_0x159377('0x29'),this[_0x159377('0x25')][_0x34b848[_0x159377('0x2c')]]);else{if(this['trunks'][_0x34b848[_0x159377('0x2c')]])this['trunks'][_0x34b848[_0x159377('0x2c')]][_0x159377('0xe')]!==_0x34b848[_0x159377('0xe')][_0x159377('0xf')]()&&(this[_0x159377('0x11')][_0x34b848['device']][_0x159377('0x7')]=_['toNumber'](moment()[_0x159377('0x3a')]('x'))),this[_0x159377('0x11')][_0x34b848['device']][_0x159377('0xe')]=_0x34b848[_0x159377('0xe')]['toLowerCase'](),this[_0x159377('0x12')](util[_0x159377('0x3a')](_0x159377('0xd'),this[_0x159377('0x11')][_0x34b848['device']][_0x159377('0x28')]),_0x159377('0x1e'),this[_0x159377('0x11')][_0x34b848[_0x159377('0x2c')]]);else{if(_[_0x159377('0x38')](_0x34b848[_0x159377('0x2c')],_0x159377('0x30'))){}else{if(_[_0x159377('0x38')](_0x34b848[_0x159377('0x2c')],_0x159377('0x24'))){const _0x35b048=_0x34b848[_0x159377('0x2c')],_0x222fde=_0x35b048[_0x159377('0x14')](_0x35b048[_0x159377('0x33')]('/')+0x1,_0x35b048[_0x159377('0x33')]('@')),_0x5f0a0f=_['find'](this['agents'],function(_0x56b2af){const _0x4e3e43=_0x159377;return _0x56b2af[_0x4e3e43('0x39')]==_0x222fde||_0x56b2af[_0x4e3e43('0x3c')]==_0x222fde||_0x56b2af[_0x4e3e43('0x27')]==_0x222fde;});_0x5f0a0f&&(_0x5f0a0f[_0x159377('0xe')]!==_0x34b848[_0x159377('0xe')][_0x159377('0xf')]()&&(_0x5f0a0f[_0x159377('0x7')]=_[_0x159377('0xa')](moment()[_0x159377('0x3a')]('x'))),_0x5f0a0f[_0x159377('0xe')]=_0x34b848['state']['toLowerCase'](),_0x5f0a0f['local']=!![],_0x5f0a0f[_0x159377('0x1d')](_0x34b848));}else{}}}}}}}catch(_0x11443d){logger[_0x159377('0x0')]('[syncDeviceState][UserReport]',util['inspect'](_0x11443d,{'showHidden':![],'depth':null}));}},UserReport[_0x228619('0x32')][_0x228619('0x10')]=function(_0x1b7f4d){const _0x479bc4=_0x228619;try{if(this[_0x479bc4('0x36')](_0x1b7f4d)&&this['isNotNull'](_0x1b7f4d['peerstatus'])){if(this[_0x479bc4('0x3')][_0x1b7f4d[_0x479bc4('0x26')]])(!this[_0x479bc4('0x3')][_0x1b7f4d[_0x479bc4('0x26')]][_0x479bc4('0x5')]||_0x1b7f4d[_0x479bc4('0x21')]['toLowerCase']()=='registered')&&(this[_0x479bc4('0x3')][_0x1b7f4d[_0x479bc4('0x26')]][_0x479bc4('0x5')]=![],this['agents'][_0x1b7f4d[_0x479bc4('0x26')]][_0x479bc4('0x4')]=_0x1b7f4d[_0x479bc4('0x21')][_0x479bc4('0xf')](),this[_0x479bc4('0x3')][_0x1b7f4d[_0x479bc4('0x26')]]['address']=_0x1b7f4d[_0x479bc4('0x8')],this[_0x479bc4('0x3')][_0x1b7f4d['peer']][_0x479bc4('0x1d')](_0x1b7f4d));else{if(this[_0x479bc4('0x25')][_0x1b7f4d[_0x479bc4('0x26')]])this[_0x479bc4('0x25')][_0x1b7f4d[_0x479bc4('0x26')]]['status']=_0x1b7f4d['peerstatus'][_0x479bc4('0xf')](),this[_0x479bc4('0x25')][_0x1b7f4d[_0x479bc4('0x26')]]['address']=_0x1b7f4d[_0x479bc4('0x8')],this[_0x479bc4('0x12')](util[_0x479bc4('0x3a')](_0x479bc4('0x1'),this[_0x479bc4('0x25')][_0x1b7f4d[_0x479bc4('0x26')]][_0x479bc4('0x28')]),_0x479bc4('0x29'),this['telephones'][_0x1b7f4d[_0x479bc4('0x26')]]);else{if(this[_0x479bc4('0x11')][_0x1b7f4d[_0x479bc4('0x26')]])this[_0x479bc4('0x11')][_0x1b7f4d[_0x479bc4('0x26')]]['status']=_0x1b7f4d[_0x479bc4('0x21')]['toLowerCase'](),this['trunks'][_0x1b7f4d['peer']][_0x479bc4('0x8')]=_0x1b7f4d[_0x479bc4('0x8')],this[_0x479bc4('0x12')](util[_0x479bc4('0x3a')](_0x479bc4('0xd'),this[_0x479bc4('0x11')][_0x1b7f4d[_0x479bc4('0x26')]][_0x479bc4('0x28')]),_0x479bc4('0x1e'),this[_0x479bc4('0x11')][_0x1b7f4d[_0x479bc4('0x26')]]);else{}}}}}catch(_0x396f37){logger[_0x479bc4('0x0')]('[syncPeerStatus][UserReport]',util[_0x479bc4('0x1c')](_0x396f37,{'showHidden':![],'depth':null}));}},module[_0x228619('0x2')]=UserReport;