Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / chatQueue / chatQueue.controller.js
index 057dd35..94b5de3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x457f=['field','from','team_has_chat_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','clone','push','sequelize','QueryTypes','SELECT','every','TeamId','union','compact','ids','isEmpty','removeAgents','userChatQueue:remove','addAgents','spread','isArray','getAgents','bluebird','util','lodash','squel','ioredis','../../config/logger','api','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./chatQueue.socket','register','sendStatus','end','status','json','offset','limit','undefined','count','set','Content-Range','then','destroy','get','ChatQueues','error','stack','name','send','index','map','ChatQueue','rawAttributes','type','key','getOptions','where','include','query','findAll','catch','show','model','keys','filters','intersection','attributes','fields','length','merge','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','describe','getMembers','findOne','hasOwnProperty','nolimit','order','sort','pick','filter','UserChatQueue','User','findAndCountAll','chatPause','createdAt','rows','format','%s/%s','SIP','updatedAt','getTeams','options','addTeams','Agents','online','voicePause','flatMap','transaction','each','findOrCreate','forEach','emit','userChatQueue:save','removeTeams','Team','select'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x457f,0x18b));var _0xf457=function(_0x150e01,_0x3fd606){_0x150e01=_0x150e01-0x0;var _0x174a2d=_0x457f[_0x150e01];return _0x174a2d;};'use strict';var BPromise=require(_0xf457('0x0'));var util=require(_0xf457('0x1'));var _=require(_0xf457('0x2'));var squel=require(_0xf457('0x3'));var Redis=require(_0xf457('0x4'));var qs=require('../../components/parsers/qs');var logger=require(_0xf457('0x5'))(_0xf457('0x6'));var config=require(_0xf457('0x7'));var db=require(_0xf457('0x8'))['db'];config[_0xf457('0x9')]=_['defaults'](config[_0xf457('0x9')],{'host':_0xf457('0xa'),'port':0x18eb});var socket=require(_0xf457('0xb'))(new Redis(config[_0xf457('0x9')]));require(_0xf457('0xc'))[_0xf457('0xd')](socket);function respondWithStatusCode(_0x21f323,_0x5eb880){_0x5eb880=_0x5eb880||0xcc;return function(_0x3e195d){if(_0x3e195d){return _0x21f323[_0xf457('0xe')](_0x5eb880);}return _0x21f323['status'](_0x5eb880)[_0xf457('0xf')]();};}function respondWithResult(_0x5cb88e,_0x12a9b6){_0x12a9b6=_0x12a9b6||0xc8;return function(_0x13848c){if(_0x13848c){return _0x5cb88e[_0xf457('0x10')](_0x12a9b6)[_0xf457('0x11')](_0x13848c);}};}function respondWithFilteredResult(_0x25efe2,_0x2f29dd){return function(_0x5bde9a){if(_0x5bde9a){var _0x1c7f8e=typeof _0x2f29dd[_0xf457('0x12')]==='undefined'&&typeof _0x2f29dd[_0xf457('0x13')]===_0xf457('0x14');var _0x1718dd=_0x5bde9a['count'];var _0x255120=_0x1c7f8e?0x0:_0x2f29dd[_0xf457('0x12')];var _0x3ab74a=_0x1c7f8e?_0x5bde9a[_0xf457('0x15')]:_0x2f29dd['offset']+_0x2f29dd[_0xf457('0x13')];var _0x5f3359;if(_0x3ab74a>=_0x1718dd){_0x3ab74a=_0x1718dd;_0x5f3359=0xc8;}else{_0x5f3359=0xce;}_0x25efe2[_0xf457('0x10')](_0x5f3359);return _0x25efe2[_0xf457('0x16')](_0xf457('0x17'),_0x255120+'-'+_0x3ab74a+'/'+_0x1718dd)[_0xf457('0x11')](_0x5bde9a);}return null;};}function saveUpdates(_0x4c4b61){return function(_0x24f294){if(_0x24f294){return _0x24f294['update'](_0x4c4b61)[_0xf457('0x18')](function(_0x11e7d1){return _0x11e7d1;});}return null;};}function removeEntity(_0x5a8bad){return function(_0x3bf9b9){if(_0x3bf9b9){return _0x3bf9b9[_0xf457('0x19')]()[_0xf457('0x18')](function(){var _0x6608e4=_0x3bf9b9[_0xf457('0x1a')]({'plain':!![]});var _0x4d68e3=_0xf457('0x1b');return db['UserProfileResource']['destroy']({'where':{'type':_0x4d68e3,'resourceId':_0x6608e4['id']}})['then'](function(){return _0x3bf9b9;});})[_0xf457('0x18')](function(){_0x5a8bad[_0xf457('0x10')](0xcc)[_0xf457('0xf')]();});}};}function handleEntityNotFound(_0x57f491){return function(_0x396a86){if(!_0x396a86){_0x57f491[_0xf457('0xe')](0x194);}return _0x396a86;};}function handleError(_0x51933f,_0x11fd9d){_0x11fd9d=_0x11fd9d||0x1f4;return function(_0x5c7035){logger[_0xf457('0x1c')](_0x5c7035[_0xf457('0x1d')]);if(_0x5c7035[_0xf457('0x1e')]){delete _0x5c7035[_0xf457('0x1e')];}_0x51933f['status'](_0x11fd9d)[_0xf457('0x1f')](_0x5c7035);};}exports[_0xf457('0x20')]=function(_0x37f398,_0xb8414c){var _0xb9e7c4={};var _0x176ae3={'count':0x0,'rows':[]};var _0x30e8f2=_[_0xf457('0x21')](db[_0xf457('0x22')][_0xf457('0x23')],function(_0x1e214d){return{'name':_0x1e214d['fieldName'],'type':_0x1e214d[_0xf457('0x24')][_0xf457('0x25')]};});_0xb9e7c4=qs[_0xf457('0x26')](_0x30e8f2,_0x37f398);var _0x2ba9e0={'where':_0xb9e7c4[_0xf457('0x27')]};return db[_0xf457('0x22')][_0xf457('0x15')](_0x2ba9e0)[_0xf457('0x18')](function(_0x2d4bda){_0x176ae3[_0xf457('0x15')]=_0x2d4bda;_0xb9e7c4['include']=qs[_0xf457('0x28')](_0x37f398[_0xf457('0x29')]);return db[_0xf457('0x22')][_0xf457('0x2a')](_0xb9e7c4);})['then'](function(_0x2c1f98){_0x176ae3['rows']=_0x2c1f98;return _0x176ae3;})[_0xf457('0x18')](respondWithFilteredResult(_0xb8414c,_0xb9e7c4))[_0xf457('0x2b')](handleError(_0xb8414c,null));};exports[_0xf457('0x2c')]=function(_0x2b4f02,_0x2256c2){var _0x117e5d={'raw':!![],'where':{'id':_0x2b4f02['params']['id']}},_0x5289e8={};_0x5289e8[_0xf457('0x2d')]=_[_0xf457('0x2e')](db[_0xf457('0x22')][_0xf457('0x23')]);_0x5289e8[_0xf457('0x29')]=_['keys'](_0x2b4f02[_0xf457('0x29')]);_0x5289e8[_0xf457('0x2f')]=_[_0xf457('0x30')](_0x5289e8[_0xf457('0x2d')],_0x5289e8[_0xf457('0x29')]);_0x117e5d[_0xf457('0x31')]=_[_0xf457('0x30')](_0x5289e8[_0xf457('0x2d')],qs['fields'](_0x2b4f02[_0xf457('0x29')][_0xf457('0x32')]));_0x117e5d[_0xf457('0x31')]=_0x117e5d[_0xf457('0x31')][_0xf457('0x33')]?_0x117e5d[_0xf457('0x31')]:_0x5289e8[_0xf457('0x2d')];if(_0x2b4f02[_0xf457('0x29')]['includeAll']){_0x117e5d[_0xf457('0x28')]=[{'all':!![]}];}_0x117e5d=_[_0xf457('0x34')]({},_0x117e5d,_0x2b4f02['options']);return db['ChatQueue'][_0xf457('0x35')](_0x117e5d)[_0xf457('0x18')](handleEntityNotFound(_0x2256c2,null))[_0xf457('0x18')](respondWithResult(_0x2256c2,null))[_0xf457('0x2b')](handleError(_0x2256c2,null));};exports[_0xf457('0x36')]=function(_0x4537d1,_0x5e4474){return db[_0xf457('0x22')][_0xf457('0x36')](_0x4537d1[_0xf457('0x37')],{})['then'](function(_0x539468){var _0x4a58c1=_0x4537d1[_0xf457('0x38')][_0xf457('0x1a')]({'plain':!![]});if(!_0x4a58c1)throw new Error(_0xf457('0x39'));if(_0x4a58c1[_0xf457('0x3a')]===_0xf457('0x38')){var _0x3141c1=_0x539468[_0xf457('0x1a')]({'plain':!![]});var _0x2b64a6=_0xf457('0x1b');return db[_0xf457('0x3b')][_0xf457('0x35')]({'where':{'name':_0x2b64a6,'userProfileId':_0x4a58c1[_0xf457('0x3c')]},'raw':!![]})[_0xf457('0x18')](function(_0x505da9){if(_0x505da9&&_0x505da9[_0xf457('0x3d')]===0x0){return db[_0xf457('0x3e')]['create']({'name':_0x3141c1[_0xf457('0x1e')],'resourceId':_0x3141c1['id'],'type':_0x505da9[_0xf457('0x1e')],'sectionId':_0x505da9['id']},{})['then'](function(){return _0x539468;});}else{return _0x539468;}})[_0xf457('0x2b')](function(_0x1c65ef){logger[_0xf457('0x1c')](_0xf457('0x3f'),_0x1c65ef);throw _0x1c65ef;});}return _0x539468;})[_0xf457('0x18')](respondWithResult(_0x5e4474,0xc9))['catch'](handleError(_0x5e4474,null));};exports[_0xf457('0x40')]=function(_0x19f1ad,_0x393d27){if(_0x19f1ad[_0xf457('0x37')]['id']){delete _0x19f1ad['body']['id'];}return db[_0xf457('0x22')][_0xf457('0x35')]({'where':{'id':_0x19f1ad['params']['id']}})[_0xf457('0x18')](handleEntityNotFound(_0x393d27,null))['then'](saveUpdates(_0x19f1ad['body'],null))[_0xf457('0x18')](respondWithResult(_0x393d27,null))['catch'](handleError(_0x393d27,null));};exports[_0xf457('0x19')]=function(_0x2fcb45,_0x22ca76){return db['ChatQueue']['find']({'where':{'id':_0x2fcb45[_0xf457('0x41')]['id']}})['then'](handleEntityNotFound(_0x22ca76,null))['then'](removeEntity(_0x22ca76,null))[_0xf457('0x2b')](handleError(_0x22ca76,null));};exports[_0xf457('0x42')]=function(_0xdf7a1,_0x1bdb1d){return db['ChatQueue']['describe']()[_0xf457('0x18')](respondWithResult(_0x1bdb1d,null))[_0xf457('0x2b')](handleError(_0x1bdb1d,null));};exports[_0xf457('0x43')]=function(_0xbc4d3f,_0x335b25){var _0x2f1dbe={'raw':!![],'where':{}},_0x2698cb={},_0xdb7060;return db[_0xf457('0x22')][_0xf457('0x44')]({'where':{'id':_0xbc4d3f[_0xf457('0x41')]['id']}})[_0xf457('0x18')](handleEntityNotFound(_0x335b25,null))['then'](function(_0xa807c3){if(_0xa807c3){_0xdb7060=_0xa807c3[_0xf457('0x1a')]({'plain':!![]});_0x2698cb[_0xf457('0x2d')]=_[_0xf457('0x2e')](db['UserChatQueue']['rawAttributes']);_0x2698cb['query']=_['keys'](_0xbc4d3f['query']);_0x2698cb[_0xf457('0x2f')]=_[_0xf457('0x30')](_0x2698cb[_0xf457('0x2d')],_0x2698cb[_0xf457('0x29')]);_0x2f1dbe[_0xf457('0x31')]=_['intersection'](_0x2698cb[_0xf457('0x2d')],qs[_0xf457('0x32')](_0xbc4d3f[_0xf457('0x29')][_0xf457('0x32')]));_0x2f1dbe['attributes']=_0x2f1dbe[_0xf457('0x31')][_0xf457('0x33')]?_0x2f1dbe[_0xf457('0x31')]:_0x2698cb['model'];if(!_0xbc4d3f['query'][_0xf457('0x45')](_0xf457('0x46'))){_0x2f1dbe['limit']=qs['limit'](_0xbc4d3f['query'][_0xf457('0x13')]);_0x2f1dbe[_0xf457('0x12')]=qs[_0xf457('0x12')](_0xbc4d3f[_0xf457('0x29')][_0xf457('0x12')]);}_0x2f1dbe[_0xf457('0x47')]=qs[_0xf457('0x48')](_0xbc4d3f['query'][_0xf457('0x48')]);_0x2f1dbe[_0xf457('0x27')]=qs[_0xf457('0x2f')](_[_0xf457('0x49')](_0xbc4d3f[_0xf457('0x29')],_0x2698cb[_0xf457('0x2f')]));_0x2f1dbe[_0xf457('0x27')]['ChatQueueId']=_0xa807c3['id'];if(_0xbc4d3f[_0xf457('0x29')]['filter']){_0x2f1dbe[_0xf457('0x27')]=_[_0xf457('0x34')](_0x2f1dbe[_0xf457('0x27')],{'$or':_[_0xf457('0x21')](_0x2f1dbe[_0xf457('0x31')],function(_0x1e6c6a){var _0x482589={};_0x482589[_0x1e6c6a]={'$like':'%'+_0xbc4d3f['query'][_0xf457('0x4a')]+'%'};return _0x482589;})});}_0x2f1dbe=_[_0xf457('0x34')]({},_0x2f1dbe,_0xbc4d3f['options']);return db[_0xf457('0x4b')][_0xf457('0x2a')](_0x2f1dbe);}})[_0xf457('0x18')](function(_0x4bf555){if(_0x4bf555){return db[_0xf457('0x4c')][_0xf457('0x4d')]({'where':{'id':_[_0xf457('0x21')](_0x4bf555,'UserId'),'role':'agent'},'attributes':['id',_0xf457('0x1e'),_0xf457('0x4e'),'updatedAt',_0xf457('0x4f')]});}})[_0xf457('0x18')](function(_0x39223a){if(_0x39223a){return{'count':_0x39223a[_0xf457('0x15')],'rows':_['map'](_0x39223a[_0xf457('0x50')],function(_0x199b6c){return{'membername':_0x199b6c[_0xf457('0x1e')],'UserId':_0x199b6c['id'],'queue_name':_0xdb7060[_0xf457('0x1e')],'ChatQueueId':_0xdb7060['id'],'interface':util[_0xf457('0x51')](_0xf457('0x52'),_0xf457('0x53'),_0x199b6c[_0xf457('0x1e')]),'penalty':0x0,'paused':_0x199b6c[_0xf457('0x4e')],'createdAt':_0x199b6c[_0xf457('0x4f')],'updatedAt':_0x199b6c[_0xf457('0x54')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xf457('0x18')](respondWithFilteredResult(_0x335b25,_0x2f1dbe))[_0xf457('0x2b')](handleError(_0x335b25,null));};exports[_0xf457('0x55')]=function(_0x4d5bdc,_0x4fe83b){var _0x5dd23c={};var _0x1156ae={};var _0x4213f0;var _0xb41770;return db['ChatQueue']['findOne']({'where':{'id':_0x4d5bdc[_0xf457('0x41')]['id']}})['then'](handleEntityNotFound(_0x4fe83b,null))[_0xf457('0x18')](function(_0x2f6ec0){if(_0x2f6ec0){_0x4213f0=_0x2f6ec0;_0x1156ae['model']=_['keys'](db['Team']['rawAttributes']);_0x1156ae[_0xf457('0x29')]=_[_0xf457('0x2e')](_0x4d5bdc[_0xf457('0x29')]);_0x1156ae[_0xf457('0x2f')]=_[_0xf457('0x30')](_0x1156ae['model'],_0x1156ae[_0xf457('0x29')]);_0x5dd23c['attributes']=_[_0xf457('0x30')](_0x1156ae[_0xf457('0x2d')],qs[_0xf457('0x32')](_0x4d5bdc[_0xf457('0x29')][_0xf457('0x32')]));_0x5dd23c[_0xf457('0x31')]=_0x5dd23c[_0xf457('0x31')][_0xf457('0x33')]?_0x5dd23c[_0xf457('0x31')]:_0x1156ae['model'];_0x5dd23c[_0xf457('0x47')]=qs[_0xf457('0x48')](_0x4d5bdc['query']['sort']);_0x5dd23c[_0xf457('0x27')]=qs[_0xf457('0x2f')](_[_0xf457('0x49')](_0x4d5bdc[_0xf457('0x29')],_0x1156ae[_0xf457('0x2f')]));if(_0x4d5bdc[_0xf457('0x29')][_0xf457('0x4a')]){_0x5dd23c[_0xf457('0x27')]=_[_0xf457('0x34')](_0x5dd23c['where'],{'$or':_[_0xf457('0x21')](_0x5dd23c[_0xf457('0x31')],function(_0x384a4f){var _0x21da05={};_0x21da05[_0x384a4f]={'$like':'%'+_0x4d5bdc['query']['filter']+'%'};return _0x21da05;})});}_0x5dd23c=_[_0xf457('0x34')]({},_0x5dd23c,_0x4d5bdc[_0xf457('0x56')]);return _0x4213f0[_0xf457('0x55')](_0x5dd23c);}})['then'](function(_0x45dc11){if(_0x45dc11){_0xb41770=_0x45dc11[_0xf457('0x33')];if(!_0x4d5bdc[_0xf457('0x29')][_0xf457('0x45')](_0xf457('0x46'))){_0x5dd23c[_0xf457('0x13')]=qs[_0xf457('0x13')](_0x4d5bdc[_0xf457('0x29')][_0xf457('0x13')]);_0x5dd23c[_0xf457('0x12')]=qs['offset'](_0x4d5bdc[_0xf457('0x29')]['offset']);}return _0x4213f0[_0xf457('0x55')](_0x5dd23c);}})[_0xf457('0x18')](function(_0xf80866){if(_0xf80866){return _0xf80866?{'count':_0xb41770,'rows':_0xf80866}:null;}})['then'](respondWithResult(_0x4fe83b,null))[_0xf457('0x2b')](handleError(_0x4fe83b,null));};exports[_0xf457('0x57')]=function(_0x337a3c,_0x3c8c1e){var _0x3649b3=_0x337a3c['body']['ids'];return db['Team'][_0xf457('0x2a')]({'where':{'id':_0x3649b3},'attributes':['id'],'include':[{'model':db['User'],'as':_0xf457('0x58'),'attributes':['id','name',_0xf457('0x59'),_0xf457('0x5a'),'interface'],'raw':!![]}]})[_0xf457('0x18')](function(_0x13dfc8){if(_0x13dfc8){var _0x3f3529=_[_0xf457('0x5b')](_0x13dfc8,function(_0x16e653){var _0x3c6530=_0x16e653['get']({'plain':!![]});return _0x3c6530['Agents'];});return db[_0xf457('0x22')]['find']({'where':{'id':_0x337a3c[_0xf457('0x41')]['id']}})[_0xf457('0x18')](function(_0x4858f0){return db['sequelize'][_0xf457('0x5c')](function(_0x3db878){return _0x4858f0['addTeams'](_0x3649b3,{'transaction':_0x3db878})[_0xf457('0x18')](function(){return BPromise[_0xf457('0x5d')](_0x3f3529,function(_0x34dfe1){return db[_0xf457('0x4b')][_0xf457('0x5e')]({'where':{'UserId':_0x34dfe1['id'],'ChatQueueId':_0x337a3c[_0xf457('0x41')]['id']},'transaction':_0x3db878});});})[_0xf457('0x18')](function(){_0x3f3529[_0xf457('0x5f')](function(_0x1daa56){socket[_0xf457('0x60')](_0xf457('0x61'),{'UserId':_0x1daa56['id'],'ChatQueueId':_0x4858f0['id']});});});});});}})[_0xf457('0x18')](respondWithStatusCode(_0x3c8c1e,null))['catch'](handleError(_0x3c8c1e,null));};exports[_0xf457('0x62')]=function(_0x1ddcb9,_0x2cc6b4){return db[_0xf457('0x63')]['findAll']({'where':{'id':_0x1ddcb9[_0xf457('0x29')]['ids']},'attributes':['id'],'include':[{'model':db[_0xf457('0x4c')],'as':_0xf457('0x58'),'attributes':['id'],'raw':!![]}]})[_0xf457('0x18')](handleEntityNotFound(_0x2cc6b4,null))[_0xf457('0x18')](function(_0x5c24f7){var _0x925346=_[_0xf457('0x21')](_0x5c24f7,'id');var _0x3b3f5d=[];var _0x3e2d61=[];var _0x1c0501=squel[_0xf457('0x64')]();_0x1c0501[_0xf457('0x65')]('tq.TeamId')[_0xf457('0x66')](_0xf457('0x67'),'tq')['join'](_0xf457('0x68'),'ut',_0xf457('0x69'))['where'](_0xf457('0x6a'),_0x1ddcb9[_0xf457('0x41')]['id']);for(var _0x3ea697=0x0;_0x3ea697<_0x5c24f7[_0xf457('0x33')];_0x3ea697+=0x1){let _0x560faa=_0x5c24f7[_0x3ea697];for(var _0x347fcb=0x0;_0x347fcb<_0x560faa[_0xf457('0x58')][_0xf457('0x33')];_0x347fcb+=0x1){let _0x1a7eef=_0x560faa[_0xf457('0x58')][_0x347fcb];var _0x331b68=_0x1c0501[_0xf457('0x6b')]();_0x331b68[_0xf457('0x27')]('ut.UserId\x20=\x20?',_0x1a7eef['id']);_0x3e2d61[_0xf457('0x6c')](db[_0xf457('0x6d')]['query'](_0x331b68['toString'](),{'type':db[_0xf457('0x6d')][_0xf457('0x6e')][_0xf457('0x6f')]})[_0xf457('0x18')](function(_0x268111){if(_0x268111[_0xf457('0x33')]===0x1){return _0x1a7eef['id'];}else{var _0x51af24=_[_0xf457('0x70')](_['map'](_0x268111,_0xf457('0x71')),function(_0x22163c){return _['includes'](_0x925346,_0x22163c);});if(_0x51af24){return _0x1a7eef['id'];}}}));}}return BPromise['all'](_0x3e2d61)[_0xf457('0x18')](function(_0x1b17f4){_0x3b3f5d=_(_0x3b3f5d)[_0xf457('0x72')](_0x1b17f4)[_0xf457('0x73')]()['value']();return db[_0xf457('0x22')][_0xf457('0x35')]({'where':{'id':_0x1ddcb9['params']['id']}})[_0xf457('0x18')](function(_0x5ce9c7){return db[_0xf457('0x6d')]['transaction'](function(_0x5520a2){return _0x5ce9c7[_0xf457('0x62')](_0x1ddcb9['query'][_0xf457('0x74')],{'transaction':_0x5520a2})[_0xf457('0x18')](function(){if(!_[_0xf457('0x75')](_0x3b3f5d)){return _0x5ce9c7[_0xf457('0x76')](_0x3b3f5d,{'transaction':_0x5520a2});}})[_0xf457('0x18')](function(){_0x3b3f5d[_0xf457('0x5f')](function(_0x10d748){socket[_0xf457('0x60')](_0xf457('0x77'),{'UserId':_0x10d748,'ChatQueueId':_0x5ce9c7['id']});});});});});});})['then'](respondWithStatusCode(_0x2cc6b4,null))['catch'](handleError(_0x2cc6b4,null));};exports[_0xf457('0x78')]=function(_0x7f1478,_0xf50db6){return db[_0xf457('0x22')][_0xf457('0x35')]({'where':{'id':_0x7f1478[_0xf457('0x41')]['id']}})[_0xf457('0x18')](handleEntityNotFound(_0xf50db6,null))[_0xf457('0x18')](function(_0x3c7531){if(_0x3c7531){return _0x3c7531[_0xf457('0x78')](_0x7f1478[_0xf457('0x37')][_0xf457('0x74')],_['omit'](_0x7f1478['body'],[_0xf457('0x74'),'id'])||{})[_0xf457('0x79')](function(_0xda8eb){for(var _0x53c5f5=0x0;_0x53c5f5<_0x7f1478[_0xf457('0x37')][_0xf457('0x74')][_0xf457('0x33')];_0x53c5f5+=0x1){socket[_0xf457('0x60')](_0xf457('0x61'),{'UserId':Number(_0x7f1478[_0xf457('0x37')]['ids'][_0x53c5f5]),'ChatQueueId':Number(_0x7f1478[_0xf457('0x41')]['id'])});}return _0xda8eb;});}})[_0xf457('0x18')](respondWithResult(_0xf50db6,null))[_0xf457('0x2b')](handleError(_0xf50db6,null));};exports[_0xf457('0x76')]=function(_0x159184,_0x311743){return db[_0xf457('0x22')]['find']({'where':{'id':_0x159184[_0xf457('0x41')]['id']}})[_0xf457('0x18')](handleEntityNotFound(_0x311743,null))[_0xf457('0x18')](function(_0x197ec7){if(_0x197ec7){return _0x197ec7['removeAgents'](_0x159184[_0xf457('0x29')]['ids'])['then'](function(){if(_[_0xf457('0x7a')](_0x159184['query'][_0xf457('0x74')])){for(var _0x128533=0x0;_0x128533<_0x159184['query'][_0xf457('0x74')][_0xf457('0x33')];_0x128533+=0x1){socket['emit'](_0xf457('0x77'),{'UserId':Number(_0x159184[_0xf457('0x29')]['ids'][_0x128533]),'ChatQueueId':Number(_0x159184[_0xf457('0x41')]['id'])});}}else{socket[_0xf457('0x60')](_0xf457('0x77'),{'UserId':Number(_0x159184[_0xf457('0x29')][_0xf457('0x74')]),'ChatQueueId':Number(_0x159184['params']['id'])});}});}})[_0xf457('0x18')](respondWithStatusCode(_0x311743,null))['catch'](handleError(_0x311743,null));};exports[_0xf457('0x7b')]=function(_0x3380c1,_0x22b5b9){var _0xdf0cf5={};var _0x524ce2={};var _0x56c117;var _0x317d77;return db[_0xf457('0x22')][_0xf457('0x44')]({'where':{'id':_0x3380c1['params']['id']}})['then'](handleEntityNotFound(_0x22b5b9,null))['then'](function(_0x500a83){if(_0x500a83){_0x56c117=_0x500a83;_0x524ce2[_0xf457('0x2d')]=_['keys'](db[_0xf457('0x4c')][_0xf457('0x23')]);_0x524ce2[_0xf457('0x29')]=_[_0xf457('0x2e')](_0x3380c1['query']);_0x524ce2[_0xf457('0x2f')]=_['intersection'](_0x524ce2[_0xf457('0x2d')],_0x524ce2[_0xf457('0x29')]);_0xdf0cf5[_0xf457('0x31')]=_[_0xf457('0x30')](_0x524ce2[_0xf457('0x2d')],qs['fields'](_0x3380c1[_0xf457('0x29')][_0xf457('0x32')]));_0xdf0cf5[_0xf457('0x31')]=_0xdf0cf5[_0xf457('0x31')][_0xf457('0x33')]?_0xdf0cf5['attributes']:_0x524ce2[_0xf457('0x2d')];_0xdf0cf5[_0xf457('0x47')]=qs[_0xf457('0x48')](_0x3380c1[_0xf457('0x29')][_0xf457('0x48')]);_0xdf0cf5[_0xf457('0x27')]=qs[_0xf457('0x2f')](_[_0xf457('0x49')](_0x3380c1['query'],_0x524ce2[_0xf457('0x2f')]));if(_0x3380c1[_0xf457('0x29')][_0xf457('0x4a')]){_0xdf0cf5[_0xf457('0x27')]=_[_0xf457('0x34')](_0xdf0cf5[_0xf457('0x27')],{'$or':_[_0xf457('0x21')](_0xdf0cf5[_0xf457('0x31')],function(_0x4380c1){var _0x153515={};_0x153515[_0x4380c1]={'$like':'%'+_0x3380c1[_0xf457('0x29')]['filter']+'%'};return _0x153515;})});}_0xdf0cf5=_['merge']({},_0xdf0cf5,_0x3380c1[_0xf457('0x56')]);return _0x56c117[_0xf457('0x7b')](_0xdf0cf5);}})[_0xf457('0x18')](function(_0x1a5dd6){if(_0x1a5dd6){_0x317d77=_0x1a5dd6[_0xf457('0x33')];if(!_0x3380c1['query'][_0xf457('0x45')](_0xf457('0x46'))){_0xdf0cf5[_0xf457('0x13')]=qs[_0xf457('0x13')](_0x3380c1[_0xf457('0x29')][_0xf457('0x13')]);_0xdf0cf5[_0xf457('0x12')]=qs['offset'](_0x3380c1[_0xf457('0x29')]['offset']);}return _0x56c117[_0xf457('0x7b')](_0xdf0cf5);}})[_0xf457('0x18')](function(_0x32456a){if(_0x32456a){return _0x32456a?{'count':_0x317d77,'rows':_0x32456a}:null;}})[_0xf457('0x18')](respondWithResult(_0x22b5b9,null))[_0xf457('0x2b')](handleError(_0x22b5b9,null));};
\ No newline at end of file
+var _0x7b3b=['voicePause','flatMap','sequelize','transaction','forEach','emit','removeTeams','field','tq.TeamId','from','team_has_chat_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ChatQueueId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','removeAgents','addAgents','spread','userChatQueue:save','getAgents','hasOwnProperty','bluebird','util','lodash','squel','ioredis','../../components/parsers/qs','api','../../config/environment','redis','defaults','localhost','socket.io-emitter','register','status','end','json','offset','undefined','limit','count','set','Content-Range','update','destroy','then','get','ChatQueues','error','stack','name','send','index','map','ChatQueue','rawAttributes','type','key','getOptions','where','include','query','catch','params','model','keys','filters','intersection','attributes','length','merge','options','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','UserChatQueue','fields','nolimit','order','sort','pick','ChatQueueId','filter','findAll','User','UserId','agent','chatPause','updatedAt','createdAt','rows','format','%s/%s','SIP','getTeams','Team','addTeams','ids','Agents','online'];(function(_0x24d8ec,_0x5f1552){var _0x409280=function(_0x3d085b){while(--_0x3d085b){_0x24d8ec['push'](_0x24d8ec['shift']());}};_0x409280(++_0x5f1552);}(_0x7b3b,0x92));var _0xb7b3=function(_0x23fa2a,_0x3816a3){_0x23fa2a=_0x23fa2a-0x0;var _0x783fba=_0x7b3b[_0x23fa2a];return _0x783fba;};'use strict';var BPromise=require(_0xb7b3('0x0'));var util=require(_0xb7b3('0x1'));var _=require(_0xb7b3('0x2'));var squel=require(_0xb7b3('0x3'));var Redis=require(_0xb7b3('0x4'));var qs=require(_0xb7b3('0x5'));var logger=require('../../config/logger')(_0xb7b3('0x6'));var config=require(_0xb7b3('0x7'));var db=require('../../mysqldb')['db'];config[_0xb7b3('0x8')]=_[_0xb7b3('0x9')](config[_0xb7b3('0x8')],{'host':_0xb7b3('0xa'),'port':0x18eb});var socket=require(_0xb7b3('0xb'))(new Redis(config[_0xb7b3('0x8')]));require('./chatQueue.socket')[_0xb7b3('0xc')](socket);function respondWithStatusCode(_0x187639,_0x202d7e){_0x202d7e=_0x202d7e||0xcc;return function(_0x4a000a){if(_0x4a000a){return _0x187639['sendStatus'](_0x202d7e);}return _0x187639[_0xb7b3('0xd')](_0x202d7e)[_0xb7b3('0xe')]();};}function respondWithResult(_0x58ad4c,_0x46a558){_0x46a558=_0x46a558||0xc8;return function(_0x2e1acd){if(_0x2e1acd){return _0x58ad4c[_0xb7b3('0xd')](_0x46a558)[_0xb7b3('0xf')](_0x2e1acd);}};}function respondWithFilteredResult(_0x281146,_0x4ce771){return function(_0x5e950e){if(_0x5e950e){var _0x2650fc=typeof _0x4ce771[_0xb7b3('0x10')]===_0xb7b3('0x11')&&typeof _0x4ce771[_0xb7b3('0x12')]==='undefined';var _0x21b5fe=_0x5e950e['count'];var _0x2bee56=_0x2650fc?0x0:_0x4ce771[_0xb7b3('0x10')];var _0x5780ec=_0x2650fc?_0x5e950e[_0xb7b3('0x13')]:_0x4ce771[_0xb7b3('0x10')]+_0x4ce771['limit'];var _0x279a15;if(_0x5780ec>=_0x21b5fe){_0x5780ec=_0x21b5fe;_0x279a15=0xc8;}else{_0x279a15=0xce;}_0x281146['status'](_0x279a15);return _0x281146[_0xb7b3('0x14')](_0xb7b3('0x15'),_0x2bee56+'-'+_0x5780ec+'/'+_0x21b5fe)[_0xb7b3('0xf')](_0x5e950e);}return null;};}function saveUpdates(_0x22f42e){return function(_0x3e85ce){if(_0x3e85ce){return _0x3e85ce[_0xb7b3('0x16')](_0x22f42e)['then'](function(_0x2086c3){return _0x2086c3;});}return null;};}function removeEntity(_0x381d18){return function(_0x28c4be){if(_0x28c4be){return _0x28c4be[_0xb7b3('0x17')]()[_0xb7b3('0x18')](function(){var _0x3ebfea=_0x28c4be[_0xb7b3('0x19')]({'plain':!![]});var _0xc0e079=_0xb7b3('0x1a');return db['UserProfileResource'][_0xb7b3('0x17')]({'where':{'type':_0xc0e079,'resourceId':_0x3ebfea['id']}})[_0xb7b3('0x18')](function(){return _0x28c4be;});})[_0xb7b3('0x18')](function(){_0x381d18[_0xb7b3('0xd')](0xcc)[_0xb7b3('0xe')]();});}};}function handleEntityNotFound(_0xae4788){return function(_0x524e72){if(!_0x524e72){_0xae4788['sendStatus'](0x194);}return _0x524e72;};}function handleError(_0x2271ad,_0x18cba1){_0x18cba1=_0x18cba1||0x1f4;return function(_0x261634){logger[_0xb7b3('0x1b')](_0x261634[_0xb7b3('0x1c')]);if(_0x261634[_0xb7b3('0x1d')]){delete _0x261634[_0xb7b3('0x1d')];}_0x2271ad[_0xb7b3('0xd')](_0x18cba1)[_0xb7b3('0x1e')](_0x261634);};}exports[_0xb7b3('0x1f')]=function(_0x27fd41,_0x1b5ce5){var _0x4e8ccb={};var _0x2dc648={'count':0x0,'rows':[]};var _0x58222a=_[_0xb7b3('0x20')](db[_0xb7b3('0x21')][_0xb7b3('0x22')],function(_0xd0bea4){return{'name':_0xd0bea4['fieldName'],'type':_0xd0bea4[_0xb7b3('0x23')][_0xb7b3('0x24')]};});_0x4e8ccb=qs[_0xb7b3('0x25')](_0x58222a,_0x27fd41);var _0x18b938={'where':_0x4e8ccb[_0xb7b3('0x26')]};return db[_0xb7b3('0x21')]['count'](_0x18b938)['then'](function(_0x5612b8){_0x2dc648[_0xb7b3('0x13')]=_0x5612b8;_0x4e8ccb['include']=qs[_0xb7b3('0x27')](_0x27fd41[_0xb7b3('0x28')]);return db['ChatQueue']['findAll'](_0x4e8ccb);})[_0xb7b3('0x18')](function(_0x5f19cc){_0x2dc648['rows']=_0x5f19cc;return _0x2dc648;})[_0xb7b3('0x18')](respondWithFilteredResult(_0x1b5ce5,_0x4e8ccb))[_0xb7b3('0x29')](handleError(_0x1b5ce5,null));};exports['show']=function(_0x102c7f,_0xef5975){var _0x3d858e={'raw':!![],'where':{'id':_0x102c7f[_0xb7b3('0x2a')]['id']}},_0x53d006={};_0x53d006[_0xb7b3('0x2b')]=_[_0xb7b3('0x2c')](db['ChatQueue'][_0xb7b3('0x22')]);_0x53d006[_0xb7b3('0x28')]=_[_0xb7b3('0x2c')](_0x102c7f[_0xb7b3('0x28')]);_0x53d006[_0xb7b3('0x2d')]=_[_0xb7b3('0x2e')](_0x53d006[_0xb7b3('0x2b')],_0x53d006[_0xb7b3('0x28')]);_0x3d858e[_0xb7b3('0x2f')]=_[_0xb7b3('0x2e')](_0x53d006['model'],qs['fields'](_0x102c7f['query']['fields']));_0x3d858e[_0xb7b3('0x2f')]=_0x3d858e[_0xb7b3('0x2f')][_0xb7b3('0x30')]?_0x3d858e[_0xb7b3('0x2f')]:_0x53d006[_0xb7b3('0x2b')];if(_0x102c7f[_0xb7b3('0x28')]['includeAll']){_0x3d858e[_0xb7b3('0x27')]=[{'all':!![]}];}_0x3d858e=_[_0xb7b3('0x31')]({},_0x3d858e,_0x102c7f[_0xb7b3('0x32')]);return db[_0xb7b3('0x21')][_0xb7b3('0x33')](_0x3d858e)['then'](handleEntityNotFound(_0xef5975,null))[_0xb7b3('0x18')](respondWithResult(_0xef5975,null))[_0xb7b3('0x29')](handleError(_0xef5975,null));};exports['create']=function(_0xa6615c,_0x6c473e){return db[_0xb7b3('0x21')][_0xb7b3('0x34')](_0xa6615c[_0xb7b3('0x35')],{})[_0xb7b3('0x18')](function(_0x24c940){var _0x3e4cd5=_0xa6615c['user']['get']({'plain':!![]});if(!_0x3e4cd5)throw new Error(_0xb7b3('0x36'));if(_0x3e4cd5[_0xb7b3('0x37')]===_0xb7b3('0x38')){var _0x5a2075=_0x24c940[_0xb7b3('0x19')]({'plain':!![]});var _0xe7f5a8='ChatQueues';return db['UserProfileSection']['find']({'where':{'name':_0xe7f5a8,'userProfileId':_0x3e4cd5[_0xb7b3('0x39')]},'raw':!![]})[_0xb7b3('0x18')](function(_0x446fc7){if(_0x446fc7&&_0x446fc7[_0xb7b3('0x3a')]===0x0){return db[_0xb7b3('0x3b')][_0xb7b3('0x34')]({'name':_0x5a2075[_0xb7b3('0x1d')],'resourceId':_0x5a2075['id'],'type':_0x446fc7[_0xb7b3('0x1d')],'sectionId':_0x446fc7['id']},{})[_0xb7b3('0x18')](function(){return _0x24c940;});}else{return _0x24c940;}})['catch'](function(_0x4219a4){logger[_0xb7b3('0x1b')](_0xb7b3('0x3c'),_0x4219a4);throw _0x4219a4;});}return _0x24c940;})['then'](respondWithResult(_0x6c473e,0xc9))[_0xb7b3('0x29')](handleError(_0x6c473e,null));};exports['update']=function(_0x45ee14,_0x27d95f){if(_0x45ee14[_0xb7b3('0x35')]['id']){delete _0x45ee14[_0xb7b3('0x35')]['id'];}return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x45ee14['params']['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x27d95f,null))[_0xb7b3('0x18')](saveUpdates(_0x45ee14[_0xb7b3('0x35')],null))['then'](respondWithResult(_0x27d95f,null))['catch'](handleError(_0x27d95f,null));};exports[_0xb7b3('0x17')]=function(_0x273c2d,_0x4aa25a){return db['ChatQueue'][_0xb7b3('0x33')]({'where':{'id':_0x273c2d[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x4aa25a,null))[_0xb7b3('0x18')](removeEntity(_0x4aa25a,null))[_0xb7b3('0x29')](handleError(_0x4aa25a,null));};exports[_0xb7b3('0x3d')]=function(_0x53454d,_0x1b1936){return db[_0xb7b3('0x21')][_0xb7b3('0x3d')]()[_0xb7b3('0x18')](respondWithResult(_0x1b1936,null))[_0xb7b3('0x29')](handleError(_0x1b1936,null));};exports['getMembers']=function(_0x300009,_0x16ad16){var _0x9899cf={'raw':!![],'where':{}},_0x5b429a={},_0x355b7f;return db[_0xb7b3('0x21')][_0xb7b3('0x3e')]({'where':{'id':_0x300009[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x16ad16,null))[_0xb7b3('0x18')](function(_0x56c874){if(_0x56c874){_0x355b7f=_0x56c874['get']({'plain':!![]});_0x5b429a[_0xb7b3('0x2b')]=_[_0xb7b3('0x2c')](db[_0xb7b3('0x3f')][_0xb7b3('0x22')]);_0x5b429a['query']=_['keys'](_0x300009[_0xb7b3('0x28')]);_0x5b429a[_0xb7b3('0x2d')]=_[_0xb7b3('0x2e')](_0x5b429a[_0xb7b3('0x2b')],_0x5b429a[_0xb7b3('0x28')]);_0x9899cf[_0xb7b3('0x2f')]=_['intersection'](_0x5b429a[_0xb7b3('0x2b')],qs[_0xb7b3('0x40')](_0x300009[_0xb7b3('0x28')][_0xb7b3('0x40')]));_0x9899cf[_0xb7b3('0x2f')]=_0x9899cf[_0xb7b3('0x2f')][_0xb7b3('0x30')]?_0x9899cf[_0xb7b3('0x2f')]:_0x5b429a[_0xb7b3('0x2b')];if(!_0x300009['query']['hasOwnProperty'](_0xb7b3('0x41'))){_0x9899cf['limit']=qs['limit'](_0x300009[_0xb7b3('0x28')]['limit']);_0x9899cf[_0xb7b3('0x10')]=qs[_0xb7b3('0x10')](_0x300009['query'][_0xb7b3('0x10')]);}_0x9899cf[_0xb7b3('0x42')]=qs[_0xb7b3('0x43')](_0x300009[_0xb7b3('0x28')][_0xb7b3('0x43')]);_0x9899cf[_0xb7b3('0x26')]=qs[_0xb7b3('0x2d')](_[_0xb7b3('0x44')](_0x300009[_0xb7b3('0x28')],_0x5b429a[_0xb7b3('0x2d')]));_0x9899cf['where'][_0xb7b3('0x45')]=_0x56c874['id'];if(_0x300009['query'][_0xb7b3('0x46')]){_0x9899cf[_0xb7b3('0x26')]=_[_0xb7b3('0x31')](_0x9899cf['where'],{'$or':_[_0xb7b3('0x20')](_0x9899cf['attributes'],function(_0x370392){var _0x5d9e2c={};_0x5d9e2c[_0x370392]={'$like':'%'+_0x300009[_0xb7b3('0x28')][_0xb7b3('0x46')]+'%'};return _0x5d9e2c;})});}_0x9899cf=_[_0xb7b3('0x31')]({},_0x9899cf,_0x300009[_0xb7b3('0x32')]);return db[_0xb7b3('0x3f')][_0xb7b3('0x47')](_0x9899cf);}})[_0xb7b3('0x18')](function(_0x552415){if(_0x552415){return db[_0xb7b3('0x48')]['findAndCountAll']({'where':{'id':_['map'](_0x552415,_0xb7b3('0x49')),'role':_0xb7b3('0x4a')},'attributes':['id',_0xb7b3('0x1d'),_0xb7b3('0x4b'),_0xb7b3('0x4c'),_0xb7b3('0x4d')]});}})[_0xb7b3('0x18')](function(_0x1c6797){if(_0x1c6797){return{'count':_0x1c6797[_0xb7b3('0x13')],'rows':_['map'](_0x1c6797[_0xb7b3('0x4e')],function(_0x2bb5b1){return{'membername':_0x2bb5b1[_0xb7b3('0x1d')],'UserId':_0x2bb5b1['id'],'queue_name':_0x355b7f[_0xb7b3('0x1d')],'ChatQueueId':_0x355b7f['id'],'interface':util[_0xb7b3('0x4f')](_0xb7b3('0x50'),_0xb7b3('0x51'),_0x2bb5b1[_0xb7b3('0x1d')]),'penalty':0x0,'paused':_0x2bb5b1[_0xb7b3('0x4b')],'createdAt':_0x2bb5b1[_0xb7b3('0x4d')],'updatedAt':_0x2bb5b1[_0xb7b3('0x4c')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xb7b3('0x18')](respondWithFilteredResult(_0x16ad16,_0x9899cf))[_0xb7b3('0x29')](handleError(_0x16ad16,null));};exports[_0xb7b3('0x52')]=function(_0x44bc4b,_0x40a7f9){var _0x2fdbe5={};var _0x3d9ce5={};var _0x293c83;var _0x633055;return db['ChatQueue'][_0xb7b3('0x3e')]({'where':{'id':_0x44bc4b[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x40a7f9,null))[_0xb7b3('0x18')](function(_0x2ca86d){if(_0x2ca86d){_0x293c83=_0x2ca86d;_0x3d9ce5[_0xb7b3('0x2b')]=_[_0xb7b3('0x2c')](db[_0xb7b3('0x53')]['rawAttributes']);_0x3d9ce5['query']=_[_0xb7b3('0x2c')](_0x44bc4b[_0xb7b3('0x28')]);_0x3d9ce5[_0xb7b3('0x2d')]=_[_0xb7b3('0x2e')](_0x3d9ce5['model'],_0x3d9ce5[_0xb7b3('0x28')]);_0x2fdbe5['attributes']=_['intersection'](_0x3d9ce5[_0xb7b3('0x2b')],qs[_0xb7b3('0x40')](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x40')]));_0x2fdbe5[_0xb7b3('0x2f')]=_0x2fdbe5[_0xb7b3('0x2f')][_0xb7b3('0x30')]?_0x2fdbe5[_0xb7b3('0x2f')]:_0x3d9ce5['model'];_0x2fdbe5['order']=qs[_0xb7b3('0x43')](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x43')]);_0x2fdbe5['where']=qs['filters'](_[_0xb7b3('0x44')](_0x44bc4b[_0xb7b3('0x28')],_0x3d9ce5[_0xb7b3('0x2d')]));if(_0x44bc4b[_0xb7b3('0x28')]['filter']){_0x2fdbe5[_0xb7b3('0x26')]=_['merge'](_0x2fdbe5['where'],{'$or':_['map'](_0x2fdbe5[_0xb7b3('0x2f')],function(_0x3c05a6){var _0x5f6362={};_0x5f6362[_0x3c05a6]={'$like':'%'+_0x44bc4b['query'][_0xb7b3('0x46')]+'%'};return _0x5f6362;})});}_0x2fdbe5=_[_0xb7b3('0x31')]({},_0x2fdbe5,_0x44bc4b[_0xb7b3('0x32')]);return _0x293c83[_0xb7b3('0x52')](_0x2fdbe5);}})[_0xb7b3('0x18')](function(_0x4ad27d){if(_0x4ad27d){_0x633055=_0x4ad27d[_0xb7b3('0x30')];if(!_0x44bc4b[_0xb7b3('0x28')]['hasOwnProperty']('nolimit')){_0x2fdbe5[_0xb7b3('0x12')]=qs['limit'](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x12')]);_0x2fdbe5['offset']=qs[_0xb7b3('0x10')](_0x44bc4b[_0xb7b3('0x28')][_0xb7b3('0x10')]);}return _0x293c83['getTeams'](_0x2fdbe5);}})[_0xb7b3('0x18')](function(_0x10df96){if(_0x10df96){return _0x10df96?{'count':_0x633055,'rows':_0x10df96}:null;}})[_0xb7b3('0x18')](respondWithResult(_0x40a7f9,null))[_0xb7b3('0x29')](handleError(_0x40a7f9,null));};exports[_0xb7b3('0x54')]=function(_0x44cb51,_0x2afb57){var _0x19006a=_0x44cb51['body'][_0xb7b3('0x55')];return db[_0xb7b3('0x53')][_0xb7b3('0x47')]({'where':{'id':_0x19006a},'attributes':['id'],'include':[{'model':db[_0xb7b3('0x48')],'as':_0xb7b3('0x56'),'attributes':['id',_0xb7b3('0x1d'),_0xb7b3('0x57'),_0xb7b3('0x58'),'interface'],'raw':!![]}]})['then'](function(_0x2618ea){if(_0x2618ea){var _0x4fa4d5=_[_0xb7b3('0x59')](_0x2618ea,function(_0x270be7){var _0x367418=_0x270be7[_0xb7b3('0x19')]({'plain':!![]});return _0x367418[_0xb7b3('0x56')];});return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x44cb51[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](function(_0x1d4f86){return db[_0xb7b3('0x5a')][_0xb7b3('0x5b')](function(_0x265bfd){return _0x1d4f86['addTeams'](_0x19006a,{'transaction':_0x265bfd})[_0xb7b3('0x18')](function(){return BPromise['each'](_0x4fa4d5,function(_0x39de53){return db[_0xb7b3('0x3f')]['findOrCreate']({'where':{'UserId':_0x39de53['id'],'ChatQueueId':_0x44cb51[_0xb7b3('0x2a')]['id']},'transaction':_0x265bfd});});})[_0xb7b3('0x18')](function(){_0x4fa4d5[_0xb7b3('0x5c')](function(_0x5e2943){socket[_0xb7b3('0x5d')]('userChatQueue:save',{'UserId':_0x5e2943['id'],'ChatQueueId':_0x1d4f86['id']});});});});});}})[_0xb7b3('0x18')](respondWithStatusCode(_0x2afb57,null))[_0xb7b3('0x29')](handleError(_0x2afb57,null));};exports[_0xb7b3('0x5e')]=function(_0x4f7461,_0xd56f49){return db['Team'][_0xb7b3('0x47')]({'where':{'id':_0x4f7461[_0xb7b3('0x28')]['ids']},'attributes':['id'],'include':[{'model':db[_0xb7b3('0x48')],'as':_0xb7b3('0x56'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0xd56f49,null))[_0xb7b3('0x18')](function(_0x389fac){var _0x23bf90=_[_0xb7b3('0x20')](_0x389fac,'id');var _0x4e7f24=[];var _0x5c6b27=[];var _0x2e383c=squel['select']();_0x2e383c[_0xb7b3('0x5f')](_0xb7b3('0x60'))[_0xb7b3('0x61')](_0xb7b3('0x62'),'tq')[_0xb7b3('0x63')](_0xb7b3('0x64'),'ut',_0xb7b3('0x65'))[_0xb7b3('0x26')](_0xb7b3('0x66'),_0x4f7461['params']['id']);for(var _0x4b46f5=0x0;_0x4b46f5<_0x389fac['length'];_0x4b46f5+=0x1){let _0x2e1ae3=_0x389fac[_0x4b46f5];for(var _0x4dec0a=0x0;_0x4dec0a<_0x2e1ae3[_0xb7b3('0x56')]['length'];_0x4dec0a+=0x1){let _0x17ffee=_0x2e1ae3['Agents'][_0x4dec0a];var _0x41eb65=_0x2e383c['clone']();_0x41eb65[_0xb7b3('0x26')]('ut.UserId\x20=\x20?',_0x17ffee['id']);_0x5c6b27[_0xb7b3('0x67')](db[_0xb7b3('0x5a')][_0xb7b3('0x28')](_0x41eb65[_0xb7b3('0x68')](),{'type':db[_0xb7b3('0x5a')][_0xb7b3('0x69')][_0xb7b3('0x6a')]})['then'](function(_0x47a65a){if(_0x47a65a[_0xb7b3('0x30')]===0x1){return _0x17ffee['id'];}else{var _0x2be45a=_[_0xb7b3('0x6b')](_[_0xb7b3('0x20')](_0x47a65a,_0xb7b3('0x6c')),function(_0x3583b2){return _[_0xb7b3('0x6d')](_0x23bf90,_0x3583b2);});if(_0x2be45a){return _0x17ffee['id'];}}}));}}return BPromise[_0xb7b3('0x6e')](_0x5c6b27)[_0xb7b3('0x18')](function(_0x25d8bd){_0x4e7f24=_(_0x4e7f24)['union'](_0x25d8bd)['compact']()['value']();return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x4f7461[_0xb7b3('0x2a')]['id']}})['then'](function(_0x20f337){return db['sequelize'][_0xb7b3('0x5b')](function(_0x400032){return _0x20f337[_0xb7b3('0x5e')](_0x4f7461[_0xb7b3('0x28')][_0xb7b3('0x55')],{'transaction':_0x400032})[_0xb7b3('0x18')](function(){if(!_['isEmpty'](_0x4e7f24)){return _0x20f337[_0xb7b3('0x6f')](_0x4e7f24,{'transaction':_0x400032});}})[_0xb7b3('0x18')](function(){_0x4e7f24[_0xb7b3('0x5c')](function(_0x43a2bf){socket[_0xb7b3('0x5d')]('userChatQueue:remove',{'UserId':_0x43a2bf,'ChatQueueId':_0x20f337['id']});});});});});});})[_0xb7b3('0x18')](respondWithStatusCode(_0xd56f49,null))[_0xb7b3('0x29')](handleError(_0xd56f49,null));};exports['addAgents']=function(_0x4f2e10,_0x17332d){return db[_0xb7b3('0x21')]['find']({'where':{'id':_0x4f2e10[_0xb7b3('0x2a')]['id']}})[_0xb7b3('0x18')](handleEntityNotFound(_0x17332d,null))[_0xb7b3('0x18')](function(_0x2d23d6){if(_0x2d23d6){return _0x2d23d6[_0xb7b3('0x70')](_0x4f2e10['body']['ids'],_['omit'](_0x4f2e10['body'],['ids','id'])||{})[_0xb7b3('0x71')](function(_0x31d5d9){for(var _0x13cd15=0x0;_0x13cd15<_0x4f2e10[_0xb7b3('0x35')][_0xb7b3('0x55')][_0xb7b3('0x30')];_0x13cd15+=0x1){socket[_0xb7b3('0x5d')](_0xb7b3('0x72'),{'UserId':Number(_0x4f2e10[_0xb7b3('0x35')]['ids'][_0x13cd15]),'ChatQueueId':Number(_0x4f2e10['params']['id'])});}return _0x31d5d9;});}})['then'](respondWithResult(_0x17332d,null))['catch'](handleError(_0x17332d,null));};exports[_0xb7b3('0x6f')]=function(_0x239445,_0x5ed5e5){return db[_0xb7b3('0x21')][_0xb7b3('0x33')]({'where':{'id':_0x239445[_0xb7b3('0x2a')]['id']}})['then'](handleEntityNotFound(_0x5ed5e5,null))[_0xb7b3('0x18')](function(_0x292b07){if(_0x292b07){return _0x292b07[_0xb7b3('0x6f')](_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')])['then'](function(){if(_['isArray'](_0x239445['query'][_0xb7b3('0x55')])){for(var _0x4f7ec3=0x0;_0x4f7ec3<_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')][_0xb7b3('0x30')];_0x4f7ec3+=0x1){socket[_0xb7b3('0x5d')]('userChatQueue:remove',{'UserId':Number(_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')][_0x4f7ec3]),'ChatQueueId':Number(_0x239445['params']['id'])});}}else{socket[_0xb7b3('0x5d')]('userChatQueue:remove',{'UserId':Number(_0x239445[_0xb7b3('0x28')][_0xb7b3('0x55')]),'ChatQueueId':Number(_0x239445['params']['id'])});}});}})['then'](respondWithStatusCode(_0x5ed5e5,null))[_0xb7b3('0x29')](handleError(_0x5ed5e5,null));};exports[_0xb7b3('0x73')]=function(_0x525e23,_0xb37a68){var _0x54adff={};var _0x1b4f42={};var _0x576079;var _0xea55b;return db[_0xb7b3('0x21')]['findOne']({'where':{'id':_0x525e23[_0xb7b3('0x2a')]['id']}})['then'](handleEntityNotFound(_0xb37a68,null))[_0xb7b3('0x18')](function(_0x12b4c5){if(_0x12b4c5){_0x576079=_0x12b4c5;_0x1b4f42['model']=_[_0xb7b3('0x2c')](db['User'][_0xb7b3('0x22')]);_0x1b4f42[_0xb7b3('0x28')]=_[_0xb7b3('0x2c')](_0x525e23['query']);_0x1b4f42[_0xb7b3('0x2d')]=_['intersection'](_0x1b4f42[_0xb7b3('0x2b')],_0x1b4f42[_0xb7b3('0x28')]);_0x54adff[_0xb7b3('0x2f')]=_[_0xb7b3('0x2e')](_0x1b4f42[_0xb7b3('0x2b')],qs['fields'](_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x40')]));_0x54adff[_0xb7b3('0x2f')]=_0x54adff['attributes'][_0xb7b3('0x30')]?_0x54adff[_0xb7b3('0x2f')]:_0x1b4f42['model'];_0x54adff['order']=qs[_0xb7b3('0x43')](_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x43')]);_0x54adff[_0xb7b3('0x26')]=qs[_0xb7b3('0x2d')](_[_0xb7b3('0x44')](_0x525e23[_0xb7b3('0x28')],_0x1b4f42[_0xb7b3('0x2d')]));if(_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x46')]){_0x54adff[_0xb7b3('0x26')]=_[_0xb7b3('0x31')](_0x54adff['where'],{'$or':_['map'](_0x54adff[_0xb7b3('0x2f')],function(_0x4696c7){var _0x6e3f63={};_0x6e3f63[_0x4696c7]={'$like':'%'+_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x46')]+'%'};return _0x6e3f63;})});}_0x54adff=_['merge']({},_0x54adff,_0x525e23['options']);return _0x576079[_0xb7b3('0x73')](_0x54adff);}})[_0xb7b3('0x18')](function(_0x19c3d3){if(_0x19c3d3){_0xea55b=_0x19c3d3[_0xb7b3('0x30')];if(!_0x525e23['query'][_0xb7b3('0x74')]('nolimit')){_0x54adff['limit']=qs[_0xb7b3('0x12')](_0x525e23[_0xb7b3('0x28')]['limit']);_0x54adff[_0xb7b3('0x10')]=qs['offset'](_0x525e23[_0xb7b3('0x28')][_0xb7b3('0x10')]);}return _0x576079['getAgents'](_0x54adff);}})[_0xb7b3('0x18')](function(_0xf97ab8){if(_0xf97ab8){return _0xf97ab8?{'count':_0xea55b,'rows':_0xf97ab8}:null;}})[_0xb7b3('0x18')](respondWithResult(_0xb37a68,null))[_0xb7b3('0x29')](handleError(_0xb37a68,null));};
\ No newline at end of file