Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / user / user.rpc.js
index 11918ff..1886fef 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8efc=['moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','./user.socket','register','request','then','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','User','findAll','options','raw','where','attributes','include','map','model','GetUser','ShowUser','find','PauseUser','name','interface','UserVoiceQueueRt','update','PAUSE','format','length','updateAttributes','forEach','push','isNil','YYYY-MM-DD\x20HH:mm:ss','body','DEFAULT\x20PAUSE','role','internal','MemberReport','bulkCreate','UnpauseUser','channel','isValidChannel','Unknown\x20channel','voice','system','chat','fax','sms','set','%s%s','Pause','all','destroy','findOne','mobile','loginInPause','SIP/%s','count','getLicense','agents','Maximum\x20login\x20has\x20been\x20reached','getVoiceQueues','upsert','UserVoiceQueue.penalty','getChannels','merge','callysquare','concat','LOGININPAUSE','util'];(function(_0x1353f9,_0x442a93){var _0x32d8e0=function(_0x38ab8e){while(--_0x38ab8e){_0x1353f9['push'](_0x1353f9['shift']());}};_0x32d8e0(++_0x442a93);}(_0x8efc,0xb3));var _0xc8ef=function(_0x401a4d,_0x4bb835){_0x401a4d=_0x401a4d-0x0;var _0x1faaff=_0x8efc[_0x401a4d];return _0x1faaff;};'use strict';var _=require('lodash');var util=require(_0xc8ef('0x0'));var moment=require(_0xc8ef('0x1'));var BPromise=require(_0xc8ef('0x2'));var rs=require(_0xc8ef('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc8ef('0x4'))['db'];var utils=require(_0xc8ef('0x5'));var logger=require(_0xc8ef('0x6'))('rpc');var config=require(_0xc8ef('0x7'));var jayson=require(_0xc8ef('0x8'));var client=jayson[_0xc8ef('0x9')][_0xc8ef('0xa')]({'port':0x232a});config['redis']=_[_0xc8ef('0xb')](config[_0xc8ef('0xc')],{'host':_0xc8ef('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc8ef('0xc')]));require(_0xc8ef('0xe'))[_0xc8ef('0xf')](socket);function respondWithRpcPromise(_0xcc3c21,_0x56cfb1,_0x315d93){return new BPromise(function(_0x574588,_0x45dbd3){return client[_0xc8ef('0x10')](_0xcc3c21,_0x315d93)[_0xc8ef('0x11')](function(_0x29d96b){logger[_0xc8ef('0x12')](_0xc8ef('0x13'),_0x56cfb1,_0xc8ef('0x14'));logger[_0xc8ef('0x15')](_0xc8ef('0x16'),_0x56cfb1,_0xc8ef('0x14'),JSON[_0xc8ef('0x17')](_0x29d96b));if(_0x29d96b[_0xc8ef('0x18')]){if(_0x29d96b[_0xc8ef('0x18')][_0xc8ef('0x19')]===0x1f4){logger[_0xc8ef('0x18')](_0xc8ef('0x13'),_0x56cfb1,_0x29d96b[_0xc8ef('0x18')][_0xc8ef('0x1a')]);return _0x45dbd3(_0x29d96b[_0xc8ef('0x18')][_0xc8ef('0x1a')]);}logger[_0xc8ef('0x18')](_0xc8ef('0x13'),_0x56cfb1,_0x29d96b['error'][_0xc8ef('0x1a')]);return _0x574588(_0x29d96b[_0xc8ef('0x18')][_0xc8ef('0x1a')]);}else{logger[_0xc8ef('0x12')](_0xc8ef('0x13'),_0x56cfb1,_0xc8ef('0x14'));_0x574588(_0x29d96b[_0xc8ef('0x1b')][_0xc8ef('0x1a')]);}})[_0xc8ef('0x1c')](function(_0x3591c){logger['error'](_0xc8ef('0x13'),_0x56cfb1,_0x3591c);_0x45dbd3(_0x3591c);});});}exports['GetUser']=function(_0x3deec3){var _0x4c020e=this;return new Promise(function(_0x4648b1,_0x4ff970){return db[_0xc8ef('0x1d')][_0xc8ef('0x1e')]({'raw':_0x3deec3[_0xc8ef('0x1f')]?_0x3deec3[_0xc8ef('0x1f')][_0xc8ef('0x20')]===undefined?!![]:![]:!![],'where':_0x3deec3['options']?_0x3deec3[_0xc8ef('0x1f')][_0xc8ef('0x21')]||null:null,'attributes':_0x3deec3[_0xc8ef('0x1f')]?_0x3deec3['options'][_0xc8ef('0x22')]||null:null,'limit':_0x3deec3['options']?_0x3deec3['options']['limit']||null:null,'include':_0x3deec3['options']?_0x3deec3[_0xc8ef('0x1f')][_0xc8ef('0x23')]?_[_0xc8ef('0x24')](_0x3deec3[_0xc8ef('0x1f')][_0xc8ef('0x23')],function(_0x319c09){return{'model':db[_0x319c09[_0xc8ef('0x25')]],'as':_0x319c09['as'],'attributes':_0x319c09[_0xc8ef('0x22')],'include':_0x319c09[_0xc8ef('0x23')]?_[_0xc8ef('0x24')](_0x319c09[_0xc8ef('0x23')],function(_0x328a91){return{'model':db[_0x328a91[_0xc8ef('0x25')]],'as':_0x328a91['as'],'attributes':_0x328a91[_0xc8ef('0x22')],'include':_0x328a91['include']?_[_0xc8ef('0x24')](_0x328a91[_0xc8ef('0x23')],function(_0x522500){return{'model':db[_0x522500['model']],'as':_0x522500['as'],'attributes':_0x522500[_0xc8ef('0x22')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xe5e45b){logger['info'](_0xc8ef('0x26'),_0x3deec3);logger['debug'](_0xc8ef('0x26'),_0x3deec3,JSON[_0xc8ef('0x17')](_0xe5e45b));_0x4648b1(_0xe5e45b);})['catch'](function(_0x5f40c9){logger[_0xc8ef('0x18')](_0xc8ef('0x26'),_0x5f40c9['message'],_0x3deec3);_0x4ff970(_0x4c020e[_0xc8ef('0x18')](0x1f4,_0x5f40c9[_0xc8ef('0x1a')]));});});};exports[_0xc8ef('0x27')]=function(_0x3555f7){var _0x2985cc=this;return new Promise(function(_0xa46ce0,_0x2c2114){return db[_0xc8ef('0x1d')][_0xc8ef('0x28')]({'raw':_0x3555f7[_0xc8ef('0x1f')]?_0x3555f7[_0xc8ef('0x1f')][_0xc8ef('0x20')]===undefined?!![]:![]:!![],'where':_0x3555f7['options']?_0x3555f7[_0xc8ef('0x1f')][_0xc8ef('0x21')]||null:null,'attributes':_0x3555f7[_0xc8ef('0x1f')]?_0x3555f7[_0xc8ef('0x1f')]['attributes']||null:null,'include':_0x3555f7[_0xc8ef('0x1f')]?_0x3555f7[_0xc8ef('0x1f')]['include']?_[_0xc8ef('0x24')](_0x3555f7[_0xc8ef('0x1f')]['include'],function(_0x541e8c){return{'model':db[_0x541e8c[_0xc8ef('0x25')]],'as':_0x541e8c['as'],'attributes':_0x541e8c[_0xc8ef('0x22')],'include':_0x541e8c[_0xc8ef('0x23')]?_['map'](_0x541e8c['include'],function(_0x32dd28){return{'model':db[_0x32dd28[_0xc8ef('0x25')]],'as':_0x32dd28['as'],'attributes':_0x32dd28[_0xc8ef('0x22')],'include':_0x32dd28[_0xc8ef('0x23')]?_[_0xc8ef('0x24')](_0x32dd28['include'],function(_0x309495){return{'model':db[_0x309495[_0xc8ef('0x25')]],'as':_0x309495['as'],'attributes':_0x309495[_0xc8ef('0x22')]};}):[]};}):[]};}):[]:[]})[_0xc8ef('0x11')](function(_0x373ca1){logger[_0xc8ef('0x12')]('ShowUser',_0x3555f7);logger[_0xc8ef('0x15')](_0xc8ef('0x27'),_0x3555f7,JSON['stringify'](_0x373ca1));_0xa46ce0(_0x373ca1);})['catch'](function(_0x5ab0d4){logger['error'](_0xc8ef('0x27'),_0x5ab0d4['message'],_0x3555f7);_0x2c2114(_0x2985cc[_0xc8ef('0x18')](0x1f4,_0x5ab0d4[_0xc8ef('0x1a')]));});});};exports[_0xc8ef('0x29')]=function(_0x48398c){var _0x3f7b94=this;return new Promise(function(_0x38fe94,_0x37fd40){var _0xdefc03;return db['User'][_0xc8ef('0x28')]({'where':_0x48398c[_0xc8ef('0x1f')][_0xc8ef('0x21')]||{},'attributes':['id',_0xc8ef('0x2a'),'role','internal',_0xc8ef('0x2b')]})[_0xc8ef('0x11')](function(_0x27dfaf){if(_0x27dfaf){_0xdefc03=_0x27dfaf;return db[_0xc8ef('0x2c')][_0xc8ef('0x2d')]({'paused':0x1},{'where':{'UserId':_0xdefc03['id']},'individualHooks':!![]});}})['then'](function(){if(_0xdefc03){return db['MemberReport'][_0xc8ef('0x1e')]({'where':{'membername':_0xdefc03['name'],'type':_0xc8ef('0x2e'),'exitAt':null}});}})[_0xc8ef('0x11')](function(_0x441f52){if(_0xdefc03){if(_0x441f52&&_0x441f52['length']){var _0x2a612e=moment()[_0xc8ef('0x2f')]('YYYY-MM-DD\x20HH:mm:ss');for(var _0x3cd290=0x0,_0x4ebbe7=_0x441f52[_0xc8ef('0x30')];_0x3cd290<_0x4ebbe7;_0x3cd290++){_0x441f52[_0x3cd290][_0xc8ef('0x31')]({'exitAt':_0x2a612e});}}}})[_0xc8ef('0x11')](function(){if(_0xdefc03){var _0x585817=[];var _0x5b1ef1=utils['getChannels']();_0x5b1ef1[_0xc8ef('0x32')](function(_0x39fa06){_0x585817[_0xc8ef('0x33')]({'channel':_0x39fa06,'membername':_0xdefc03[_0xc8ef('0x2a')],'interface':_[_0xc8ef('0x34')](_0xdefc03[_0xc8ef('0x2b')])?util[_0xc8ef('0x2f')]('SIP/%s',_0xdefc03['name']):_0xdefc03[_0xc8ef('0x2b')],'type':_0xc8ef('0x2e'),'enterAt':moment()[_0xc8ef('0x2f')](_0xc8ef('0x35')),'data1':_0x48398c[_0xc8ef('0x36')]['type']||_0xc8ef('0x37'),'role':_0xdefc03[_0xc8ef('0x38')],'internal':_0xdefc03[_0xc8ef('0x39')],'uniqueid':_0x48398c[_0xc8ef('0x36')]['uniqueid']||null});});return db[_0xc8ef('0x3a')][_0xc8ef('0x3b')](_0x585817,{'individualHooks':!![]});}})[_0xc8ef('0x11')](function(){if(_0xdefc03){return _0xdefc03['update']({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'whatsappPause':!![],'pauseType':_0x48398c[_0xc8ef('0x36')]['type']||_0xc8ef('0x37'),'lastPauseAt':moment()['format'](_0xc8ef('0x35'))});}})[_0xc8ef('0x11')](function(_0x240de4){_0x38fe94(_0x240de4);})[_0xc8ef('0x1c')](function(_0xab53f3){_0x37fd40(_0x3f7b94[_0xc8ef('0x18')](0x1f4,_0xab53f3[_0xc8ef('0x1a')]));});});};exports[_0xc8ef('0x3c')]=function(_0x49eac5){var _0x411923=this;return new Promise(function(_0x32167f,_0x4be92d){var _0x587ddb;return db[_0xc8ef('0x1d')]['findOne']({'where':_0x49eac5[_0xc8ef('0x1f')]['where']||{},'attributes':['id',_0xc8ef('0x2a')]})['then'](function(_0x45e799){if(_0x45e799){_0x587ddb=_0x45e799;if(_0x49eac5[_0xc8ef('0x36')][_0xc8ef('0x3d')]&&!utils[_0xc8ef('0x3e')](_0x49eac5[_0xc8ef('0x36')]['channel'])){throw new Error(_0xc8ef('0x3f'));}switch(_0x49eac5[_0xc8ef('0x36')][_0xc8ef('0x3d')]){case _0xc8ef('0x40'):return db[_0xc8ef('0x2c')][_0xc8ef('0x2d')]({'paused':0x0},{'where':{'UserId':_0x587ddb['id']}})['then'](function(){return db['MemberReport'][_0xc8ef('0x28')]({'where':{'channel':_0x49eac5[_0xc8ef('0x36')]['channel'],'membername':_0x587ddb['name'],'type':_0xc8ef('0x2e'),'exitAt':null}});})[_0xc8ef('0x11')](function(_0x5c1c72){if(_0x5c1c72){return _0x5c1c72['update']({'exitAt':moment()[_0xc8ef('0x2f')](_0xc8ef('0x35')),'data2':_0xc8ef('0x41')},{'individualHooks':!![]});}return null;})[_0xc8ef('0x11')](function(){return _0x587ddb[_0xc8ef('0x2d')]({'voicePause':![]});});case'mail':case _0xc8ef('0x42'):case _0xc8ef('0x43'):case _0xc8ef('0x44'):case'openchannel':case'whatsapp':return db[_0xc8ef('0x3a')][_0xc8ef('0x28')]({'where':{'channel':_0x49eac5[_0xc8ef('0x36')][_0xc8ef('0x3d')],'membername':_0x587ddb[_0xc8ef('0x2a')],'type':_0xc8ef('0x2e'),'exitAt':null}})[_0xc8ef('0x11')](function(_0xe64c5){return _0xe64c5[_0xc8ef('0x2d')]({'exitAt':moment()['format'](_0xc8ef('0x35')),'data2':'system'},{'individualHooks':!![]});})[_0xc8ef('0x11')](function(){var _0x40607a={};_[_0xc8ef('0x45')](_0x40607a,util[_0xc8ef('0x2f')](_0xc8ef('0x46'),_0x49eac5[_0xc8ef('0x36')]['channel'],_0xc8ef('0x47')),![]);return _0x587ddb[_0xc8ef('0x2d')](_0x40607a);});default:return db[_0xc8ef('0x2c')][_0xc8ef('0x2d')]({'paused':0x0},{'where':{'UserId':_0x587ddb['id']}})[_0xc8ef('0x11')](function(){return db[_0xc8ef('0x3a')][_0xc8ef('0x1e')]({'where':{'membername':_0x587ddb[_0xc8ef('0x2a')],'type':_0xc8ef('0x2e'),'exitAt':null}});})[_0xc8ef('0x11')](function(_0x5128f2){var _0x2b6543=[];_0x5128f2[_0xc8ef('0x32')](function(_0x56f8cb){_0x2b6543[_0xc8ef('0x33')](_0x56f8cb['update']({'exitAt':moment()[_0xc8ef('0x2f')](_0xc8ef('0x35')),'data2':'system'}));});return BPromise[_0xc8ef('0x48')](_0x2b6543);})[_0xc8ef('0x11')](function(){return _0x587ddb[_0xc8ef('0x2d')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![]});});}}})['then'](function(_0x2ed3ea){_0x32167f(_0x2ed3ea);})[_0xc8ef('0x1c')](function(_0x1b9c37){_0x4be92d(_0x411923[_0xc8ef('0x18')](0x1f4,_0x1b9c37[_0xc8ef('0x1a')]));});});};exports['LogoutUser']=function(_0xd832de){var _0x1644e1=this;return new Promise(function(_0x704534,_0x26d9f1){var _0x41cab2;return db[_0xc8ef('0x1d')]['findOne']({'where':_0xd832de['options'][_0xc8ef('0x21')]||{},'attributes':['id',_0xc8ef('0x2a')]})[_0xc8ef('0x11')](function(_0x5928d9){if(_0x5928d9){_0x41cab2=_0x5928d9;return db[_0xc8ef('0x2c')][_0xc8ef('0x49')]({'where':{'membername':_0x41cab2['name']},'individualHooks':!![]});}})['then'](function(){if(_0x41cab2){return db['MemberReport'][_0xc8ef('0x1e')]({'where':{'membername':_0x41cab2[_0xc8ef('0x2a')],'exitAt':null}});}})[_0xc8ef('0x11')](function(_0x28a5c6){if(_0x41cab2){if(_0x28a5c6&&_0x28a5c6[_0xc8ef('0x30')]){var _0xf691bc=[];_0x28a5c6[_0xc8ef('0x32')](function(_0x32c5a6){_0xf691bc[_0xc8ef('0x33')](_0x32c5a6[_0xc8ef('0x2d')]({'exitAt':moment()['format'](_0xc8ef('0x35'))}));});return BPromise[_0xc8ef('0x48')](_0xf691bc);}}})[_0xc8ef('0x11')](function(){if(_0x41cab2){return _0x41cab2[_0xc8ef('0x2d')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});}})[_0xc8ef('0x11')](function(_0x405672){_0x704534(_0x405672);})['catch'](function(_0x38e239){_0x26d9f1(_0x1644e1['error'](0x1f4,_0x38e239['message']));});});};exports['LoginUser']=function(_0x20d3e5){var _0x24159f=this;return new Promise(function(_0x278159,_0x20c829){var _0x2229df;var _0x3b2301;var _0x4e7f87;var _0x1d1498;return db[_0xc8ef('0x1d')][_0xc8ef('0x4a')]({'where':_0x20d3e5[_0xc8ef('0x1f')]['where']||{},'attributes':['id',_0xc8ef('0x2a'),_0xc8ef('0x38'),_0xc8ef('0x4b'),'phone',_0xc8ef('0x39'),_0xc8ef('0x4c'),_0xc8ef('0x2b')]})[_0xc8ef('0x11')](function(_0x5ca85b){if(_0x5ca85b){_0x2229df=_0x5ca85b;_0x1d1498=_0x20d3e5['body']['interface']?_0x20d3e5[_0xc8ef('0x36')][_0xc8ef('0x2b')]:util[_0xc8ef('0x2f')](_0xc8ef('0x4d'),_0x2229df[_0xc8ef('0x2a')]);return db[_0xc8ef('0x1d')][_0xc8ef('0x4e')]({'where':{'role':'agent','online':!![],'id':{'$ne':_0x2229df['id']}}});}})[_0xc8ef('0x11')](function(_0x447d1c){if(_0x447d1c){_0x4e7f87=_0x447d1c;return require('../../config/license/util')[_0xc8ef('0x4f')]();}})[_0xc8ef('0x11')](function(_0x145697){if(_0x145697&&_0x145697[_0xc8ef('0x50')]&&_0x4e7f87>=_0x145697['agents']){throw new Error(_0xc8ef('0x51'));}})['then'](function(){if(_0x2229df){return db['UserVoiceQueueRt'][_0xc8ef('0x49')]({'where':{'membername':_0x2229df['name']},'individualHooks':!![]});}})[_0xc8ef('0x11')](function(){if(_0x2229df){return _0x2229df[_0xc8ef('0x52')]({'raw':!![]});}})['then'](function(_0x2c10f1){if(_0x2229df){if(_0x2c10f1){var _0x40e101=[];_0x3b2301=_0x2c10f1;if(_0x3b2301[_0xc8ef('0x30')]){for(var _0x4830e7=0x0;_0x4830e7<_0x3b2301[_0xc8ef('0x30')];_0x4830e7++){_0x40e101[_0xc8ef('0x33')](db['UserVoiceQueueRt'][_0xc8ef('0x53')]({'membername':_0x2229df[_0xc8ef('0x2a')],'UserId':_0x2229df['id'],'queue_name':_0x3b2301[_0x4830e7][_0xc8ef('0x2a')],'VoiceQueueId':_0x3b2301[_0x4830e7]['id'],'interface':_0x1d1498,'paused':_0x2229df[_0xc8ef('0x4c')]||![],'penalty':_0x3b2301[_0x4830e7][_0xc8ef('0x54')]||0x0}));}return BPromise['all'](_0x40e101);}}}})[_0xc8ef('0x11')](function(){if(_0x2229df){return db[_0xc8ef('0x3a')][_0xc8ef('0x1e')]({'where':{'membername':_0x2229df['name'],'exitAt':null}});}})[_0xc8ef('0x11')](function(_0x1bd7f0){if(_0x2229df){if(_0x1bd7f0&&_0x1bd7f0[_0xc8ef('0x30')]){var _0x4f67f4=[];_0x1bd7f0[_0xc8ef('0x32')](function(_0x204c41){_0x4f67f4['push'](_0x204c41['update']({'exitAt':moment()[_0xc8ef('0x2f')](_0xc8ef('0x35'))}));});return BPromise[_0xc8ef('0x48')](_0x4f67f4);}}})[_0xc8ef('0x11')](function(_0x584988){if(_0x2229df){var _0x5cbaa3=[];var _0x6b4180=[];var _0x457ca4=utils[_0xc8ef('0x55')]();var _0x734d4e={'membername':_0x2229df[_0xc8ef('0x2a')],'interface':_0x1d1498,'enterAt':moment()[_0xc8ef('0x2f')](_0xc8ef('0x35')),'role':_0x2229df[_0xc8ef('0x38')],'internal':_0x2229df['internal']};_0x457ca4['forEach'](function(_0x4a0795){_0x5cbaa3[_0xc8ef('0x33')](_[_0xc8ef('0x56')]({'channel':_0x4a0795,'type':'LOGIN','data1':_0xc8ef('0x57'),'data2':_0x1d1498},_0x734d4e));if(_0x2229df[_0xc8ef('0x4c')]){_0x6b4180[_0xc8ef('0x33')](_['merge']({'channel':_0x4a0795,'type':'PAUSE','data1':'LOGININPAUSE'},_0x734d4e));}});return db[_0xc8ef('0x3a')][_0xc8ef('0x3b')](_0x5cbaa3[_0xc8ef('0x58')](_0x6b4180),{'individualHooks':!![]});}})[_0xc8ef('0x11')](function(){if(_0x2229df){return _0x2229df[_0xc8ef('0x2d')]({'online':!![],'lastLoginAt':moment()[_0xc8ef('0x2f')]('YYYY-MM-DD\x20HH:mm:ss'),'voicePause':_0x2229df[_0xc8ef('0x4c')]||![],'mailPause':_0x2229df[_0xc8ef('0x4c')]||![],'chatPause':_0x2229df[_0xc8ef('0x4c')]||![],'faxPause':_0x2229df[_0xc8ef('0x4c')]||![],'smsPause':_0x2229df[_0xc8ef('0x4c')]||![],'openchannelPause':_0x2229df['loginInPause']||![],'pauseType':_0x2229df['loginInPause']?_0xc8ef('0x59'):null,'lastPauseAt':moment()[_0xc8ef('0x2f')](_0xc8ef('0x35')),'interface':_0x1d1498});}})[_0xc8ef('0x11')](function(_0x133392){_0x278159(_0x133392);})[_0xc8ef('0x1c')](function(_0x1d78ba){_0x20c829(_0x24159f[_0xc8ef('0x18')](0x1f4,_0x1d78ba[_0xc8ef('0x1a')]));});});};
\ No newline at end of file
+var _0x60a5=['length','format','YYYY-MM-DD\x20HH:mm:ss','updateAttributes','forEach','push','isNil','SIP/%s','DEFAULT\x20PAUSE','uniqueid','MemberReport','bulkCreate','body','type','findOne','channel','isValidChannel','Unknown\x20channel','voice','UserVoiceQueueRt','mail','chat','fax','sms','system','set','Pause','all','LogoutUser','destroy','role','mobile','phone','count','agent','getLicense','agents','upsert','loginInPause','UserVoiceQueue.penalty','getChannels','merge','callysquare','concat','lodash','bluebird','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','localhost','socket.io-emitter','redis','./user.socket','then','info','User,\x20%s,\x20%s','request\x20sent','debug','User,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetUser','User','findAll','options','raw','where','attributes','limit','map','model','include','catch','ShowUser','PauseUser','find','name','internal','interface','update','PAUSE'];(function(_0x1d5bfd,_0x25075b){var _0xd5b68d=function(_0x15802a){while(--_0x15802a){_0x1d5bfd['push'](_0x1d5bfd['shift']());}};_0xd5b68d(++_0x25075b);}(_0x60a5,0x83));var _0x560a=function(_0x46aff0,_0x122890){_0x46aff0=_0x46aff0-0x0;var _0x9d78cf=_0x60a5[_0x46aff0];return _0x9d78cf;};'use strict';var _=require(_0x560a('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x560a('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x560a('0x2'))['db'];var utils=require(_0x560a('0x3'));var logger=require(_0x560a('0x4'))('rpc');var config=require(_0x560a('0x5'));var jayson=require(_0x560a('0x6'));var client=jayson[_0x560a('0x7')]['http']({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':_0x560a('0x8'),'port':0x18eb});var socket=require(_0x560a('0x9'))(new Redis(config[_0x560a('0xa')]));require(_0x560a('0xb'))['register'](socket);function respondWithRpcPromise(_0x4c7a7a,_0x359da4,_0x5d95ee){return new BPromise(function(_0x2e3b88,_0x13c6a3){return client['request'](_0x4c7a7a,_0x5d95ee)[_0x560a('0xc')](function(_0x36e345){logger[_0x560a('0xd')](_0x560a('0xe'),_0x359da4,_0x560a('0xf'));logger[_0x560a('0x10')](_0x560a('0x11'),_0x359da4,_0x560a('0xf'),JSON[_0x560a('0x12')](_0x36e345));if(_0x36e345['error']){if(_0x36e345[_0x560a('0x13')][_0x560a('0x14')]===0x1f4){logger[_0x560a('0x13')]('User,\x20%s,\x20%s',_0x359da4,_0x36e345[_0x560a('0x13')][_0x560a('0x15')]);return _0x13c6a3(_0x36e345[_0x560a('0x13')][_0x560a('0x15')]);}logger['error'](_0x560a('0xe'),_0x359da4,_0x36e345[_0x560a('0x13')][_0x560a('0x15')]);return _0x2e3b88(_0x36e345[_0x560a('0x13')]['message']);}else{logger['info'](_0x560a('0xe'),_0x359da4,_0x560a('0xf'));_0x2e3b88(_0x36e345[_0x560a('0x16')][_0x560a('0x15')]);}})['catch'](function(_0x96deb7){logger[_0x560a('0x13')](_0x560a('0xe'),_0x359da4,_0x96deb7);_0x13c6a3(_0x96deb7);});});}exports[_0x560a('0x17')]=function(_0xe9be04){var _0x4807f2=this;return new Promise(function(_0x32ff83,_0x155c2b){return db[_0x560a('0x18')][_0x560a('0x19')]({'raw':_0xe9be04[_0x560a('0x1a')]?_0xe9be04[_0x560a('0x1a')][_0x560a('0x1b')]===undefined?!![]:![]:!![],'where':_0xe9be04['options']?_0xe9be04[_0x560a('0x1a')][_0x560a('0x1c')]||null:null,'attributes':_0xe9be04[_0x560a('0x1a')]?_0xe9be04[_0x560a('0x1a')][_0x560a('0x1d')]||null:null,'limit':_0xe9be04[_0x560a('0x1a')]?_0xe9be04[_0x560a('0x1a')][_0x560a('0x1e')]||null:null,'include':_0xe9be04['options']?_0xe9be04['options']['include']?_[_0x560a('0x1f')](_0xe9be04[_0x560a('0x1a')]['include'],function(_0x47b251){return{'model':db[_0x47b251[_0x560a('0x20')]],'as':_0x47b251['as'],'attributes':_0x47b251['attributes'],'include':_0x47b251[_0x560a('0x21')]?_[_0x560a('0x1f')](_0x47b251['include'],function(_0x6ad203){return{'model':db[_0x6ad203[_0x560a('0x20')]],'as':_0x6ad203['as'],'attributes':_0x6ad203['attributes'],'include':_0x6ad203[_0x560a('0x21')]?_[_0x560a('0x1f')](_0x6ad203[_0x560a('0x21')],function(_0x305bd9){return{'model':db[_0x305bd9[_0x560a('0x20')]],'as':_0x305bd9['as'],'attributes':_0x305bd9['attributes']};}):[]};}):[]};}):[]:[]})[_0x560a('0xc')](function(_0x3c4af2){logger['info'](_0x560a('0x17'),_0xe9be04);logger[_0x560a('0x10')](_0x560a('0x17'),_0xe9be04,JSON[_0x560a('0x12')](_0x3c4af2));_0x32ff83(_0x3c4af2);})[_0x560a('0x22')](function(_0x226c9c){logger[_0x560a('0x13')]('GetUser',_0x226c9c[_0x560a('0x15')],_0xe9be04);_0x155c2b(_0x4807f2[_0x560a('0x13')](0x1f4,_0x226c9c['message']));});});};exports['ShowUser']=function(_0x16bccd){var _0x465418=this;return new Promise(function(_0x155e3e,_0x546f45){return db['User']['find']({'raw':_0x16bccd['options']?_0x16bccd[_0x560a('0x1a')][_0x560a('0x1b')]===undefined?!![]:![]:!![],'where':_0x16bccd[_0x560a('0x1a')]?_0x16bccd[_0x560a('0x1a')][_0x560a('0x1c')]||null:null,'attributes':_0x16bccd[_0x560a('0x1a')]?_0x16bccd[_0x560a('0x1a')][_0x560a('0x1d')]||null:null,'include':_0x16bccd[_0x560a('0x1a')]?_0x16bccd[_0x560a('0x1a')]['include']?_[_0x560a('0x1f')](_0x16bccd[_0x560a('0x1a')][_0x560a('0x21')],function(_0x2b3c21){return{'model':db[_0x2b3c21[_0x560a('0x20')]],'as':_0x2b3c21['as'],'attributes':_0x2b3c21['attributes'],'include':_0x2b3c21['include']?_[_0x560a('0x1f')](_0x2b3c21[_0x560a('0x21')],function(_0x4388f4){return{'model':db[_0x4388f4[_0x560a('0x20')]],'as':_0x4388f4['as'],'attributes':_0x4388f4[_0x560a('0x1d')],'include':_0x4388f4['include']?_[_0x560a('0x1f')](_0x4388f4[_0x560a('0x21')],function(_0x4c027e){return{'model':db[_0x4c027e[_0x560a('0x20')]],'as':_0x4c027e['as'],'attributes':_0x4c027e[_0x560a('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x560a('0xc')](function(_0x384f39){logger[_0x560a('0xd')](_0x560a('0x23'),_0x16bccd);logger['debug'](_0x560a('0x23'),_0x16bccd,JSON[_0x560a('0x12')](_0x384f39));_0x155e3e(_0x384f39);})[_0x560a('0x22')](function(_0x30fa04){logger['error'](_0x560a('0x23'),_0x30fa04['message'],_0x16bccd);_0x546f45(_0x465418[_0x560a('0x13')](0x1f4,_0x30fa04[_0x560a('0x15')]));});});};exports[_0x560a('0x24')]=function(_0x21b999){var _0x329f01=this;return new Promise(function(_0x8f8f84,_0xc562ac){var _0x2c01c0;return db[_0x560a('0x18')][_0x560a('0x25')]({'where':_0x21b999[_0x560a('0x1a')][_0x560a('0x1c')]||{},'attributes':['id',_0x560a('0x26'),'role',_0x560a('0x27'),_0x560a('0x28')]})[_0x560a('0xc')](function(_0x175719){if(_0x175719){_0x2c01c0=_0x175719;return db['UserVoiceQueueRt'][_0x560a('0x29')]({'paused':0x1},{'where':{'UserId':_0x2c01c0['id']},'individualHooks':!![]});}})['then'](function(){if(_0x2c01c0){return db['MemberReport'][_0x560a('0x19')]({'where':{'membername':_0x2c01c0[_0x560a('0x26')],'type':_0x560a('0x2a'),'exitAt':null}});}})[_0x560a('0xc')](function(_0x1a1d3a){if(_0x2c01c0){if(_0x1a1d3a&&_0x1a1d3a[_0x560a('0x2b')]){var _0x4b245d=moment()[_0x560a('0x2c')](_0x560a('0x2d'));for(var _0x4eb404=0x0,_0x50a2b6=_0x1a1d3a['length'];_0x4eb404<_0x50a2b6;_0x4eb404++){_0x1a1d3a[_0x4eb404][_0x560a('0x2e')]({'exitAt':_0x4b245d});}}}})[_0x560a('0xc')](function(){if(_0x2c01c0){var _0xa7d1a=[];var _0x4813b3=utils['getChannels']();_0x4813b3[_0x560a('0x2f')](function(_0x4e52c3){_0xa7d1a[_0x560a('0x30')]({'channel':_0x4e52c3,'membername':_0x2c01c0[_0x560a('0x26')],'interface':_[_0x560a('0x31')](_0x2c01c0['interface'])?util[_0x560a('0x2c')](_0x560a('0x32'),_0x2c01c0[_0x560a('0x26')]):_0x2c01c0['interface'],'type':_0x560a('0x2a'),'enterAt':moment()[_0x560a('0x2c')](_0x560a('0x2d')),'data1':_0x21b999['body']['type']||_0x560a('0x33'),'role':_0x2c01c0['role'],'internal':_0x2c01c0[_0x560a('0x27')],'uniqueid':_0x21b999['body'][_0x560a('0x34')]||null});});return db[_0x560a('0x35')][_0x560a('0x36')](_0xa7d1a,{'individualHooks':!![]});}})[_0x560a('0xc')](function(){if(_0x2c01c0){return _0x2c01c0[_0x560a('0x29')]({'voicePause':!![],'mailPause':!![],'chatPause':!![],'faxPause':!![],'smsPause':!![],'openchannelPause':!![],'whatsappPause':!![],'pauseType':_0x21b999[_0x560a('0x37')][_0x560a('0x38')]||_0x560a('0x33'),'lastPauseAt':moment()['format'](_0x560a('0x2d'))});}})['then'](function(_0x580999){_0x8f8f84(_0x580999);})[_0x560a('0x22')](function(_0xdf1613){_0xc562ac(_0x329f01[_0x560a('0x13')](0x1f4,_0xdf1613[_0x560a('0x15')]));});});};exports['UnpauseUser']=function(_0x563f94){var _0x211111=this;return new Promise(function(_0x5ab3f0,_0x3f8a48){var _0x2146ca;return db['User'][_0x560a('0x39')]({'where':_0x563f94[_0x560a('0x1a')][_0x560a('0x1c')]||{},'attributes':['id',_0x560a('0x26')]})['then'](function(_0x38dae1){if(_0x38dae1){_0x2146ca=_0x38dae1;if(_0x563f94[_0x560a('0x37')][_0x560a('0x3a')]&&!utils[_0x560a('0x3b')](_0x563f94['body'][_0x560a('0x3a')])){throw new Error(_0x560a('0x3c'));}switch(_0x563f94[_0x560a('0x37')][_0x560a('0x3a')]){case _0x560a('0x3d'):return db[_0x560a('0x3e')][_0x560a('0x29')]({'paused':0x0},{'where':{'UserId':_0x2146ca['id']}})[_0x560a('0xc')](function(){return db['MemberReport'][_0x560a('0x25')]({'where':{'channel':_0x563f94[_0x560a('0x37')][_0x560a('0x3a')],'membername':_0x2146ca[_0x560a('0x26')],'type':'PAUSE','exitAt':null}});})[_0x560a('0xc')](function(_0x5eb025){if(_0x5eb025){return _0x5eb025[_0x560a('0x29')]({'exitAt':moment()['format'](_0x560a('0x2d')),'data2':'system'},{'individualHooks':!![]});}return null;})[_0x560a('0xc')](function(){return _0x2146ca[_0x560a('0x29')]({'voicePause':![]});});case _0x560a('0x3f'):case _0x560a('0x40'):case _0x560a('0x41'):case _0x560a('0x42'):case'openchannel':case'whatsapp':return db[_0x560a('0x35')][_0x560a('0x25')]({'where':{'channel':_0x563f94[_0x560a('0x37')][_0x560a('0x3a')],'membername':_0x2146ca[_0x560a('0x26')],'type':_0x560a('0x2a'),'exitAt':null}})[_0x560a('0xc')](function(_0x178f7a){return _0x178f7a[_0x560a('0x29')]({'exitAt':moment()['format'](_0x560a('0x2d')),'data2':_0x560a('0x43')},{'individualHooks':!![]});})['then'](function(){var _0x131744={};_[_0x560a('0x44')](_0x131744,util[_0x560a('0x2c')]('%s%s',_0x563f94[_0x560a('0x37')]['channel'],_0x560a('0x45')),![]);return _0x2146ca[_0x560a('0x29')](_0x131744);});default:return db[_0x560a('0x3e')]['update']({'paused':0x0},{'where':{'UserId':_0x2146ca['id']}})[_0x560a('0xc')](function(){return db[_0x560a('0x35')][_0x560a('0x19')]({'where':{'membername':_0x2146ca[_0x560a('0x26')],'type':'PAUSE','exitAt':null}});})[_0x560a('0xc')](function(_0x6361d5){var _0x234c5b=[];_0x6361d5['forEach'](function(_0x23fdd4){_0x234c5b['push'](_0x23fdd4['update']({'exitAt':moment()['format'](_0x560a('0x2d')),'data2':_0x560a('0x43')}));});return BPromise[_0x560a('0x46')](_0x234c5b);})[_0x560a('0xc')](function(){return _0x2146ca[_0x560a('0x29')]({'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![],'whatsappPause':![]});});}}})[_0x560a('0xc')](function(_0x7e602e){_0x5ab3f0(_0x7e602e);})['catch'](function(_0x27384b){_0x3f8a48(_0x211111[_0x560a('0x13')](0x1f4,_0x27384b[_0x560a('0x15')]));});});};exports[_0x560a('0x47')]=function(_0x50c05c){var _0x3e0314=this;return new Promise(function(_0x3e8800,_0x2dfad1){var _0x2ea8b8;return db[_0x560a('0x18')][_0x560a('0x39')]({'where':_0x50c05c[_0x560a('0x1a')]['where']||{},'attributes':['id',_0x560a('0x26')]})['then'](function(_0x3874d2){if(_0x3874d2){_0x2ea8b8=_0x3874d2;return db['UserVoiceQueueRt'][_0x560a('0x48')]({'where':{'membername':_0x2ea8b8[_0x560a('0x26')]},'individualHooks':!![]});}})[_0x560a('0xc')](function(){if(_0x2ea8b8){return db['MemberReport'][_0x560a('0x19')]({'where':{'membername':_0x2ea8b8[_0x560a('0x26')],'exitAt':null}});}})[_0x560a('0xc')](function(_0x1c161a){if(_0x2ea8b8){if(_0x1c161a&&_0x1c161a['length']){var _0x745abe=[];_0x1c161a[_0x560a('0x2f')](function(_0x326a69){_0x745abe[_0x560a('0x30')](_0x326a69[_0x560a('0x29')]({'exitAt':moment()['format'](_0x560a('0x2d'))}));});return BPromise['all'](_0x745abe);}}})[_0x560a('0xc')](function(){if(_0x2ea8b8){return _0x2ea8b8[_0x560a('0x29')]({'online':![],'lastLoginAt':null,'voicePause':![],'mailPause':![],'chatPause':![],'faxPause':![],'smsPause':![],'openchannelPause':![]});}})[_0x560a('0xc')](function(_0x5c6bfe){_0x3e8800(_0x5c6bfe);})[_0x560a('0x22')](function(_0x15a58d){_0x2dfad1(_0x3e0314[_0x560a('0x13')](0x1f4,_0x15a58d[_0x560a('0x15')]));});});};exports['LoginUser']=function(_0x5f305a){var _0x52facf=this;return new Promise(function(_0x5dd836,_0x118cb8){var _0x38feb5;var _0x8c479f;var _0x5075b0;var _0xb992b3;return db[_0x560a('0x18')][_0x560a('0x39')]({'where':_0x5f305a[_0x560a('0x1a')][_0x560a('0x1c')]||{},'attributes':['id',_0x560a('0x26'),_0x560a('0x49'),_0x560a('0x4a'),_0x560a('0x4b'),_0x560a('0x27'),'loginInPause',_0x560a('0x28')]})[_0x560a('0xc')](function(_0x2a1eae){if(_0x2a1eae){_0x38feb5=_0x2a1eae;_0xb992b3=_0x5f305a[_0x560a('0x37')][_0x560a('0x28')]?_0x5f305a[_0x560a('0x37')]['interface']:util['format'](_0x560a('0x32'),_0x38feb5[_0x560a('0x26')]);return db['User'][_0x560a('0x4c')]({'where':{'role':_0x560a('0x4d'),'online':!![],'id':{'$ne':_0x38feb5['id']}}});}})[_0x560a('0xc')](function(_0x1b5d07){if(_0x1b5d07){_0x5075b0=_0x1b5d07;return require('../../config/license/util')[_0x560a('0x4e')]();}})[_0x560a('0xc')](function(_0x3ec18c){if(_0x3ec18c&&_0x3ec18c[_0x560a('0x4f')]&&_0x5075b0>=_0x3ec18c[_0x560a('0x4f')]){throw new Error('Maximum\x20login\x20has\x20been\x20reached');}})[_0x560a('0xc')](function(){if(_0x38feb5){return db[_0x560a('0x3e')][_0x560a('0x48')]({'where':{'membername':_0x38feb5[_0x560a('0x26')]},'individualHooks':!![]});}})[_0x560a('0xc')](function(){if(_0x38feb5){return _0x38feb5['getVoiceQueues']({'raw':!![]});}})[_0x560a('0xc')](function(_0x306546){if(_0x38feb5){if(_0x306546){var _0x1e9d4b=[];_0x8c479f=_0x306546;if(_0x8c479f[_0x560a('0x2b')]){for(var _0x29daba=0x0;_0x29daba<_0x8c479f[_0x560a('0x2b')];_0x29daba++){_0x1e9d4b['push'](db['UserVoiceQueueRt'][_0x560a('0x50')]({'membername':_0x38feb5[_0x560a('0x26')],'UserId':_0x38feb5['id'],'queue_name':_0x8c479f[_0x29daba][_0x560a('0x26')],'VoiceQueueId':_0x8c479f[_0x29daba]['id'],'interface':_0xb992b3,'paused':_0x38feb5[_0x560a('0x51')]||![],'penalty':_0x8c479f[_0x29daba][_0x560a('0x52')]||0x0}));}return BPromise[_0x560a('0x46')](_0x1e9d4b);}}}})[_0x560a('0xc')](function(){if(_0x38feb5){return db[_0x560a('0x35')][_0x560a('0x19')]({'where':{'membername':_0x38feb5['name'],'exitAt':null}});}})['then'](function(_0x402606){if(_0x38feb5){if(_0x402606&&_0x402606[_0x560a('0x2b')]){var _0x16a9ce=[];_0x402606['forEach'](function(_0xbda73e){_0x16a9ce['push'](_0xbda73e[_0x560a('0x29')]({'exitAt':moment()[_0x560a('0x2c')](_0x560a('0x2d'))}));});return BPromise[_0x560a('0x46')](_0x16a9ce);}}})[_0x560a('0xc')](function(_0x198a85){if(_0x38feb5){var _0x16d150=[];var _0x29f194=[];var _0x42ef64=utils[_0x560a('0x53')]();var _0x5ac917={'membername':_0x38feb5['name'],'interface':_0xb992b3,'enterAt':moment()['format'](_0x560a('0x2d')),'role':_0x38feb5['role'],'internal':_0x38feb5['internal']};_0x42ef64[_0x560a('0x2f')](function(_0x42266e){_0x16d150[_0x560a('0x30')](_[_0x560a('0x54')]({'channel':_0x42266e,'type':'LOGIN','data1':_0x560a('0x55'),'data2':_0xb992b3},_0x5ac917));if(_0x38feb5[_0x560a('0x51')]){_0x29f194[_0x560a('0x30')](_[_0x560a('0x54')]({'channel':_0x42266e,'type':_0x560a('0x2a'),'data1':'LOGININPAUSE'},_0x5ac917));}});return db['MemberReport'][_0x560a('0x36')](_0x16d150[_0x560a('0x56')](_0x29f194),{'individualHooks':!![]});}})['then'](function(){if(_0x38feb5){return _0x38feb5[_0x560a('0x29')]({'online':!![],'lastLoginAt':moment()['format'](_0x560a('0x2d')),'voicePause':_0x38feb5[_0x560a('0x51')]||![],'mailPause':_0x38feb5[_0x560a('0x51')]||![],'chatPause':_0x38feb5[_0x560a('0x51')]||![],'faxPause':_0x38feb5[_0x560a('0x51')]||![],'smsPause':_0x38feb5[_0x560a('0x51')]||![],'openchannelPause':_0x38feb5[_0x560a('0x51')]||![],'pauseType':_0x38feb5[_0x560a('0x51')]?'LOGININPAUSE':null,'lastPauseAt':moment()[_0x560a('0x2c')](_0x560a('0x2d')),'interface':_0xb992b3});}})[_0x560a('0xc')](function(_0x4cd8f8){_0x5dd836(_0x4cd8f8);})['catch'](function(_0x340611){_0x118cb8(_0x52facf[_0x560a('0x13')](0x1f4,_0x340611['message']));});});};
\ No newline at end of file