Built motion from commit b7e79837.|2.6.29
[motion2.git] / server / services / ami / report / userReport.js
index 952616f..9751a54 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x06aa=['[userReport][devicestatechange]\x20sending\x20trunk:save\x20event:','trunk:save','startsWith','Local','substring','indexOf','find','mobile','phone','accountcode','[userReport][peerstatus]\x20peer:%s\x20address:%s\x20status:%s','peer','address','[userReport][peerstatus]','registered','status','[userReport][peerstatus]\x20sending\x20trunk:save\x20event:','exports','bluebird','../../../config/environment','../../../config/logger','ami','../ami','redis','defaults','socket.io-emitter','agents','telephones','registryentry','bind','registry','syncRegistry','devicestatechange','peerstatus','syncPeerStatus','syncRealtimeShow','resolve','then','actionSipShowRegistry','catch','error','[userReport][sipshowregistry]','inspect','[userReport][devicestatelist]','actionSipPeerStatus','[userReport][sippeerstatus]','prototype','isNotNull','isUndefined','emit','info','username','state','debug','[userReport][registry]','trunks','stateRegistry','merge','omit','event','actionid','[userReport][registry]\x20sending\x20trunk:save\x20event:','format','trunk:%s','name','syncDeviceState','[userReport][devicestatechange]','device','local','toLowerCase','inuse','stateTime','updateStatusRealtime','[userReport][devicestatechange]\x20sending\x20telephone:save\x20event:','telephone:%s','telephone:save','toNumber'];(function(_0x2f7243,_0x522727){var _0xdc763e=function(_0x38a4c5){while(--_0x38a4c5){_0x2f7243['push'](_0x2f7243['shift']());}};_0xdc763e(++_0x522727);}(_0x06aa,0xac));var _0xa06a=function(_0x57ecd8,_0x38063d){_0x57ecd8=_0x57ecd8-0x0;var _0x1e18e6=_0x06aa[_0x57ecd8];return _0x1e18e6;};'use strict';var _=require('lodash');var moment=require('moment');var util=require('util');var Redis=require('ioredis');var BPromise=require(_0xa06a('0x0'));var config=require(_0xa06a('0x1'));var logger=require(_0xa06a('0x2'))(_0xa06a('0x3'));var ami=require(_0xa06a('0x4'));config[_0xa06a('0x5')]=_[_0xa06a('0x6')](config[_0xa06a('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0xa06a('0x7'))(new Redis(config[_0xa06a('0x5')]));function UserReport(_0x5486f8){this['trunks']=_0x5486f8['trunks'];this[_0xa06a('0x8')]=_0x5486f8[_0xa06a('0x8')];this[_0xa06a('0x9')]=_0x5486f8[_0xa06a('0x9')];ami['on'](_0xa06a('0xa'),this['syncRegistry'][_0xa06a('0xb')](this));ami['on'](_0xa06a('0xc'),this[_0xa06a('0xd')][_0xa06a('0xb')](this));ami['on'](_0xa06a('0xe'),this['syncDeviceState'][_0xa06a('0xb')](this));ami['on'](_0xa06a('0xf'),this[_0xa06a('0x10')][_0xa06a('0xb')](this));return this[_0xa06a('0x11')]();}function showSipRegistrations(){Promise[_0xa06a('0x12')]()[_0xa06a('0x13')](ami[_0xa06a('0x14')]())[_0xa06a('0x15')](function(_0x32c9e5){logger[_0xa06a('0x16')](_0xa06a('0x17'),util[_0xa06a('0x18')](_0x32c9e5,{'showHidden':![],'depth':null}));});}function listDeviceStates(){Promise[_0xa06a('0x12')]()[_0xa06a('0x13')](ami['actionDeviceStateList']())[_0xa06a('0x15')](function(_0x4b9083){logger['error'](_0xa06a('0x19'),util[_0xa06a('0x18')](_0x4b9083,{'showHidden':![],'depth':null}));});}function showPeersStatus(){Promise[_0xa06a('0x12')]()['then'](ami[_0xa06a('0x1a')]())[_0xa06a('0x15')](function(_0x1cedfd){logger['error'](_0xa06a('0x1b'),util[_0xa06a('0x18')](_0x1cedfd,{'showHidden':![],'depth':null}));});}UserReport[_0xa06a('0x1c')][_0xa06a('0x11')]=function(){setInterval(function(){BPromise[_0xa06a('0x12')]()[_0xa06a('0x13')](showSipRegistrations())[_0xa06a('0x13')](listDeviceStates())[_0xa06a('0x13')](showPeersStatus());},0x32c8);};UserReport[_0xa06a('0x1c')][_0xa06a('0x1d')]=function(_0x5d8e74){return _0x5d8e74!==null&&!_[_0xa06a('0x1e')](_0x5d8e74);};UserReport[_0xa06a('0x1c')][_0xa06a('0x1f')]=function(_0x2b922b,_0x4285c0,_0x2d4cf6){io['to'](_0x2b922b)['emit'](_0x4285c0,_0x2d4cf6);};UserReport[_0xa06a('0x1c')]['syncRegistry']=function(_0x89c231){try{if(this[_0xa06a('0x1d')](_0x89c231)){logger[_0xa06a('0x20')]('[userReport][registry]\x20registry:%s\x20state:%s',_0x89c231[_0xa06a('0x21')],_0x89c231[_0xa06a('0x22')]);logger[_0xa06a('0x23')](_0xa06a('0x24'),util[_0xa06a('0x18')](_0x89c231,{'showHidden':![],'depth':null}));var _0x4f3a9a=_['find'](this[_0xa06a('0x25')],{'defaultuser':_0x89c231[_0xa06a('0x21')]});if(_0x4f3a9a){_0x89c231[_0xa06a('0x26')]=_0x89c231['state'];_[_0xa06a('0x27')](_0x4f3a9a,_[_0xa06a('0x28')](_0x89c231,[_0xa06a('0x29'),_0xa06a('0x2a'),'username','state']));logger[_0xa06a('0x23')](_0xa06a('0x2b'),util['inspect'](_0x4f3a9a,{'showHidden':![],'depth':null}));this['emit'](util[_0xa06a('0x2c')](_0xa06a('0x2d'),_0x4f3a9a[_0xa06a('0x2e')]),'trunk:save',_0x4f3a9a);}}}catch(_0x4befc6){logger[_0xa06a('0x16')](_0xa06a('0x24'),util[_0xa06a('0x18')](_0x4befc6,{'showHidden':![],'depth':null}));}};UserReport[_0xa06a('0x1c')][_0xa06a('0x2f')]=function(_0x3452ae){try{if(this['isNotNull'](_0x3452ae)){logger['info']('[userReport][devicestatechange]\x20device:%s\x20state:%s',_0x3452ae['device'],_0x3452ae[_0xa06a('0x22')]);logger[_0xa06a('0x23')](_0xa06a('0x30'),util['inspect'](_0x3452ae,{'showHidden':![],'depth':null}));if(this[_0xa06a('0x8')][_0x3452ae['device']]){if(!this[_0xa06a('0x8')][_0x3452ae[_0xa06a('0x31')]][_0xa06a('0x32')]||_0x3452ae[_0xa06a('0x22')][_0xa06a('0x33')]()==_0xa06a('0x34')){this['agents'][_0x3452ae[_0xa06a('0x31')]]['local']=![];if(this[_0xa06a('0x8')][_0x3452ae[_0xa06a('0x31')]][_0xa06a('0x22')]!==_0x3452ae[_0xa06a('0x22')][_0xa06a('0x33')]()){this[_0xa06a('0x8')][_0x3452ae[_0xa06a('0x31')]][_0xa06a('0x35')]=_['toNumber'](moment()['format']('x'));}this[_0xa06a('0x8')][_0x3452ae['device']][_0xa06a('0x22')]=_0x3452ae['state'][_0xa06a('0x33')]();this['agents'][_0x3452ae[_0xa06a('0x31')]][_0xa06a('0x36')](_0x3452ae);}}else if(this[_0xa06a('0x9')][_0x3452ae[_0xa06a('0x31')]]){if(this[_0xa06a('0x9')][_0x3452ae['device']]['state']!==_0x3452ae[_0xa06a('0x22')][_0xa06a('0x33')]()){this[_0xa06a('0x9')][_0x3452ae['device']][_0xa06a('0x35')]=_['toNumber'](moment()[_0xa06a('0x2c')]('x'));}this[_0xa06a('0x9')][_0x3452ae[_0xa06a('0x31')]][_0xa06a('0x22')]=_0x3452ae['state'][_0xa06a('0x33')]();logger[_0xa06a('0x23')](_0xa06a('0x37'),util[_0xa06a('0x18')](this[_0xa06a('0x9')][_0x3452ae[_0xa06a('0x31')]],{'showHidden':![],'depth':null}));this[_0xa06a('0x1f')](util[_0xa06a('0x2c')](_0xa06a('0x38'),this['telephones'][_0x3452ae[_0xa06a('0x31')]]['name']),_0xa06a('0x39'),this[_0xa06a('0x9')][_0x3452ae[_0xa06a('0x31')]]);}else if(this[_0xa06a('0x25')][_0x3452ae[_0xa06a('0x31')]]){if(this[_0xa06a('0x25')][_0x3452ae[_0xa06a('0x31')]][_0xa06a('0x22')]!==_0x3452ae['state'][_0xa06a('0x33')]()){this['trunks'][_0x3452ae[_0xa06a('0x31')]][_0xa06a('0x35')]=_[_0xa06a('0x3a')](moment()['format']('x'));}this[_0xa06a('0x25')][_0x3452ae['device']][_0xa06a('0x22')]=_0x3452ae[_0xa06a('0x22')][_0xa06a('0x33')]();logger['debug'](_0xa06a('0x3b'),util[_0xa06a('0x18')](this['trunks'][_0x3452ae[_0xa06a('0x31')]],{'showHidden':![],'depth':null}));this[_0xa06a('0x1f')](util[_0xa06a('0x2c')]('trunk:%s',this[_0xa06a('0x25')][_0x3452ae['device']][_0xa06a('0x2e')]),_0xa06a('0x3c'),this['trunks'][_0x3452ae[_0xa06a('0x31')]]);}else if(_[_0xa06a('0x3d')](_0x3452ae[_0xa06a('0x31')],_0xa06a('0x3e'))){var _0x428d21=_0x3452ae[_0xa06a('0x31')];var _0x5a4736=_0x428d21[_0xa06a('0x3f')](_0x428d21['indexOf']('/')+0x1,_0x428d21[_0xa06a('0x40')]('@'));var _0xc93ed8=_[_0xa06a('0x41')](this['agents'],function(_0x2d88a1){return _0x2d88a1[_0xa06a('0x42')]==_0x5a4736||_0x2d88a1[_0xa06a('0x43')]==_0x5a4736||_0x2d88a1[_0xa06a('0x44')]==_0x5a4736;});if(_0xc93ed8){if(_0xc93ed8[_0xa06a('0x22')]!==_0x3452ae[_0xa06a('0x22')]['toLowerCase']()){_0xc93ed8[_0xa06a('0x35')]=_[_0xa06a('0x3a')](moment()[_0xa06a('0x2c')]('x'));}_0xc93ed8[_0xa06a('0x22')]=_0x3452ae[_0xa06a('0x22')][_0xa06a('0x33')]();_0xc93ed8[_0xa06a('0x32')]=!![];_0xc93ed8[_0xa06a('0x36')](_0x3452ae);}}}}catch(_0x3d2078){logger[_0xa06a('0x16')](_0xa06a('0x30'),util['inspect'](_0x3d2078,{'showHidden':![],'depth':null}));}};UserReport[_0xa06a('0x1c')]['syncPeerStatus']=function(_0x53ccfa){try{if(this[_0xa06a('0x1d')](_0x53ccfa)&&this[_0xa06a('0x1d')](_0x53ccfa['peerstatus'])){logger[_0xa06a('0x20')](_0xa06a('0x45'),_0x53ccfa[_0xa06a('0x46')],_0x53ccfa[_0xa06a('0x47')],_0x53ccfa['peerstatus']);logger[_0xa06a('0x23')](_0xa06a('0x48'),util[_0xa06a('0x18')](_0x53ccfa,{'showHidden':![],'depth':null}));if(this[_0xa06a('0x8')][_0x53ccfa[_0xa06a('0x46')]]){if(!this['agents'][_0x53ccfa['peer']][_0xa06a('0x32')]||_0x53ccfa['peerstatus']['toLowerCase']()==_0xa06a('0x49')){this[_0xa06a('0x8')][_0x53ccfa[_0xa06a('0x46')]][_0xa06a('0x32')]=![];this[_0xa06a('0x8')][_0x53ccfa[_0xa06a('0x46')]]['status']=_0x53ccfa['peerstatus']['toLowerCase']();this['agents'][_0x53ccfa[_0xa06a('0x46')]]['address']=_0x53ccfa[_0xa06a('0x47')];this[_0xa06a('0x8')][_0x53ccfa['peer']]['updateStatusRealtime'](_0x53ccfa);}}else if(this[_0xa06a('0x9')][_0x53ccfa[_0xa06a('0x46')]]){this[_0xa06a('0x9')][_0x53ccfa[_0xa06a('0x46')]][_0xa06a('0x4a')]=_0x53ccfa[_0xa06a('0xf')][_0xa06a('0x33')]();this[_0xa06a('0x9')][_0x53ccfa[_0xa06a('0x46')]][_0xa06a('0x47')]=_0x53ccfa[_0xa06a('0x47')];logger[_0xa06a('0x23')]('[userReport][peerstatus]\x20sending\x20telephone:save\x20event:',util[_0xa06a('0x18')](this[_0xa06a('0x9')][_0x53ccfa['peer']],{'showHidden':![],'depth':null}));this[_0xa06a('0x1f')](util[_0xa06a('0x2c')]('telephone:%s',this[_0xa06a('0x9')][_0x53ccfa['peer']][_0xa06a('0x2e')]),'telephone:save',this[_0xa06a('0x9')][_0x53ccfa[_0xa06a('0x46')]]);}else if(this[_0xa06a('0x25')][_0x53ccfa['peer']]){this[_0xa06a('0x25')][_0x53ccfa[_0xa06a('0x46')]]['status']=_0x53ccfa['peerstatus'][_0xa06a('0x33')]();this[_0xa06a('0x25')][_0x53ccfa[_0xa06a('0x46')]][_0xa06a('0x47')]=_0x53ccfa['address'];logger['debug'](_0xa06a('0x4b'),util['inspect'](this[_0xa06a('0x25')][_0x53ccfa['peer']],{'showHidden':![],'depth':null}));this['emit'](util[_0xa06a('0x2c')](_0xa06a('0x2d'),this[_0xa06a('0x25')][_0x53ccfa['peer']][_0xa06a('0x2e')]),'trunk:save',this[_0xa06a('0x25')][_0x53ccfa['peer']]);}}}catch(_0x3e1b18){logger[_0xa06a('0x16')](_0xa06a('0x48'),util['inspect'](_0x3e1b18,{'showHidden':![],'depth':null}));}};module[_0xa06a('0x4c')]=UserReport;
\ No newline at end of file
+var _0xa3a0=['actionSipShowRegistry','catch','error','[userReport][sipshowregistry]','then','actionDeviceStateList','[userReport][devicestatelist]','inspect','[userReport][sippeerstatus]','prototype','syncRealtimeShow','isNotNull','isUndefined','emit','info','[userReport][registry]\x20registry:%s\x20state:%s','username','state','[userReport][registry]','find','stateRegistry','merge','event','actionid','debug','format','trunk:%s','name','device','[userReport][devicestatechange]','local','toLowerCase','inuse','toNumber','updateStatusRealtime','[userReport][devicestatechange]\x20sending\x20telephone:save\x20event:','telephone:%s','telephone:save','trunk:save','Local','substring','indexOf','mobile','phone','stateTime','syncPeerStatus','peer','address','[userReport][peerstatus]','status','[userReport][peerstatus]\x20sending\x20telephone:save\x20event:','[userReport][peerstatus]\x20sending\x20trunk:save\x20event:','exports','moment','util','ioredis','bluebird','../../../config/environment','../../../config/logger','ami','defaults','socket.io-emitter','trunks','agents','telephones','registryentry','bind','registry','syncRegistry','syncDeviceState','peerstatus','resolve'];(function(_0x562593,_0x53e7e9){var _0x2a4117=function(_0x31d938){while(--_0x31d938){_0x562593['push'](_0x562593['shift']());}};_0x2a4117(++_0x53e7e9);}(_0xa3a0,0x10d));var _0x0a3a=function(_0x50ba63,_0x25dfdd){_0x50ba63=_0x50ba63-0x0;var _0xc3bf64=_0xa3a0[_0x50ba63];return _0xc3bf64;};'use strict';var _=require('lodash');var moment=require(_0x0a3a('0x0'));var util=require(_0x0a3a('0x1'));var Redis=require(_0x0a3a('0x2'));var BPromise=require(_0x0a3a('0x3'));var config=require(_0x0a3a('0x4'));var logger=require(_0x0a3a('0x5'))(_0x0a3a('0x6'));var ami=require('../ami');config['redis']=_[_0x0a3a('0x7')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x0a3a('0x8'))(new Redis(config['redis']));function UserReport(_0x2c6c04){this['trunks']=_0x2c6c04[_0x0a3a('0x9')];this[_0x0a3a('0xa')]=_0x2c6c04[_0x0a3a('0xa')];this[_0x0a3a('0xb')]=_0x2c6c04[_0x0a3a('0xb')];ami['on'](_0x0a3a('0xc'),this['syncRegistry'][_0x0a3a('0xd')](this));ami['on'](_0x0a3a('0xe'),this[_0x0a3a('0xf')][_0x0a3a('0xd')](this));ami['on']('devicestatechange',this[_0x0a3a('0x10')][_0x0a3a('0xd')](this));ami['on'](_0x0a3a('0x11'),this['syncPeerStatus'][_0x0a3a('0xd')](this));return this['syncRealtimeShow']();}function showSipRegistrations(){Promise[_0x0a3a('0x12')]()['then'](ami[_0x0a3a('0x13')]())[_0x0a3a('0x14')](function(_0x59ac68){logger[_0x0a3a('0x15')](_0x0a3a('0x16'),util['inspect'](_0x59ac68,{'showHidden':![],'depth':null}));});}function listDeviceStates(){Promise['resolve']()[_0x0a3a('0x17')](ami[_0x0a3a('0x18')]())[_0x0a3a('0x14')](function(_0x86998d){logger[_0x0a3a('0x15')](_0x0a3a('0x19'),util[_0x0a3a('0x1a')](_0x86998d,{'showHidden':![],'depth':null}));});}function showPeersStatus(){Promise['resolve']()[_0x0a3a('0x17')](ami['actionSipPeerStatus']())['catch'](function(_0x52f02a){logger[_0x0a3a('0x15')](_0x0a3a('0x1b'),util['inspect'](_0x52f02a,{'showHidden':![],'depth':null}));});}UserReport[_0x0a3a('0x1c')][_0x0a3a('0x1d')]=function(){setInterval(function(){BPromise['resolve']()[_0x0a3a('0x17')](showSipRegistrations())[_0x0a3a('0x17')](listDeviceStates())['then'](showPeersStatus());},0x32c8);};UserReport[_0x0a3a('0x1c')][_0x0a3a('0x1e')]=function(_0x258de7){return _0x258de7!==null&&!_[_0x0a3a('0x1f')](_0x258de7);};UserReport[_0x0a3a('0x1c')][_0x0a3a('0x20')]=function(_0x15710c,_0x29f240,_0x1cc69b){io['to'](_0x15710c)[_0x0a3a('0x20')](_0x29f240,_0x1cc69b);};UserReport[_0x0a3a('0x1c')][_0x0a3a('0xf')]=function(_0x55561b){try{if(this[_0x0a3a('0x1e')](_0x55561b)){logger[_0x0a3a('0x21')](_0x0a3a('0x22'),_0x55561b[_0x0a3a('0x23')],_0x55561b[_0x0a3a('0x24')]);logger['debug'](_0x0a3a('0x25'),util[_0x0a3a('0x1a')](_0x55561b,{'showHidden':![],'depth':null}));var _0xbd9e5f=_[_0x0a3a('0x26')](this[_0x0a3a('0x9')],{'defaultuser':_0x55561b['username']});if(_0xbd9e5f){_0x55561b[_0x0a3a('0x27')]=_0x55561b[_0x0a3a('0x24')];_[_0x0a3a('0x28')](_0xbd9e5f,_['omit'](_0x55561b,[_0x0a3a('0x29'),_0x0a3a('0x2a'),_0x0a3a('0x23'),_0x0a3a('0x24')]));logger[_0x0a3a('0x2b')]('[userReport][registry]\x20sending\x20trunk:save\x20event:',util[_0x0a3a('0x1a')](_0xbd9e5f,{'showHidden':![],'depth':null}));this[_0x0a3a('0x20')](util[_0x0a3a('0x2c')](_0x0a3a('0x2d'),_0xbd9e5f[_0x0a3a('0x2e')]),'trunk:save',_0xbd9e5f);}}}catch(_0x58d6a1){logger['error']('[userReport][registry]',util[_0x0a3a('0x1a')](_0x58d6a1,{'showHidden':![],'depth':null}));}};UserReport['prototype'][_0x0a3a('0x10')]=function(_0x213fa1){try{if(this[_0x0a3a('0x1e')](_0x213fa1)){logger[_0x0a3a('0x21')]('[userReport][devicestatechange]\x20device:%s\x20state:%s',_0x213fa1[_0x0a3a('0x2f')],_0x213fa1['state']);logger[_0x0a3a('0x2b')](_0x0a3a('0x30'),util['inspect'](_0x213fa1,{'showHidden':![],'depth':null}));if(this[_0x0a3a('0xa')][_0x213fa1[_0x0a3a('0x2f')]]){if(!this[_0x0a3a('0xa')][_0x213fa1[_0x0a3a('0x2f')]][_0x0a3a('0x31')]||_0x213fa1[_0x0a3a('0x24')][_0x0a3a('0x32')]()==_0x0a3a('0x33')){this[_0x0a3a('0xa')][_0x213fa1[_0x0a3a('0x2f')]]['local']=![];if(this[_0x0a3a('0xa')][_0x213fa1['device']]['state']!==_0x213fa1[_0x0a3a('0x24')]['toLowerCase']()){this[_0x0a3a('0xa')][_0x213fa1['device']]['stateTime']=_[_0x0a3a('0x34')](moment()[_0x0a3a('0x2c')]('x'));}this['agents'][_0x213fa1['device']][_0x0a3a('0x24')]=_0x213fa1[_0x0a3a('0x24')][_0x0a3a('0x32')]();this['agents'][_0x213fa1['device']][_0x0a3a('0x35')](_0x213fa1);}}else if(this[_0x0a3a('0xb')][_0x213fa1['device']]){if(this[_0x0a3a('0xb')][_0x213fa1['device']]['state']!==_0x213fa1[_0x0a3a('0x24')][_0x0a3a('0x32')]()){this[_0x0a3a('0xb')][_0x213fa1[_0x0a3a('0x2f')]]['stateTime']=_[_0x0a3a('0x34')](moment()[_0x0a3a('0x2c')]('x'));}this[_0x0a3a('0xb')][_0x213fa1['device']][_0x0a3a('0x24')]=_0x213fa1[_0x0a3a('0x24')]['toLowerCase']();logger[_0x0a3a('0x2b')](_0x0a3a('0x36'),util[_0x0a3a('0x1a')](this[_0x0a3a('0xb')][_0x213fa1[_0x0a3a('0x2f')]],{'showHidden':![],'depth':null}));this['emit'](util[_0x0a3a('0x2c')](_0x0a3a('0x37'),this[_0x0a3a('0xb')][_0x213fa1['device']]['name']),_0x0a3a('0x38'),this[_0x0a3a('0xb')][_0x213fa1[_0x0a3a('0x2f')]]);}else if(this[_0x0a3a('0x9')][_0x213fa1[_0x0a3a('0x2f')]]){if(this[_0x0a3a('0x9')][_0x213fa1['device']][_0x0a3a('0x24')]!==_0x213fa1[_0x0a3a('0x24')]['toLowerCase']()){this[_0x0a3a('0x9')][_0x213fa1[_0x0a3a('0x2f')]]['stateTime']=_['toNumber'](moment()[_0x0a3a('0x2c')]('x'));}this[_0x0a3a('0x9')][_0x213fa1[_0x0a3a('0x2f')]][_0x0a3a('0x24')]=_0x213fa1[_0x0a3a('0x24')][_0x0a3a('0x32')]();logger[_0x0a3a('0x2b')]('[userReport][devicestatechange]\x20sending\x20trunk:save\x20event:',util[_0x0a3a('0x1a')](this['trunks'][_0x213fa1[_0x0a3a('0x2f')]],{'showHidden':![],'depth':null}));this[_0x0a3a('0x20')](util['format'](_0x0a3a('0x2d'),this[_0x0a3a('0x9')][_0x213fa1[_0x0a3a('0x2f')]][_0x0a3a('0x2e')]),_0x0a3a('0x39'),this[_0x0a3a('0x9')][_0x213fa1[_0x0a3a('0x2f')]]);}else if(_['startsWith'](_0x213fa1[_0x0a3a('0x2f')],_0x0a3a('0x3a'))){var _0xfc8341=_0x213fa1[_0x0a3a('0x2f')];var _0x4ee7ac=_0xfc8341[_0x0a3a('0x3b')](_0xfc8341['indexOf']('/')+0x1,_0xfc8341[_0x0a3a('0x3c')]('@'));var _0x5a9338=_[_0x0a3a('0x26')](this[_0x0a3a('0xa')],function(_0x32d8e0){return _0x32d8e0[_0x0a3a('0x3d')]==_0x4ee7ac||_0x32d8e0[_0x0a3a('0x3e')]==_0x4ee7ac||_0x32d8e0['accountcode']==_0x4ee7ac;});if(_0x5a9338){if(_0x5a9338[_0x0a3a('0x24')]!==_0x213fa1[_0x0a3a('0x24')][_0x0a3a('0x32')]()){_0x5a9338[_0x0a3a('0x3f')]=_[_0x0a3a('0x34')](moment()[_0x0a3a('0x2c')]('x'));}_0x5a9338[_0x0a3a('0x24')]=_0x213fa1['state']['toLowerCase']();_0x5a9338[_0x0a3a('0x31')]=!![];_0x5a9338[_0x0a3a('0x35')](_0x213fa1);}}}}catch(_0x4072d3){logger[_0x0a3a('0x15')](_0x0a3a('0x30'),util['inspect'](_0x4072d3,{'showHidden':![],'depth':null}));}};UserReport[_0x0a3a('0x1c')][_0x0a3a('0x40')]=function(_0x16eec7){try{if(this[_0x0a3a('0x1e')](_0x16eec7)&&this[_0x0a3a('0x1e')](_0x16eec7['peerstatus'])){logger['info']('[userReport][peerstatus]\x20peer:%s\x20address:%s\x20status:%s',_0x16eec7[_0x0a3a('0x41')],_0x16eec7[_0x0a3a('0x42')],_0x16eec7['peerstatus']);logger[_0x0a3a('0x2b')](_0x0a3a('0x43'),util['inspect'](_0x16eec7,{'showHidden':![],'depth':null}));if(this[_0x0a3a('0xa')][_0x16eec7['peer']]){if(!this[_0x0a3a('0xa')][_0x16eec7[_0x0a3a('0x41')]][_0x0a3a('0x31')]||_0x16eec7[_0x0a3a('0x11')][_0x0a3a('0x32')]()=='registered'){this[_0x0a3a('0xa')][_0x16eec7['peer']][_0x0a3a('0x31')]=![];this['agents'][_0x16eec7['peer']][_0x0a3a('0x44')]=_0x16eec7[_0x0a3a('0x11')][_0x0a3a('0x32')]();this[_0x0a3a('0xa')][_0x16eec7['peer']][_0x0a3a('0x42')]=_0x16eec7['address'];this[_0x0a3a('0xa')][_0x16eec7[_0x0a3a('0x41')]]['updateStatusRealtime'](_0x16eec7);}}else if(this[_0x0a3a('0xb')][_0x16eec7['peer']]){this[_0x0a3a('0xb')][_0x16eec7['peer']][_0x0a3a('0x44')]=_0x16eec7[_0x0a3a('0x11')]['toLowerCase']();this[_0x0a3a('0xb')][_0x16eec7[_0x0a3a('0x41')]][_0x0a3a('0x42')]=_0x16eec7['address'];logger['debug'](_0x0a3a('0x45'),util[_0x0a3a('0x1a')](this[_0x0a3a('0xb')][_0x16eec7[_0x0a3a('0x41')]],{'showHidden':![],'depth':null}));this['emit'](util[_0x0a3a('0x2c')]('telephone:%s',this[_0x0a3a('0xb')][_0x16eec7[_0x0a3a('0x41')]][_0x0a3a('0x2e')]),_0x0a3a('0x38'),this[_0x0a3a('0xb')][_0x16eec7[_0x0a3a('0x41')]]);}else if(this['trunks'][_0x16eec7[_0x0a3a('0x41')]]){this[_0x0a3a('0x9')][_0x16eec7['peer']]['status']=_0x16eec7[_0x0a3a('0x11')][_0x0a3a('0x32')]();this['trunks'][_0x16eec7[_0x0a3a('0x41')]][_0x0a3a('0x42')]=_0x16eec7[_0x0a3a('0x42')];logger['debug'](_0x0a3a('0x46'),util[_0x0a3a('0x1a')](this[_0x0a3a('0x9')][_0x16eec7['peer']],{'showHidden':![],'depth':null}));this['emit'](util[_0x0a3a('0x2c')](_0x0a3a('0x2d'),this[_0x0a3a('0x9')][_0x16eec7[_0x0a3a('0x41')]][_0x0a3a('0x2e')]),_0x0a3a('0x39'),this[_0x0a3a('0x9')][_0x16eec7[_0x0a3a('0x41')]]);}}}catch(_0x512503){logger[_0x0a3a('0x15')](_0x0a3a('0x43'),util[_0x0a3a('0x1a')](_0x512503,{'showHidden':![],'depth':null}));}};module[_0x0a3a('0x47')]=UserReport;
\ No newline at end of file