Built motion from commit 973e3e332e1c8e2f84c4b0cd2e5af794131724f5. Version 3.0.0...
[motion-next.git] / server / api / user / user.rpc.js
index 59317cb..e1fee39 100644 (file)
@@ -1 +1 @@
-const a651_0x1cf8=['debug','GetUser','sequelize','%s%s','system','role','../../config/license/util','catch','channel','getChannels','DEFAULT\x20PAUSE','merge','error','isNil','../../config/utils','interface','Unknown\x20channel','UserVoiceQueueRt','uniqueid','SIP/%s','isValidChannel','../../mysqldb','ShowUser','lodash','all','sms','set','name','YYYY-MM-DD\x20HH:mm:ss','voice','update','length','../../rediscache','format','util','chat','type','LOGIN','loginInPause','include','push','LogoutUser','UserVoiceQueue.penalty','count','limit','where','forEach','options','PAUSE','map','then','body','MemberReport','mail','getLicense','register','mobile','findOne','LoginUser','message','internal','concat','agents','findAll','User','destroy','attributes','stringify','model','LOGININPAUSE','moment','upsert','info'];(function(_0x27a0eb,_0x1cf82b){const _0x4b8377=function(_0x189ad3){while(--_0x189ad3){_0x27a0eb['push'](_0x27a0eb['shift']());}};_0x4b8377(++_0x1cf82b);}(a651_0x1cf8,0x169));const a651_0x4b83=function(_0x27a0eb,_0x1cf82b){_0x27a0eb=_0x27a0eb-0x0;let _0x4b8377=a651_0x1cf8[_0x27a0eb];return _0x4b8377;};const _0x30f56c=a651_0x4b83;'use strict';const _=require(_0x30f56c('0x1b')),util=require(_0x30f56c('0x26')),db=require(_0x30f56c('0x19'))['db'],logger=require('../../config/logger')('rpc'),moment=require(_0x30f56c('0x1')),utils=require(_0x30f56c('0x12')),{getSocket}=require(_0x30f56c('0x24')),socket=getSocket(),sequelize=require(_0x30f56c('0x6')),{Op}=sequelize;require('./user.socket')[_0x30f56c('0x3b')](socket),exports[_0x30f56c('0x5')]=function(_0x189ad3){const _0xe831dc=this;return new Promise(function(_0x641e53,_0x879149){const _0x484a01=a651_0x4b83;return db[_0x484a01('0x44')]['findAll']({'raw':_0x189ad3[_0x484a01('0x33')]?_0x189ad3[_0x484a01('0x33')]['raw']===undefined?!![]:![]:!![],'where':_0x189ad3[_0x484a01('0x33')]?_0x189ad3[_0x484a01('0x33')][_0x484a01('0x31')]||null:null,'attributes':_0x189ad3[_0x484a01('0x33')]?_0x189ad3['options'][_0x484a01('0x46')]||null:null,'limit':_0x189ad3[_0x484a01('0x33')]?_0x189ad3[_0x484a01('0x33')][_0x484a01('0x30')]||null:null,'include':_0x189ad3[_0x484a01('0x33')]?_0x189ad3[_0x484a01('0x33')]['include']?_[_0x484a01('0x35')](_0x189ad3[_0x484a01('0x33')][_0x484a01('0x2b')],function(_0x18e1e3){const _0x5a9020=_0x484a01;return{'model':db[_0x18e1e3[_0x5a9020('0x48')]],'as':_0x18e1e3['as'],'attributes':_0x18e1e3[_0x5a9020('0x46')],'include':_0x18e1e3['include']?_['map'](_0x18e1e3[_0x5a9020('0x2b')],function(_0x635ea6){const _0x14340e=_0x5a9020;return{'model':db[_0x635ea6[_0x14340e('0x48')]],'as':_0x635ea6['as'],'attributes':_0x635ea6[_0x14340e('0x46')],'include':_0x635ea6[_0x14340e('0x2b')]?_[_0x14340e('0x35')](_0x635ea6[_0x14340e('0x2b')],function(_0x5a9f60){const _0x1ada9d=_0x14340e;return{'model':db[_0x5a9f60[_0x1ada9d('0x48')]],'as':_0x5a9f60['as'],'attributes':_0x5a9f60[_0x1ada9d('0x46')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x210779){const _0x585435=_0x484a01;logger[_0x585435('0x3')](_0x585435('0x5'),_0x189ad3),logger['debug']('GetUser',_0x189ad3,JSON[_0x585435('0x47')](_0x210779)),_0x641e53(_0x210779);})['catch'](function(_0x23c99f){const _0x3ddd66=_0x484a01;logger[_0x3ddd66('0x10')](_0x3ddd66('0x5'),_0x23c99f[_0x3ddd66('0x3f')],_0x189ad3),_0x879149(_0xe831dc[_0x3ddd66('0x10')](0x1f4,_0x23c99f[_0x3ddd66('0x3f')]));});});},exports[_0x30f56c('0x1a')]=function(_0x472f41){const _0xa0485f=this;return new Promise(function(_0x167b4,_0xc8ae){const _0x204831=a651_0x4b83;return db[_0x204831('0x44')]['findOne']({'raw':_0x472f41['options']?_0x472f41[_0x204831('0x33')]['raw']===undefined?!![]:![]:!![],'where':_0x472f41['options']?_0x472f41['options'][_0x204831('0x31')]||null:null,'attributes':_0x472f41[_0x204831('0x33')]?_0x472f41[_0x204831('0x33')][_0x204831('0x46')]||null:null,'include':_0x472f41[_0x204831('0x33')]?_0x472f41[_0x204831('0x33')][_0x204831('0x2b')]?_[_0x204831('0x35')](_0x472f41[_0x204831('0x33')][_0x204831('0x2b')],function(_0x4a35e9){const _0x43f9c8=_0x204831;return{'model':db[_0x4a35e9[_0x43f9c8('0x48')]],'as':_0x4a35e9['as'],'attributes':_0x4a35e9['attributes'],'include':_0x4a35e9[_0x43f9c8('0x2b')]?_[_0x43f9c8('0x35')](_0x4a35e9[_0x43f9c8('0x2b')],function(_0x2d3a10){const _0x12a72b=_0x43f9c8;return{'model':db[_0x2d3a10[_0x12a72b('0x48')]],'as':_0x2d3a10['as'],'attributes':_0x2d3a10[_0x12a72b('0x46')],'include':_0x2d3a10[_0x12a72b('0x2b')]?_['map'](_0x2d3a10[_0x12a72b('0x2b')],function(_0x3d9e85){return{'model':db[_0x3d9e85['model']],'as':_0x3d9e85['as'],'attributes':_0x3d9e85['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x38c470){const _0x3363b9=_0x204831;logger[_0x3363b9('0x3')](_0x3363b9('0x1a'),_0x472f41),logger[_0x3363b9('0x4')](_0x3363b9('0x1a'),_0x472f41,JSON[_0x3363b9('0x47')](_0x38c470)),_0x167b4(_0x38c470);})[_0x204831('0xb')](function(_0x1c0eb5){const _0x1ab0ea=_0x204831;logger[_0x1ab0ea('0x10')]('ShowUser',_0x1c0eb5['message'],_0x472f41),_0xc8ae(_0xa0485f[_0x1ab0ea('0x10')](0x1f4,_0x1c0eb5['message']));});});},exports['PauseUser']=function(_0xc78d69){const _0x403a0d=this;return new Promise(function(_0x1db044,_0x201fef){const _0x3f5bc9=a651_0x4b83;let _0x73f41e;return db[_0x3f5bc9('0x44')]['findOne']({'where':_0xc78d69[_0x3f5bc9('0x33')][_0x3f5bc9('0x31')]||{},'attributes':['id',_0x3f5bc9('0x1f'),_0x3f5bc9('0x9'),'internal','interface']})[_0x3f5bc9('0x36')](function(_0x45d4f3){const _0x38887e=_0x3f5bc9;if(_0x45d4f3)return _0x73f41e=_0x45d4f3,db[_0x38887e('0x15')][_0x38887e('0x22')]({'paused':0x1},{'where':{'UserId':_0x73f41e['id']},'individualHooks':!![]});})[_0x3f5bc9('0x36')](function(){const _0x4c9d19=_0x3f5bc9;if(_0x73f41e)return db[_0x4c9d19('0x38')][_0x4c9d19('0x43')]({'where':{'membername':_0x73f41e[_0x4c9d19('0x1f')],'type':'PAUSE','exitAt':null}});})['then'](function(_0x139285){const _0x5381dd=_0x3f5bc9;if(_0x73f41e){if(_0x139285&&_0x139285[_0x5381dd('0x23')]){const _0x194452=moment()[_0x5381dd('0x25')](_0x5381dd('0x20'));for(let _0x161197=0x0,_0x1230bd=_0x139285[_0x5381dd('0x23')];_0x161197<_0x1230bd;_0x161197++){_0x139285[_0x161197][_0x5381dd('0x22')]({'exitAt':_0x194452});}}}})[_0x3f5bc9('0x36')](function(){const _0x240dd4=_0x3f5bc9;if(_0x73f41e){const _0x3eeb26=[],_0x5283df=utils[_0x240dd4('0xd')]();return _0x5283df['forEach'](function(_0x264da6){const _0x2e00b6=_0x240dd4;_0x3eeb26[_0x2e00b6('0x2c')]({'channel':_0x264da6,'membername':_0x73f41e['name'],'interface':_[_0x2e00b6('0x11')](_0x73f41e[_0x2e00b6('0x13')])?util[_0x2e00b6('0x25')](_0x2e00b6('0x17'),_0x73f41e[_0x2e00b6('0x1f')]):_0x73f41e['interface'],'type':_0x2e00b6('0x34'),'enterAt':moment()['format'](_0x2e00b6('0x20')),'data1':_0xc78d69[_0x2e00b6('0x37')]['type']||'DEFAULT\x20PAUSE','role':_0x73f41e['role'],'internal':_0x73f41e[_0x2e00b6('0x40')],'uniqueid':_0xc78d69[_0x2e00b6('0x37')][_0x2e00b6('0x16')]||null});}),db[_0x240dd4('0x38')]['bulkCreate'](_0x3eeb26,{'individualHooks':!![]});}})['then'](function(){const _0x49c0e4=_0x3f5bc9;if(_0x73f41e)return _0x73f41e[_0x49c0e4('0x22')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'pauseType':_0xc78d69[_0x49c0e4('0x37')][_0x49c0e4('0x28')]||_0x49c0e4('0xe'),'lastPauseAt':moment()[_0x49c0e4('0x25')](_0x49c0e4('0x20'))});})['then'](function(_0x420e44){_0x1db044(_0x420e44);})[_0x3f5bc9('0xb')](function(_0x58092e){const _0x1980f1=_0x3f5bc9;_0x201fef(_0x403a0d[_0x1980f1('0x10')](0x1f4,_0x58092e[_0x1980f1('0x3f')]));});});},exports['UnpauseUser']=function(_0x2a3438){const _0x573c62=this;return new Promise(function(_0x36f558,_0x507dfe){const _0x29ac93=a651_0x4b83;let _0x1f4dc0;return db[_0x29ac93('0x44')][_0x29ac93('0x3d')]({'where':_0x2a3438[_0x29ac93('0x33')][_0x29ac93('0x31')]||{},'attributes':['id',_0x29ac93('0x1f')]})['then'](function(_0x3d23f0){const _0xf86737=_0x29ac93;if(_0x3d23f0){_0x1f4dc0=_0x3d23f0;if(_0x2a3438[_0xf86737('0x37')]['channel']&&!utils[_0xf86737('0x18')](_0x2a3438['body'][_0xf86737('0xc')]))throw new Error(_0xf86737('0x14'));switch(_0x2a3438[_0xf86737('0x37')][_0xf86737('0xc')]){case _0xf86737('0x21'):return db['UserVoiceQueueRt'][_0xf86737('0x22')]({'paused':0x0},{'where':{'UserId':_0x1f4dc0['id']}})[_0xf86737('0x36')](function(){const _0xa8653d=_0xf86737;return db[_0xa8653d('0x38')]['findOne']({'where':{'channel':_0x2a3438[_0xa8653d('0x37')]['channel'],'membername':_0x1f4dc0[_0xa8653d('0x1f')],'type':_0xa8653d('0x34'),'exitAt':null}});})[_0xf86737('0x36')](function(_0x13853f){const _0x4ea209=_0xf86737;if(_0x13853f)return _0x13853f[_0x4ea209('0x22')]({'exitAt':moment()[_0x4ea209('0x25')](_0x4ea209('0x20')),'data2':_0x4ea209('0x8')},{'individualHooks':!![]});return null;})[_0xf86737('0x36')](function(){const _0x1cd9fd=_0xf86737;return _0x1f4dc0[_0x1cd9fd('0x22')]({'voicePause':![]});});case _0xf86737('0x39'):case _0xf86737('0x27'):case'fax':case _0xf86737('0x1d'):case'openchannel':return db[_0xf86737('0x38')][_0xf86737('0x3d')]({'where':{'channel':_0x2a3438[_0xf86737('0x37')]['channel'],'membername':_0x1f4dc0[_0xf86737('0x1f')],'type':_0xf86737('0x34'),'exitAt':null}})[_0xf86737('0x36')](function(_0x5d493c){const _0x3e356a=_0xf86737;return _0x5d493c[_0x3e356a('0x22')]({'exitAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'data2':'system'},{'individualHooks':!![]});})['then'](function(){const _0x50db9d=_0xf86737,_0x84b9df={};return _[_0x50db9d('0x1e')](_0x84b9df,util['format'](_0x50db9d('0x7'),_0x2a3438[_0x50db9d('0x37')]['channel'],'Pause'),![]),_0x1f4dc0[_0x50db9d('0x22')](_0x84b9df);});default:return db[_0xf86737('0x15')][_0xf86737('0x22')]({'paused':0x0},{'where':{'UserId':_0x1f4dc0['id']}})['then'](function(){const _0xf688e7=_0xf86737;return db[_0xf688e7('0x38')][_0xf688e7('0x43')]({'where':{'membername':_0x1f4dc0['name'],'type':_0xf688e7('0x34'),'exitAt':null}});})['then'](function(_0x219277){const _0x2409fc=_0xf86737,_0x1f0e50=[];return _0x219277[_0x2409fc('0x32')](function(_0x58ae74){const _0x44b95a=_0x2409fc;_0x1f0e50[_0x44b95a('0x2c')](_0x58ae74[_0x44b95a('0x22')]({'exitAt':moment()[_0x44b95a('0x25')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x44b95a('0x8')}));}),Promise[_0x2409fc('0x1c')](_0x1f0e50);})[_0xf86737('0x36')](function(){return _0x1f4dc0['update']({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});});}}})[_0x29ac93('0x36')](function(_0x66042){_0x36f558(_0x66042);})[_0x29ac93('0xb')](function(_0xd5c371){const _0x3e1ecd=_0x29ac93;_0x507dfe(_0x573c62[_0x3e1ecd('0x10')](0x1f4,_0xd5c371['message']));});});},exports[_0x30f56c('0x2d')]=function(_0x1f53c3){const _0x43dbfc=this;return new Promise(function(_0x233415,_0x4940f7){const _0x152526=a651_0x4b83;let _0x4985ef;return db[_0x152526('0x44')][_0x152526('0x3d')]({'where':_0x1f53c3[_0x152526('0x33')]['where']||{},'attributes':['id',_0x152526('0x1f')]})[_0x152526('0x36')](function(_0x4395dc){const _0xc9d935=_0x152526;if(_0x4395dc)return _0x4985ef=_0x4395dc,db[_0xc9d935('0x15')][_0xc9d935('0x45')]({'where':{'membername':_0x4985ef[_0xc9d935('0x1f')]},'individualHooks':!![]});})[_0x152526('0x36')](function(){const _0x1a200e=_0x152526;if(_0x4985ef)return db[_0x1a200e('0x38')]['findAll']({'where':{'membername':_0x4985ef['name'],'exitAt':null}});})['then'](function(_0x24cdf2){const _0x2031af=_0x152526;if(_0x4985ef){if(_0x24cdf2&&_0x24cdf2[_0x2031af('0x23')]){const _0x5e7489=[];return _0x24cdf2[_0x2031af('0x32')](function(_0x11b6f){const _0x3ee6f3=_0x2031af;_0x5e7489[_0x3ee6f3('0x2c')](_0x11b6f['update']({'exitAt':moment()['format'](_0x3ee6f3('0x20'))}));}),Promise[_0x2031af('0x1c')](_0x5e7489);}}})[_0x152526('0x36')](function(){const _0x3b080d=_0x152526;if(_0x4985ef)return _0x4985ef[_0x3b080d('0x22')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});})['then'](function(_0x26e417){_0x233415(_0x26e417);})[_0x152526('0xb')](function(_0x4b7e53){const _0x1081e7=_0x152526;_0x4940f7(_0x43dbfc[_0x1081e7('0x10')](0x1f4,_0x4b7e53[_0x1081e7('0x3f')]));});});},exports[_0x30f56c('0x3e')]=function(_0x3e0ecd){const _0x35acdb=this;return new Promise(function(_0x26bcfa,_0x5cd645){const _0x5dcab4=a651_0x4b83;let _0x2835b6,_0x1f9aa2,_0x451f70,_0x1a066b;return db[_0x5dcab4('0x44')][_0x5dcab4('0x3d')]({'where':_0x3e0ecd[_0x5dcab4('0x33')][_0x5dcab4('0x31')]||{},'attributes':['id','name',_0x5dcab4('0x9'),_0x5dcab4('0x3c'),'phone',_0x5dcab4('0x40'),_0x5dcab4('0x2a'),_0x5dcab4('0x13')]})['then'](function(_0x23565b){const _0x1cf4ef=_0x5dcab4;if(_0x23565b)return _0x2835b6=_0x23565b,_0x1a066b=_0x3e0ecd[_0x1cf4ef('0x37')][_0x1cf4ef('0x13')]?_0x3e0ecd[_0x1cf4ef('0x37')]['interface']:util[_0x1cf4ef('0x25')](_0x1cf4ef('0x17'),_0x2835b6[_0x1cf4ef('0x1f')]),db[_0x1cf4ef('0x44')][_0x1cf4ef('0x2f')]({'where':{'role':'agent','online':!![],'id':{[Op['ne']]:_0x2835b6['id']}}});})[_0x5dcab4('0x36')](function(_0x13456a){const _0x14b537=_0x5dcab4;if(_0x13456a)return _0x451f70=_0x13456a,require(_0x14b537('0xa'))[_0x14b537('0x3a')]();})[_0x5dcab4('0x36')](function(_0x5a4a2d){const _0x244d64=_0x5dcab4;if(_0x5a4a2d&&_0x5a4a2d[_0x244d64('0x42')]&&_0x451f70>=_0x5a4a2d[_0x244d64('0x42')])throw new Error('Maximum\x20login\x20has\x20been\x20reached');})[_0x5dcab4('0x36')](function(){const _0x40855c=_0x5dcab4;if(_0x2835b6)return db[_0x40855c('0x15')]['destroy']({'where':{'membername':_0x2835b6[_0x40855c('0x1f')]},'individualHooks':!![]});})[_0x5dcab4('0x36')](function(){if(_0x2835b6)return _0x2835b6['getVoiceQueues']({'raw':!![]});})[_0x5dcab4('0x36')](function(_0x593e8b){const _0x3b000b=_0x5dcab4;if(_0x2835b6){if(_0x593e8b){const _0xa4f3e5=[];_0x1f9aa2=_0x593e8b;if(_0x1f9aa2[_0x3b000b('0x23')]){for(let _0x51c78d=0x0;_0x51c78d<_0x1f9aa2[_0x3b000b('0x23')];_0x51c78d++){_0xa4f3e5[_0x3b000b('0x2c')](db[_0x3b000b('0x15')][_0x3b000b('0x2')]({'membername':_0x2835b6[_0x3b000b('0x1f')],'UserId':_0x2835b6['id'],'queue_name':_0x1f9aa2[_0x51c78d][_0x3b000b('0x1f')],'VoiceQueueId':_0x1f9aa2[_0x51c78d]['id'],'interface':_0x1a066b,'paused':_0x2835b6[_0x3b000b('0x2a')]||![],'penalty':_0x1f9aa2[_0x51c78d][_0x3b000b('0x2e')]||0x0}));}return Promise[_0x3b000b('0x1c')](_0xa4f3e5);}}}})[_0x5dcab4('0x36')](function(){const _0x46db7b=_0x5dcab4;if(_0x2835b6)return db[_0x46db7b('0x38')][_0x46db7b('0x43')]({'where':{'membername':_0x2835b6[_0x46db7b('0x1f')],'exitAt':null}});})[_0x5dcab4('0x36')](function(_0x5c2b1d){const _0x364910=_0x5dcab4;if(_0x2835b6){if(_0x5c2b1d&&_0x5c2b1d[_0x364910('0x23')]){const _0x472c9d=[];return _0x5c2b1d[_0x364910('0x32')](function(_0x5553b8){const _0x5c9923=_0x364910;_0x472c9d['push'](_0x5553b8[_0x5c9923('0x22')]({'exitAt':moment()[_0x5c9923('0x25')](_0x5c9923('0x20'))}));}),Promise[_0x364910('0x1c')](_0x472c9d);}}})[_0x5dcab4('0x36')](function(){const _0x2d9f1f=_0x5dcab4;if(_0x2835b6){const _0x5376b1=[],_0x534ef8=[],_0x3af4f1=utils[_0x2d9f1f('0xd')](),_0x25a271={'membername':_0x2835b6['name'],'interface':_0x1a066b,'enterAt':moment()['format'](_0x2d9f1f('0x20')),'role':_0x2835b6[_0x2d9f1f('0x9')],'internal':_0x2835b6[_0x2d9f1f('0x40')]};return _0x3af4f1[_0x2d9f1f('0x32')](function(_0x22b0e4){const _0x498b13=_0x2d9f1f;_0x5376b1['push'](_[_0x498b13('0xf')]({'channel':_0x22b0e4,'type':_0x498b13('0x29'),'data1':'callysquare','data2':_0x1a066b},_0x25a271)),_0x2835b6[_0x498b13('0x2a')]&&_0x534ef8[_0x498b13('0x2c')](_[_0x498b13('0xf')]({'channel':_0x22b0e4,'type':_0x498b13('0x34'),'data1':_0x498b13('0x0')},_0x25a271));}),db['MemberReport']['bulkCreate'](_0x5376b1[_0x2d9f1f('0x41')](_0x534ef8),{'individualHooks':!![]});}})['then'](function(){const _0x57ef3c=_0x5dcab4;if(_0x2835b6)return _0x2835b6[_0x57ef3c('0x22')]({'online':!![],'lastLoginAt':moment()[_0x57ef3c('0x25')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x2835b6['loginInPause']||![],'mailPause':_0x2835b6[_0x57ef3c('0x2a')]||![],'chatPause':_0x2835b6[_0x57ef3c('0x2a')]||![],'faxPause':_0x2835b6[_0x57ef3c('0x2a')]||![],'smsPause':_0x2835b6[_0x57ef3c('0x2a')]||![],'openchannelPause':_0x2835b6[_0x57ef3c('0x2a')]||![],'pauseType':_0x2835b6[_0x57ef3c('0x2a')]?_0x57ef3c('0x0'):null,'lastPauseAt':moment()[_0x57ef3c('0x25')]('YYYY-MM-DD\x20HH:mm:ss'),'interface':_0x1a066b});})['then'](function(_0x1b817b){_0x26bcfa(_0x1b817b);})[_0x5dcab4('0xb')](function(_0x382edc){const _0x35593b=_0x5dcab4;_0x5cd645(_0x35acdb[_0x35593b('0x10')](0x1f4,_0x382edc[_0x35593b('0x3f')]));});});};
\ No newline at end of file
+const a651_0xcf7a=['findOne','push','../../config/logger','concat','bulkCreate','YYYY-MM-DD\x20HH:mm:ss','update','model','getChannels','ShowUser','internal','PauseUser','merge','forEach','agent','lodash','system','UserVoiceQueue.penalty','Maximum\x20login\x20has\x20been\x20reached','PAUSE','count','all','where','stringify','SIP/%s','LOGIN','options','loginInPause','catch','util','moment','message','destroy','attributes','name','MemberReport','upsert','debug','length','openchannel','agents','sequelize','User','findAll','include','raw','voice','type','uniqueid','role','getVoiceQueues','GetUser','DEFAULT\x20PAUSE','UnpauseUser','fax','format','map','Unknown\x20channel','getLicense','chat','interface','info','LOGININPAUSE','set','then','channel','UserVoiceQueueRt','body','limit','../../config/license/util','register','mobile','mail','error'];(function(_0xe11839,_0xcf7a26){const _0x4fb34c=function(_0x3e5c0c){while(--_0x3e5c0c){_0xe11839['push'](_0xe11839['shift']());}};_0x4fb34c(++_0xcf7a26);}(a651_0xcf7a,0x164));const a651_0x4fb3=function(_0xe11839,_0xcf7a26){_0xe11839=_0xe11839-0x0;let _0x4fb34c=a651_0xcf7a[_0xe11839];return _0x4fb34c;};const _0x2960ca=a651_0x4fb3;'use strict';const _=require(_0x2960ca('0x1d')),util=require(_0x2960ca('0x2b')),db=require('../../mysqldb')['db'],logger=require(_0x2960ca('0x10'))('rpc'),moment=require(_0x2960ca('0x2c')),utils=require('../../config/utils'),{getSocket}=require('../../rediscache'),socket=getSocket(),sequelize=require(_0x2960ca('0x37')),{Op}=sequelize;require('./user.socket')[_0x2960ca('0xa')](socket),exports[_0x2960ca('0x41')]=function(_0x3e5c0c){const _0xff258b=this;return new Promise(function(_0x3d7795,_0x2cf9cf){const _0x1ffaff=a651_0x4fb3;return db[_0x1ffaff('0x38')][_0x1ffaff('0x39')]({'raw':_0x3e5c0c[_0x1ffaff('0x28')]?_0x3e5c0c[_0x1ffaff('0x28')][_0x1ffaff('0x3b')]===undefined?!![]:![]:!![],'where':_0x3e5c0c[_0x1ffaff('0x28')]?_0x3e5c0c[_0x1ffaff('0x28')][_0x1ffaff('0x24')]||null:null,'attributes':_0x3e5c0c['options']?_0x3e5c0c['options'][_0x1ffaff('0x2f')]||null:null,'limit':_0x3e5c0c['options']?_0x3e5c0c[_0x1ffaff('0x28')][_0x1ffaff('0x8')]||null:null,'include':_0x3e5c0c[_0x1ffaff('0x28')]?_0x3e5c0c['options'][_0x1ffaff('0x3a')]?_[_0x1ffaff('0x46')](_0x3e5c0c[_0x1ffaff('0x28')][_0x1ffaff('0x3a')],function(_0x11820e){const _0x4c3067=_0x1ffaff;return{'model':db[_0x11820e[_0x4c3067('0x15')]],'as':_0x11820e['as'],'attributes':_0x11820e[_0x4c3067('0x2f')],'include':_0x11820e['include']?_[_0x4c3067('0x46')](_0x11820e['include'],function(_0x2870e9){const _0x2796d5=_0x4c3067;return{'model':db[_0x2870e9['model']],'as':_0x2870e9['as'],'attributes':_0x2870e9['attributes'],'include':_0x2870e9[_0x2796d5('0x3a')]?_[_0x2796d5('0x46')](_0x2870e9[_0x2796d5('0x3a')],function(_0x2795e2){const _0x88e8af=_0x2796d5;return{'model':db[_0x2795e2['model']],'as':_0x2795e2['as'],'attributes':_0x2795e2[_0x88e8af('0x2f')]};}):[]};}):[]};}):[]:[]})[_0x1ffaff('0x4')](function(_0x35735a){const _0x4d0b13=_0x1ffaff;logger['info'](_0x4d0b13('0x41'),_0x3e5c0c),logger[_0x4d0b13('0x33')](_0x4d0b13('0x41'),_0x3e5c0c,JSON['stringify'](_0x35735a)),_0x3d7795(_0x35735a);})[_0x1ffaff('0x2a')](function(_0x47cd5b){const _0x35bc16=_0x1ffaff;logger['error']('GetUser',_0x47cd5b['message'],_0x3e5c0c),_0x2cf9cf(_0xff258b[_0x35bc16('0xd')](0x1f4,_0x47cd5b[_0x35bc16('0x2d')]));});});},exports[_0x2960ca('0x17')]=function(_0x45142c){const _0x59183b=this;return new Promise(function(_0x5a20af,_0x851f05){const _0x25edac=a651_0x4fb3;return db[_0x25edac('0x38')]['findOne']({'raw':_0x45142c[_0x25edac('0x28')]?_0x45142c[_0x25edac('0x28')][_0x25edac('0x3b')]===undefined?!![]:![]:!![],'where':_0x45142c['options']?_0x45142c['options'][_0x25edac('0x24')]||null:null,'attributes':_0x45142c[_0x25edac('0x28')]?_0x45142c[_0x25edac('0x28')][_0x25edac('0x2f')]||null:null,'include':_0x45142c[_0x25edac('0x28')]?_0x45142c[_0x25edac('0x28')][_0x25edac('0x3a')]?_[_0x25edac('0x46')](_0x45142c[_0x25edac('0x28')][_0x25edac('0x3a')],function(_0x30f491){const _0x571ec5=_0x25edac;return{'model':db[_0x30f491[_0x571ec5('0x15')]],'as':_0x30f491['as'],'attributes':_0x30f491[_0x571ec5('0x2f')],'include':_0x30f491[_0x571ec5('0x3a')]?_[_0x571ec5('0x46')](_0x30f491[_0x571ec5('0x3a')],function(_0x2ff1a9){const _0x4f1147=_0x571ec5;return{'model':db[_0x2ff1a9[_0x4f1147('0x15')]],'as':_0x2ff1a9['as'],'attributes':_0x2ff1a9[_0x4f1147('0x2f')],'include':_0x2ff1a9[_0x4f1147('0x3a')]?_['map'](_0x2ff1a9[_0x4f1147('0x3a')],function(_0x399083){const _0x5c11ab=_0x4f1147;return{'model':db[_0x399083[_0x5c11ab('0x15')]],'as':_0x399083['as'],'attributes':_0x399083[_0x5c11ab('0x2f')]};}):[]};}):[]};}):[]:[]})[_0x25edac('0x4')](function(_0x3e6273){const _0x42cf2e=_0x25edac;logger[_0x42cf2e('0x1')](_0x42cf2e('0x17'),_0x45142c),logger[_0x42cf2e('0x33')](_0x42cf2e('0x17'),_0x45142c,JSON[_0x42cf2e('0x25')](_0x3e6273)),_0x5a20af(_0x3e6273);})[_0x25edac('0x2a')](function(_0x1df774){const _0x343a1a=_0x25edac;logger[_0x343a1a('0xd')]('ShowUser',_0x1df774[_0x343a1a('0x2d')],_0x45142c),_0x851f05(_0x59183b['error'](0x1f4,_0x1df774[_0x343a1a('0x2d')]));});});},exports[_0x2960ca('0x19')]=function(_0x20bd1a){const _0xd4bc2e=this;return new Promise(function(_0x4f2243,_0x204b22){const _0x530646=a651_0x4fb3;let _0x40c23a;return db[_0x530646('0x38')][_0x530646('0xe')]({'where':_0x20bd1a[_0x530646('0x28')][_0x530646('0x24')]||{},'attributes':['id',_0x530646('0x30'),_0x530646('0x3f'),_0x530646('0x18'),_0x530646('0x0')]})[_0x530646('0x4')](function(_0x4a4b2b){const _0x5bfe0e=_0x530646;if(_0x4a4b2b)return _0x40c23a=_0x4a4b2b,db[_0x5bfe0e('0x6')][_0x5bfe0e('0x14')]({'paused':0x1},{'where':{'UserId':_0x40c23a['id']},'individualHooks':!![]});})[_0x530646('0x4')](function(){const _0x26de41=_0x530646;if(_0x40c23a)return db[_0x26de41('0x31')][_0x26de41('0x39')]({'where':{'membername':_0x40c23a['name'],'type':_0x26de41('0x21'),'exitAt':null}});})['then'](function(_0x2d185a){const _0x448fce=_0x530646;if(_0x40c23a){if(_0x2d185a&&_0x2d185a['length']){const _0x108c5a=moment()['format'](_0x448fce('0x13'));for(let _0x95a1ab=0x0,_0x7baf95=_0x2d185a[_0x448fce('0x34')];_0x95a1ab<_0x7baf95;_0x95a1ab++){_0x2d185a[_0x95a1ab][_0x448fce('0x14')]({'exitAt':_0x108c5a});}}}})[_0x530646('0x4')](function(){const _0x1b6d4b=_0x530646;if(_0x40c23a){const _0x142122=[],_0x476bdf=utils['getChannels']();return _0x476bdf[_0x1b6d4b('0x1b')](function(_0x18c27b){const _0x5484b2=_0x1b6d4b;_0x142122[_0x5484b2('0xf')]({'channel':_0x18c27b,'membername':_0x40c23a[_0x5484b2('0x30')],'interface':_['isNil'](_0x40c23a[_0x5484b2('0x0')])?util[_0x5484b2('0x45')](_0x5484b2('0x26'),_0x40c23a[_0x5484b2('0x30')]):_0x40c23a[_0x5484b2('0x0')],'type':_0x5484b2('0x21'),'enterAt':moment()['format'](_0x5484b2('0x13')),'data1':_0x20bd1a['body'][_0x5484b2('0x3d')]||_0x5484b2('0x42'),'role':_0x40c23a[_0x5484b2('0x3f')],'internal':_0x40c23a['internal'],'uniqueid':_0x20bd1a[_0x5484b2('0x7')][_0x5484b2('0x3e')]||null});}),db[_0x1b6d4b('0x31')][_0x1b6d4b('0x12')](_0x142122,{'individualHooks':!![]});}})['then'](function(){const _0x5aeaac=_0x530646;if(_0x40c23a)return _0x40c23a[_0x5aeaac('0x14')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'pauseType':_0x20bd1a[_0x5aeaac('0x7')][_0x5aeaac('0x3d')]||_0x5aeaac('0x42'),'lastPauseAt':moment()[_0x5aeaac('0x45')](_0x5aeaac('0x13'))});})[_0x530646('0x4')](function(_0x54dd14){_0x4f2243(_0x54dd14);})[_0x530646('0x2a')](function(_0x8a9ca4){const _0x5e1c85=_0x530646;_0x204b22(_0xd4bc2e[_0x5e1c85('0xd')](0x1f4,_0x8a9ca4[_0x5e1c85('0x2d')]));});});},exports[_0x2960ca('0x43')]=function(_0x1fa554){const _0x504e4b=this;return new Promise(function(_0x212fbd,_0x1ba424){const _0x514d5e=a651_0x4fb3;let _0x58b7c1;return db[_0x514d5e('0x38')]['findOne']({'where':_0x1fa554['options'][_0x514d5e('0x24')]||{},'attributes':['id','name']})[_0x514d5e('0x4')](function(_0x4f3765){const _0x2ee0f0=_0x514d5e;if(_0x4f3765){_0x58b7c1=_0x4f3765;if(_0x1fa554[_0x2ee0f0('0x7')][_0x2ee0f0('0x5')]&&!utils['isValidChannel'](_0x1fa554[_0x2ee0f0('0x7')][_0x2ee0f0('0x5')]))throw new Error(_0x2ee0f0('0x47'));switch(_0x1fa554[_0x2ee0f0('0x7')][_0x2ee0f0('0x5')]){case _0x2ee0f0('0x3c'):return db[_0x2ee0f0('0x6')][_0x2ee0f0('0x14')]({'paused':0x0},{'where':{'UserId':_0x58b7c1['id']}})[_0x2ee0f0('0x4')](function(){const _0x437d7f=_0x2ee0f0;return db[_0x437d7f('0x31')][_0x437d7f('0xe')]({'where':{'channel':_0x1fa554[_0x437d7f('0x7')][_0x437d7f('0x5')],'membername':_0x58b7c1[_0x437d7f('0x30')],'type':'PAUSE','exitAt':null}});})[_0x2ee0f0('0x4')](function(_0x42042b){const _0x3fdbd9=_0x2ee0f0;if(_0x42042b)return _0x42042b[_0x3fdbd9('0x14')]({'exitAt':moment()[_0x3fdbd9('0x45')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':_0x3fdbd9('0x1e')},{'individualHooks':!![]});return null;})[_0x2ee0f0('0x4')](function(){const _0xa7f06c=_0x2ee0f0;return _0x58b7c1[_0xa7f06c('0x14')]({'voicePause':![]});});case _0x2ee0f0('0xc'):case _0x2ee0f0('0x49'):case _0x2ee0f0('0x44'):case'sms':case _0x2ee0f0('0x35'):return db[_0x2ee0f0('0x31')][_0x2ee0f0('0xe')]({'where':{'channel':_0x1fa554[_0x2ee0f0('0x7')][_0x2ee0f0('0x5')],'membername':_0x58b7c1['name'],'type':'PAUSE','exitAt':null}})[_0x2ee0f0('0x4')](function(_0x180be4){const _0x125c18=_0x2ee0f0;return _0x180be4['update']({'exitAt':moment()[_0x125c18('0x45')]('YYYY-MM-DD\x20HH:mm:ss'),'data2':'system'},{'individualHooks':!![]});})[_0x2ee0f0('0x4')](function(){const _0x4a6d03=_0x2ee0f0,_0x271f3f={};return _[_0x4a6d03('0x3')](_0x271f3f,util[_0x4a6d03('0x45')]('%s%s',_0x1fa554['body']['channel'],'Pause'),![]),_0x58b7c1[_0x4a6d03('0x14')](_0x271f3f);});default:return db['UserVoiceQueueRt'][_0x2ee0f0('0x14')]({'paused':0x0},{'where':{'UserId':_0x58b7c1['id']}})[_0x2ee0f0('0x4')](function(){const _0x42f9d4=_0x2ee0f0;return db['MemberReport'][_0x42f9d4('0x39')]({'where':{'membername':_0x58b7c1[_0x42f9d4('0x30')],'type':_0x42f9d4('0x21'),'exitAt':null}});})['then'](function(_0x39865a){const _0x341363=_0x2ee0f0,_0x5388c1=[];return _0x39865a[_0x341363('0x1b')](function(_0x142fc4){const _0x285f22=_0x341363;_0x5388c1[_0x285f22('0xf')](_0x142fc4[_0x285f22('0x14')]({'exitAt':moment()['format'](_0x285f22('0x13')),'data2':_0x285f22('0x1e')}));}),Promise[_0x341363('0x23')](_0x5388c1);})['then'](function(){const _0x489a95=_0x2ee0f0;return _0x58b7c1[_0x489a95('0x14')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});});}}})['then'](function(_0x4bdcf6){_0x212fbd(_0x4bdcf6);})['catch'](function(_0x5c14a2){const _0x135f82=_0x514d5e;_0x1ba424(_0x504e4b[_0x135f82('0xd')](0x1f4,_0x5c14a2[_0x135f82('0x2d')]));});});},exports['LogoutUser']=function(_0x57732b){const _0x1d9159=this;return new Promise(function(_0x336d9b,_0x59664f){const _0x1d6d7c=a651_0x4fb3;let _0x47faf1;return db[_0x1d6d7c('0x38')]['findOne']({'where':_0x57732b[_0x1d6d7c('0x28')][_0x1d6d7c('0x24')]||{},'attributes':['id',_0x1d6d7c('0x30')]})[_0x1d6d7c('0x4')](function(_0x57b9dc){const _0x4ddb4f=_0x1d6d7c;if(_0x57b9dc)return _0x47faf1=_0x57b9dc,db[_0x4ddb4f('0x6')]['destroy']({'where':{'membername':_0x47faf1[_0x4ddb4f('0x30')]},'individualHooks':!![]});})[_0x1d6d7c('0x4')](function(){const _0x1ec73c=_0x1d6d7c;if(_0x47faf1)return db[_0x1ec73c('0x31')]['findAll']({'where':{'membername':_0x47faf1[_0x1ec73c('0x30')],'exitAt':null}});})['then'](function(_0x3d47d3){const _0x2088e9=_0x1d6d7c;if(_0x47faf1){if(_0x3d47d3&&_0x3d47d3[_0x2088e9('0x34')]){const _0x3feeee=[];return _0x3d47d3[_0x2088e9('0x1b')](function(_0x1cd700){const _0x5d37b2=_0x2088e9;_0x3feeee[_0x5d37b2('0xf')](_0x1cd700[_0x5d37b2('0x14')]({'exitAt':moment()[_0x5d37b2('0x45')]('YYYY-MM-DD\x20HH:mm:ss')}));}),Promise[_0x2088e9('0x23')](_0x3feeee);}}})[_0x1d6d7c('0x4')](function(){if(_0x47faf1)return _0x47faf1['update']({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});})['then'](function(_0x5e4562){_0x336d9b(_0x5e4562);})[_0x1d6d7c('0x2a')](function(_0x8ce580){const _0x3242b2=_0x1d6d7c;_0x59664f(_0x1d9159['error'](0x1f4,_0x8ce580[_0x3242b2('0x2d')]));});});},exports['LoginUser']=function(_0x2d1f73){const _0x2fc31a=this;return new Promise(function(_0x269e37,_0x4cc504){const _0x171eb6=a651_0x4fb3;let _0x351ed3,_0x4e6404,_0x4c9b4c,_0x5a138e;return db[_0x171eb6('0x38')][_0x171eb6('0xe')]({'where':_0x2d1f73['options'][_0x171eb6('0x24')]||{},'attributes':['id','name',_0x171eb6('0x3f'),_0x171eb6('0xb'),'phone',_0x171eb6('0x18'),_0x171eb6('0x29'),_0x171eb6('0x0')]})[_0x171eb6('0x4')](function(_0x1ea00e){const _0x2ef9af=_0x171eb6;if(_0x1ea00e)return _0x351ed3=_0x1ea00e,_0x5a138e=_0x2d1f73[_0x2ef9af('0x7')][_0x2ef9af('0x0')]?_0x2d1f73[_0x2ef9af('0x7')][_0x2ef9af('0x0')]:util[_0x2ef9af('0x45')](_0x2ef9af('0x26'),_0x351ed3[_0x2ef9af('0x30')]),db[_0x2ef9af('0x38')][_0x2ef9af('0x22')]({'where':{'role':_0x2ef9af('0x1c'),'online':!![],'id':{[Op['ne']]:_0x351ed3['id']}}});})['then'](function(_0x2457c4){const _0x5e84e6=_0x171eb6;if(_0x2457c4)return _0x4c9b4c=_0x2457c4,require(_0x5e84e6('0x9'))[_0x5e84e6('0x48')]();})['then'](function(_0x1ee3fb){const _0x39ee51=_0x171eb6;if(_0x1ee3fb&&_0x1ee3fb[_0x39ee51('0x36')]&&_0x4c9b4c>=_0x1ee3fb[_0x39ee51('0x36')])throw new Error(_0x39ee51('0x20'));})[_0x171eb6('0x4')](function(){const _0x21c23c=_0x171eb6;if(_0x351ed3)return db[_0x21c23c('0x6')][_0x21c23c('0x2e')]({'where':{'membername':_0x351ed3[_0x21c23c('0x30')]},'individualHooks':!![]});})[_0x171eb6('0x4')](function(){const _0x241685=_0x171eb6;if(_0x351ed3)return _0x351ed3[_0x241685('0x40')]({'raw':!![]});})['then'](function(_0xc6276f){const _0x323122=_0x171eb6;if(_0x351ed3){if(_0xc6276f){const _0x3808a5=[];_0x4e6404=_0xc6276f;if(_0x4e6404['length']){for(let _0x29f564=0x0;_0x29f564<_0x4e6404[_0x323122('0x34')];_0x29f564++){_0x3808a5[_0x323122('0xf')](db[_0x323122('0x6')][_0x323122('0x32')]({'membername':_0x351ed3[_0x323122('0x30')],'UserId':_0x351ed3['id'],'queue_name':_0x4e6404[_0x29f564][_0x323122('0x30')],'VoiceQueueId':_0x4e6404[_0x29f564]['id'],'interface':_0x5a138e,'paused':_0x351ed3[_0x323122('0x29')]||![],'penalty':_0x4e6404[_0x29f564][_0x323122('0x1f')]||0x0}));}return Promise[_0x323122('0x23')](_0x3808a5);}}}})[_0x171eb6('0x4')](function(){const _0x28c24e=_0x171eb6;if(_0x351ed3)return db[_0x28c24e('0x31')]['findAll']({'where':{'membername':_0x351ed3[_0x28c24e('0x30')],'exitAt':null}});})[_0x171eb6('0x4')](function(_0x332d2a){const _0x19b76e=_0x171eb6;if(_0x351ed3){if(_0x332d2a&&_0x332d2a[_0x19b76e('0x34')]){const _0x25d7a0=[];return _0x332d2a[_0x19b76e('0x1b')](function(_0x15ee96){const _0x463c65=_0x19b76e;_0x25d7a0[_0x463c65('0xf')](_0x15ee96[_0x463c65('0x14')]({'exitAt':moment()[_0x463c65('0x45')]('YYYY-MM-DD\x20HH:mm:ss')}));}),Promise[_0x19b76e('0x23')](_0x25d7a0);}}})[_0x171eb6('0x4')](function(){const _0x4ecd08=_0x171eb6;if(_0x351ed3){const _0x53a6ec=[],_0x543d9e=[],_0x2b36eb=utils[_0x4ecd08('0x16')](),_0x2392c3={'membername':_0x351ed3[_0x4ecd08('0x30')],'interface':_0x5a138e,'enterAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x351ed3['role'],'internal':_0x351ed3['internal']};return _0x2b36eb[_0x4ecd08('0x1b')](function(_0x497e34){const _0x2a3a44=_0x4ecd08;_0x53a6ec[_0x2a3a44('0xf')](_[_0x2a3a44('0x1a')]({'channel':_0x497e34,'type':_0x2a3a44('0x27'),'data1':'callysquare','data2':_0x5a138e},_0x2392c3)),_0x351ed3[_0x2a3a44('0x29')]&&_0x543d9e[_0x2a3a44('0xf')](_[_0x2a3a44('0x1a')]({'channel':_0x497e34,'type':_0x2a3a44('0x21'),'data1':_0x2a3a44('0x2')},_0x2392c3));}),db[_0x4ecd08('0x31')]['bulkCreate'](_0x53a6ec[_0x4ecd08('0x11')](_0x543d9e),{'individualHooks':!![]});}})['then'](function(){const _0x3025b3=_0x171eb6;if(_0x351ed3)return _0x351ed3['update']({'online':!![],'lastLoginAt':moment()[_0x3025b3('0x45')](_0x3025b3('0x13')),'voicePause':_0x351ed3[_0x3025b3('0x29')]||![],'mailPause':_0x351ed3[_0x3025b3('0x29')]||![],'chatPause':_0x351ed3[_0x3025b3('0x29')]||![],'faxPause':_0x351ed3[_0x3025b3('0x29')]||![],'smsPause':_0x351ed3[_0x3025b3('0x29')]||![],'openchannelPause':_0x351ed3['loginInPause']||![],'pauseType':_0x351ed3[_0x3025b3('0x29')]?_0x3025b3('0x2'):null,'lastPauseAt':moment()[_0x3025b3('0x45')](_0x3025b3('0x13')),'interface':_0x5a138e});})[_0x171eb6('0x4')](function(_0x59b78b){_0x269e37(_0x59b78b);})[_0x171eb6('0x2a')](function(_0x5acc62){const _0x4407a2=_0x171eb6;_0x4cc504(_0x2fc31a[_0x4407a2('0xd')](0x1f4,_0x5acc62[_0x4407a2('0x2d')]));});});};
\ No newline at end of file