52898753bd6f762dd913df473be551f5521ea2dd
[motion-next.git] / server / services / ami / report / userReport.js
1 const a1094_0x28d9=['[loopSyncRealTimeShow]','name','status','[syncDeviceState][UserReport]','trunk:save','emit','stateRegistry','../ami','omit','stateTime','format','registered','error','agents','toLowerCase','device','telephone:save','mobile','devicestatechange','state','address','resolve','startsWith','indexOf','prototype','find','bind','event','accountcode','username','util','trunks','registryentry','local','actionSipPeerStatus','actionSipShowRegistry','isUndefined','peerstatus','isNotNull','inuse','actionid','peer','toNumber','substring','telephones','actionDeviceStateList','trunk:%s','../../../rediscache','syncDeviceState','syncRegistry','registry','then','syncPeerStatus','merge','Queue','catch','inspect','updateStatusRealtime','ami','telephone:%s','exports'];(function(_0x29c4b1,_0x28d940){const _0x271f88=function(_0x256293){while(--_0x256293){_0x29c4b1['push'](_0x29c4b1['shift']());}};_0x271f88(++_0x28d940);}(a1094_0x28d9,0x17d));const a1094_0x271f=function(_0x29c4b1,_0x28d940){_0x29c4b1=_0x29c4b1-0x0;let _0x271f88=a1094_0x28d9[_0x29c4b1];return _0x271f88;};const _0x819c0b=a1094_0x271f;'use strict';const _=require('lodash'),moment=require('moment'),util=require(_0x819c0b('0xf')),logger=require('../../../config/logger')(_0x819c0b('0x2b')),ami=require(_0x819c0b('0x35')),{getSocket}=require(_0x819c0b('0x20')),io=getSocket();function UserReport(_0x256293){const _0x117b17=_0x819c0b;return this[_0x117b17('0x10')]=_0x256293[_0x117b17('0x10')],this['agents']=_0x256293[_0x117b17('0x3b')],this[_0x117b17('0x1d')]=_0x256293['telephones'],ami['on'](_0x117b17('0x11'),this['syncRegistry'][_0x117b17('0xb')](this)),ami['on'](_0x117b17('0x23'),this[_0x117b17('0x22')][_0x117b17('0xb')](this)),ami['on'](_0x117b17('0x3'),this[_0x117b17('0x21')][_0x117b17('0xb')](this)),ami['on']('peerstatus',this['syncPeerStatus']['bind'](this)),this['loopSyncRealTimeShow'](),Promise[_0x117b17('0x6')]()[_0x117b17('0x24')](ami[_0x117b17('0x14')]())[_0x117b17('0x24')](ami[_0x117b17('0x1e')]())[_0x117b17('0x24')](ami['actionSipPeerStatus']())['catch'](loggerCatch(_0x117b17('0x2e')));}function loggerCatch(_0x2c1667){return function(_0x5f2ede){const _0x103888=a1094_0x271f;logger[_0x103888('0x3a')](_0x2c1667,util[_0x103888('0x29')](_0x5f2ede,{'showHidden':![],'depth':null}));};}UserReport[_0x819c0b('0x9')]['loopSyncRealTimeShow']=function(){setInterval(function(){const _0x550c58=a1094_0x271f;Promise['resolve']()[_0x550c58('0x24')](ami[_0x550c58('0x14')]())[_0x550c58('0x24')](ami[_0x550c58('0x1e')]())[_0x550c58('0x24')](ami[_0x550c58('0x13')]())[_0x550c58('0x28')](loggerCatch(_0x550c58('0x2e')));},0x32c8);},UserReport[_0x819c0b('0x9')][_0x819c0b('0x17')]=function(_0x51ce78){const _0xd08099=_0x819c0b;return _0x51ce78!==null&&!_[_0xd08099('0x15')](_0x51ce78);},UserReport[_0x819c0b('0x9')][_0x819c0b('0x33')]=function(_0x183b7b,_0x215306,_0x23a428){io['to'](_0x183b7b)['emit'](_0x215306,_0x23a428);},UserReport[_0x819c0b('0x9')][_0x819c0b('0x22')]=function(_0x79ebc4){const _0x595e68=_0x819c0b;try{if(this[_0x595e68('0x17')](_0x79ebc4)){const _0x5a0518=_[_0x595e68('0xa')](this[_0x595e68('0x10')],{'registry':_0x79ebc4[_0x595e68('0xe')]});_0x5a0518&&(_0x79ebc4[_0x595e68('0x34')]=_0x79ebc4[_0x595e68('0x4')],_[_0x595e68('0x26')](_0x5a0518,_[_0x595e68('0x36')](_0x79ebc4,[_0x595e68('0xc'),_0x595e68('0x19'),_0x595e68('0xe'),_0x595e68('0x4')])),this['emit'](util[_0x595e68('0x38')](_0x595e68('0x1f'),_0x5a0518['name']),_0x595e68('0x32'),_0x5a0518));}}catch(_0x4642fd){logger['error']('[syncRegistry][UserReport]',util['inspect'](_0x4642fd,{'showHidden':![],'depth':null}));}},UserReport[_0x819c0b('0x9')][_0x819c0b('0x21')]=function(_0x3da52a){const _0x9e32c0=_0x819c0b;try{if(this['isNotNull'](_0x3da52a)){if(this[_0x9e32c0('0x3b')][_0x3da52a[_0x9e32c0('0x0')]])(!this[_0x9e32c0('0x3b')][_0x3da52a[_0x9e32c0('0x0')]][_0x9e32c0('0x12')]||_0x3da52a[_0x9e32c0('0x4')][_0x9e32c0('0x3c')]()==_0x9e32c0('0x18'))&&(this['agents'][_0x3da52a[_0x9e32c0('0x0')]][_0x9e32c0('0x12')]=![],this['agents'][_0x3da52a['device']][_0x9e32c0('0x4')]!==_0x3da52a[_0x9e32c0('0x4')][_0x9e32c0('0x3c')]()&&(this[_0x9e32c0('0x3b')][_0x3da52a[_0x9e32c0('0x0')]][_0x9e32c0('0x37')]=_['toNumber'](moment()[_0x9e32c0('0x38')]('x'))),this[_0x9e32c0('0x3b')][_0x3da52a[_0x9e32c0('0x0')]]['state']=_0x3da52a[_0x9e32c0('0x4')][_0x9e32c0('0x3c')](),this[_0x9e32c0('0x3b')][_0x3da52a[_0x9e32c0('0x0')]][_0x9e32c0('0x2a')](_0x3da52a));else{if(this['telephones'][_0x3da52a[_0x9e32c0('0x0')]])this[_0x9e32c0('0x1d')][_0x3da52a['device']][_0x9e32c0('0x4')]!==_0x3da52a['state']['toLowerCase']()&&(this['telephones'][_0x3da52a[_0x9e32c0('0x0')]][_0x9e32c0('0x37')]=_[_0x9e32c0('0x1b')](moment()[_0x9e32c0('0x38')]('x'))),this[_0x9e32c0('0x1d')][_0x3da52a['device']][_0x9e32c0('0x4')]=_0x3da52a[_0x9e32c0('0x4')][_0x9e32c0('0x3c')](),this[_0x9e32c0('0x33')](util[_0x9e32c0('0x38')]('telephone:%s',this['telephones'][_0x3da52a[_0x9e32c0('0x0')]]['name']),'telephone:save',this[_0x9e32c0('0x1d')][_0x3da52a[_0x9e32c0('0x0')]]);else{if(this['trunks'][_0x3da52a['device']])this['trunks'][_0x3da52a[_0x9e32c0('0x0')]][_0x9e32c0('0x4')]!==_0x3da52a['state'][_0x9e32c0('0x3c')]()&&(this['trunks'][_0x3da52a[_0x9e32c0('0x0')]][_0x9e32c0('0x37')]=_[_0x9e32c0('0x1b')](moment()['format']('x'))),this[_0x9e32c0('0x10')][_0x3da52a['device']][_0x9e32c0('0x4')]=_0x3da52a[_0x9e32c0('0x4')]['toLowerCase'](),this['emit'](util[_0x9e32c0('0x38')](_0x9e32c0('0x1f'),this[_0x9e32c0('0x10')][_0x3da52a[_0x9e32c0('0x0')]][_0x9e32c0('0x2f')]),_0x9e32c0('0x32'),this[_0x9e32c0('0x10')][_0x3da52a['device']]);else{if(_[_0x9e32c0('0x7')](_0x3da52a[_0x9e32c0('0x0')],_0x9e32c0('0x27'))){}else{if(_[_0x9e32c0('0x7')](_0x3da52a[_0x9e32c0('0x0')],'Local')){const _0x12f344=_0x3da52a['device'],_0x1cc09f=_0x12f344[_0x9e32c0('0x1c')](_0x12f344['indexOf']('/')+0x1,_0x12f344[_0x9e32c0('0x8')]('@')),_0x13f1f9=_[_0x9e32c0('0xa')](this[_0x9e32c0('0x3b')],function(_0x584b4e){const _0x4a30cd=_0x9e32c0;return _0x584b4e[_0x4a30cd('0x2')]==_0x1cc09f||_0x584b4e['phone']==_0x1cc09f||_0x584b4e[_0x4a30cd('0xd')]==_0x1cc09f;});_0x13f1f9&&(_0x13f1f9[_0x9e32c0('0x4')]!==_0x3da52a[_0x9e32c0('0x4')][_0x9e32c0('0x3c')]()&&(_0x13f1f9[_0x9e32c0('0x37')]=_['toNumber'](moment()['format']('x'))),_0x13f1f9[_0x9e32c0('0x4')]=_0x3da52a[_0x9e32c0('0x4')][_0x9e32c0('0x3c')](),_0x13f1f9[_0x9e32c0('0x12')]=!![],_0x13f1f9['updateStatusRealtime'](_0x3da52a));}else{}}}}}}}catch(_0x53c3a0){logger['error'](_0x9e32c0('0x31'),util[_0x9e32c0('0x29')](_0x53c3a0,{'showHidden':![],'depth':null}));}},UserReport['prototype'][_0x819c0b('0x25')]=function(_0x2a928b){const _0x578cd3=_0x819c0b;try{if(this[_0x578cd3('0x17')](_0x2a928b)&&this[_0x578cd3('0x17')](_0x2a928b[_0x578cd3('0x16')])){if(this[_0x578cd3('0x3b')][_0x2a928b[_0x578cd3('0x1a')]])(!this[_0x578cd3('0x3b')][_0x2a928b[_0x578cd3('0x1a')]][_0x578cd3('0x12')]||_0x2a928b[_0x578cd3('0x16')]['toLowerCase']()==_0x578cd3('0x39'))&&(this['agents'][_0x2a928b[_0x578cd3('0x1a')]][_0x578cd3('0x12')]=![],this[_0x578cd3('0x3b')][_0x2a928b[_0x578cd3('0x1a')]][_0x578cd3('0x30')]=_0x2a928b[_0x578cd3('0x16')][_0x578cd3('0x3c')](),this[_0x578cd3('0x3b')][_0x2a928b['peer']][_0x578cd3('0x5')]=_0x2a928b[_0x578cd3('0x5')],this[_0x578cd3('0x3b')][_0x2a928b[_0x578cd3('0x1a')]][_0x578cd3('0x2a')](_0x2a928b));else{if(this[_0x578cd3('0x1d')][_0x2a928b[_0x578cd3('0x1a')]])this['telephones'][_0x2a928b[_0x578cd3('0x1a')]]['status']=_0x2a928b[_0x578cd3('0x16')][_0x578cd3('0x3c')](),this[_0x578cd3('0x1d')][_0x2a928b['peer']][_0x578cd3('0x5')]=_0x2a928b[_0x578cd3('0x5')],this[_0x578cd3('0x33')](util[_0x578cd3('0x38')](_0x578cd3('0x2c'),this[_0x578cd3('0x1d')][_0x2a928b[_0x578cd3('0x1a')]][_0x578cd3('0x2f')]),_0x578cd3('0x1'),this[_0x578cd3('0x1d')][_0x2a928b[_0x578cd3('0x1a')]]);else{if(this[_0x578cd3('0x10')][_0x2a928b[_0x578cd3('0x1a')]])this[_0x578cd3('0x10')][_0x2a928b[_0x578cd3('0x1a')]][_0x578cd3('0x30')]=_0x2a928b[_0x578cd3('0x16')][_0x578cd3('0x3c')](),this[_0x578cd3('0x10')][_0x2a928b[_0x578cd3('0x1a')]][_0x578cd3('0x5')]=_0x2a928b[_0x578cd3('0x5')],this[_0x578cd3('0x33')](util['format'](_0x578cd3('0x1f'),this['trunks'][_0x2a928b[_0x578cd3('0x1a')]]['name']),_0x578cd3('0x32'),this[_0x578cd3('0x10')][_0x2a928b[_0x578cd3('0x1a')]]);else{}}}}}catch(_0x34dd88){logger[_0x578cd3('0x3a')]('[syncPeerStatus][UserReport]',util[_0x578cd3('0x29')](_0x34dd88,{'showHidden':![],'depth':null}));}},module[_0x819c0b('0x2d')]=UserReport;