Built motion from commit ae138b72.|2.6.28
[motion2.git] / server / api / user / user.rpc.js
index 5ca48ff..7ad8b15 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x129c=['length','updateAttributes','getChannels','forEach','interface','SIP/%s','YYYY-MM-DD\x20HH:mm:ss','body','DEFAULT\x20PAUSE','uniqueid','bulkCreate','type','UnpauseUser','resolve','channel','isValidChannel','Channel\x20parameter\x20%s\x20is\x20invalid','findOne','online','mailPause','chatPause','faxPause','openchannelPause','smsPause','pauseType','unpause','system','LogoutUser','MemberReport','push','phone','internal','loginInPause','agent','../../config/license/util','Maximum\x20login\x20has\x20been\x20reached','getVoiceQueues','UserVoiceQueue.penalty','all','merge','LOGIN','LOGININPAUSE','concat','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','redis','defaults','socket.io-emitter','./user.socket','register','GetUser','User','raw','options','where','attributes','limit','include','map','model','info','stringify','catch','error','message','ShowUser','then','debug','find','name','role','format','params','UserVoiceQueueRt','update','findAll','PAUSE'];(function(_0x2106f9,_0x4cc28b){var _0x5d2286=function(_0x4737b2){while(--_0x4737b2){_0x2106f9['push'](_0x2106f9['shift']());}};_0x5d2286(++_0x4cc28b);}(_0x129c,0xcf));var _0xc129=function(_0x20f072,_0x37d9cf){_0x20f072=_0x20f072-0x0;var _0x25ebd0=_0x129c[_0x20f072];return _0x25ebd0;};'use strict';var _=require('lodash');var util=require(_0xc129('0x0'));var moment=require(_0xc129('0x1'));var BPromise=require('bluebird');var Redis=require(_0xc129('0x2'));var db=require(_0xc129('0x3'))['db'];var utils=require(_0xc129('0x4'));var logger=require(_0xc129('0x5'))('rpc');var config=require(_0xc129('0x6'));config[_0xc129('0x7')]=_[_0xc129('0x8')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xc129('0x9'))(new Redis(config[_0xc129('0x7')]));require(_0xc129('0xa'))[_0xc129('0xb')](socket);exports[_0xc129('0xc')]=function(_0x562bf6){var _0x259ca7=this;return new Promise(function(_0x455970,_0xbd6efe){return db[_0xc129('0xd')]['findAll']({'raw':_0x562bf6['options']?_0x562bf6['options'][_0xc129('0xe')]===undefined?!![]:![]:!![],'where':_0x562bf6[_0xc129('0xf')]?_0x562bf6['options'][_0xc129('0x10')]||null:null,'attributes':_0x562bf6[_0xc129('0xf')]?_0x562bf6['options'][_0xc129('0x11')]||null:null,'limit':_0x562bf6['options']?_0x562bf6[_0xc129('0xf')][_0xc129('0x12')]||null:null,'include':_0x562bf6['options']?_0x562bf6['options'][_0xc129('0x13')]?_[_0xc129('0x14')](_0x562bf6[_0xc129('0xf')][_0xc129('0x13')],function(_0x13d5b0){return{'model':db[_0x13d5b0[_0xc129('0x15')]],'as':_0x13d5b0['as'],'attributes':_0x13d5b0['attributes'],'include':_0x13d5b0['include']?_[_0xc129('0x14')](_0x13d5b0[_0xc129('0x13')],function(_0x100f1f){return{'model':db[_0x100f1f[_0xc129('0x15')]],'as':_0x100f1f['as'],'attributes':_0x100f1f['attributes'],'include':_0x100f1f[_0xc129('0x13')]?_['map'](_0x100f1f[_0xc129('0x13')],function(_0x59cada){return{'model':db[_0x59cada[_0xc129('0x15')]],'as':_0x59cada['as'],'attributes':_0x59cada[_0xc129('0x11')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x56fb17){logger[_0xc129('0x16')](_0xc129('0xc'),_0x562bf6);logger['debug'](_0xc129('0xc'),_0x562bf6,JSON[_0xc129('0x17')](_0x56fb17));_0x455970(_0x56fb17);})[_0xc129('0x18')](function(_0x42d8ce){logger[_0xc129('0x19')](_0xc129('0xc'),_0x42d8ce['message'],_0x562bf6);_0xbd6efe(_0x259ca7[_0xc129('0x19')](0x1f4,_0x42d8ce[_0xc129('0x1a')]));});});};exports[_0xc129('0x1b')]=function(_0x429e2c){var _0x3d9957=this;return new Promise(function(_0x5db046,_0x17cb80){return db[_0xc129('0xd')]['find']({'raw':_0x429e2c[_0xc129('0xf')]?_0x429e2c[_0xc129('0xf')]['raw']===undefined?!![]:![]:!![],'where':_0x429e2c[_0xc129('0xf')]?_0x429e2c[_0xc129('0xf')][_0xc129('0x10')]||null:null,'attributes':_0x429e2c[_0xc129('0xf')]?_0x429e2c[_0xc129('0xf')]['attributes']||null:null,'include':_0x429e2c[_0xc129('0xf')]?_0x429e2c[_0xc129('0xf')][_0xc129('0x13')]?_[_0xc129('0x14')](_0x429e2c['options'][_0xc129('0x13')],function(_0x1d98da){return{'model':db[_0x1d98da[_0xc129('0x15')]],'as':_0x1d98da['as'],'attributes':_0x1d98da[_0xc129('0x11')],'include':_0x1d98da[_0xc129('0x13')]?_[_0xc129('0x14')](_0x1d98da['include'],function(_0x29ea03){return{'model':db[_0x29ea03[_0xc129('0x15')]],'as':_0x29ea03['as'],'attributes':_0x29ea03[_0xc129('0x11')],'include':_0x29ea03['include']?_[_0xc129('0x14')](_0x29ea03[_0xc129('0x13')],function(_0x4eca76){return{'model':db[_0x4eca76[_0xc129('0x15')]],'as':_0x4eca76['as'],'attributes':_0x4eca76[_0xc129('0x11')]};}):[]};}):[]};}):[]:[]})[_0xc129('0x1c')](function(_0x2f714d){logger[_0xc129('0x16')](_0xc129('0x1b'),_0x429e2c);logger[_0xc129('0x1d')](_0xc129('0x1b'),_0x429e2c,JSON[_0xc129('0x17')](_0x2f714d));_0x5db046(_0x2f714d);})[_0xc129('0x18')](function(_0x2be5ea){logger[_0xc129('0x19')](_0xc129('0x1b'),_0x2be5ea[_0xc129('0x1a')],_0x429e2c);_0x17cb80(_0x3d9957[_0xc129('0x19')](0x1f4,_0x2be5ea['message']));});});};exports['PauseUser']=function(_0xd8b19e){var _0x3cbb5d;return db[_0xc129('0xd')][_0xc129('0x1e')]({'where':_0xd8b19e['options'][_0xc129('0x10')]||{},'attributes':['id',_0xc129('0x1f'),_0xc129('0x20'),'internal','interface']})[_0xc129('0x1c')](function(_0x54c2dd){if(!_0x54c2dd){throw new Error(util[_0xc129('0x21')]('User\x20with\x20id\x20%s\x20not\x20found',_0xd8b19e[_0xc129('0x22')]['id']));}_0x3cbb5d=_0x54c2dd;return db[_0xc129('0x23')][_0xc129('0x24')]({'paused':0x1},{'where':{'UserId':_0x3cbb5d['id']},'individualHooks':!![]});})[_0xc129('0x1c')](function(){return db['MemberReport'][_0xc129('0x25')]({'where':{'membername':_0x3cbb5d[_0xc129('0x1f')],'type':_0xc129('0x26'),'exitAt':null}});})[_0xc129('0x1c')](function(_0x15afec){if(_0x15afec&&_0x15afec[_0xc129('0x27')]){var _0x3216aa=moment()[_0xc129('0x21')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x488a72=0x0,_0x4841dc=_0x15afec[_0xc129('0x27')];_0x488a72<_0x4841dc;_0x488a72++){_0x15afec[_0x488a72][_0xc129('0x28')]({'exitAt':_0x3216aa});}}})[_0xc129('0x1c')](function(){var _0x576030=[];var _0x5274dc=utils[_0xc129('0x29')]();_0x5274dc[_0xc129('0x2a')](function(_0xd58859){_0x576030['push']({'channel':_0xd58859,'membername':_0x3cbb5d['name'],'interface':_['isNil'](_0x3cbb5d[_0xc129('0x2b')])?util[_0xc129('0x21')](_0xc129('0x2c'),_0x3cbb5d[_0xc129('0x1f')]):_0x3cbb5d[_0xc129('0x2b')],'type':_0xc129('0x26'),'enterAt':moment()[_0xc129('0x21')](_0xc129('0x2d')),'data1':_0xd8b19e[_0xc129('0x2e')]['type']||_0xc129('0x2f'),'role':_0x3cbb5d['role'],'internal':_0x3cbb5d['internal'],'uniqueid':_0xd8b19e[_0xc129('0x2e')][_0xc129('0x30')]||null});});return db['MemberReport'][_0xc129('0x31')](_0x576030,{'individualHooks':!![]});})[_0xc129('0x1c')](function(){return _0x3cbb5d['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'whatsappPause':!![],'pauseType':_0xd8b19e['body'][_0xc129('0x32')]||_0xc129('0x2f'),'lastPauseAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss')});})[_0xc129('0x18')](function(_0x4c78e1){throw _0x4c78e1;});};exports[_0xc129('0x33')]=function(_0x11fe8b){return Promise[_0xc129('0x34')]()[_0xc129('0x1c')](function(){if(_0x11fe8b[_0xc129('0x2e')][_0xc129('0x35')]&&!utils[_0xc129('0x36')](_0x11fe8b[_0xc129('0x2e')][_0xc129('0x35')])){throw new Error(util[_0xc129('0x21')](_0xc129('0x37'),_0x11fe8b[_0xc129('0x2e')]['channel']));}return db['User'][_0xc129('0x38')]({'where':_0x11fe8b['options'][_0xc129('0x10')]||{},'attributes':['id',_0xc129('0x1f'),_0xc129('0x20'),'internal',_0xc129('0x2b'),_0xc129('0x39'),'voicePause',_0xc129('0x3a'),_0xc129('0x3b'),_0xc129('0x3c'),_0xc129('0x3d'),_0xc129('0x3e'),'whatsappPause',_0xc129('0x3f'),'lastPauseAt']});})[_0xc129('0x1c')](function(_0x23d965){if(!_0x23d965){throw new Error(util[_0xc129('0x21')]('User\x20with\x20id\x20%s\x20not\x20found',_0x11fe8b[_0xc129('0x22')]['id']));}return _0x23d965[_0xc129('0x40')](_0x11fe8b[_0xc129('0x2e')]['channel'],_0xc129('0x41'));})[_0xc129('0x18')](function(_0x188a34){throw _0x188a34;});};exports[_0xc129('0x42')]=function(_0x2bc2dd){var _0x13a299=this;return new Promise(function(_0x1a4c15,_0x31b8b3){var _0x53f746;return db['User'][_0xc129('0x38')]({'where':_0x2bc2dd[_0xc129('0xf')][_0xc129('0x10')]||{},'attributes':['id',_0xc129('0x1f')]})[_0xc129('0x1c')](function(_0x831897){if(_0x831897){_0x53f746=_0x831897;return db[_0xc129('0x23')]['destroy']({'where':{'membername':_0x53f746[_0xc129('0x1f')]},'individualHooks':!![]});}})[_0xc129('0x1c')](function(){if(_0x53f746){return db[_0xc129('0x43')][_0xc129('0x25')]({'where':{'membername':_0x53f746[_0xc129('0x1f')],'exitAt':null}});}})[_0xc129('0x1c')](function(_0x4a7330){if(_0x53f746){if(_0x4a7330&&_0x4a7330[_0xc129('0x27')]){var _0x4e57ef=[];_0x4a7330['forEach'](function(_0x2bb412){_0x4e57ef[_0xc129('0x44')](_0x2bb412['update']({'exitAt':moment()[_0xc129('0x21')]('YYYY-MM-DD\x20HH:mm:ss')}));});return BPromise['all'](_0x4e57ef);}}})[_0xc129('0x1c')](function(){if(_0x53f746){return _0x53f746[_0xc129('0x24')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});}})['then'](function(_0x44c23f){_0x1a4c15(_0x44c23f);})[_0xc129('0x18')](function(_0xbed5a){_0x31b8b3(_0x13a299[_0xc129('0x19')](0x1f4,_0xbed5a[_0xc129('0x1a')]));});});};exports['LoginUser']=function(_0x57b822){var _0x4337f7=this;return new Promise(function(_0x2e7808,_0x4e64bc){var _0x127be4;var _0x95499;var _0x21aa2e;var _0x55f957;return db['User'][_0xc129('0x38')]({'where':_0x57b822[_0xc129('0xf')][_0xc129('0x10')]||{},'attributes':['id',_0xc129('0x1f'),_0xc129('0x20'),'mobile',_0xc129('0x45'),_0xc129('0x46'),_0xc129('0x47'),_0xc129('0x2b')]})['then'](function(_0x29afc4){if(_0x29afc4){_0x127be4=_0x29afc4;_0x55f957=_0x57b822['body'][_0xc129('0x2b')]?_0x57b822[_0xc129('0x2e')][_0xc129('0x2b')]:util[_0xc129('0x21')]('SIP/%s',_0x127be4['name']);return db[_0xc129('0xd')]['count']({'where':{'role':_0xc129('0x48'),'online':!![],'id':{'$ne':_0x127be4['id']}}});}})[_0xc129('0x1c')](function(_0x5edb34){if(_0x5edb34){_0x21aa2e=_0x5edb34;return require(_0xc129('0x49'))['getLicense']();}})[_0xc129('0x1c')](function(_0xddacee){if(_0xddacee&&_0xddacee['agents']&&_0x21aa2e>=_0xddacee['agents']){throw new Error(_0xc129('0x4a'));}})[_0xc129('0x1c')](function(){if(_0x127be4){return db[_0xc129('0x23')]['destroy']({'where':{'membername':_0x127be4[_0xc129('0x1f')]},'individualHooks':!![]});}})[_0xc129('0x1c')](function(){if(_0x127be4){return _0x127be4[_0xc129('0x4b')]({'raw':!![]});}})[_0xc129('0x1c')](function(_0xbc7da3){if(_0x127be4){if(_0xbc7da3){var _0xff5d9=[];_0x95499=_0xbc7da3;if(_0x95499[_0xc129('0x27')]){for(var _0x166370=0x0;_0x166370<_0x95499[_0xc129('0x27')];_0x166370++){_0xff5d9['push'](db[_0xc129('0x23')]['upsert']({'membername':_0x127be4[_0xc129('0x1f')],'UserId':_0x127be4['id'],'queue_name':_0x95499[_0x166370][_0xc129('0x1f')],'VoiceQueueId':_0x95499[_0x166370]['id'],'interface':_0x55f957,'paused':_0x127be4['loginInPause']||![],'penalty':_0x95499[_0x166370][_0xc129('0x4c')]||0x0}));}return BPromise[_0xc129('0x4d')](_0xff5d9);}}}})['then'](function(){if(_0x127be4){return db[_0xc129('0x43')][_0xc129('0x25')]({'where':{'membername':_0x127be4[_0xc129('0x1f')],'exitAt':null}});}})['then'](function(_0x30a278){if(_0x127be4){if(_0x30a278&&_0x30a278[_0xc129('0x27')]){var _0x45ad04=[];_0x30a278[_0xc129('0x2a')](function(_0x519115){_0x45ad04['push'](_0x519115[_0xc129('0x24')]({'exitAt':moment()[_0xc129('0x21')](_0xc129('0x2d'))}));});return BPromise[_0xc129('0x4d')](_0x45ad04);}}})[_0xc129('0x1c')](function(){if(_0x127be4){var _0x3300e0=[];var _0x3e8630=[];var _0xff772c=utils[_0xc129('0x29')]();var _0x2c16c7={'membername':_0x127be4['name'],'interface':_0x55f957,'enterAt':moment()[_0xc129('0x21')]('YYYY-MM-DD\x20HH:mm:ss'),'role':_0x127be4[_0xc129('0x20')],'internal':_0x127be4['internal']};_0xff772c['forEach'](function(_0x536baa){_0x3300e0['push'](_[_0xc129('0x4e')]({'channel':_0x536baa,'type':_0xc129('0x4f'),'data1':'callysquare','data2':_0x55f957},_0x2c16c7));if(_0x127be4['loginInPause']){_0x3e8630[_0xc129('0x44')](_[_0xc129('0x4e')]({'channel':_0x536baa,'type':_0xc129('0x26'),'data1':_0xc129('0x50')},_0x2c16c7));}});return db['MemberReport'][_0xc129('0x31')](_0x3300e0[_0xc129('0x51')](_0x3e8630),{'individualHooks':!![]});}})['then'](function(){if(_0x127be4){return _0x127be4[_0xc129('0x24')]({'online':!![],'lastLoginAt':moment()[_0xc129('0x21')](_0xc129('0x2d')),'voicePause':_0x127be4[_0xc129('0x47')]||![],'mailPause':_0x127be4[_0xc129('0x47')]||![],'chatPause':_0x127be4[_0xc129('0x47')]||![],'faxPause':_0x127be4[_0xc129('0x47')]||![],'smsPause':_0x127be4[_0xc129('0x47')]||![],'openchannelPause':_0x127be4[_0xc129('0x47')]||![],'pauseType':_0x127be4['loginInPause']?_0xc129('0x50'):null,'lastPauseAt':moment()['format'](_0xc129('0x2d')),'interface':_0x55f957});}})['then'](function(_0x1f3e8d){_0x2e7808(_0x1f3e8d);})[_0xc129('0x18')](function(_0x859b80){_0x4e64bc(_0x4337f7['error'](0x1f4,_0x859b80[_0xc129('0x1a')]));});});};
\ No newline at end of file
+var _0x7265=['bulkCreate','concat','lodash','util','bluebird','ioredis','../../config/utils','../../config/logger','../../config/environment','redis','socket.io-emitter','./user.socket','User','findAll','options','where','limit','include','model','attributes','map','then','GetUser','stringify','message','find','raw','ShowUser','catch','error','PauseUser','name','role','internal','interface','format','params','UserVoiceQueueRt','update','PAUSE','length','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','forEach','push','isNil','SIP/%s','body','type','uniqueid','DEFAULT\x20PAUSE','UnpauseUser','channel','isValidChannel','Channel\x20parameter\x20%s\x20is\x20invalid','findOne','mailPause','chatPause','faxPause','openchannelPause','smsPause','whatsappPause','pauseType','lastPauseAt','User\x20with\x20id\x20%s\x20not\x20found','unpause','system','destroy','MemberReport','all','mobile','phone','loginInPause','count','../../config/license/util','getLicense','agents','Maximum\x20login\x20has\x20been\x20reached','getVoiceQueues','upsert','UserVoiceQueue.penalty','getChannels','merge','callysquare','LOGININPAUSE'];(function(_0x2bddd1,_0x43a74d){var _0x55ca88=function(_0x3ea724){while(--_0x3ea724){_0x2bddd1['push'](_0x2bddd1['shift']());}};_0x55ca88(++_0x43a74d);}(_0x7265,0xac));var _0x5726=function(_0x444198,_0xed7596){_0x444198=_0x444198-0x0;var _0x50ca69=_0x7265[_0x444198];return _0x50ca69;};'use strict';var _=require(_0x5726('0x0'));var util=require(_0x5726('0x1'));var moment=require('moment');var BPromise=require(_0x5726('0x2'));var Redis=require(_0x5726('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x5726('0x4'));var logger=require(_0x5726('0x5'))('rpc');var config=require(_0x5726('0x6'));config[_0x5726('0x7')]=_['defaults'](config[_0x5726('0x7')],{'host':'localhost','port':0x18eb});var socket=require(_0x5726('0x8'))(new Redis(config['redis']));require(_0x5726('0x9'))['register'](socket);exports['GetUser']=function(_0x890fc3){var _0x24a7ca=this;return new Promise(function(_0x650305,_0x2aec70){return db[_0x5726('0xa')][_0x5726('0xb')]({'raw':_0x890fc3[_0x5726('0xc')]?_0x890fc3[_0x5726('0xc')]['raw']===undefined?!![]:![]:!![],'where':_0x890fc3[_0x5726('0xc')]?_0x890fc3[_0x5726('0xc')][_0x5726('0xd')]||null:null,'attributes':_0x890fc3[_0x5726('0xc')]?_0x890fc3['options']['attributes']||null:null,'limit':_0x890fc3[_0x5726('0xc')]?_0x890fc3[_0x5726('0xc')][_0x5726('0xe')]||null:null,'include':_0x890fc3[_0x5726('0xc')]?_0x890fc3[_0x5726('0xc')][_0x5726('0xf')]?_['map'](_0x890fc3['options'][_0x5726('0xf')],function(_0x5d2f98){return{'model':db[_0x5d2f98[_0x5726('0x10')]],'as':_0x5d2f98['as'],'attributes':_0x5d2f98[_0x5726('0x11')],'include':_0x5d2f98['include']?_[_0x5726('0x12')](_0x5d2f98[_0x5726('0xf')],function(_0x4f1c34){return{'model':db[_0x4f1c34[_0x5726('0x10')]],'as':_0x4f1c34['as'],'attributes':_0x4f1c34['attributes'],'include':_0x4f1c34['include']?_[_0x5726('0x12')](_0x4f1c34[_0x5726('0xf')],function(_0x45d0e3){return{'model':db[_0x45d0e3[_0x5726('0x10')]],'as':_0x45d0e3['as'],'attributes':_0x45d0e3[_0x5726('0x11')]};}):[]};}):[]};}):[]:[]})[_0x5726('0x13')](function(_0x2f7bc5){logger['info'](_0x5726('0x14'),_0x890fc3);logger['debug'](_0x5726('0x14'),_0x890fc3,JSON[_0x5726('0x15')](_0x2f7bc5));_0x650305(_0x2f7bc5);})['catch'](function(_0x4b7b0c){logger['error'](_0x5726('0x14'),_0x4b7b0c['message'],_0x890fc3);_0x2aec70(_0x24a7ca['error'](0x1f4,_0x4b7b0c[_0x5726('0x16')]));});});};exports['ShowUser']=function(_0x3895c4){var _0x177c10=this;return new Promise(function(_0x1a9406,_0x4d4e55){return db['User'][_0x5726('0x17')]({'raw':_0x3895c4[_0x5726('0xc')]?_0x3895c4[_0x5726('0xc')][_0x5726('0x18')]===undefined?!![]:![]:!![],'where':_0x3895c4[_0x5726('0xc')]?_0x3895c4[_0x5726('0xc')]['where']||null:null,'attributes':_0x3895c4[_0x5726('0xc')]?_0x3895c4[_0x5726('0xc')]['attributes']||null:null,'include':_0x3895c4[_0x5726('0xc')]?_0x3895c4[_0x5726('0xc')][_0x5726('0xf')]?_['map'](_0x3895c4[_0x5726('0xc')][_0x5726('0xf')],function(_0x415d01){return{'model':db[_0x415d01[_0x5726('0x10')]],'as':_0x415d01['as'],'attributes':_0x415d01['attributes'],'include':_0x415d01[_0x5726('0xf')]?_[_0x5726('0x12')](_0x415d01[_0x5726('0xf')],function(_0x3fc34c){return{'model':db[_0x3fc34c[_0x5726('0x10')]],'as':_0x3fc34c['as'],'attributes':_0x3fc34c[_0x5726('0x11')],'include':_0x3fc34c[_0x5726('0xf')]?_[_0x5726('0x12')](_0x3fc34c['include'],function(_0x3e787b){return{'model':db[_0x3e787b['model']],'as':_0x3e787b['as'],'attributes':_0x3e787b['attributes']};}):[]};}):[]};}):[]:[]})[_0x5726('0x13')](function(_0x294af2){logger['info']('ShowUser',_0x3895c4);logger['debug'](_0x5726('0x19'),_0x3895c4,JSON['stringify'](_0x294af2));_0x1a9406(_0x294af2);})[_0x5726('0x1a')](function(_0x352442){logger['error'](_0x5726('0x19'),_0x352442['message'],_0x3895c4);_0x4d4e55(_0x177c10[_0x5726('0x1b')](0x1f4,_0x352442['message']));});});};exports[_0x5726('0x1c')]=function(_0x2f11a9){var _0x4b9a12;return db[_0x5726('0xa')][_0x5726('0x17')]({'where':_0x2f11a9[_0x5726('0xc')]['where']||{},'attributes':['id',_0x5726('0x1d'),_0x5726('0x1e'),_0x5726('0x1f'),_0x5726('0x20')]})['then'](function(_0x42a176){if(!_0x42a176){throw new Error(util[_0x5726('0x21')]('User\x20with\x20id\x20%s\x20not\x20found',_0x2f11a9[_0x5726('0x22')]['id']));}_0x4b9a12=_0x42a176;return db[_0x5726('0x23')][_0x5726('0x24')]({'paused':0x1},{'where':{'UserId':_0x4b9a12['id']},'individualHooks':!![]});})['then'](function(){return db['MemberReport'][_0x5726('0xb')]({'where':{'membername':_0x4b9a12[_0x5726('0x1d')],'type':_0x5726('0x25'),'exitAt':null}});})[_0x5726('0x13')](function(_0x35ddbd){if(_0x35ddbd&&_0x35ddbd[_0x5726('0x26')]){var _0x6b86cd=moment()[_0x5726('0x21')](_0x5726('0x27'));for(var _0x53b928=0x0,_0x15c361=_0x35ddbd[_0x5726('0x26')];_0x53b928<_0x15c361;_0x53b928++){_0x35ddbd[_0x53b928][_0x5726('0x28')]({'exitAt':_0x6b86cd});}}})[_0x5726('0x13')](function(){var _0x85236b=[];var _0x3b8c1a=utils['getChannels']();_0x3b8c1a[_0x5726('0x29')](function(_0x3aa326){_0x85236b[_0x5726('0x2a')]({'channel':_0x3aa326,'membername':_0x4b9a12[_0x5726('0x1d')],'interface':_[_0x5726('0x2b')](_0x4b9a12[_0x5726('0x20')])?util['format'](_0x5726('0x2c'),_0x4b9a12['name']):_0x4b9a12[_0x5726('0x20')],'type':'PAUSE','enterAt':moment()[_0x5726('0x21')]('YYYY-MM-DD\x20HH:mm:ss'),'data1':_0x2f11a9[_0x5726('0x2d')][_0x5726('0x2e')]||'DEFAULT\x20PAUSE','role':_0x4b9a12['role'],'internal':_0x4b9a12['internal'],'uniqueid':_0x2f11a9['body'][_0x5726('0x2f')]||null});});return db['MemberReport']['bulkCreate'](_0x85236b,{'individualHooks':!![]});})['then'](function(){return _0x4b9a12[_0x5726('0x24')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'whatsappPause':!![],'pauseType':_0x2f11a9[_0x5726('0x2d')][_0x5726('0x2e')]||_0x5726('0x30'),'lastPauseAt':moment()['format'](_0x5726('0x27'))});})[_0x5726('0x1a')](function(_0x5227c9){throw _0x5227c9;});};exports[_0x5726('0x31')]=function(_0x3c8e12){return Promise['resolve']()[_0x5726('0x13')](function(){if(_0x3c8e12[_0x5726('0x2d')][_0x5726('0x32')]&&!utils[_0x5726('0x33')](_0x3c8e12['body'][_0x5726('0x32')])){throw new Error(util['format'](_0x5726('0x34'),_0x3c8e12[_0x5726('0x2d')]['channel']));}return db[_0x5726('0xa')][_0x5726('0x35')]({'where':_0x3c8e12['options'][_0x5726('0xd')]||{},'attributes':['id',_0x5726('0x1d'),_0x5726('0x1e'),_0x5726('0x1f'),_0x5726('0x20'),'online','voicePause',_0x5726('0x36'),_0x5726('0x37'),_0x5726('0x38'),_0x5726('0x39'),_0x5726('0x3a'),_0x5726('0x3b'),_0x5726('0x3c'),_0x5726('0x3d')]});})[_0x5726('0x13')](function(_0x133e79){if(!_0x133e79){throw new Error(util[_0x5726('0x21')](_0x5726('0x3e'),_0x3c8e12['params']['id']));}return _0x133e79[_0x5726('0x3f')](_0x3c8e12[_0x5726('0x2d')][_0x5726('0x32')],_0x5726('0x40'));})['catch'](function(_0x2adc9c){throw _0x2adc9c;});};exports['LogoutUser']=function(_0x49df25){var _0x180037=this;return new Promise(function(_0x3667c8,_0x246ffd){var _0x5429d9;return db[_0x5726('0xa')]['findOne']({'where':_0x49df25[_0x5726('0xc')][_0x5726('0xd')]||{},'attributes':['id',_0x5726('0x1d')]})['then'](function(_0x4f5495){if(_0x4f5495){_0x5429d9=_0x4f5495;return db[_0x5726('0x23')][_0x5726('0x41')]({'where':{'membername':_0x5429d9[_0x5726('0x1d')]},'individualHooks':!![]});}})['then'](function(){if(_0x5429d9){return db[_0x5726('0x42')][_0x5726('0xb')]({'where':{'membername':_0x5429d9['name'],'exitAt':null}});}})[_0x5726('0x13')](function(_0x5eccea){if(_0x5429d9){if(_0x5eccea&&_0x5eccea[_0x5726('0x26')]){var _0xb23882=[];_0x5eccea[_0x5726('0x29')](function(_0x5c8f5a){_0xb23882[_0x5726('0x2a')](_0x5c8f5a[_0x5726('0x24')]({'exitAt':moment()[_0x5726('0x21')](_0x5726('0x27'))}));});return BPromise[_0x5726('0x43')](_0xb23882);}}})[_0x5726('0x13')](function(){if(_0x5429d9){return _0x5429d9[_0x5726('0x24')]({'online':![],'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});}})[_0x5726('0x13')](function(_0x16394f){_0x3667c8(_0x16394f);})[_0x5726('0x1a')](function(_0x5eef60){_0x246ffd(_0x180037[_0x5726('0x1b')](0x1f4,_0x5eef60[_0x5726('0x16')]));});});};exports['LoginUser']=function(_0x511479){var _0x46c6dc=this;return new Promise(function(_0x3267a2,_0x4922d6){var _0x4d8db7;var _0x59c2e0;var _0xbbc457;var _0x35abab;return db[_0x5726('0xa')][_0x5726('0x35')]({'where':_0x511479[_0x5726('0xc')][_0x5726('0xd')]||{},'attributes':['id',_0x5726('0x1d'),_0x5726('0x1e'),_0x5726('0x44'),_0x5726('0x45'),_0x5726('0x1f'),_0x5726('0x46'),_0x5726('0x20')]})[_0x5726('0x13')](function(_0x17b708){if(_0x17b708){_0x4d8db7=_0x17b708;_0x35abab=_0x511479[_0x5726('0x2d')]['interface']?_0x511479[_0x5726('0x2d')][_0x5726('0x20')]:util[_0x5726('0x21')](_0x5726('0x2c'),_0x4d8db7[_0x5726('0x1d')]);return db[_0x5726('0xa')][_0x5726('0x47')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x4d8db7['id']}}});}})[_0x5726('0x13')](function(_0x12c210){if(_0x12c210){_0xbbc457=_0x12c210;return require(_0x5726('0x48'))[_0x5726('0x49')]();}})[_0x5726('0x13')](function(_0x266182){if(_0x266182&&_0x266182[_0x5726('0x4a')]&&_0xbbc457>=_0x266182[_0x5726('0x4a')]){throw new Error(_0x5726('0x4b'));}})['then'](function(){if(_0x4d8db7){return db[_0x5726('0x23')][_0x5726('0x41')]({'where':{'membername':_0x4d8db7['name']},'individualHooks':!![]});}})[_0x5726('0x13')](function(){if(_0x4d8db7){return _0x4d8db7[_0x5726('0x4c')]({'raw':!![]});}})[_0x5726('0x13')](function(_0x27c49c){if(_0x4d8db7){if(_0x27c49c){var _0x3d080e=[];_0x59c2e0=_0x27c49c;if(_0x59c2e0[_0x5726('0x26')]){for(var _0x4f8eb4=0x0;_0x4f8eb4<_0x59c2e0[_0x5726('0x26')];_0x4f8eb4++){_0x3d080e[_0x5726('0x2a')](db[_0x5726('0x23')][_0x5726('0x4d')]({'membername':_0x4d8db7['name'],'UserId':_0x4d8db7['id'],'queue_name':_0x59c2e0[_0x4f8eb4][_0x5726('0x1d')],'VoiceQueueId':_0x59c2e0[_0x4f8eb4]['id'],'interface':_0x35abab,'paused':_0x4d8db7[_0x5726('0x46')]||![],'penalty':_0x59c2e0[_0x4f8eb4][_0x5726('0x4e')]||0x0}));}return BPromise[_0x5726('0x43')](_0x3d080e);}}}})['then'](function(){if(_0x4d8db7){return db[_0x5726('0x42')][_0x5726('0xb')]({'where':{'membername':_0x4d8db7[_0x5726('0x1d')],'exitAt':null}});}})[_0x5726('0x13')](function(_0x52057f){if(_0x4d8db7){if(_0x52057f&&_0x52057f[_0x5726('0x26')]){var _0x4fee3b=[];_0x52057f[_0x5726('0x29')](function(_0x3b341e){_0x4fee3b[_0x5726('0x2a')](_0x3b341e[_0x5726('0x24')]({'exitAt':moment()[_0x5726('0x21')](_0x5726('0x27'))}));});return BPromise[_0x5726('0x43')](_0x4fee3b);}}})[_0x5726('0x13')](function(){if(_0x4d8db7){var _0x2b8710=[];var _0x5435e1=[];var _0x2ddd74=utils[_0x5726('0x4f')]();var _0x5e4213={'membername':_0x4d8db7[_0x5726('0x1d')],'interface':_0x35abab,'enterAt':moment()['format'](_0x5726('0x27')),'role':_0x4d8db7['role'],'internal':_0x4d8db7[_0x5726('0x1f')]};_0x2ddd74[_0x5726('0x29')](function(_0x3871b3){_0x2b8710['push'](_[_0x5726('0x50')]({'channel':_0x3871b3,'type':'LOGIN','data1':_0x5726('0x51'),'data2':_0x35abab},_0x5e4213));if(_0x4d8db7[_0x5726('0x46')]){_0x5435e1[_0x5726('0x2a')](_['merge']({'channel':_0x3871b3,'type':_0x5726('0x25'),'data1':_0x5726('0x52')},_0x5e4213));}});return db[_0x5726('0x42')][_0x5726('0x53')](_0x2b8710[_0x5726('0x54')](_0x5435e1),{'individualHooks':!![]});}})['then'](function(){if(_0x4d8db7){return _0x4d8db7[_0x5726('0x24')]({'online':!![],'lastLoginAt':moment()[_0x5726('0x21')](_0x5726('0x27')),'voicePause':_0x4d8db7[_0x5726('0x46')]||![],'mailPause':_0x4d8db7[_0x5726('0x46')]||![],'chatPause':_0x4d8db7[_0x5726('0x46')]||![],'faxPause':_0x4d8db7[_0x5726('0x46')]||![],'smsPause':_0x4d8db7[_0x5726('0x46')]||![],'openchannelPause':_0x4d8db7[_0x5726('0x46')]||![],'pauseType':_0x4d8db7[_0x5726('0x46')]?_0x5726('0x52'):null,'lastPauseAt':moment()[_0x5726('0x21')](_0x5726('0x27')),'interface':_0x35abab});}})[_0x5726('0x13')](function(_0x4c0f06){_0x3267a2(_0x4c0f06);})[_0x5726('0x1a')](function(_0x55848b){_0x4922d6(_0x46c6dc['error'](0x1f4,_0x55848b[_0x5726('0x16')]));});});};
\ No newline at end of file