Built motion from commit 598073ad.|2.5.44
[motion2.git] / server / services / ami / report / userReport.js
index 71adab4..b547d8b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb995=['stateTime','[userReport][devicestatechange]\x20sending\x20telephone:save\x20event:','telephone:%s','name','telephone:save','[userReport][devicestatechange]\x20sending\x20trunk:save\x20event:','startsWith','indexOf','mobile','phone','accountcode','local','address','[userReport][peerstatus]','peer','registered','status','exports','lodash','moment','util','ioredis','../../../config/environment','../../../config/logger','ami','../ami','redis','localhost','socket.io-emitter','trunks','agents','telephones','registryentry','syncRegistry','registry','bind','devicestatechange','peerstatus','syncRealtimeShow','resolve','then','catch','error','actionDeviceStateList','[userReport][devicestatelist]','inspect','[userReport][sippeerstatus]','prototype','isNotNull','emit','info','username','state','debug','find','stateRegistry','merge','omit','actionid','[userReport][registry]\x20sending\x20trunk:save\x20event:','format','trunk:%s','trunk:save','syncDeviceState','[userReport][devicestatechange]\x20device:%s\x20state:%s','device','[userReport][devicestatechange]','inuse','toLowerCase','toNumber','updateStatusRealtime'];(function(_0x436f25,_0x5c883a){var _0x6e773=function(_0x1ab473){while(--_0x1ab473){_0x436f25['push'](_0x436f25['shift']());}};_0x6e773(++_0x5c883a);}(_0xb995,0x12e));var _0x5b99=function(_0x3643f8,_0x88d2b8){_0x3643f8=_0x3643f8-0x0;var _0x164478=_0xb995[_0x3643f8];return _0x164478;};'use strict';var _=require(_0x5b99('0x0'));var moment=require(_0x5b99('0x1'));var util=require(_0x5b99('0x2'));var Redis=require(_0x5b99('0x3'));var BPromise=require('bluebird');var config=require(_0x5b99('0x4'));var logger=require(_0x5b99('0x5'))(_0x5b99('0x6'));var ami=require(_0x5b99('0x7'));config[_0x5b99('0x8')]=_['defaults'](config['redis'],{'host':_0x5b99('0x9'),'port':0x18eb});var io=require(_0x5b99('0xa'))(new Redis(config[_0x5b99('0x8')]));function UserReport(_0x1583b2){this[_0x5b99('0xb')]=_0x1583b2[_0x5b99('0xb')];this['agents']=_0x1583b2[_0x5b99('0xc')];this['telephones']=_0x1583b2[_0x5b99('0xd')];ami['on'](_0x5b99('0xe'),this[_0x5b99('0xf')]['bind'](this));ami['on'](_0x5b99('0x10'),this['syncRegistry'][_0x5b99('0x11')](this));ami['on'](_0x5b99('0x12'),this['syncDeviceState'][_0x5b99('0x11')](this));ami['on'](_0x5b99('0x13'),this['syncPeerStatus']['bind'](this));return this[_0x5b99('0x14')]();}function showSipRegistrations(){Promise[_0x5b99('0x15')]()[_0x5b99('0x16')](ami['actionSipShowRegistry']())[_0x5b99('0x17')](function(_0x35b953){logger[_0x5b99('0x18')]('[userReport][sipshowregistry]',util['inspect'](_0x35b953,{'showHidden':![],'depth':null}));});}function listDeviceStates(){Promise[_0x5b99('0x15')]()[_0x5b99('0x16')](ami[_0x5b99('0x19')]())[_0x5b99('0x17')](function(_0x4fc049){logger['error'](_0x5b99('0x1a'),util[_0x5b99('0x1b')](_0x4fc049,{'showHidden':![],'depth':null}));});}function showPeersStatus(){Promise[_0x5b99('0x15')]()['then'](ami['actionSipPeerStatus']())[_0x5b99('0x17')](function(_0x300a58){logger[_0x5b99('0x18')](_0x5b99('0x1c'),util[_0x5b99('0x1b')](_0x300a58,{'showHidden':![],'depth':null}));});}UserReport[_0x5b99('0x1d')][_0x5b99('0x14')]=function(){setInterval(function(){BPromise[_0x5b99('0x15')]()[_0x5b99('0x16')](showSipRegistrations())[_0x5b99('0x16')](listDeviceStates())[_0x5b99('0x16')](showPeersStatus());},0x32c8);};UserReport['prototype'][_0x5b99('0x1e')]=function(_0x333013){return _0x333013!==null&&!_['isUndefined'](_0x333013);};UserReport[_0x5b99('0x1d')]['emit']=function(_0x318157,_0x36f1e0,_0x5f1e59){io['to'](_0x318157)[_0x5b99('0x1f')](_0x36f1e0,_0x5f1e59);};UserReport[_0x5b99('0x1d')][_0x5b99('0xf')]=function(_0x39ca89){try{if(this[_0x5b99('0x1e')](_0x39ca89)){logger[_0x5b99('0x20')]('[userReport][registry]\x20registry:%s\x20state:%s',_0x39ca89[_0x5b99('0x21')],_0x39ca89[_0x5b99('0x22')]);logger[_0x5b99('0x23')]('[userReport][registry]',util['inspect'](_0x39ca89,{'showHidden':![],'depth':null}));var _0xe7dcbd=_[_0x5b99('0x24')](this[_0x5b99('0xb')],{'defaultuser':_0x39ca89[_0x5b99('0x21')]});if(_0xe7dcbd){_0x39ca89[_0x5b99('0x25')]=_0x39ca89['state'];_[_0x5b99('0x26')](_0xe7dcbd,_[_0x5b99('0x27')](_0x39ca89,['event',_0x5b99('0x28'),_0x5b99('0x21'),_0x5b99('0x22')]));logger[_0x5b99('0x23')](_0x5b99('0x29'),util['inspect'](_0xe7dcbd,{'showHidden':![],'depth':null}));this['emit'](util[_0x5b99('0x2a')](_0x5b99('0x2b'),_0xe7dcbd['name']),_0x5b99('0x2c'),_0xe7dcbd);}}}catch(_0x3bcbfb){logger['error']('[userReport][registry]',util[_0x5b99('0x1b')](_0x3bcbfb,{'showHidden':![],'depth':null}));}};UserReport[_0x5b99('0x1d')][_0x5b99('0x2d')]=function(_0x4a9f97){try{if(this[_0x5b99('0x1e')](_0x4a9f97)){logger[_0x5b99('0x20')](_0x5b99('0x2e'),_0x4a9f97[_0x5b99('0x2f')],_0x4a9f97[_0x5b99('0x22')]);logger['debug'](_0x5b99('0x30'),util[_0x5b99('0x1b')](_0x4a9f97,{'showHidden':![],'depth':null}));if(this[_0x5b99('0xc')][_0x4a9f97['device']]){if(!this[_0x5b99('0xc')][_0x4a9f97[_0x5b99('0x2f')]]['local']||_0x4a9f97[_0x5b99('0x22')]['toLowerCase']()==_0x5b99('0x31')){this[_0x5b99('0xc')][_0x4a9f97[_0x5b99('0x2f')]]['local']=![];if(this['agents'][_0x4a9f97[_0x5b99('0x2f')]][_0x5b99('0x22')]!==_0x4a9f97[_0x5b99('0x22')][_0x5b99('0x32')]()){this['agents'][_0x4a9f97[_0x5b99('0x2f')]]['stateTime']=_[_0x5b99('0x33')](moment()['format']('x'));}this['agents'][_0x4a9f97[_0x5b99('0x2f')]][_0x5b99('0x22')]=_0x4a9f97[_0x5b99('0x22')][_0x5b99('0x32')]();this[_0x5b99('0xc')][_0x4a9f97['device']][_0x5b99('0x34')](_0x4a9f97);}}else if(this[_0x5b99('0xd')][_0x4a9f97[_0x5b99('0x2f')]]){if(this[_0x5b99('0xd')][_0x4a9f97[_0x5b99('0x2f')]][_0x5b99('0x22')]!==_0x4a9f97[_0x5b99('0x22')][_0x5b99('0x32')]()){this['telephones'][_0x4a9f97[_0x5b99('0x2f')]][_0x5b99('0x35')]=_[_0x5b99('0x33')](moment()[_0x5b99('0x2a')]('x'));}this[_0x5b99('0xd')][_0x4a9f97[_0x5b99('0x2f')]][_0x5b99('0x22')]=_0x4a9f97[_0x5b99('0x22')][_0x5b99('0x32')]();logger['debug'](_0x5b99('0x36'),util[_0x5b99('0x1b')](this[_0x5b99('0xd')][_0x4a9f97['device']],{'showHidden':![],'depth':null}));this[_0x5b99('0x1f')](util['format'](_0x5b99('0x37'),this[_0x5b99('0xd')][_0x4a9f97[_0x5b99('0x2f')]][_0x5b99('0x38')]),_0x5b99('0x39'),this[_0x5b99('0xd')][_0x4a9f97[_0x5b99('0x2f')]]);}else if(this[_0x5b99('0xb')][_0x4a9f97[_0x5b99('0x2f')]]){if(this[_0x5b99('0xb')][_0x4a9f97[_0x5b99('0x2f')]][_0x5b99('0x22')]!==_0x4a9f97[_0x5b99('0x22')]['toLowerCase']()){this['trunks'][_0x4a9f97['device']][_0x5b99('0x35')]=_[_0x5b99('0x33')](moment()[_0x5b99('0x2a')]('x'));}this[_0x5b99('0xb')][_0x4a9f97['device']][_0x5b99('0x22')]=_0x4a9f97[_0x5b99('0x22')]['toLowerCase']();logger['debug'](_0x5b99('0x3a'),util[_0x5b99('0x1b')](this[_0x5b99('0xb')][_0x4a9f97[_0x5b99('0x2f')]],{'showHidden':![],'depth':null}));this['emit'](util[_0x5b99('0x2a')]('trunk:%s',this['trunks'][_0x4a9f97[_0x5b99('0x2f')]][_0x5b99('0x38')]),_0x5b99('0x2c'),this['trunks'][_0x4a9f97[_0x5b99('0x2f')]]);}else if(_[_0x5b99('0x3b')](_0x4a9f97[_0x5b99('0x2f')],'Local')){var _0x4b248d=_0x4a9f97[_0x5b99('0x2f')];var _0x3224d2=_0x4b248d['substring'](_0x4b248d[_0x5b99('0x3c')]('/')+0x1,_0x4b248d[_0x5b99('0x3c')]('@'));var _0x1359f0=_[_0x5b99('0x24')](this['agents'],function(_0x39ca5f){return _0x39ca5f[_0x5b99('0x3d')]==_0x3224d2||_0x39ca5f[_0x5b99('0x3e')]==_0x3224d2||_0x39ca5f[_0x5b99('0x3f')]==_0x3224d2;});if(_0x1359f0){if(_0x1359f0[_0x5b99('0x22')]!==_0x4a9f97[_0x5b99('0x22')]['toLowerCase']()){_0x1359f0['stateTime']=_[_0x5b99('0x33')](moment()['format']('x'));}_0x1359f0[_0x5b99('0x22')]=_0x4a9f97['state'][_0x5b99('0x32')]();_0x1359f0[_0x5b99('0x40')]=!![];_0x1359f0[_0x5b99('0x34')](_0x4a9f97);}}}}catch(_0x5e8a96){logger[_0x5b99('0x18')](_0x5b99('0x30'),util[_0x5b99('0x1b')](_0x5e8a96,{'showHidden':![],'depth':null}));}};UserReport[_0x5b99('0x1d')]['syncPeerStatus']=function(_0x566eb9){try{if(this[_0x5b99('0x1e')](_0x566eb9)&&this['isNotNull'](_0x566eb9[_0x5b99('0x13')])){logger[_0x5b99('0x20')]('[userReport][peerstatus]\x20peer:%s\x20address:%s\x20status:%s',_0x566eb9['peer'],_0x566eb9[_0x5b99('0x41')],_0x566eb9[_0x5b99('0x13')]);logger[_0x5b99('0x23')](_0x5b99('0x42'),util[_0x5b99('0x1b')](_0x566eb9,{'showHidden':![],'depth':null}));if(this['agents'][_0x566eb9[_0x5b99('0x43')]]){if(!this['agents'][_0x566eb9[_0x5b99('0x43')]][_0x5b99('0x40')]||_0x566eb9[_0x5b99('0x13')][_0x5b99('0x32')]()==_0x5b99('0x44')){this[_0x5b99('0xc')][_0x566eb9[_0x5b99('0x43')]]['local']=![];this[_0x5b99('0xc')][_0x566eb9[_0x5b99('0x43')]]['status']=_0x566eb9['peerstatus']['toLowerCase']();this['agents'][_0x566eb9[_0x5b99('0x43')]][_0x5b99('0x41')]=_0x566eb9[_0x5b99('0x41')];this['agents'][_0x566eb9[_0x5b99('0x43')]][_0x5b99('0x34')](_0x566eb9);}}else if(this[_0x5b99('0xd')][_0x566eb9[_0x5b99('0x43')]]){this[_0x5b99('0xd')][_0x566eb9[_0x5b99('0x43')]][_0x5b99('0x45')]=_0x566eb9['peerstatus'][_0x5b99('0x32')]();this[_0x5b99('0xd')][_0x566eb9[_0x5b99('0x43')]][_0x5b99('0x41')]=_0x566eb9['address'];logger[_0x5b99('0x23')]('[userReport][peerstatus]\x20sending\x20telephone:save\x20event:',util[_0x5b99('0x1b')](this[_0x5b99('0xd')][_0x566eb9[_0x5b99('0x43')]],{'showHidden':![],'depth':null}));this['emit'](util[_0x5b99('0x2a')]('telephone:%s',this[_0x5b99('0xd')][_0x566eb9[_0x5b99('0x43')]]['name']),_0x5b99('0x39'),this[_0x5b99('0xd')][_0x566eb9['peer']]);}else if(this['trunks'][_0x566eb9[_0x5b99('0x43')]]){this[_0x5b99('0xb')][_0x566eb9[_0x5b99('0x43')]]['status']=_0x566eb9['peerstatus'][_0x5b99('0x32')]();this['trunks'][_0x566eb9[_0x5b99('0x43')]][_0x5b99('0x41')]=_0x566eb9[_0x5b99('0x41')];logger['debug']('[userReport][peerstatus]\x20sending\x20trunk:save\x20event:',util[_0x5b99('0x1b')](this[_0x5b99('0xb')][_0x566eb9[_0x5b99('0x43')]],{'showHidden':![],'depth':null}));this[_0x5b99('0x1f')](util[_0x5b99('0x2a')](_0x5b99('0x2b'),this['trunks'][_0x566eb9['peer']]['name']),_0x5b99('0x2c'),this[_0x5b99('0xb')][_0x566eb9[_0x5b99('0x43')]]);}}}catch(_0x1cea42){logger['error'](_0x5b99('0x42'),util[_0x5b99('0x1b')](_0x1cea42,{'showHidden':![],'depth':null}));}};module[_0x5b99('0x46')]=UserReport;
\ No newline at end of file
+var _0xa181=['peer','[userReport][peerstatus]','registered','status','address','[userReport][peerstatus]\x20sending\x20telephone:save\x20event:','telephone:%s','[userReport][peerstatus]\x20sending\x20trunk:save\x20event:','exports','lodash','moment','util','ioredis','bluebird','../../../config/environment','../../../config/logger','ami','redis','localhost','socket.io-emitter','trunks','bind','registry','syncRegistry','syncDeviceState','peerstatus','syncPeerStatus','syncRealtimeShow','resolve','then','actionSipShowRegistry','catch','error','[userReport][sipshowregistry]','inspect','[userReport][devicestatelist]','[userReport][sippeerstatus]','prototype','isNotNull','isUndefined','emit','info','state','[userReport][registry]','username','stateRegistry','omit','event','actionid','debug','[userReport][registry]\x20sending\x20trunk:save\x20event:','format','trunk:%s','name','trunk:save','device','agents','local','toLowerCase','stateTime','toNumber','updateStatusRealtime','telephones','telephone:save','[userReport][devicestatechange]\x20sending\x20trunk:save\x20event:','startsWith','Local','substring','indexOf','phone','[userReport][peerstatus]\x20peer:%s\x20address:%s\x20status:%s'];(function(_0x293a47,_0x2991c2){var _0x4e2baf=function(_0x41907b){while(--_0x41907b){_0x293a47['push'](_0x293a47['shift']());}};_0x4e2baf(++_0x2991c2);}(_0xa181,0x16c));var _0x1a18=function(_0xf35638,_0x2b8487){_0xf35638=_0xf35638-0x0;var _0x1972c7=_0xa181[_0xf35638];return _0x1972c7;};'use strict';var _=require(_0x1a18('0x0'));var moment=require(_0x1a18('0x1'));var util=require(_0x1a18('0x2'));var Redis=require(_0x1a18('0x3'));var BPromise=require(_0x1a18('0x4'));var config=require(_0x1a18('0x5'));var logger=require(_0x1a18('0x6'))(_0x1a18('0x7'));var ami=require('../ami');config['redis']=_['defaults'](config[_0x1a18('0x8')],{'host':_0x1a18('0x9'),'port':0x18eb});var io=require(_0x1a18('0xa'))(new Redis(config['redis']));function UserReport(_0xd1bd3f){this[_0x1a18('0xb')]=_0xd1bd3f[_0x1a18('0xb')];this['agents']=_0xd1bd3f['agents'];this['telephones']=_0xd1bd3f['telephones'];ami['on']('registryentry',this['syncRegistry'][_0x1a18('0xc')](this));ami['on'](_0x1a18('0xd'),this[_0x1a18('0xe')][_0x1a18('0xc')](this));ami['on']('devicestatechange',this[_0x1a18('0xf')][_0x1a18('0xc')](this));ami['on'](_0x1a18('0x10'),this[_0x1a18('0x11')]['bind'](this));return this[_0x1a18('0x12')]();}function showSipRegistrations(){Promise[_0x1a18('0x13')]()[_0x1a18('0x14')](ami[_0x1a18('0x15')]())[_0x1a18('0x16')](function(_0x3e97ad){logger[_0x1a18('0x17')](_0x1a18('0x18'),util[_0x1a18('0x19')](_0x3e97ad,{'showHidden':![],'depth':null}));});}function listDeviceStates(){Promise['resolve']()[_0x1a18('0x14')](ami['actionDeviceStateList']())[_0x1a18('0x16')](function(_0x1d144d){logger[_0x1a18('0x17')](_0x1a18('0x1a'),util[_0x1a18('0x19')](_0x1d144d,{'showHidden':![],'depth':null}));});}function showPeersStatus(){Promise[_0x1a18('0x13')]()[_0x1a18('0x14')](ami['actionSipPeerStatus']())[_0x1a18('0x16')](function(_0x33f2ea){logger[_0x1a18('0x17')](_0x1a18('0x1b'),util[_0x1a18('0x19')](_0x33f2ea,{'showHidden':![],'depth':null}));});}UserReport[_0x1a18('0x1c')][_0x1a18('0x12')]=function(){setInterval(function(){BPromise['resolve']()[_0x1a18('0x14')](showSipRegistrations())[_0x1a18('0x14')](listDeviceStates())[_0x1a18('0x14')](showPeersStatus());},0x32c8);};UserReport[_0x1a18('0x1c')][_0x1a18('0x1d')]=function(_0xf97e90){return _0xf97e90!==null&&!_[_0x1a18('0x1e')](_0xf97e90);};UserReport[_0x1a18('0x1c')][_0x1a18('0x1f')]=function(_0x3c472f,_0x12f2fe,_0x126449){io['to'](_0x3c472f)[_0x1a18('0x1f')](_0x12f2fe,_0x126449);};UserReport['prototype']['syncRegistry']=function(_0x3992ce){try{if(this[_0x1a18('0x1d')](_0x3992ce)){logger[_0x1a18('0x20')]('[userReport][registry]\x20registry:%s\x20state:%s',_0x3992ce['username'],_0x3992ce[_0x1a18('0x21')]);logger['debug'](_0x1a18('0x22'),util[_0x1a18('0x19')](_0x3992ce,{'showHidden':![],'depth':null}));var _0x5f3953=_['find'](this[_0x1a18('0xb')],{'defaultuser':_0x3992ce[_0x1a18('0x23')]});if(_0x5f3953){_0x3992ce[_0x1a18('0x24')]=_0x3992ce[_0x1a18('0x21')];_['merge'](_0x5f3953,_[_0x1a18('0x25')](_0x3992ce,[_0x1a18('0x26'),_0x1a18('0x27'),_0x1a18('0x23'),_0x1a18('0x21')]));logger[_0x1a18('0x28')](_0x1a18('0x29'),util[_0x1a18('0x19')](_0x5f3953,{'showHidden':![],'depth':null}));this[_0x1a18('0x1f')](util[_0x1a18('0x2a')](_0x1a18('0x2b'),_0x5f3953[_0x1a18('0x2c')]),_0x1a18('0x2d'),_0x5f3953);}}}catch(_0x57b272){logger[_0x1a18('0x17')](_0x1a18('0x22'),util[_0x1a18('0x19')](_0x57b272,{'showHidden':![],'depth':null}));}};UserReport[_0x1a18('0x1c')][_0x1a18('0xf')]=function(_0x3ef243){try{if(this[_0x1a18('0x1d')](_0x3ef243)){logger['info']('[userReport][devicestatechange]\x20device:%s\x20state:%s',_0x3ef243[_0x1a18('0x2e')],_0x3ef243['state']);logger[_0x1a18('0x28')]('[userReport][devicestatechange]',util[_0x1a18('0x19')](_0x3ef243,{'showHidden':![],'depth':null}));if(this[_0x1a18('0x2f')][_0x3ef243[_0x1a18('0x2e')]]){if(!this[_0x1a18('0x2f')][_0x3ef243[_0x1a18('0x2e')]][_0x1a18('0x30')]||_0x3ef243[_0x1a18('0x21')][_0x1a18('0x31')]()=='inuse'){this['agents'][_0x3ef243[_0x1a18('0x2e')]][_0x1a18('0x30')]=![];if(this[_0x1a18('0x2f')][_0x3ef243[_0x1a18('0x2e')]][_0x1a18('0x21')]!==_0x3ef243[_0x1a18('0x21')][_0x1a18('0x31')]()){this[_0x1a18('0x2f')][_0x3ef243['device']][_0x1a18('0x32')]=_[_0x1a18('0x33')](moment()['format']('x'));}this[_0x1a18('0x2f')][_0x3ef243[_0x1a18('0x2e')]][_0x1a18('0x21')]=_0x3ef243[_0x1a18('0x21')][_0x1a18('0x31')]();this[_0x1a18('0x2f')][_0x3ef243[_0x1a18('0x2e')]][_0x1a18('0x34')](_0x3ef243);}}else if(this[_0x1a18('0x35')][_0x3ef243[_0x1a18('0x2e')]]){if(this[_0x1a18('0x35')][_0x3ef243[_0x1a18('0x2e')]][_0x1a18('0x21')]!==_0x3ef243[_0x1a18('0x21')][_0x1a18('0x31')]()){this[_0x1a18('0x35')][_0x3ef243['device']][_0x1a18('0x32')]=_['toNumber'](moment()['format']('x'));}this[_0x1a18('0x35')][_0x3ef243[_0x1a18('0x2e')]][_0x1a18('0x21')]=_0x3ef243[_0x1a18('0x21')][_0x1a18('0x31')]();logger[_0x1a18('0x28')]('[userReport][devicestatechange]\x20sending\x20telephone:save\x20event:',util[_0x1a18('0x19')](this[_0x1a18('0x35')][_0x3ef243[_0x1a18('0x2e')]],{'showHidden':![],'depth':null}));this[_0x1a18('0x1f')](util['format']('telephone:%s',this[_0x1a18('0x35')][_0x3ef243[_0x1a18('0x2e')]][_0x1a18('0x2c')]),_0x1a18('0x36'),this[_0x1a18('0x35')][_0x3ef243[_0x1a18('0x2e')]]);}else if(this[_0x1a18('0xb')][_0x3ef243[_0x1a18('0x2e')]]){if(this['trunks'][_0x3ef243[_0x1a18('0x2e')]]['state']!==_0x3ef243[_0x1a18('0x21')]['toLowerCase']()){this[_0x1a18('0xb')][_0x3ef243[_0x1a18('0x2e')]]['stateTime']=_[_0x1a18('0x33')](moment()[_0x1a18('0x2a')]('x'));}this['trunks'][_0x3ef243[_0x1a18('0x2e')]][_0x1a18('0x21')]=_0x3ef243[_0x1a18('0x21')][_0x1a18('0x31')]();logger[_0x1a18('0x28')](_0x1a18('0x37'),util[_0x1a18('0x19')](this[_0x1a18('0xb')][_0x3ef243[_0x1a18('0x2e')]],{'showHidden':![],'depth':null}));this['emit'](util['format'](_0x1a18('0x2b'),this[_0x1a18('0xb')][_0x3ef243['device']][_0x1a18('0x2c')]),'trunk:save',this[_0x1a18('0xb')][_0x3ef243[_0x1a18('0x2e')]]);}else if(_[_0x1a18('0x38')](_0x3ef243['device'],_0x1a18('0x39'))){var _0x4f32df=_0x3ef243[_0x1a18('0x2e')];var _0x4590da=_0x4f32df[_0x1a18('0x3a')](_0x4f32df[_0x1a18('0x3b')]('/')+0x1,_0x4f32df[_0x1a18('0x3b')]('@'));var _0xc0746a=_['find'](this['agents'],function(_0x277d0e){return _0x277d0e['mobile']==_0x4590da||_0x277d0e[_0x1a18('0x3c')]==_0x4590da||_0x277d0e['accountcode']==_0x4590da;});if(_0xc0746a){if(_0xc0746a[_0x1a18('0x21')]!==_0x3ef243[_0x1a18('0x21')][_0x1a18('0x31')]()){_0xc0746a['stateTime']=_[_0x1a18('0x33')](moment()[_0x1a18('0x2a')]('x'));}_0xc0746a[_0x1a18('0x21')]=_0x3ef243['state'][_0x1a18('0x31')]();_0xc0746a['local']=!![];_0xc0746a[_0x1a18('0x34')](_0x3ef243);}}}}catch(_0x4fcced){logger[_0x1a18('0x17')]('[userReport][devicestatechange]',util[_0x1a18('0x19')](_0x4fcced,{'showHidden':![],'depth':null}));}};UserReport[_0x1a18('0x1c')][_0x1a18('0x11')]=function(_0x1f5f10){try{if(this[_0x1a18('0x1d')](_0x1f5f10)&&this[_0x1a18('0x1d')](_0x1f5f10[_0x1a18('0x10')])){logger['info'](_0x1a18('0x3d'),_0x1f5f10[_0x1a18('0x3e')],_0x1f5f10['address'],_0x1f5f10['peerstatus']);logger[_0x1a18('0x28')](_0x1a18('0x3f'),util[_0x1a18('0x19')](_0x1f5f10,{'showHidden':![],'depth':null}));if(this[_0x1a18('0x2f')][_0x1f5f10[_0x1a18('0x3e')]]){if(!this[_0x1a18('0x2f')][_0x1f5f10['peer']][_0x1a18('0x30')]||_0x1f5f10['peerstatus']['toLowerCase']()==_0x1a18('0x40')){this[_0x1a18('0x2f')][_0x1f5f10[_0x1a18('0x3e')]][_0x1a18('0x30')]=![];this['agents'][_0x1f5f10[_0x1a18('0x3e')]][_0x1a18('0x41')]=_0x1f5f10[_0x1a18('0x10')][_0x1a18('0x31')]();this[_0x1a18('0x2f')][_0x1f5f10[_0x1a18('0x3e')]][_0x1a18('0x42')]=_0x1f5f10[_0x1a18('0x42')];this[_0x1a18('0x2f')][_0x1f5f10[_0x1a18('0x3e')]][_0x1a18('0x34')](_0x1f5f10);}}else if(this['telephones'][_0x1f5f10[_0x1a18('0x3e')]]){this[_0x1a18('0x35')][_0x1f5f10[_0x1a18('0x3e')]]['status']=_0x1f5f10[_0x1a18('0x10')]['toLowerCase']();this[_0x1a18('0x35')][_0x1f5f10[_0x1a18('0x3e')]][_0x1a18('0x42')]=_0x1f5f10['address'];logger[_0x1a18('0x28')](_0x1a18('0x43'),util[_0x1a18('0x19')](this[_0x1a18('0x35')][_0x1f5f10[_0x1a18('0x3e')]],{'showHidden':![],'depth':null}));this[_0x1a18('0x1f')](util[_0x1a18('0x2a')](_0x1a18('0x44'),this[_0x1a18('0x35')][_0x1f5f10['peer']]['name']),_0x1a18('0x36'),this[_0x1a18('0x35')][_0x1f5f10[_0x1a18('0x3e')]]);}else if(this[_0x1a18('0xb')][_0x1f5f10['peer']]){this[_0x1a18('0xb')][_0x1f5f10[_0x1a18('0x3e')]][_0x1a18('0x41')]=_0x1f5f10[_0x1a18('0x10')][_0x1a18('0x31')]();this['trunks'][_0x1f5f10[_0x1a18('0x3e')]]['address']=_0x1f5f10[_0x1a18('0x42')];logger[_0x1a18('0x28')](_0x1a18('0x45'),util[_0x1a18('0x19')](this['trunks'][_0x1f5f10[_0x1a18('0x3e')]],{'showHidden':![],'depth':null}));this[_0x1a18('0x1f')](util['format'](_0x1a18('0x2b'),this['trunks'][_0x1f5f10[_0x1a18('0x3e')]][_0x1a18('0x2c')]),_0x1a18('0x2d'),this['trunks'][_0x1f5f10['peer']]);}}}catch(_0x3ce5b3){logger[_0x1a18('0x17')](_0x1a18('0x3f'),util[_0x1a18('0x19')](_0x3ce5b3,{'showHidden':![],'depth':null}));}};module[_0x1a18('0x46')]=UserReport;
\ No newline at end of file