Built motion from commit c49361c37b5f784889c8087ac6e0e91b7e6b561a. Version 3.0.0...
[motion-next.git] / server / api / user / user.rpc.js
index e3f71e3..1a3d2f0 100644 (file)
@@ -1 +1 @@
-const a651_0x1c38=['lodash','model','message','info','GetUser','isValidChannel','getChannels','stringify','LogoutUser','ShowUser','format','then','channel','mobile','voice','getLicense','internal','agents','openchannel','include','length','loginInPause','MemberReport','role','destroy','count','UnpauseUser','body','chat','rpc','type','push','concat','system','attributes','forEach','error','update','Maximum\x20login\x20has\x20been\x20reached','where','../../config/license/util','PAUSE','upsert','fax','interface','map','findOne','DEFAULT\x20PAUSE','name','./user.socket','catch','sms','findAll','set','raw','callysquare','options','../../config/utils','../../config/logger','register','bulkCreate','moment','YYYY-MM-DD\x20HH:mm:ss','SIP/%s','UserVoiceQueueRt','agent','Unknown\x20channel','LOGININPAUSE','util','phone','isNil','all','PauseUser','sequelize','User','limit','uniqueid'];(function(_0x266af0,_0x1c380e){const _0x8f7944=function(_0x173e84){while(--_0x173e84){_0x266af0['push'](_0x266af0['shift']());}};_0x8f7944(++_0x1c380e);}(a651_0x1c38,0x1df));const a651_0x8f79=function(_0x266af0,_0x1c380e){_0x266af0=_0x266af0-0x0;let _0x8f7944=a651_0x1c38[_0x266af0];return _0x8f7944;};const _0x5ee018=a651_0x8f79;'use strict';const _=require(_0x5ee018('0x3c')),util=require(_0x5ee018('0x33')),db=require('../../mysqldb')['db'],logger=require(_0x5ee018('0x29'))(_0x5ee018('0xc')),moment=require(_0x5ee018('0x2c')),utils=require(_0x5ee018('0x28')),{getSocket}=require('../../rediscache'),socket=getSocket(),sequelize=require(_0x5ee018('0x38')),{Op}=sequelize;require(_0x5ee018('0x20'))[_0x5ee018('0x2a')](socket),exports['GetUser']=function(_0x173e84){const _0x58a5df=this;return new Promise(function(_0x45aa9e,_0x372abf){const _0x1d2f45=a651_0x8f79;return db[_0x1d2f45('0x39')][_0x1d2f45('0x23')]({'raw':_0x173e84[_0x1d2f45('0x27')]?_0x173e84[_0x1d2f45('0x27')]['raw']===undefined?!![]:![]:!![],'where':_0x173e84[_0x1d2f45('0x27')]?_0x173e84[_0x1d2f45('0x27')]['where']||null:null,'attributes':_0x173e84[_0x1d2f45('0x27')]?_0x173e84[_0x1d2f45('0x27')][_0x1d2f45('0x11')]||null:null,'limit':_0x173e84[_0x1d2f45('0x27')]?_0x173e84[_0x1d2f45('0x27')][_0x1d2f45('0x3a')]||null:null,'include':_0x173e84[_0x1d2f45('0x27')]?_0x173e84[_0x1d2f45('0x27')]['include']?_[_0x1d2f45('0x1c')](_0x173e84[_0x1d2f45('0x27')][_0x1d2f45('0x2')],function(_0x488d5c){const _0x2b816c=_0x1d2f45;return{'model':db[_0x488d5c[_0x2b816c('0x3d')]],'as':_0x488d5c['as'],'attributes':_0x488d5c[_0x2b816c('0x11')],'include':_0x488d5c[_0x2b816c('0x2')]?_[_0x2b816c('0x1c')](_0x488d5c[_0x2b816c('0x2')],function(_0x30ee86){const _0x19a3ee=_0x2b816c;return{'model':db[_0x30ee86[_0x19a3ee('0x3d')]],'as':_0x30ee86['as'],'attributes':_0x30ee86['attributes'],'include':_0x30ee86[_0x19a3ee('0x2')]?_[_0x19a3ee('0x1c')](_0x30ee86[_0x19a3ee('0x2')],function(_0x28b06b){const _0x4a1dde=_0x19a3ee;return{'model':db[_0x28b06b[_0x4a1dde('0x3d')]],'as':_0x28b06b['as'],'attributes':_0x28b06b[_0x4a1dde('0x11')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x457269){const _0x31bdd5=_0x1d2f45;logger[_0x31bdd5('0x3f')](_0x31bdd5('0x40'),_0x173e84),logger['debug']('GetUser',_0x173e84,JSON['stringify'](_0x457269)),_0x45aa9e(_0x457269);})[_0x1d2f45('0x21')](function(_0x2c06b6){const _0x52c590=_0x1d2f45;logger[_0x52c590('0x13')](_0x52c590('0x40'),_0x2c06b6[_0x52c590('0x3e')],_0x173e84),_0x372abf(_0x58a5df['error'](0x1f4,_0x2c06b6['message']));});});},exports[_0x5ee018('0x45')]=function(_0x27152b){const _0x4f636d=this;return new Promise(function(_0x16b5b2,_0x3481b8){const _0x27681a=a651_0x8f79;return db[_0x27681a('0x39')][_0x27681a('0x1d')]({'raw':_0x27152b[_0x27681a('0x27')]?_0x27152b['options'][_0x27681a('0x25')]===undefined?!![]:![]:!![],'where':_0x27152b['options']?_0x27152b[_0x27681a('0x27')][_0x27681a('0x16')]||null:null,'attributes':_0x27152b[_0x27681a('0x27')]?_0x27152b['options'][_0x27681a('0x11')]||null:null,'include':_0x27152b[_0x27681a('0x27')]?_0x27152b['options']['include']?_[_0x27681a('0x1c')](_0x27152b['options'][_0x27681a('0x2')],function(_0x3c5f4d){const _0x3674fc=_0x27681a;return{'model':db[_0x3c5f4d['model']],'as':_0x3c5f4d['as'],'attributes':_0x3c5f4d[_0x3674fc('0x11')],'include':_0x3c5f4d['include']?_['map'](_0x3c5f4d[_0x3674fc('0x2')],function(_0x467be2){const _0x52018c=_0x3674fc;return{'model':db[_0x467be2[_0x52018c('0x3d')]],'as':_0x467be2['as'],'attributes':_0x467be2[_0x52018c('0x11')],'include':_0x467be2[_0x52018c('0x2')]?_[_0x52018c('0x1c')](_0x467be2['include'],function(_0x512206){const _0x286995=_0x52018c;return{'model':db[_0x512206[_0x286995('0x3d')]],'as':_0x512206['as'],'attributes':_0x512206[_0x286995('0x11')]};}):[]};}):[]};}):[]:[]})[_0x27681a('0x47')](function(_0x572851){const _0x3ed388=_0x27681a;logger[_0x3ed388('0x3f')](_0x3ed388('0x45'),_0x27152b),logger['debug']('ShowUser',_0x27152b,JSON[_0x3ed388('0x43')](_0x572851)),_0x16b5b2(_0x572851);})[_0x27681a('0x21')](function(_0x27e83f){const _0x14b370=_0x27681a;logger['error']('ShowUser',_0x27e83f[_0x14b370('0x3e')],_0x27152b),_0x3481b8(_0x4f636d[_0x14b370('0x13')](0x1f4,_0x27e83f['message']));});});},exports[_0x5ee018('0x37')]=function(_0x594a52){const _0x254182=this;return new Promise(function(_0x453b01,_0x8a703b){const _0x4ed777=a651_0x8f79;let _0x471647;return db[_0x4ed777('0x39')][_0x4ed777('0x1d')]({'where':_0x594a52[_0x4ed777('0x27')][_0x4ed777('0x16')]||{},'attributes':['id','name',_0x4ed777('0x6'),'internal','interface']})['then'](function(_0x3ee93c){const _0x432f68=_0x4ed777;if(_0x3ee93c)return _0x471647=_0x3ee93c,db[_0x432f68('0x2f')][_0x432f68('0x14')]({'paused':0x1},{'where':{'UserId':_0x471647['id']},'individualHooks':!![]});})[_0x4ed777('0x47')](function(){const _0x17547e=_0x4ed777;if(_0x471647)return db[_0x17547e('0x5')]['findAll']({'where':{'membername':_0x471647[_0x17547e('0x1f')],'type':_0x17547e('0x18'),'exitAt':null}});})[_0x4ed777('0x47')](function(_0x363e34){const _0xef96eb=_0x4ed777;if(_0x471647){if(_0x363e34&&_0x363e34[_0xef96eb('0x3')]){const _0x5ac0e5=moment()[_0xef96eb('0x46')]('YYYY-MM-DD\x20HH:mm:ss');for(let _0x1cfb9f=0x0,_0x2283cf=_0x363e34[_0xef96eb('0x3')];_0x1cfb9f<_0x2283cf;_0x1cfb9f++){_0x363e34[_0x1cfb9f][_0xef96eb('0x14')]({'exitAt':_0x5ac0e5});}}}})[_0x4ed777('0x47')](function(){const _0x4f7331=_0x4ed777;if(_0x471647){const _0x1f827d=[],_0x9a1f33=utils['getChannels']();return _0x9a1f33[_0x4f7331('0x12')](function(_0x27afe6){const _0x4191ae=_0x4f7331;_0x1f827d[_0x4191ae('0xe')]({'channel':_0x27afe6,'membername':_0x471647[_0x4191ae('0x1f')],'interface':_[_0x4191ae('0x35')](_0x471647[_0x4191ae('0x1b')])?util[_0x4191ae('0x46')]('SIP/%s',_0x471647[_0x4191ae('0x1f')]):_0x471647[_0x4191ae('0x1b')],'type':_0x4191ae('0x18'),'enterAt':moment()[_0x4191ae('0x46')](_0x4191ae('0x2d')),'data1':_0x594a52[_0x4191ae('0xa')][_0x4191ae('0xd')]||_0x4191ae('0x1e'),'role':_0x471647[_0x4191ae('0x6')],'internal':_0x471647[_0x4191ae('0x4c')],'uniqueid':_0x594a52[_0x4191ae('0xa')][_0x4191ae('0x3b')]||null});}),db[_0x4f7331('0x5')]['bulkCreate'](_0x1f827d,{'individualHooks':!![]});}})[_0x4ed777('0x47')](function(){const _0x123c47=_0x4ed777;if(_0x471647)return _0x471647[_0x123c47('0x14')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'pauseType':_0x594a52[_0x123c47('0xa')][_0x123c47('0xd')]||_0x123c47('0x1e'),'lastPauseAt':moment()[_0x123c47('0x46')](_0x123c47('0x2d'))});})[_0x4ed777('0x47')](function(_0x557fe5){_0x453b01(_0x557fe5);})[_0x4ed777('0x21')](function(_0x5a72be){const _0x965557=_0x4ed777;_0x8a703b(_0x254182[_0x965557('0x13')](0x1f4,_0x5a72be[_0x965557('0x3e')]));});});},exports[_0x5ee018('0x9')]=function(_0x14e715){const _0x55c3e0=this;return new Promise(function(_0x3b491c,_0x13d10b){const _0x5441ee=a651_0x8f79;let _0x30946c;return db['User']['findOne']({'where':_0x14e715['options'][_0x5441ee('0x16')]||{},'attributes':['id',_0x5441ee('0x1f')]})[_0x5441ee('0x47')](function(_0x2c1396){const _0x25bc96=_0x5441ee;if(_0x2c1396){_0x30946c=_0x2c1396;if(_0x14e715[_0x25bc96('0xa')]['channel']&&!utils[_0x25bc96('0x41')](_0x14e715[_0x25bc96('0xa')][_0x25bc96('0x48')]))throw new Error(_0x25bc96('0x31'));switch(_0x14e715[_0x25bc96('0xa')][_0x25bc96('0x48')]){case _0x25bc96('0x4a'):return db[_0x25bc96('0x2f')][_0x25bc96('0x14')]({'paused':0x0},{'where':{'UserId':_0x30946c['id']}})['then'](function(){const _0x27585f=_0x25bc96;return db[_0x27585f('0x5')][_0x27585f('0x1d')]({'where':{'channel':_0x14e715[_0x27585f('0xa')][_0x27585f('0x48')],'membername':_0x30946c[_0x27585f('0x1f')],'type':'PAUSE','exitAt':null}});})[_0x25bc96('0x47')](function(_0x5dc0fc){const _0x354272=_0x25bc96;if(_0x5dc0fc)return _0x5dc0fc[_0x354272('0x14')]({'exitAt':moment()[_0x354272('0x46')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x354272('0x10')},{'individualHooks':!![]});return null;})[_0x25bc96('0x47')](function(){const _0x533f40=_0x25bc96;return _0x30946c[_0x533f40('0x14')]({'voicePause':![]});});case'mail':case _0x25bc96('0xb'):case _0x25bc96('0x1a'):case _0x25bc96('0x22'):case _0x25bc96('0x1'):return db[_0x25bc96('0x5')][_0x25bc96('0x1d')]({'where':{'channel':_0x14e715[_0x25bc96('0xa')]['channel'],'membername':_0x30946c['name'],'type':_0x25bc96('0x18'),'exitAt':null}})[_0x25bc96('0x47')](function(_0x1540e3){const _0x1fd0ed=_0x25bc96;return _0x1540e3[_0x1fd0ed('0x14')]({'exitAt':moment()['format'](_0x1fd0ed('0x2d')),'data2':_0x1fd0ed('0x10')},{'individualHooks':!![]});})[_0x25bc96('0x47')](function(){const _0x154ff9=_0x25bc96,_0x280e13={};return _[_0x154ff9('0x24')](_0x280e13,util[_0x154ff9('0x46')]('%s%s',_0x14e715[_0x154ff9('0xa')]['channel'],'Pause'),![]),_0x30946c[_0x154ff9('0x14')](_0x280e13);});default:return db[_0x25bc96('0x2f')]['update']({'paused':0x0},{'where':{'UserId':_0x30946c['id']}})[_0x25bc96('0x47')](function(){const _0x904074=_0x25bc96;return db[_0x904074('0x5')][_0x904074('0x23')]({'where':{'membername':_0x30946c[_0x904074('0x1f')],'type':_0x904074('0x18'),'exitAt':null}});})['then'](function(_0x2a6b0b){const _0x44a3eb=_0x25bc96,_0x4a465b=[];return _0x2a6b0b[_0x44a3eb('0x12')](function(_0x4d4483){const _0x231748=_0x44a3eb;_0x4a465b['push'](_0x4d4483[_0x231748('0x14')]({'exitAt':moment()[_0x231748('0x46')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x231748('0x10')}));}),Promise[_0x44a3eb('0x36')](_0x4a465b);})[_0x25bc96('0x47')](function(){const _0x4188ff=_0x25bc96;return _0x30946c[_0x4188ff('0x14')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});});}}})[_0x5441ee('0x47')](function(_0x26e1af){_0x3b491c(_0x26e1af);})[_0x5441ee('0x21')](function(_0x567993){const _0x57f3c6=_0x5441ee;_0x13d10b(_0x55c3e0[_0x57f3c6('0x13')](0x1f4,_0x567993[_0x57f3c6('0x3e')]));});});},exports[_0x5ee018('0x44')]=function(_0x45b6fb){const _0x4707c4=this;return new Promise(function(_0x4c315d,_0x4a365c){const _0x250f6e=a651_0x8f79;let _0x413951;return db[_0x250f6e('0x39')][_0x250f6e('0x1d')]({'where':_0x45b6fb['options'][_0x250f6e('0x16')]||{},'attributes':['id',_0x250f6e('0x1f')]})[_0x250f6e('0x47')](function(_0x212554){const _0x1e083d=_0x250f6e;if(_0x212554)return _0x413951=_0x212554,db[_0x1e083d('0x2f')]['destroy']({'where':{'membername':_0x413951[_0x1e083d('0x1f')]},'individualHooks':!![]});})['then'](function(){const _0x201162=_0x250f6e;if(_0x413951)return db[_0x201162('0x5')][_0x201162('0x23')]({'where':{'membername':_0x413951[_0x201162('0x1f')],'exitAt':null}});})[_0x250f6e('0x47')](function(_0x4d8768){const _0x1c8188=_0x250f6e;if(_0x413951){if(_0x4d8768&&_0x4d8768[_0x1c8188('0x3')]){const _0x5368fc=[];return _0x4d8768['forEach'](function(_0x244f36){const _0x3cc652=_0x1c8188;_0x5368fc[_0x3cc652('0xe')](_0x244f36['update']({'exitAt':moment()[_0x3cc652('0x46')]('YYYY-MM-DD\x20HH:mm:ss')}));}),Promise[_0x1c8188('0x36')](_0x5368fc);}}})[_0x250f6e('0x47')](function(){const _0x511151=_0x250f6e;if(_0x413951)return _0x413951[_0x511151('0x14')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});})[_0x250f6e('0x47')](function(_0x538f09){_0x4c315d(_0x538f09);})[_0x250f6e('0x21')](function(_0x147934){const _0x870a57=_0x250f6e;_0x4a365c(_0x4707c4['error'](0x1f4,_0x147934[_0x870a57('0x3e')]));});});},exports['LoginUser']=function(_0x5e2c07){const _0x40ef1f=this;return new Promise(function(_0x5c2bce,_0x4d7573){const _0x28cb65=a651_0x8f79;let _0x2e8b61,_0x2eb55c,_0x46df7b,_0x45d678;return db[_0x28cb65('0x39')][_0x28cb65('0x1d')]({'where':_0x5e2c07[_0x28cb65('0x27')][_0x28cb65('0x16')]||{},'attributes':['id','name',_0x28cb65('0x6'),_0x28cb65('0x49'),_0x28cb65('0x34'),_0x28cb65('0x4c'),_0x28cb65('0x4'),_0x28cb65('0x1b')]})[_0x28cb65('0x47')](function(_0x1a69a6){const _0x5476c6=_0x28cb65;if(_0x1a69a6)return _0x2e8b61=_0x1a69a6,_0x45d678=_0x5e2c07['body'][_0x5476c6('0x1b')]?_0x5e2c07['body'][_0x5476c6('0x1b')]:util['format'](_0x5476c6('0x2e'),_0x2e8b61[_0x5476c6('0x1f')]),db[_0x5476c6('0x39')][_0x5476c6('0x8')]({'where':{'role':_0x5476c6('0x30'),'online':!![],'id':{[Op['ne']]:_0x2e8b61['id']}}});})[_0x28cb65('0x47')](function(_0x4de1bb){const _0x46f653=_0x28cb65;if(_0x4de1bb)return _0x46df7b=_0x4de1bb,require(_0x46f653('0x17'))[_0x46f653('0x4b')]();})['then'](function(_0x830767){const _0x288764=_0x28cb65;if(_0x830767&&_0x830767['agents']&&_0x46df7b>=_0x830767[_0x288764('0x0')])throw new Error(_0x288764('0x15'));})[_0x28cb65('0x47')](function(){const _0x312f2d=_0x28cb65;if(_0x2e8b61)return db[_0x312f2d('0x2f')][_0x312f2d('0x7')]({'where':{'membername':_0x2e8b61['name']},'individualHooks':!![]});})[_0x28cb65('0x47')](function(){if(_0x2e8b61)return _0x2e8b61['getVoiceQueues']({'raw':!![]});})[_0x28cb65('0x47')](function(_0x3ec38e){const _0x42ae97=_0x28cb65;if(_0x2e8b61){if(_0x3ec38e){const _0x381c3b=[];_0x2eb55c=_0x3ec38e;if(_0x2eb55c[_0x42ae97('0x3')]){for(let _0x502938=0x0;_0x502938<_0x2eb55c[_0x42ae97('0x3')];_0x502938++){_0x381c3b['push'](db[_0x42ae97('0x2f')][_0x42ae97('0x19')]({'membername':_0x2e8b61[_0x42ae97('0x1f')],'UserId':_0x2e8b61['id'],'queue_name':_0x2eb55c[_0x502938][_0x42ae97('0x1f')],'VoiceQueueId':_0x2eb55c[_0x502938]['id'],'interface':_0x45d678,'paused':_0x2e8b61['loginInPause']||![],'penalty':_0x2eb55c[_0x502938]['UserVoiceQueue.penalty']||0x0}));}return Promise[_0x42ae97('0x36')](_0x381c3b);}}}})[_0x28cb65('0x47')](function(){const _0xe787d6=_0x28cb65;if(_0x2e8b61)return db[_0xe787d6('0x5')][_0xe787d6('0x23')]({'where':{'membername':_0x2e8b61[_0xe787d6('0x1f')],'exitAt':null}});})[_0x28cb65('0x47')](function(_0x2b6399){const _0x5cf7d0=_0x28cb65;if(_0x2e8b61){if(_0x2b6399&&_0x2b6399[_0x5cf7d0('0x3')]){const _0x1b20fd=[];return _0x2b6399[_0x5cf7d0('0x12')](function(_0x32c71c){const _0x1ffb33=_0x5cf7d0;_0x1b20fd[_0x1ffb33('0xe')](_0x32c71c[_0x1ffb33('0x14')]({'exitAt':moment()[_0x1ffb33('0x46')](_0x1ffb33('0x2d'))}));}),Promise[_0x5cf7d0('0x36')](_0x1b20fd);}}})[_0x28cb65('0x47')](function(){const _0x3309d0=_0x28cb65;if(_0x2e8b61){const _0x53c56c=[],_0x4f3152=[],_0x580067=utils[_0x3309d0('0x42')](),_0x46c764={'membername':_0x2e8b61['name'],'interface':_0x45d678,'enterAt':moment()[_0x3309d0('0x46')](_0x3309d0('0x2d')),'role':_0x2e8b61[_0x3309d0('0x6')],'internal':_0x2e8b61[_0x3309d0('0x4c')]};return _0x580067[_0x3309d0('0x12')](function(_0x1ca598){const _0xb7b08=_0x3309d0;_0x53c56c[_0xb7b08('0xe')](_['merge']({'channel':_0x1ca598,'type':'LOGIN','data1':_0xb7b08('0x26'),'data2':_0x45d678},_0x46c764)),_0x2e8b61[_0xb7b08('0x4')]&&_0x4f3152[_0xb7b08('0xe')](_['merge']({'channel':_0x1ca598,'type':_0xb7b08('0x18'),'data1':_0xb7b08('0x32')},_0x46c764));}),db[_0x3309d0('0x5')][_0x3309d0('0x2b')](_0x53c56c[_0x3309d0('0xf')](_0x4f3152),{'individualHooks':!![]});}})[_0x28cb65('0x47')](function(){const _0x9e8a13=_0x28cb65;if(_0x2e8b61)return _0x2e8b61[_0x9e8a13('0x14')]({'online':!![],'lastLoginAt':moment()[_0x9e8a13('0x46')](_0x9e8a13('0x2d')),'voicePause':_0x2e8b61[_0x9e8a13('0x4')]||![],'mailPause':_0x2e8b61['loginInPause']||![],'chatPause':_0x2e8b61[_0x9e8a13('0x4')]||![],'faxPause':_0x2e8b61[_0x9e8a13('0x4')]||![],'smsPause':_0x2e8b61[_0x9e8a13('0x4')]||![],'openchannelPause':_0x2e8b61[_0x9e8a13('0x4')]||![],'pauseType':_0x2e8b61[_0x9e8a13('0x4')]?_0x9e8a13('0x32'):null,'lastPauseAt':moment()['format'](_0x9e8a13('0x2d')),'interface':_0x45d678});})[_0x28cb65('0x47')](function(_0x1919f8){_0x5c2bce(_0x1919f8);})[_0x28cb65('0x21')](function(_0x93723b){const _0x5b452d=_0x28cb65;_0x4d7573(_0x40ef1f[_0x5b452d('0x13')](0x1f4,_0x93723b[_0x5b452d('0x3e')]));});});};
\ No newline at end of file
+const a651_0x105f=['LOGININPAUSE','limit','voice','attributes','fax','User','update','SIP/%s','getLicense','GetUser','type','stringify','forEach','PAUSE','../../config/license/util','openchannel','%s%s','upsert','all','where','PauseUser','findAll','format','rpc','./user.socket','../../config/utils','model','UserVoiceQueue.penalty','MemberReport','internal','options','../../config/logger','sms','lodash','phone','role','push','length','ShowUser','bulkCreate','chat','loginInPause','interface','channel','catch','destroy','Unknown\x20channel','callysquare','name','findOne','mail','agent','count','getVoiceQueues','register','../../rediscache','LoginUser','util','merge','LOGIN','sequelize','mobile','include','moment','YYYY-MM-DD\x20HH:mm:ss','getChannels','set','map','Pause','UserVoiceQueueRt','error','debug','then','agents','message','DEFAULT\x20PAUSE','body','system'];(function(_0x108f2e,_0x105fcf){const _0x4c6f36=function(_0x529722){while(--_0x529722){_0x108f2e['push'](_0x108f2e['shift']());}};_0x4c6f36(++_0x105fcf);}(a651_0x105f,0xe2));const a651_0x4c6f=function(_0x108f2e,_0x105fcf){_0x108f2e=_0x108f2e-0x0;let _0x4c6f36=a651_0x105f[_0x108f2e];return _0x4c6f36;};const _0x436deb=a651_0x4c6f;'use strict';const _=require(_0x436deb('0x29')),util=require(_0x436deb('0x41')),db=require('../../mysqldb')['db'],logger=require(_0x436deb('0x27'))(_0x436deb('0x1f')),moment=require(_0x436deb('0x47')),utils=require(_0x436deb('0x21')),{getSocket}=require(_0x436deb('0x3f')),socket=getSocket(),sequelize=require(_0x436deb('0x44')),{Op}=sequelize;require(_0x436deb('0x20'))[_0x436deb('0x3e')](socket),exports['GetUser']=function(_0x529722){const _0x3951bf=this;return new Promise(function(_0x2f2ae7,_0x291d8f){const _0xf842c8=a651_0x4c6f;return db[_0xf842c8('0xd')][_0xf842c8('0x1d')]({'raw':_0x529722[_0xf842c8('0x26')]?_0x529722[_0xf842c8('0x26')]['raw']===undefined?!![]:![]:!![],'where':_0x529722[_0xf842c8('0x26')]?_0x529722['options']['where']||null:null,'attributes':_0x529722['options']?_0x529722['options'][_0xf842c8('0xb')]||null:null,'limit':_0x529722[_0xf842c8('0x26')]?_0x529722[_0xf842c8('0x26')][_0xf842c8('0x9')]||null:null,'include':_0x529722[_0xf842c8('0x26')]?_0x529722[_0xf842c8('0x26')]['include']?_['map'](_0x529722[_0xf842c8('0x26')][_0xf842c8('0x46')],function(_0x417ec4){const _0xa5d9f6=_0xf842c8;return{'model':db[_0x417ec4[_0xa5d9f6('0x22')]],'as':_0x417ec4['as'],'attributes':_0x417ec4[_0xa5d9f6('0xb')],'include':_0x417ec4[_0xa5d9f6('0x46')]?_[_0xa5d9f6('0x4b')](_0x417ec4[_0xa5d9f6('0x46')],function(_0x227220){const _0x150883=_0xa5d9f6;return{'model':db[_0x227220[_0x150883('0x22')]],'as':_0x227220['as'],'attributes':_0x227220[_0x150883('0xb')],'include':_0x227220[_0x150883('0x46')]?_[_0x150883('0x4b')](_0x227220[_0x150883('0x46')],function(_0x532c30){const _0x81a3c5=_0x150883;return{'model':db[_0x532c30[_0x81a3c5('0x22')]],'as':_0x532c30['as'],'attributes':_0x532c30[_0x81a3c5('0xb')]};}):[]};}):[]};}):[]:[]})[_0xf842c8('0x2')](function(_0x523f3f){const _0x27e1a4=_0xf842c8;logger['info'](_0x27e1a4('0x11'),_0x529722),logger['debug'](_0x27e1a4('0x11'),_0x529722,JSON[_0x27e1a4('0x13')](_0x523f3f)),_0x2f2ae7(_0x523f3f);})[_0xf842c8('0x34')](function(_0x1a0c6e){const _0xa4b546=_0xf842c8;logger[_0xa4b546('0x0')](_0xa4b546('0x11'),_0x1a0c6e[_0xa4b546('0x4')],_0x529722),_0x291d8f(_0x3951bf[_0xa4b546('0x0')](0x1f4,_0x1a0c6e[_0xa4b546('0x4')]));});});},exports[_0x436deb('0x2e')]=function(_0x2adab6){const _0x1643fe=this;return new Promise(function(_0x2ee8f3,_0x3ed150){const _0x4f58ed=a651_0x4c6f;return db[_0x4f58ed('0xd')][_0x4f58ed('0x39')]({'raw':_0x2adab6[_0x4f58ed('0x26')]?_0x2adab6['options']['raw']===undefined?!![]:![]:!![],'where':_0x2adab6[_0x4f58ed('0x26')]?_0x2adab6[_0x4f58ed('0x26')]['where']||null:null,'attributes':_0x2adab6['options']?_0x2adab6[_0x4f58ed('0x26')][_0x4f58ed('0xb')]||null:null,'include':_0x2adab6['options']?_0x2adab6['options'][_0x4f58ed('0x46')]?_[_0x4f58ed('0x4b')](_0x2adab6['options'][_0x4f58ed('0x46')],function(_0x55baa4){const _0x569281=_0x4f58ed;return{'model':db[_0x55baa4['model']],'as':_0x55baa4['as'],'attributes':_0x55baa4[_0x569281('0xb')],'include':_0x55baa4[_0x569281('0x46')]?_[_0x569281('0x4b')](_0x55baa4[_0x569281('0x46')],function(_0x3b3eb7){const _0x432844=_0x569281;return{'model':db[_0x3b3eb7[_0x432844('0x22')]],'as':_0x3b3eb7['as'],'attributes':_0x3b3eb7[_0x432844('0xb')],'include':_0x3b3eb7[_0x432844('0x46')]?_[_0x432844('0x4b')](_0x3b3eb7[_0x432844('0x46')],function(_0x5a0fc6){const _0x36f8c5=_0x432844;return{'model':db[_0x5a0fc6['model']],'as':_0x5a0fc6['as'],'attributes':_0x5a0fc6[_0x36f8c5('0xb')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xd4125d){const _0x32186f=_0x4f58ed;logger['info'](_0x32186f('0x2e'),_0x2adab6),logger[_0x32186f('0x1')](_0x32186f('0x2e'),_0x2adab6,JSON['stringify'](_0xd4125d)),_0x2ee8f3(_0xd4125d);})['catch'](function(_0xee9116){const _0x10976a=_0x4f58ed;logger['error'](_0x10976a('0x2e'),_0xee9116[_0x10976a('0x4')],_0x2adab6),_0x3ed150(_0x1643fe[_0x10976a('0x0')](0x1f4,_0xee9116['message']));});});},exports[_0x436deb('0x1c')]=function(_0x37d9c7){const _0x5712cc=this;return new Promise(function(_0x40956a,_0x11e74a){const _0x52645c=a651_0x4c6f;let _0x400e7b;return db[_0x52645c('0xd')]['findOne']({'where':_0x37d9c7[_0x52645c('0x26')][_0x52645c('0x1b')]||{},'attributes':['id',_0x52645c('0x38'),'role',_0x52645c('0x25'),_0x52645c('0x32')]})[_0x52645c('0x2')](function(_0x55a047){const _0x1429d2=_0x52645c;if(_0x55a047)return _0x400e7b=_0x55a047,db[_0x1429d2('0x4d')][_0x1429d2('0xe')]({'paused':0x1},{'where':{'UserId':_0x400e7b['id']},'individualHooks':!![]});})[_0x52645c('0x2')](function(){const _0x51d4b8=_0x52645c;if(_0x400e7b)return db[_0x51d4b8('0x24')][_0x51d4b8('0x1d')]({'where':{'membername':_0x400e7b[_0x51d4b8('0x38')],'type':_0x51d4b8('0x15'),'exitAt':null}});})[_0x52645c('0x2')](function(_0x5f011f){const _0x1cdefd=_0x52645c;if(_0x400e7b){if(_0x5f011f&&_0x5f011f[_0x1cdefd('0x2d')]){const _0x3a1b25=moment()[_0x1cdefd('0x1e')](_0x1cdefd('0x48'));for(let _0x616c0f=0x0,_0x101f26=_0x5f011f[_0x1cdefd('0x2d')];_0x616c0f<_0x101f26;_0x616c0f++){_0x5f011f[_0x616c0f]['update']({'exitAt':_0x3a1b25});}}}})[_0x52645c('0x2')](function(){const _0x54916b=_0x52645c;if(_0x400e7b){const _0xc094d8=[],_0x2f0029=utils[_0x54916b('0x49')]();return _0x2f0029['forEach'](function(_0x3d4892){const _0x2bfbb0=_0x54916b;_0xc094d8[_0x2bfbb0('0x2c')]({'channel':_0x3d4892,'membername':_0x400e7b[_0x2bfbb0('0x38')],'interface':_['isNil'](_0x400e7b['interface'])?util[_0x2bfbb0('0x1e')](_0x2bfbb0('0xf'),_0x400e7b[_0x2bfbb0('0x38')]):_0x400e7b[_0x2bfbb0('0x32')],'type':_0x2bfbb0('0x15'),'enterAt':moment()[_0x2bfbb0('0x1e')](_0x2bfbb0('0x48')),'data1':_0x37d9c7['body'][_0x2bfbb0('0x12')]||_0x2bfbb0('0x5'),'role':_0x400e7b[_0x2bfbb0('0x2b')],'internal':_0x400e7b['internal'],'uniqueid':_0x37d9c7[_0x2bfbb0('0x6')]['uniqueid']||null});}),db[_0x54916b('0x24')][_0x54916b('0x2f')](_0xc094d8,{'individualHooks':!![]});}})[_0x52645c('0x2')](function(){const _0x42573c=_0x52645c;if(_0x400e7b)return _0x400e7b[_0x42573c('0xe')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'pauseType':_0x37d9c7[_0x42573c('0x6')][_0x42573c('0x12')]||_0x42573c('0x5'),'lastPauseAt':moment()[_0x42573c('0x1e')](_0x42573c('0x48'))});})['then'](function(_0x1a4e52){_0x40956a(_0x1a4e52);})['catch'](function(_0x15bb51){const _0x4d7d23=_0x52645c;_0x11e74a(_0x5712cc[_0x4d7d23('0x0')](0x1f4,_0x15bb51['message']));});});},exports['UnpauseUser']=function(_0x1b2ad1){const _0x5948d5=this;return new Promise(function(_0x3a9291,_0x4939d5){const _0x3b0c7f=a651_0x4c6f;let _0x315c11;return db[_0x3b0c7f('0xd')][_0x3b0c7f('0x39')]({'where':_0x1b2ad1[_0x3b0c7f('0x26')][_0x3b0c7f('0x1b')]||{},'attributes':['id',_0x3b0c7f('0x38')]})[_0x3b0c7f('0x2')](function(_0x42c4aa){const _0x2abd7a=_0x3b0c7f;if(_0x42c4aa){_0x315c11=_0x42c4aa;if(_0x1b2ad1['body']['channel']&&!utils['isValidChannel'](_0x1b2ad1[_0x2abd7a('0x6')]['channel']))throw new Error(_0x2abd7a('0x36'));switch(_0x1b2ad1[_0x2abd7a('0x6')][_0x2abd7a('0x33')]){case _0x2abd7a('0xa'):return db[_0x2abd7a('0x4d')][_0x2abd7a('0xe')]({'paused':0x0},{'where':{'UserId':_0x315c11['id']}})[_0x2abd7a('0x2')](function(){const _0x5b7b54=_0x2abd7a;return db[_0x5b7b54('0x24')][_0x5b7b54('0x39')]({'where':{'channel':_0x1b2ad1[_0x5b7b54('0x6')][_0x5b7b54('0x33')],'membername':_0x315c11[_0x5b7b54('0x38')],'type':'PAUSE','exitAt':null}});})[_0x2abd7a('0x2')](function(_0x30e37a){const _0x223c7b=_0x2abd7a;if(_0x30e37a)return _0x30e37a[_0x223c7b('0xe')]({'exitAt':moment()[_0x223c7b('0x1e')](_0x223c7b('0x48')),'data2':_0x223c7b('0x7')},{'individualHooks':!![]});return null;})[_0x2abd7a('0x2')](function(){return _0x315c11['update']({'voicePause':![]});});case _0x2abd7a('0x3a'):case _0x2abd7a('0x30'):case _0x2abd7a('0xc'):case _0x2abd7a('0x28'):case _0x2abd7a('0x17'):return db[_0x2abd7a('0x24')][_0x2abd7a('0x39')]({'where':{'channel':_0x1b2ad1['body'][_0x2abd7a('0x33')],'membername':_0x315c11['name'],'type':_0x2abd7a('0x15'),'exitAt':null}})[_0x2abd7a('0x2')](function(_0x14c6ca){const _0x247d76=_0x2abd7a;return _0x14c6ca[_0x247d76('0xe')]({'exitAt':moment()[_0x247d76('0x1e')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':'system'},{'individualHooks':!![]});})[_0x2abd7a('0x2')](function(){const _0x48ee84=_0x2abd7a,_0x2f1a79={};return _[_0x48ee84('0x4a')](_0x2f1a79,util[_0x48ee84('0x1e')](_0x48ee84('0x18'),_0x1b2ad1['body'][_0x48ee84('0x33')],_0x48ee84('0x4c')),![]),_0x315c11[_0x48ee84('0xe')](_0x2f1a79);});default:return db[_0x2abd7a('0x4d')][_0x2abd7a('0xe')]({'paused':0x0},{'where':{'UserId':_0x315c11['id']}})[_0x2abd7a('0x2')](function(){const _0x154af6=_0x2abd7a;return db[_0x154af6('0x24')][_0x154af6('0x1d')]({'where':{'membername':_0x315c11[_0x154af6('0x38')],'type':_0x154af6('0x15'),'exitAt':null}});})[_0x2abd7a('0x2')](function(_0x15ea54){const _0x42d99a=_0x2abd7a,_0x2f2b22=[];return _0x15ea54[_0x42d99a('0x14')](function(_0x4d8c21){const _0x22e043=_0x42d99a;_0x2f2b22[_0x22e043('0x2c')](_0x4d8c21['update']({'exitAt':moment()[_0x22e043('0x1e')](_0x22e043('0x48')),'data2':_0x22e043('0x7')}));}),Promise[_0x42d99a('0x1a')](_0x2f2b22);})[_0x2abd7a('0x2')](function(){const _0x23455b=_0x2abd7a;return _0x315c11[_0x23455b('0xe')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});});}}})[_0x3b0c7f('0x2')](function(_0x3ab600){_0x3a9291(_0x3ab600);})[_0x3b0c7f('0x34')](function(_0x4fa7d9){const _0x1a816a=_0x3b0c7f;_0x4939d5(_0x5948d5[_0x1a816a('0x0')](0x1f4,_0x4fa7d9[_0x1a816a('0x4')]));});});},exports['LogoutUser']=function(_0x3a2d39){const _0xbf6757=this;return new Promise(function(_0xed6b24,_0x50eb84){const _0x56514b=a651_0x4c6f;let _0x247cdf;return db[_0x56514b('0xd')][_0x56514b('0x39')]({'where':_0x3a2d39[_0x56514b('0x26')][_0x56514b('0x1b')]||{},'attributes':['id','name']})['then'](function(_0x1139a4){const _0x12a437=_0x56514b;if(_0x1139a4)return _0x247cdf=_0x1139a4,db['UserVoiceQueueRt'][_0x12a437('0x35')]({'where':{'membername':_0x247cdf['name']},'individualHooks':!![]});})[_0x56514b('0x2')](function(){const _0x160752=_0x56514b;if(_0x247cdf)return db[_0x160752('0x24')][_0x160752('0x1d')]({'where':{'membername':_0x247cdf[_0x160752('0x38')],'exitAt':null}});})[_0x56514b('0x2')](function(_0x5004c1){const _0x40ee19=_0x56514b;if(_0x247cdf){if(_0x5004c1&&_0x5004c1[_0x40ee19('0x2d')]){const _0x41180a=[];return _0x5004c1[_0x40ee19('0x14')](function(_0x50ce66){const _0x760af9=_0x40ee19;_0x41180a[_0x760af9('0x2c')](_0x50ce66[_0x760af9('0xe')]({'exitAt':moment()[_0x760af9('0x1e')](_0x760af9('0x48'))}));}),Promise[_0x40ee19('0x1a')](_0x41180a);}}})[_0x56514b('0x2')](function(){const _0x4ed622=_0x56514b;if(_0x247cdf)return _0x247cdf[_0x4ed622('0xe')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});})['then'](function(_0x5dd0a9){_0xed6b24(_0x5dd0a9);})['catch'](function(_0x20cb38){const _0x1462bf=_0x56514b;_0x50eb84(_0xbf6757[_0x1462bf('0x0')](0x1f4,_0x20cb38[_0x1462bf('0x4')]));});});},exports[_0x436deb('0x40')]=function(_0x1dfd49){const _0x56052c=this;return new Promise(function(_0x48b5fd,_0x4c76f7){const _0x416250=a651_0x4c6f;let _0x32ee74,_0x15828f,_0x37663e,_0x188637;return db['User'][_0x416250('0x39')]({'where':_0x1dfd49['options']['where']||{},'attributes':['id',_0x416250('0x38'),'role',_0x416250('0x45'),_0x416250('0x2a'),_0x416250('0x25'),_0x416250('0x31'),_0x416250('0x32')]})[_0x416250('0x2')](function(_0x246e69){const _0x4510f0=_0x416250;if(_0x246e69)return _0x32ee74=_0x246e69,_0x188637=_0x1dfd49[_0x4510f0('0x6')]['interface']?_0x1dfd49[_0x4510f0('0x6')]['interface']:util[_0x4510f0('0x1e')](_0x4510f0('0xf'),_0x32ee74[_0x4510f0('0x38')]),db[_0x4510f0('0xd')][_0x4510f0('0x3c')]({'where':{'role':_0x4510f0('0x3b'),'online':!![],'id':{[Op['ne']]:_0x32ee74['id']}}});})[_0x416250('0x2')](function(_0x32fd8e){const _0x2bbe7f=_0x416250;if(_0x32fd8e)return _0x37663e=_0x32fd8e,require(_0x2bbe7f('0x16'))[_0x2bbe7f('0x10')]();})[_0x416250('0x2')](function(_0x5f1f39){const _0x5d70d9=_0x416250;if(_0x5f1f39&&_0x5f1f39[_0x5d70d9('0x3')]&&_0x37663e>=_0x5f1f39[_0x5d70d9('0x3')])throw new Error('Maximum\x20login\x20has\x20been\x20reached');})[_0x416250('0x2')](function(){const _0x317610=_0x416250;if(_0x32ee74)return db[_0x317610('0x4d')]['destroy']({'where':{'membername':_0x32ee74[_0x317610('0x38')]},'individualHooks':!![]});})[_0x416250('0x2')](function(){const _0x1347c5=_0x416250;if(_0x32ee74)return _0x32ee74[_0x1347c5('0x3d')]({'raw':!![]});})[_0x416250('0x2')](function(_0xc2bd8c){const _0x3605e4=_0x416250;if(_0x32ee74){if(_0xc2bd8c){const _0x212d35=[];_0x15828f=_0xc2bd8c;if(_0x15828f['length']){for(let _0x230d40=0x0;_0x230d40<_0x15828f[_0x3605e4('0x2d')];_0x230d40++){_0x212d35[_0x3605e4('0x2c')](db[_0x3605e4('0x4d')][_0x3605e4('0x19')]({'membername':_0x32ee74['name'],'UserId':_0x32ee74['id'],'queue_name':_0x15828f[_0x230d40][_0x3605e4('0x38')],'VoiceQueueId':_0x15828f[_0x230d40]['id'],'interface':_0x188637,'paused':_0x32ee74[_0x3605e4('0x31')]||![],'penalty':_0x15828f[_0x230d40][_0x3605e4('0x23')]||0x0}));}return Promise[_0x3605e4('0x1a')](_0x212d35);}}}})[_0x416250('0x2')](function(){const _0x34d2e6=_0x416250;if(_0x32ee74)return db['MemberReport'][_0x34d2e6('0x1d')]({'where':{'membername':_0x32ee74[_0x34d2e6('0x38')],'exitAt':null}});})[_0x416250('0x2')](function(_0x947c15){const _0x2d2f65=_0x416250;if(_0x32ee74){if(_0x947c15&&_0x947c15[_0x2d2f65('0x2d')]){const _0x5c42c5=[];return _0x947c15[_0x2d2f65('0x14')](function(_0x4ba4f3){const _0x4ae8fc=_0x2d2f65;_0x5c42c5[_0x4ae8fc('0x2c')](_0x4ba4f3[_0x4ae8fc('0xe')]({'exitAt':moment()[_0x4ae8fc('0x1e')](_0x4ae8fc('0x48'))}));}),Promise[_0x2d2f65('0x1a')](_0x5c42c5);}}})['then'](function(){const _0x519721=_0x416250;if(_0x32ee74){const _0x2a4cb9=[],_0x2f29eb=[],_0x6804d=utils[_0x519721('0x49')](),_0x26d8fc={'membername':_0x32ee74[_0x519721('0x38')],'interface':_0x188637,'enterAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x32ee74[_0x519721('0x2b')],'internal':_0x32ee74[_0x519721('0x25')]};return _0x6804d[_0x519721('0x14')](function(_0x4043d9){const _0x6fcf3f=_0x519721;_0x2a4cb9['push'](_['merge']({'channel':_0x4043d9,'type':_0x6fcf3f('0x43'),'data1':_0x6fcf3f('0x37'),'data2':_0x188637},_0x26d8fc)),_0x32ee74[_0x6fcf3f('0x31')]&&_0x2f29eb[_0x6fcf3f('0x2c')](_[_0x6fcf3f('0x42')]({'channel':_0x4043d9,'type':_0x6fcf3f('0x15'),'data1':_0x6fcf3f('0x8')},_0x26d8fc));}),db['MemberReport'][_0x519721('0x2f')](_0x2a4cb9['concat'](_0x2f29eb),{'individualHooks':!![]});}})['then'](function(){const _0x169da1=_0x416250;if(_0x32ee74)return _0x32ee74['update']({'online':!![],'lastLoginAt':moment()[_0x169da1('0x1e')](_0x169da1('0x48')),'voicePause':_0x32ee74[_0x169da1('0x31')]||![],'mailPause':_0x32ee74[_0x169da1('0x31')]||![],'chatPause':_0x32ee74[_0x169da1('0x31')]||![],'faxPause':_0x32ee74['loginInPause']||![],'smsPause':_0x32ee74[_0x169da1('0x31')]||![],'openchannelPause':_0x32ee74[_0x169da1('0x31')]||![],'pauseType':_0x32ee74[_0x169da1('0x31')]?_0x169da1('0x8'):null,'lastPauseAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'interface':_0x188637});})[_0x416250('0x2')](function(_0x4e9305){_0x48b5fd(_0x4e9305);})[_0x416250('0x34')](function(_0x17a90d){const _0x3755a5=_0x416250;_0x4c76f7(_0x56052c['error'](0x1f4,_0x17a90d[_0x3755a5('0x4')]));});});};
\ No newline at end of file