Built motion from commit be44e1e4d16f8b29d243415b03d27262d8601e0e. Version 3.0.0...
[motion-next.git] / server / api / chatQueue / chatQueue.controller.js
1 const a95_0x560d=['params','compact','format','nolimit','end','name','error','rows','key','get','query','set','create','includeAll','fields','order','type','send','status','QueryTypes','model','each','length','user','attributes','Unable\x20to\x20retrieve\x20the\x20current\x20user','merge','online','../../config/logger','findOrCreate','ut.TeamId\x20=\x20tq.TeamId','Content-Range','body','findOne','show','User','then','offset','ChatQueue','ChatQueueId\x20=\x20?','destroy','undefined','filter','addAgents','describe','like','UserChatQueue','json','intersection','toString','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','select','options','limit','findAll','VIRTUAL','../../components/parsers/qs','Agents','createdAt','keys','include','filters','getMembers','where','removeAgents','flatMap','ids','../../mysqldb','catch','chatPause','UserId','autoAssociation','updatedAt','pick','rawAttributes','omit','UserProfileSection','sequelize','squel','Team','api','from','../../rediscache','getTeams','userChatQueue:save','removeTeams','./chatQueue.socket','UserProfileResource','team_has_chat_queues','userChatQueue:remove','map','lodash','findAndCountAll','push','forEach','user_has_teams','emit','addTeams','SELECT','register','tq.TeamId','agent','sort','update','sendStatus'];(function(_0x503a1b,_0x560d4f){const _0x2f0ec6=function(_0x5d1b99){while(--_0x5d1b99){_0x503a1b['push'](_0x503a1b['shift']());}};_0x2f0ec6(++_0x560d4f);}(a95_0x560d,0x1e1));const a95_0x2f0e=function(_0x503a1b,_0x560d4f){_0x503a1b=_0x503a1b-0x0;let _0x2f0ec6=a95_0x560d[_0x503a1b];return _0x2f0ec6;};const _0x484143=a95_0x2f0e;'use strict';const util=require('util'),_=require(_0x484143('0x1e')),squel=require(_0x484143('0x11')),qs=require(_0x484143('0x64')),logger=require(_0x484143('0x48'))(_0x484143('0x13')),{getSocket}=require(_0x484143('0x15')),db=require(_0x484143('0x6'))['db'],{Op}=require(_0x484143('0x10')),socket=getSocket();require(_0x484143('0x19'))[_0x484143('0x26')](socket);function respondWithStatusCode(_0x5d1b99,_0x47ea5d){return _0x47ea5d=_0x47ea5d||0xcc,function(_0x4cd74e){if(_0x4cd74e)return _0x5d1b99['sendStatus'](_0x47ea5d);return _0x5d1b99['status'](_0x47ea5d)['end']();};}function respondWithResult(_0x185b0e,_0x20e566){return _0x20e566=_0x20e566||0xc8,function(_0x4372b5){const _0xcf35c5=a95_0x2f0e;if(_0x4372b5)return _0x185b0e[_0xcf35c5('0x3e')](_0x20e566)[_0xcf35c5('0x5b')](_0x4372b5);};}function respondWithFilteredResult(_0x5056b3,_0x3f6c1b){return function(_0x3c12b1){const _0x372aea=a95_0x2f0e;if(_0x3c12b1){const _0x12991c=_0x3c12b1['count'],_0x5e46cf=_0x3f6c1b[_0x372aea('0x51')];let _0x3627df=_0x3f6c1b[_0x372aea('0x51')]+_0x3f6c1b[_0x372aea('0x61')],_0x48fc2b;return _0x3627df>=_0x12991c?(_0x3627df=_0x12991c,_0x48fc2b=0xc8):_0x48fc2b=0xce,_0x5056b3[_0x372aea('0x3e')](_0x48fc2b),_0x5056b3[_0x372aea('0x37')](_0x372aea('0x4b'),_0x5e46cf+'-'+_0x3627df+'/'+_0x12991c)[_0x372aea('0x5b')](_0x3c12b1);}return null;};}function saveUpdates(_0x181143){return function(_0x541ffe){const _0x427aa4=a95_0x2f0e;if(_0x541ffe)return _0x541ffe[_0x427aa4('0x2a')](_0x181143)[_0x427aa4('0x50')](function(_0x27a277){return _0x27a277;});return null;};}function removeEntity(_0x16f558){return function(_0x55b848){const _0x354340=a95_0x2f0e;if(_0x55b848)return _0x55b848[_0x354340('0x54')]()[_0x354340('0x50')](function(){const _0x5ed810=_0x354340,_0x5cee5e=_0x55b848[_0x5ed810('0x35')]({'plain':!![]}),_0x3d3133='ChatQueues';return db[_0x5ed810('0x1a')]['destroy']({'where':{'type':_0x3d3133,'resourceId':_0x5cee5e['id']}})[_0x5ed810('0x50')](function(){return _0x55b848;});})[_0x354340('0x50')](function(){const _0x39840f=_0x354340;_0x16f558['status'](0xcc)[_0x39840f('0x30')]();});};}function handleEntityNotFound(_0x5f0011){return function(_0x2cbefc){const _0x39af15=a95_0x2f0e;return!_0x2cbefc&&_0x5f0011[_0x39af15('0x2b')](0x194),_0x2cbefc;};}function handleError(_0x4e9a59,_0x423628){return _0x423628=_0x423628||0x1f4,function(_0x54c658){const _0x16d36f=a95_0x2f0e;logger[_0x16d36f('0x32')](_0x54c658['stack']),_0x54c658[_0x16d36f('0x31')]&&delete _0x54c658[_0x16d36f('0x31')],_0x4e9a59['status'](_0x423628)[_0x16d36f('0x3d')](_0x54c658);};}exports['index']=function(_0x20ed71,_0x40dbba){const _0x23d485=_0x484143;let _0x3b8a7f={};const _0x3b3ef9={},_0x1e36a3={'count':0x0,'rows':[]},_0x34c49e=_[_0x23d485('0x1d')](db[_0x23d485('0x52')][_0x23d485('0xd')],function(_0x5bf8dd){const _0x11d793=_0x23d485;return{'name':_0x5bf8dd['fieldName'],'type':_0x5bf8dd[_0x11d793('0x3c')][_0x11d793('0x34')]};});_0x3b3ef9[_0x23d485('0x40')]=_[_0x23d485('0x1d')](_0x34c49e,_0x23d485('0x31')),_0x3b3ef9['query']=_['keys'](_0x20ed71[_0x23d485('0x36')]),_0x3b3ef9[_0x23d485('0x0')]=_['intersection'](_0x3b3ef9[_0x23d485('0x40')],_0x3b3ef9[_0x23d485('0x36')]),_0x3b8a7f[_0x23d485('0x44')]=_[_0x23d485('0x5c')](_0x3b3ef9[_0x23d485('0x40')],qs[_0x23d485('0x3a')](_0x20ed71[_0x23d485('0x36')][_0x23d485('0x3a')])),_0x3b8a7f[_0x23d485('0x44')]=_0x3b8a7f[_0x23d485('0x44')]['length']?_0x3b8a7f[_0x23d485('0x44')]:_0x3b3ef9['model'];typeof _0x20ed71['query'][_0x23d485('0x2f')]===_0x23d485('0x55')&&(_0x3b8a7f[_0x23d485('0x61')]=qs[_0x23d485('0x61')](_0x20ed71[_0x23d485('0x36')]['limit']),_0x3b8a7f['offset']=qs[_0x23d485('0x51')](_0x20ed71[_0x23d485('0x36')]['offset']));_0x3b8a7f[_0x23d485('0x3b')]=qs[_0x23d485('0x29')](_0x20ed71['query'][_0x23d485('0x29')]),_0x3b8a7f['where']=qs[_0x23d485('0x0')](_[_0x23d485('0xc')](_0x20ed71[_0x23d485('0x36')],_0x3b3ef9[_0x23d485('0x0')]),_0x34c49e);_0x20ed71[_0x23d485('0x36')]['filter']&&(_0x3b8a7f[_0x23d485('0x2')]=_[_0x23d485('0x46')](_0x3b8a7f[_0x23d485('0x2')],{[Op['or']]:_['map'](_0x34c49e,function(_0x5394d8){const _0x21c99b=_0x23d485;if(_0x5394d8[_0x21c99b('0x3c')]!==_0x21c99b('0x63')){const _0x4c7c4b={};return _0x4c7c4b[_0x5394d8[_0x21c99b('0x31')]]={[Op[_0x21c99b('0x59')]]:'%'+_0x20ed71[_0x21c99b('0x36')][_0x21c99b('0x56')]+'%'},_0x4c7c4b;}})}));_0x3b8a7f=_[_0x23d485('0x46')]({},_0x3b8a7f,_0x20ed71[_0x23d485('0x60')]);const _0x57f65e={'where':_0x3b8a7f[_0x23d485('0x2')]};return db[_0x23d485('0x52')]['count'](_0x57f65e)[_0x23d485('0x50')](function(_0x241a90){const _0x44591d=_0x23d485;return _0x1e36a3['count']=_0x241a90,_0x20ed71[_0x44591d('0x36')][_0x44591d('0x39')]&&(_0x3b8a7f[_0x44591d('0x68')]=[{'all':!![]}]),db[_0x44591d('0x52')][_0x44591d('0x62')](_0x3b8a7f);})['then'](function(_0x403e59){const _0x243919=_0x23d485;return _0x1e36a3[_0x243919('0x33')]=_0x403e59,_0x1e36a3;})[_0x23d485('0x50')](respondWithFilteredResult(_0x40dbba,_0x3b8a7f))['catch'](handleError(_0x40dbba,null));},exports[_0x484143('0x4e')]=function(_0x37eaf5,_0x5b17fe){const _0x20e161=_0x484143;let _0x2372f6={'raw':!![],'where':{'id':_0x37eaf5[_0x20e161('0x2c')]['id']}};const _0x56852b={};return _0x56852b[_0x20e161('0x40')]=_[_0x20e161('0x67')](db[_0x20e161('0x52')]['rawAttributes']),_0x56852b['query']=_['keys'](_0x37eaf5['query']),_0x56852b[_0x20e161('0x0')]=_['intersection'](_0x56852b[_0x20e161('0x40')],_0x56852b['query']),_0x2372f6[_0x20e161('0x44')]=_[_0x20e161('0x5c')](_0x56852b[_0x20e161('0x40')],qs[_0x20e161('0x3a')](_0x37eaf5[_0x20e161('0x36')][_0x20e161('0x3a')])),_0x2372f6[_0x20e161('0x44')]=_0x2372f6[_0x20e161('0x44')][_0x20e161('0x42')]?_0x2372f6[_0x20e161('0x44')]:_0x56852b[_0x20e161('0x40')],_0x37eaf5[_0x20e161('0x36')]['includeAll']&&(_0x2372f6[_0x20e161('0x68')]=[{'all':!![]}]),_0x2372f6=_[_0x20e161('0x46')]({},_0x2372f6,_0x37eaf5[_0x20e161('0x60')]),db['ChatQueue']['findOne'](_0x2372f6)['then'](handleEntityNotFound(_0x5b17fe,null))['then'](respondWithResult(_0x5b17fe,null))[_0x20e161('0x7')](handleError(_0x5b17fe,null));},exports[_0x484143('0x38')]=function(_0x39c908,_0x59a3c8){const _0x234898=_0x484143;return db['ChatQueue'][_0x234898('0x38')](_0x39c908[_0x234898('0x4c')],{})[_0x234898('0x50')](function(_0x3375dd){const _0x472b92=_0x234898,_0x410c90=_0x39c908[_0x472b92('0x43')]['get']({'plain':!![]});if(!_0x410c90)throw new Error(_0x472b92('0x45'));if(_0x410c90['role']===_0x472b92('0x43')){const _0x22cb6b=_0x3375dd[_0x472b92('0x35')]({'plain':!![]}),_0x5b5ec0='ChatQueues';return db[_0x472b92('0xf')][_0x472b92('0x4d')]({'where':{'name':_0x5b5ec0,'userProfileId':_0x410c90['userProfileId']},'raw':!![]})[_0x472b92('0x50')](function(_0x816c8c){const _0x558a88=_0x472b92;return _0x816c8c&&_0x816c8c[_0x558a88('0xa')]===0x0?db[_0x558a88('0x1a')][_0x558a88('0x38')]({'name':_0x22cb6b[_0x558a88('0x31')],'resourceId':_0x22cb6b['id'],'type':_0x816c8c[_0x558a88('0x31')],'sectionId':_0x816c8c['id']},{})[_0x558a88('0x50')](function(){return _0x3375dd;}):_0x3375dd;})['catch'](function(_0x568c71){const _0x1d86a6=_0x472b92;logger[_0x1d86a6('0x32')](_0x1d86a6('0x5e'),_0x568c71);throw _0x568c71;});}return _0x3375dd;})[_0x234898('0x50')](respondWithResult(_0x59a3c8,0xc9))[_0x234898('0x7')](handleError(_0x59a3c8,null));},exports[_0x484143('0x2a')]=function(_0x429460,_0x1e20d5){const _0xd6e386=_0x484143;return _0x429460[_0xd6e386('0x4c')]['id']&&delete _0x429460[_0xd6e386('0x4c')]['id'],db['ChatQueue'][_0xd6e386('0x4d')]({'where':{'id':_0x429460[_0xd6e386('0x2c')]['id']}})[_0xd6e386('0x50')](handleEntityNotFound(_0x1e20d5,null))[_0xd6e386('0x50')](saveUpdates(_0x429460['body'],null))['then'](respondWithResult(_0x1e20d5,null))[_0xd6e386('0x7')](handleError(_0x1e20d5,null));},exports[_0x484143('0x54')]=function(_0xbd7094,_0x41667b){const _0x1521a3=_0x484143;return db['ChatQueue'][_0x1521a3('0x4d')]({'where':{'id':_0xbd7094['params']['id']}})[_0x1521a3('0x50')](handleEntityNotFound(_0x41667b,null))[_0x1521a3('0x50')](removeEntity(_0x41667b,null))[_0x1521a3('0x7')](handleError(_0x41667b,null));},exports[_0x484143('0x58')]=function(_0x512bd2,_0x4a75a3){const _0x426538=_0x484143;return db['ChatQueue'][_0x426538('0x58')]()[_0x426538('0x50')](respondWithResult(_0x4a75a3,null))[_0x426538('0x7')](handleError(_0x4a75a3,null));},exports[_0x484143('0x1')]=function(_0x4678d2,_0x48fac1){const _0x416ecb=_0x484143;let _0xb1f4a7={'raw':!![],'where':{}};const _0x58233e={};let _0x5b2f33;return db[_0x416ecb('0x52')][_0x416ecb('0x4d')]({'where':{'id':_0x4678d2['params']['id']}})['then'](handleEntityNotFound(_0x48fac1,null))['then'](function(_0x2422f1){const _0x3fefe5=_0x416ecb;if(_0x2422f1)return _0x5b2f33=_0x2422f1['get']({'plain':!![]}),_0x58233e[_0x3fefe5('0x40')]=_[_0x3fefe5('0x67')](db[_0x3fefe5('0x5a')][_0x3fefe5('0xd')]),_0x58233e['query']=_['keys'](_0x4678d2['query']),_0x58233e[_0x3fefe5('0x0')]=_['intersection'](_0x58233e[_0x3fefe5('0x40')],_0x58233e['query']),_0xb1f4a7[_0x3fefe5('0x44')]=_[_0x3fefe5('0x5c')](_0x58233e['model'],qs['fields'](_0x4678d2[_0x3fefe5('0x36')][_0x3fefe5('0x3a')])),_0xb1f4a7['attributes']=_0xb1f4a7[_0x3fefe5('0x44')]['length']?_0xb1f4a7['attributes']:_0x58233e[_0x3fefe5('0x40')],typeof _0x4678d2[_0x3fefe5('0x36')][_0x3fefe5('0x2f')]==='undefined'&&(_0xb1f4a7[_0x3fefe5('0x61')]=qs['limit'](_0x4678d2[_0x3fefe5('0x36')]['limit']),_0xb1f4a7[_0x3fefe5('0x51')]=qs[_0x3fefe5('0x51')](_0x4678d2['query'][_0x3fefe5('0x51')])),_0xb1f4a7[_0x3fefe5('0x3b')]=qs[_0x3fefe5('0x29')](_0x4678d2[_0x3fefe5('0x36')][_0x3fefe5('0x29')]),_0xb1f4a7[_0x3fefe5('0x2')]=qs[_0x3fefe5('0x0')](_['pick'](_0x4678d2[_0x3fefe5('0x36')],_0x58233e['filters'])),_0xb1f4a7[_0x3fefe5('0x2')]['ChatQueueId']=_0x2422f1['id'],_0x4678d2[_0x3fefe5('0x36')][_0x3fefe5('0x56')]&&(_0xb1f4a7['where']=_[_0x3fefe5('0x46')](_0xb1f4a7['where'],{[Op['or']]:_['map'](_0xb1f4a7[_0x3fefe5('0x44')],function(_0x6bbcae){const _0x350865=_0x3fefe5,_0x445da2={};return _0x445da2[_0x6bbcae]={[Op['like']]:'%'+_0x4678d2['query'][_0x350865('0x56')]+'%'},_0x445da2;})})),_0xb1f4a7=_[_0x3fefe5('0x46')]({},_0xb1f4a7,_0x4678d2[_0x3fefe5('0x60')]),db['UserChatQueue'][_0x3fefe5('0x62')](_0xb1f4a7);})[_0x416ecb('0x50')](function(_0x219f58){const _0x5a7be5=_0x416ecb;if(_0x219f58)return db['User'][_0x5a7be5('0x1f')]({'where':{'id':_[_0x5a7be5('0x1d')](_0x219f58,_0x5a7be5('0x9')),'role':_0x5a7be5('0x28')},'attributes':['id',_0x5a7be5('0x31'),'chatPause','updatedAt',_0x5a7be5('0x66')]});})['then'](function(_0x485585){const _0x22c28f=_0x416ecb;return _0x485585?{'count':_0x485585['count'],'rows':_['map'](_0x485585[_0x22c28f('0x33')],function(_0x39e0c0){const _0x1784e6=_0x22c28f;return{'membername':_0x39e0c0[_0x1784e6('0x31')],'UserId':_0x39e0c0['id'],'queue_name':_0x5b2f33[_0x1784e6('0x31')],'ChatQueueId':_0x5b2f33['id'],'interface':util[_0x1784e6('0x2e')]('%s/%s','SIP',_0x39e0c0[_0x1784e6('0x31')]),'penalty':0x0,'paused':_0x39e0c0[_0x1784e6('0x8')],'createdAt':_0x39e0c0[_0x1784e6('0x66')],'updatedAt':_0x39e0c0[_0x1784e6('0xb')]};})}:{'count':0x0,'rows':[]};})[_0x416ecb('0x50')](respondWithFilteredResult(_0x48fac1,_0xb1f4a7))[_0x416ecb('0x7')](handleError(_0x48fac1,null));},exports['getTeams']=function(_0x3cc4f0,_0x4843df){const _0x171832=_0x484143;let _0x3f2e20={};const _0x9bf40={};let _0x2515a0,_0x4300cc;return db[_0x171832('0x52')]['findOne']({'where':{'id':_0x3cc4f0[_0x171832('0x2c')]['id']}})[_0x171832('0x50')](handleEntityNotFound(_0x4843df,null))['then'](function(_0x2007f7){const _0x23b68c=_0x171832;if(_0x2007f7)return _0x2515a0=_0x2007f7,_0x9bf40[_0x23b68c('0x40')]=_[_0x23b68c('0x67')](db[_0x23b68c('0x12')]['rawAttributes']),_0x9bf40[_0x23b68c('0x36')]=_['keys'](_0x3cc4f0['query']),_0x9bf40[_0x23b68c('0x0')]=_[_0x23b68c('0x5c')](_0x9bf40[_0x23b68c('0x40')],_0x9bf40['query']),_0x3f2e20[_0x23b68c('0x44')]=_[_0x23b68c('0x5c')](_0x9bf40[_0x23b68c('0x40')],qs[_0x23b68c('0x3a')](_0x3cc4f0[_0x23b68c('0x36')][_0x23b68c('0x3a')])),_0x3f2e20[_0x23b68c('0x44')]=_0x3f2e20[_0x23b68c('0x44')][_0x23b68c('0x42')]?_0x3f2e20[_0x23b68c('0x44')]:_0x9bf40[_0x23b68c('0x40')],_0x3f2e20[_0x23b68c('0x3b')]=qs[_0x23b68c('0x29')](_0x3cc4f0[_0x23b68c('0x36')]['sort']),_0x3f2e20[_0x23b68c('0x2')]=qs['filters'](_[_0x23b68c('0xc')](_0x3cc4f0[_0x23b68c('0x36')],_0x9bf40[_0x23b68c('0x0')])),_0x3cc4f0['query'][_0x23b68c('0x56')]&&(_0x3f2e20[_0x23b68c('0x2')]=_[_0x23b68c('0x46')](_0x3f2e20[_0x23b68c('0x2')],{[Op['or']]:_[_0x23b68c('0x1d')](_0x3f2e20['attributes'],function(_0x840fc1){const _0x25dad4=_0x23b68c,_0x5c635e={};return _0x5c635e[_0x840fc1]={[Op[_0x25dad4('0x59')]]:'%'+_0x3cc4f0['query'][_0x25dad4('0x56')]+'%'},_0x5c635e;})})),_0x3f2e20=_['merge']({},_0x3f2e20,_0x3cc4f0['options']),_0x2515a0[_0x23b68c('0x16')](_0x3f2e20);})[_0x171832('0x50')](function(_0x5a0f22){const _0x34277b=_0x171832;if(_0x5a0f22)return _0x4300cc=_0x5a0f22[_0x34277b('0x42')],typeof _0x3cc4f0['query'][_0x34277b('0x2f')]==='undefined'&&(_0x3f2e20[_0x34277b('0x61')]=qs[_0x34277b('0x61')](_0x3cc4f0[_0x34277b('0x36')][_0x34277b('0x61')]),_0x3f2e20[_0x34277b('0x51')]=qs[_0x34277b('0x51')](_0x3cc4f0['query']['offset'])),_0x2515a0[_0x34277b('0x16')](_0x3f2e20);})[_0x171832('0x50')](function(_0x58824f){if(_0x58824f)return _0x58824f?{'count':_0x4300cc,'rows':_0x58824f}:null;})['then'](respondWithResult(_0x4843df,null))['catch'](handleError(_0x4843df,null));},exports[_0x484143('0x24')]=function(_0x4a5a5b,_0xbfa842){const _0x34182e=_0x484143,_0x5ab9fc=_0x4a5a5b[_0x34182e('0x4c')]['ids'];return db[_0x34182e('0x12')][_0x34182e('0x62')]({'where':{'id':_0x5ab9fc},'attributes':['id'],'include':[{'model':db[_0x34182e('0x4f')],'as':_0x34182e('0x65'),'attributes':['id',_0x34182e('0x31'),_0x34182e('0x47'),'voicePause','interface'],'raw':!![]}]})[_0x34182e('0x50')](function(_0x34a0f2){const _0x11d52a=_0x34182e;if(_0x34a0f2){const _0x1fe783=_[_0x11d52a('0x4')](_0x34a0f2,function(_0x4d9076){const _0x173cc7=_0x11d52a,_0x5a815d=_0x4d9076[_0x173cc7('0x35')]({'plain':!![]});return _0x5a815d['Agents'];});return db[_0x11d52a('0x52')][_0x11d52a('0x4d')]({'where':{'id':_0x4a5a5b[_0x11d52a('0x2c')]['id']}})[_0x11d52a('0x50')](function(_0x310473){return db['sequelize']['transaction'](function(_0xff44ef){const _0x5bdcb9=a95_0x2f0e;return _0x310473[_0x5bdcb9('0x24')](_0x5ab9fc,{'transaction':_0xff44ef})[_0x5bdcb9('0x50')](function(){const _0x67580e=_0x5bdcb9;return Promise[_0x67580e('0x41')](_0x1fe783,function(_0x2891bd){const _0x692bf6=_0x67580e;return db['UserChatQueue'][_0x692bf6('0x49')]({'where':{'UserId':_0x2891bd['id'],'ChatQueueId':_0x4a5a5b[_0x692bf6('0x2c')]['id']},'transaction':_0xff44ef});});})[_0x5bdcb9('0x50')](function(){const _0x3ad91f=_0x5bdcb9;_0x1fe783[_0x3ad91f('0x21')](function(_0x1abad1){const _0x1b324c=_0x3ad91f;socket[_0x1b324c('0x23')](_0x1b324c('0x17'),{'UserId':_0x1abad1['id'],'ChatQueueId':_0x310473['id']});});});});});}})[_0x34182e('0x50')](respondWithStatusCode(_0xbfa842,null))[_0x34182e('0x7')](handleError(_0xbfa842,null));},exports[_0x484143('0x18')]=function(_0x3a7edd,_0x2e9afd){const _0x21225e=_0x484143;return db[_0x21225e('0x12')][_0x21225e('0x62')]({'where':{'id':_0x3a7edd['query'][_0x21225e('0x5')]},'attributes':['id'],'include':[{'model':db[_0x21225e('0x4f')],'as':_0x21225e('0x65'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x2e9afd,null))[_0x21225e('0x50')](function(_0x46865c){const _0x4f4880=_0x21225e,_0x19c848=_['map'](_0x46865c,'id');let _0x5720cc=[];const _0x37e4a6=[],_0x300c3b=squel[_0x4f4880('0x5f')]();_0x300c3b['field'](_0x4f4880('0x27'))[_0x4f4880('0x14')](_0x4f4880('0x1b'),'tq')['join'](_0x4f4880('0x22'),'ut',_0x4f4880('0x4a'))[_0x4f4880('0x2')](_0x4f4880('0x53'),_0x3a7edd[_0x4f4880('0x2c')]['id']);for(let _0x4a5f15=0x0;_0x4a5f15<_0x46865c[_0x4f4880('0x42')];_0x4a5f15+=0x1){const _0x366d89=_0x46865c[_0x4a5f15];for(let _0xe5b340=0x0;_0xe5b340<_0x366d89['Agents'][_0x4f4880('0x42')];_0xe5b340+=0x1){const _0x5ef8df=_0x366d89[_0x4f4880('0x65')][_0xe5b340],_0x53abd1=_0x300c3b['clone']();_0x53abd1[_0x4f4880('0x2')]('ut.UserId\x20=\x20?',_0x5ef8df['id']),_0x37e4a6[_0x4f4880('0x20')](db[_0x4f4880('0x10')][_0x4f4880('0x36')](_0x53abd1[_0x4f4880('0x5d')](),{'type':db[_0x4f4880('0x10')][_0x4f4880('0x3f')][_0x4f4880('0x25')]})['then'](function(_0x3fbad9){const _0x22325a=_0x4f4880;if(_0x3fbad9[_0x22325a('0x42')]===0x1)return _0x5ef8df['id'];else{const _0x4a286d=_['every'](_[_0x22325a('0x1d')](_0x3fbad9,'TeamId'),function(_0x18808f){return _['includes'](_0x19c848,_0x18808f);});if(_0x4a286d)return _0x5ef8df['id'];}}));}}return Promise['all'](_0x37e4a6)[_0x4f4880('0x50')](function(_0x320725){const _0x59c692=_0x4f4880;return _0x5720cc=_(_0x5720cc)['union'](_0x320725)[_0x59c692('0x2d')]()['value'](),db[_0x59c692('0x52')]['findOne']({'where':{'id':_0x3a7edd[_0x59c692('0x2c')]['id']}})[_0x59c692('0x50')](function(_0x3575a8){return db['sequelize']['transaction'](function(_0x4de5c7){const _0x572f86=a95_0x2f0e;return _0x3575a8['removeTeams'](_0x3a7edd['query'][_0x572f86('0x5')],{'transaction':_0x4de5c7})['then'](function(){const _0x1a4bd0=_0x572f86;if(!_['isEmpty'](_0x5720cc))return _0x3575a8[_0x1a4bd0('0x3')](_0x5720cc,{'transaction':_0x4de5c7});})[_0x572f86('0x50')](function(){const _0x5f3257=_0x572f86;_0x5720cc[_0x5f3257('0x21')](function(_0xb6dec4){const _0x58cac1=_0x5f3257;socket[_0x58cac1('0x23')]('userChatQueue:remove',{'UserId':_0xb6dec4,'ChatQueueId':_0x3575a8['id']});});});});});});})[_0x21225e('0x50')](respondWithStatusCode(_0x2e9afd,null))[_0x21225e('0x7')](handleError(_0x2e9afd,null));},exports[_0x484143('0x57')]=function(_0x38347c,_0xcbb739){const _0x29a5f6=_0x484143;return db['ChatQueue'][_0x29a5f6('0x4d')]({'where':{'id':_0x38347c['params']['id']}})['then'](function(_0x4640d3){const _0x57cdf2=_0x29a5f6;if(_0x4640d3)return _0x4640d3[_0x57cdf2('0x57')](_0x38347c[_0x57cdf2('0x4c')][_0x57cdf2('0x5')],{'through':_[_0x57cdf2('0xe')](_0x38347c[_0x57cdf2('0x4c')],[_0x57cdf2('0x5'),'id'])})['then'](function(_0x4e2867){const _0x352318=_0x57cdf2;for(let _0x3b3419=0x0;_0x3b3419<_0x38347c[_0x352318('0x4c')][_0x352318('0x5')]['length'];_0x3b3419+=0x1){socket[_0x352318('0x23')](_0x352318('0x17'),{'UserId':_0x38347c['body'][_0x352318('0x5')][_0x3b3419],'ChatQueueId':_0x38347c[_0x352318('0x2c')]['id']});}return _0x4e2867;});})['then'](respondWithResult(_0xcbb739,null))['catch'](handleError(_0xcbb739,null));},exports[_0x484143('0x3')]=function(_0x2abace,_0x415c35){const _0x1e03c7=_0x484143;return db[_0x1e03c7('0x52')][_0x1e03c7('0x4d')]({'where':{'id':_0x2abace[_0x1e03c7('0x2c')]['id']}})[_0x1e03c7('0x50')](handleEntityNotFound(_0x415c35,null))[_0x1e03c7('0x50')](function(_0x30c654){const _0x321425=_0x1e03c7;if(_0x30c654)return _0x30c654[_0x321425('0x3')](_0x2abace[_0x321425('0x36')][_0x321425('0x5')])['then'](function(){const _0x48fd0d=_0x321425;if(_['isArray'](_0x2abace[_0x48fd0d('0x36')]['ids']))for(let _0x59ac6f=0x0;_0x59ac6f<_0x2abace[_0x48fd0d('0x36')][_0x48fd0d('0x5')][_0x48fd0d('0x42')];_0x59ac6f+=0x1){socket[_0x48fd0d('0x23')](_0x48fd0d('0x1c'),{'UserId':Number(_0x2abace[_0x48fd0d('0x36')][_0x48fd0d('0x5')][_0x59ac6f]),'ChatQueueId':Number(_0x2abace[_0x48fd0d('0x2c')]['id'])});}else socket[_0x48fd0d('0x23')]('userChatQueue:remove',{'UserId':Number(_0x2abace[_0x48fd0d('0x36')][_0x48fd0d('0x5')]),'ChatQueueId':Number(_0x2abace[_0x48fd0d('0x2c')]['id'])});});})[_0x1e03c7('0x50')](respondWithStatusCode(_0x415c35,null))[_0x1e03c7('0x7')](handleError(_0x415c35,null));},exports['getAgents']=function(_0x1b6e09,_0x2d2fd6){const _0x118119=_0x484143;let _0x3582a7={};const _0x2bda3f={};let _0x225741,_0x8f9261;return db[_0x118119('0x52')][_0x118119('0x4d')]({'where':{'id':_0x1b6e09[_0x118119('0x2c')]['id']}})['then'](handleEntityNotFound(_0x2d2fd6,null))[_0x118119('0x50')](function(_0x304404){const _0xebd7a9=_0x118119;if(_0x304404)return _0x225741=_0x304404,_0x2bda3f[_0xebd7a9('0x40')]=_[_0xebd7a9('0x67')](db[_0xebd7a9('0x4f')][_0xebd7a9('0xd')]),_0x2bda3f[_0xebd7a9('0x36')]=_[_0xebd7a9('0x67')](_0x1b6e09[_0xebd7a9('0x36')]),_0x2bda3f[_0xebd7a9('0x0')]=_[_0xebd7a9('0x5c')](_0x2bda3f[_0xebd7a9('0x40')],_0x2bda3f[_0xebd7a9('0x36')]),_0x3582a7['attributes']=_[_0xebd7a9('0x5c')](_0x2bda3f[_0xebd7a9('0x40')],qs['fields'](_0x1b6e09[_0xebd7a9('0x36')][_0xebd7a9('0x3a')])),_0x3582a7[_0xebd7a9('0x44')]=_0x3582a7[_0xebd7a9('0x44')][_0xebd7a9('0x42')]?_0x3582a7[_0xebd7a9('0x44')]:_0x2bda3f['model'],_0x3582a7[_0xebd7a9('0x3b')]=qs[_0xebd7a9('0x29')](_0x1b6e09[_0xebd7a9('0x36')][_0xebd7a9('0x29')]),_0x3582a7['where']=qs['filters'](_[_0xebd7a9('0xc')](_0x1b6e09[_0xebd7a9('0x36')],_0x2bda3f[_0xebd7a9('0x0')])),_0x1b6e09['query'][_0xebd7a9('0x56')]&&(_0x3582a7['where']=_['merge'](_0x3582a7[_0xebd7a9('0x2')],{[Op['or']]:_[_0xebd7a9('0x1d')](_0x3582a7[_0xebd7a9('0x44')],function(_0x4f5302){const _0x3c98be=_0xebd7a9,_0x21bc3b={};return _0x21bc3b[_0x4f5302]={[Op[_0x3c98be('0x59')]]:'%'+_0x1b6e09[_0x3c98be('0x36')][_0x3c98be('0x56')]+'%'},_0x21bc3b;})})),_0x3582a7=_['merge']({},_0x3582a7,_0x1b6e09[_0xebd7a9('0x60')]),_0x225741['getAgents'](_0x3582a7);})['then'](function(_0xe66ce5){const _0x2d7dff=_0x118119;if(_0xe66ce5)return _0x8f9261=_0xe66ce5[_0x2d7dff('0x42')],typeof _0x1b6e09[_0x2d7dff('0x36')][_0x2d7dff('0x2f')]==='undefined'&&(_0x3582a7['limit']=qs[_0x2d7dff('0x61')](_0x1b6e09[_0x2d7dff('0x36')][_0x2d7dff('0x61')]),_0x3582a7[_0x2d7dff('0x51')]=qs[_0x2d7dff('0x51')](_0x1b6e09[_0x2d7dff('0x36')]['offset'])),_0x225741['getAgents'](_0x3582a7);})[_0x118119('0x50')](function(_0x5370f4){if(_0x5370f4)return _0x5370f4?{'count':_0x8f9261,'rows':_0x5370f4}:null;})[_0x118119('0x50')](respondWithResult(_0x2d2fd6,null))[_0x118119('0x7')](handleError(_0x2d2fd6,null));};