Built motion from commit ecdc8e66766c75b1b08288b0ea13eb12d42606b4. Version 3.0.0...
[motion-next.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 178f127..c63c1d7 100644 (file)
@@ -1 +1 @@
-const a808_0x429c=['userProfileId','value','where','../../components/parsers/qs','stack','addAgents','tq.TeamId','findOrCreate','ut.TeamId\x20=\x20tq.TeamId','describe','include','toString','offset','omit','json','user','type','removeTeams','from','status','interface','ut.UserId\x20=\x20?','order','sendStatus','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','findAll','WhatsappQueueId','push','Content-Range','./whatsappQueue.socket','undefined','transaction','all','lodash','Team','catch','clone','set','userWhatsappQueue:remove','body','findAndCountAll','isArray','VIRTUAL','User','addTeams','end','map','then','query','intersection','update','getAgents','team_has_whatsapp_queues','Unable\x20to\x20retrieve\x20the\x20current\x20user','createdAt','ids','sort','options','nolimit','name','format','whatsappPause','WhatsappQueueId\x20=\x20?','rows','../../mysqldb','Agents','emit','isEmpty','error','keys','autoAssociation','destroy','filter','union','WhatsappQueue','WhatsappQueues','filters','api','length','role','model','includes','get','send','forEach','../../rediscache','merge','params','count','UserId','like','pick','agent','every','userWhatsappQueue:save','compact','fields','UserProfileSection','show','getTeams','index','UserWhatsappQueue','getMembers','findOne','attributes','sequelize','create','limit','each','includeAll','removeAgents','select','../../config/logger','UserProfileResource','squel','updatedAt','rawAttributes','TeamId'];(function(_0x4b5aaf,_0x429c08){const _0x4fe405=function(_0x2d157b){while(--_0x2d157b){_0x4b5aaf['push'](_0x4b5aaf['shift']());}};_0x4fe405(++_0x429c08);}(a808_0x429c,0x6e));const a808_0x4fe4=function(_0x4b5aaf,_0x429c08){_0x4b5aaf=_0x4b5aaf-0x0;let _0x4fe405=a808_0x429c[_0x4b5aaf];return _0x4fe405;};const _0x29acfd=a808_0x4fe4;'use strict';const util=require('util'),_=require(_0x29acfd('0x29')),squel=require(_0x29acfd('0x4')),qs=require(_0x29acfd('0xb')),logger=require(_0x29acfd('0x2'))(_0x29acfd('0x55')),{getSocket}=require(_0x29acfd('0x5d')),socket=getSocket(),db=require(_0x29acfd('0x48'))['db'],{Op,QueryTypes}=require('sequelize');require(_0x29acfd('0x25'))['register'](socket);function respondWithStatusCode(_0x2d157b,_0x4826d7){return _0x4826d7=_0x4826d7||0xcc,function(_0x2c1ca1){const _0x5b78be=a808_0x4fe4;if(_0x2c1ca1)return _0x2d157b['sendStatus'](_0x4826d7);return _0x2d157b[_0x5b78be('0x1b')](_0x4826d7)[_0x5b78be('0x35')]();};}function respondWithResult(_0x50511e,_0x467f1f){return _0x467f1f=_0x467f1f||0xc8,function(_0x1e2d81){if(_0x1e2d81)return _0x50511e['status'](_0x467f1f)['json'](_0x1e2d81);};}function respondWithFilteredResult(_0x340d15,_0x59c166){return function(_0x10e643){const _0x1f97b7=a808_0x4fe4;if(_0x10e643){const _0x73015e=_0x10e643[_0x1f97b7('0x60')],_0x411f67=_0x59c166[_0x1f97b7('0x14')];let _0x35953a=_0x59c166[_0x1f97b7('0x14')]+_0x59c166[_0x1f97b7('0x73')],_0xa90a89;return _0x35953a>=_0x73015e?(_0x35953a=_0x73015e,_0xa90a89=0xc8):_0xa90a89=0xce,_0x340d15[_0x1f97b7('0x1b')](_0xa90a89),_0x340d15[_0x1f97b7('0x2d')](_0x1f97b7('0x24'),_0x411f67+'-'+_0x35953a+'/'+_0x73015e)[_0x1f97b7('0x16')](_0x10e643);}return null;};}function saveUpdates(_0x476af5){return function(_0x51c767){const _0x5612e4=a808_0x4fe4;if(_0x51c767)return _0x51c767[_0x5612e4('0x3a')](_0x476af5)[_0x5612e4('0x37')](function(_0x294f02){return _0x294f02;});return null;};}function removeEntity(_0x112209){return function(_0x16f0d8){const _0x3f4eec=a808_0x4fe4;if(_0x16f0d8)return _0x16f0d8[_0x3f4eec('0x4f')]()[_0x3f4eec('0x37')](function(){const _0x5a6e6f=_0x3f4eec,_0x36cc5d=_0x16f0d8[_0x5a6e6f('0x5a')]({'plain':!![]}),_0x27a377=_0x5a6e6f('0x53');return db[_0x5a6e6f('0x3')][_0x5a6e6f('0x4f')]({'where':{'type':_0x27a377,'resourceId':_0x36cc5d['id']}})[_0x5a6e6f('0x37')](function(){return _0x16f0d8;});})[_0x3f4eec('0x37')](function(){const _0x540a2a=_0x3f4eec;_0x112209[_0x540a2a('0x1b')](0xcc)['end']();});};}function handleEntityNotFound(_0x4ecb99){return function(_0x16a51c){const _0x18b0bd=a808_0x4fe4;return!_0x16a51c&&_0x4ecb99[_0x18b0bd('0x1f')](0x194),_0x16a51c;};}function handleError(_0xa4f010,_0x3b54bf){return _0x3b54bf=_0x3b54bf||0x1f4,function(_0x3d1f8e){const _0x1b43fd=a808_0x4fe4;logger[_0x1b43fd('0x4c')](_0x3d1f8e[_0x1b43fd('0xc')]),_0x3d1f8e[_0x1b43fd('0x43')]&&delete _0x3d1f8e[_0x1b43fd('0x43')],_0xa4f010[_0x1b43fd('0x1b')](_0x3b54bf)[_0x1b43fd('0x5b')](_0x3d1f8e);};}exports[_0x29acfd('0x6c')]=function(_0x4dc4ca,_0x5eb569){const _0x248af3=_0x29acfd;let _0xaa37ff={};const _0x533361={},_0x459dc7={'count':0x0,'rows':[]},_0x2a52d4=_[_0x248af3('0x36')](db[_0x248af3('0x52')][_0x248af3('0x6')],function(_0x5f133d){const _0x1243c3=_0x248af3;return{'name':_0x5f133d['fieldName'],'type':_0x5f133d[_0x1243c3('0x18')]['key']};});_0x533361['model']=_[_0x248af3('0x36')](_0x2a52d4,'name'),_0x533361['query']=_['keys'](_0x4dc4ca[_0x248af3('0x38')]),_0x533361[_0x248af3('0x54')]=_['intersection'](_0x533361[_0x248af3('0x58')],_0x533361[_0x248af3('0x38')]),_0xaa37ff[_0x248af3('0x70')]=_[_0x248af3('0x39')](_0x533361[_0x248af3('0x58')],qs[_0x248af3('0x68')](_0x4dc4ca[_0x248af3('0x38')][_0x248af3('0x68')])),_0xaa37ff[_0x248af3('0x70')]=_0xaa37ff[_0x248af3('0x70')][_0x248af3('0x56')]?_0xaa37ff[_0x248af3('0x70')]:_0x533361[_0x248af3('0x58')];typeof _0x4dc4ca[_0x248af3('0x38')][_0x248af3('0x42')]==='undefined'&&(_0xaa37ff[_0x248af3('0x73')]=qs[_0x248af3('0x73')](_0x4dc4ca['query'][_0x248af3('0x73')]),_0xaa37ff[_0x248af3('0x14')]=qs[_0x248af3('0x14')](_0x4dc4ca[_0x248af3('0x38')][_0x248af3('0x14')]));_0xaa37ff['order']=qs[_0x248af3('0x40')](_0x4dc4ca[_0x248af3('0x38')]['sort']),_0xaa37ff['where']=qs[_0x248af3('0x54')](_[_0x248af3('0x63')](_0x4dc4ca[_0x248af3('0x38')],_0x533361[_0x248af3('0x54')]),_0x2a52d4);_0x4dc4ca[_0x248af3('0x38')][_0x248af3('0x50')]&&(_0xaa37ff['where']=_['merge'](_0xaa37ff['where'],{[Op['or']]:_[_0x248af3('0x36')](_0x2a52d4,function(_0x57b3db){const _0x22df5c=_0x248af3;if(_0x57b3db['type']!==_0x22df5c('0x32')){const _0xdd52c3={};return _0xdd52c3[_0x57b3db[_0x22df5c('0x43')]]={[Op[_0x22df5c('0x62')]]:'%'+_0x4dc4ca[_0x22df5c('0x38')][_0x22df5c('0x50')]+'%'},_0xdd52c3;}})}));_0xaa37ff=_[_0x248af3('0x5e')]({},_0xaa37ff,_0x4dc4ca[_0x248af3('0x41')]);const _0x5d3f1d={'where':_0xaa37ff[_0x248af3('0xa')]};return db[_0x248af3('0x52')]['count'](_0x5d3f1d)[_0x248af3('0x37')](function(_0x2b95cf){const _0x510a86=_0x248af3;return _0x459dc7[_0x510a86('0x60')]=_0x2b95cf,_0x4dc4ca[_0x510a86('0x38')][_0x510a86('0x75')]&&(_0xaa37ff[_0x510a86('0x12')]=[{'all':!![]}]),db['WhatsappQueue'][_0x510a86('0x21')](_0xaa37ff);})[_0x248af3('0x37')](function(_0x1dedce){const _0x18ee97=_0x248af3;return _0x459dc7[_0x18ee97('0x47')]=_0x1dedce,_0x459dc7;})['then'](respondWithFilteredResult(_0x5eb569,_0xaa37ff))[_0x248af3('0x2b')](handleError(_0x5eb569,null));},exports[_0x29acfd('0x6a')]=function(_0x13c158,_0x427360){const _0x2ec0bc=_0x29acfd;let _0x34353d={'raw':!![],'where':{'id':_0x13c158[_0x2ec0bc('0x5f')]['id']}};const _0x2f8ea8={};return _0x2f8ea8[_0x2ec0bc('0x58')]=_[_0x2ec0bc('0x4d')](db[_0x2ec0bc('0x52')][_0x2ec0bc('0x6')]),_0x2f8ea8[_0x2ec0bc('0x38')]=_['keys'](_0x13c158[_0x2ec0bc('0x38')]),_0x2f8ea8['filters']=_[_0x2ec0bc('0x39')](_0x2f8ea8[_0x2ec0bc('0x58')],_0x2f8ea8[_0x2ec0bc('0x38')]),_0x34353d[_0x2ec0bc('0x70')]=_[_0x2ec0bc('0x39')](_0x2f8ea8[_0x2ec0bc('0x58')],qs[_0x2ec0bc('0x68')](_0x13c158[_0x2ec0bc('0x38')]['fields'])),_0x34353d[_0x2ec0bc('0x70')]=_0x34353d[_0x2ec0bc('0x70')][_0x2ec0bc('0x56')]?_0x34353d[_0x2ec0bc('0x70')]:_0x2f8ea8[_0x2ec0bc('0x58')],_0x13c158[_0x2ec0bc('0x38')][_0x2ec0bc('0x75')]&&(_0x34353d[_0x2ec0bc('0x12')]=[{'all':!![]}]),_0x34353d=_[_0x2ec0bc('0x5e')]({},_0x34353d,_0x13c158[_0x2ec0bc('0x41')]),db['WhatsappQueue'][_0x2ec0bc('0x6f')](_0x34353d)[_0x2ec0bc('0x37')](handleEntityNotFound(_0x427360,null))[_0x2ec0bc('0x37')](respondWithResult(_0x427360,null))[_0x2ec0bc('0x2b')](handleError(_0x427360,null));},exports[_0x29acfd('0x72')]=function(_0x5611c5,_0x327020){const _0x2b084b=_0x29acfd;return db[_0x2b084b('0x52')][_0x2b084b('0x72')](_0x5611c5[_0x2b084b('0x2f')],{})[_0x2b084b('0x37')](function(_0x1e8b5a){const _0x13b9ae=_0x2b084b,_0x20b033=_0x5611c5['user']['get']({'plain':!![]});if(!_0x20b033)throw new Error(_0x13b9ae('0x3d'));if(_0x20b033[_0x13b9ae('0x57')]===_0x13b9ae('0x17')){const _0x5ccb7f=_0x1e8b5a[_0x13b9ae('0x5a')]({'plain':!![]}),_0x5bb6e0='WhatsappQueues';return db[_0x13b9ae('0x69')][_0x13b9ae('0x6f')]({'where':{'name':_0x5bb6e0,'userProfileId':_0x20b033[_0x13b9ae('0x8')]},'raw':!![]})[_0x13b9ae('0x37')](function(_0x232dd7){const _0x5b2923=_0x13b9ae;return _0x232dd7&&_0x232dd7[_0x5b2923('0x4e')]===0x0?db[_0x5b2923('0x3')][_0x5b2923('0x72')]({'name':_0x5ccb7f[_0x5b2923('0x43')],'resourceId':_0x5ccb7f['id'],'type':_0x232dd7[_0x5b2923('0x43')],'sectionId':_0x232dd7['id']},{})[_0x5b2923('0x37')](function(){return _0x1e8b5a;}):_0x1e8b5a;})['catch'](function(_0x4e8550){const _0x24a433=_0x13b9ae;logger['error'](_0x24a433('0x20'),_0x4e8550);throw _0x4e8550;});}return _0x1e8b5a;})['then'](respondWithResult(_0x327020,0xc9))[_0x2b084b('0x2b')](handleError(_0x327020,null));},exports[_0x29acfd('0x3a')]=function(_0x36c609,_0x5a65bd){const _0x1270f2=_0x29acfd;return _0x36c609['body']['id']&&delete _0x36c609['body']['id'],db[_0x1270f2('0x52')][_0x1270f2('0x6f')]({'where':{'id':_0x36c609[_0x1270f2('0x5f')]['id']}})[_0x1270f2('0x37')](handleEntityNotFound(_0x5a65bd,null))[_0x1270f2('0x37')](saveUpdates(_0x36c609[_0x1270f2('0x2f')],null))[_0x1270f2('0x37')](respondWithResult(_0x5a65bd,null))['catch'](handleError(_0x5a65bd,null));},exports[_0x29acfd('0x4f')]=function(_0x175b6a,_0x23f31d){const _0x53681e=_0x29acfd;return db[_0x53681e('0x52')]['findOne']({'where':{'id':_0x175b6a[_0x53681e('0x5f')]['id']}})[_0x53681e('0x37')](handleEntityNotFound(_0x23f31d,null))['then'](removeEntity(_0x23f31d,null))[_0x53681e('0x2b')](handleError(_0x23f31d,null));},exports[_0x29acfd('0x11')]=function(_0x3202ab,_0x19f2ce){const _0x418c31=_0x29acfd;return db[_0x418c31('0x52')][_0x418c31('0x11')]()[_0x418c31('0x37')](respondWithResult(_0x19f2ce,null))['catch'](handleError(_0x19f2ce,null));},exports[_0x29acfd('0x6e')]=function(_0x3dfa3f,_0x30a633){const _0x56c517=_0x29acfd;let _0x380273={'raw':!![],'where':{}};const _0x3b3576={};let _0x11de73;return db[_0x56c517('0x52')][_0x56c517('0x6f')]({'where':{'id':_0x3dfa3f[_0x56c517('0x5f')]['id']}})[_0x56c517('0x37')](handleEntityNotFound(_0x30a633,null))[_0x56c517('0x37')](function(_0x9d2cc){const _0x2173da=_0x56c517;if(_0x9d2cc)return _0x11de73=_0x9d2cc['get']({'plain':!![]}),_0x3b3576['model']=_[_0x2173da('0x4d')](db[_0x2173da('0x6d')][_0x2173da('0x6')]),_0x3b3576[_0x2173da('0x38')]=_['keys'](_0x3dfa3f[_0x2173da('0x38')]),_0x3b3576[_0x2173da('0x54')]=_[_0x2173da('0x39')](_0x3b3576[_0x2173da('0x58')],_0x3b3576[_0x2173da('0x38')]),_0x380273[_0x2173da('0x70')]=_[_0x2173da('0x39')](_0x3b3576[_0x2173da('0x58')],qs[_0x2173da('0x68')](_0x3dfa3f['query'][_0x2173da('0x68')])),_0x380273[_0x2173da('0x70')]=_0x380273[_0x2173da('0x70')]['length']?_0x380273['attributes']:_0x3b3576[_0x2173da('0x58')],typeof _0x3dfa3f[_0x2173da('0x38')][_0x2173da('0x42')]===_0x2173da('0x26')&&(_0x380273[_0x2173da('0x73')]=qs[_0x2173da('0x73')](_0x3dfa3f[_0x2173da('0x38')][_0x2173da('0x73')]),_0x380273[_0x2173da('0x14')]=qs[_0x2173da('0x14')](_0x3dfa3f[_0x2173da('0x38')][_0x2173da('0x14')])),_0x380273[_0x2173da('0x1e')]=qs[_0x2173da('0x40')](_0x3dfa3f['query'][_0x2173da('0x40')]),_0x380273[_0x2173da('0xa')]=qs[_0x2173da('0x54')](_[_0x2173da('0x63')](_0x3dfa3f[_0x2173da('0x38')],_0x3b3576[_0x2173da('0x54')])),_0x380273[_0x2173da('0xa')][_0x2173da('0x22')]=_0x9d2cc['id'],_0x3dfa3f[_0x2173da('0x38')][_0x2173da('0x50')]&&(_0x380273[_0x2173da('0xa')]=_[_0x2173da('0x5e')](_0x380273[_0x2173da('0xa')],{[Op['or']]:_[_0x2173da('0x36')](_0x380273[_0x2173da('0x70')],function(_0x120f80){const _0x1b1bb4=_0x2173da,_0x38b9c4={};return _0x38b9c4[_0x120f80]={[Op[_0x1b1bb4('0x62')]]:'%'+_0x3dfa3f[_0x1b1bb4('0x38')][_0x1b1bb4('0x50')]+'%'},_0x38b9c4;})})),_0x380273=_[_0x2173da('0x5e')]({},_0x380273,_0x3dfa3f[_0x2173da('0x41')]),db[_0x2173da('0x6d')]['findAll'](_0x380273);})[_0x56c517('0x37')](function(_0x162eef){const _0x1128ef=_0x56c517;if(_0x162eef)return db['User'][_0x1128ef('0x30')]({'where':{'id':_[_0x1128ef('0x36')](_0x162eef,_0x1128ef('0x61')),'role':_0x1128ef('0x64')},'attributes':['id',_0x1128ef('0x43'),_0x1128ef('0x45'),'updatedAt',_0x1128ef('0x3e')]});})[_0x56c517('0x37')](function(_0x25bb39){const _0x21840f=_0x56c517;return _0x25bb39?{'count':_0x25bb39[_0x21840f('0x60')],'rows':_['map'](_0x25bb39[_0x21840f('0x47')],function(_0x17c276){const _0x305917=_0x21840f;return{'membername':_0x17c276[_0x305917('0x43')],'UserId':_0x17c276['id'],'queue_name':_0x11de73[_0x305917('0x43')],'WhatsappQueueId':_0x11de73['id'],'interface':util[_0x305917('0x44')]('%s/%s','SIP',_0x17c276[_0x305917('0x43')]),'penalty':0x0,'paused':_0x17c276['whatsappPause'],'createdAt':_0x17c276[_0x305917('0x3e')],'updatedAt':_0x17c276[_0x305917('0x5')]};})}:{'count':0x0,'rows':[]};})[_0x56c517('0x37')](respondWithFilteredResult(_0x30a633,_0x380273))[_0x56c517('0x2b')](handleError(_0x30a633,null));},exports[_0x29acfd('0x6b')]=function(_0x4f80bc,_0x1b0f5f){const _0x340035=_0x29acfd;let _0x184295={};const _0x150090={};let _0x4320e7,_0x5b7f07;return db[_0x340035('0x52')][_0x340035('0x6f')]({'where':{'id':_0x4f80bc[_0x340035('0x5f')]['id']}})[_0x340035('0x37')](handleEntityNotFound(_0x1b0f5f,null))[_0x340035('0x37')](function(_0x58308e){const _0x4100bf=_0x340035;if(_0x58308e)return _0x4320e7=_0x58308e,_0x150090[_0x4100bf('0x58')]=_['keys'](db['Team'][_0x4100bf('0x6')]),_0x150090[_0x4100bf('0x38')]=_[_0x4100bf('0x4d')](_0x4f80bc[_0x4100bf('0x38')]),_0x150090[_0x4100bf('0x54')]=_[_0x4100bf('0x39')](_0x150090['model'],_0x150090[_0x4100bf('0x38')]),_0x184295[_0x4100bf('0x70')]=_['intersection'](_0x150090[_0x4100bf('0x58')],qs[_0x4100bf('0x68')](_0x4f80bc[_0x4100bf('0x38')][_0x4100bf('0x68')])),_0x184295[_0x4100bf('0x70')]=_0x184295['attributes'][_0x4100bf('0x56')]?_0x184295[_0x4100bf('0x70')]:_0x150090['model'],_0x184295[_0x4100bf('0x1e')]=qs['sort'](_0x4f80bc[_0x4100bf('0x38')][_0x4100bf('0x40')]),_0x184295[_0x4100bf('0xa')]=qs['filters'](_[_0x4100bf('0x63')](_0x4f80bc[_0x4100bf('0x38')],_0x150090[_0x4100bf('0x54')])),_0x4f80bc['query'][_0x4100bf('0x50')]&&(_0x184295[_0x4100bf('0xa')]=_[_0x4100bf('0x5e')](_0x184295[_0x4100bf('0xa')],{[Op['or']]:_[_0x4100bf('0x36')](_0x184295[_0x4100bf('0x70')],function(_0x5a6372){const _0x2dc56c=_0x4100bf,_0x18b41f={};return _0x18b41f[_0x5a6372]={[Op[_0x2dc56c('0x62')]]:'%'+_0x4f80bc[_0x2dc56c('0x38')][_0x2dc56c('0x50')]+'%'},_0x18b41f;})})),_0x184295=_[_0x4100bf('0x5e')]({},_0x184295,_0x4f80bc[_0x4100bf('0x41')]),_0x4320e7[_0x4100bf('0x6b')](_0x184295);})[_0x340035('0x37')](function(_0x21d9d6){const _0x2b809=_0x340035;if(_0x21d9d6)return _0x5b7f07=_0x21d9d6[_0x2b809('0x56')],typeof _0x4f80bc[_0x2b809('0x38')][_0x2b809('0x42')]===_0x2b809('0x26')&&(_0x184295['limit']=qs[_0x2b809('0x73')](_0x4f80bc[_0x2b809('0x38')][_0x2b809('0x73')]),_0x184295[_0x2b809('0x14')]=qs['offset'](_0x4f80bc[_0x2b809('0x38')]['offset'])),_0x4320e7[_0x2b809('0x6b')](_0x184295);})[_0x340035('0x37')](function(_0xa0798){if(_0xa0798)return _0xa0798?{'count':_0x5b7f07,'rows':_0xa0798}:null;})['then'](respondWithResult(_0x1b0f5f,null))[_0x340035('0x2b')](handleError(_0x1b0f5f,null));},exports[_0x29acfd('0x34')]=function(_0x1021b3,_0x10993a){const _0x17c436=_0x29acfd,_0x4bec0f=_0x1021b3[_0x17c436('0x2f')][_0x17c436('0x3f')];return db['Team'][_0x17c436('0x21')]({'where':{'id':_0x4bec0f},'attributes':['id'],'include':[{'model':db['User'],'as':_0x17c436('0x49'),'attributes':['id',_0x17c436('0x43'),'online','voicePause',_0x17c436('0x1c')],'raw':!![]}]})['then'](function(_0x498504){const _0x3d9eee=_0x17c436;if(_0x498504){const _0xfbc532=_['flatMap'](_0x498504,function(_0x3bd832){const _0x2fb5c3=a808_0x4fe4,_0x2b0499=_0x3bd832[_0x2fb5c3('0x5a')]({'plain':!![]});return _0x2b0499['Agents'];});return db[_0x3d9eee('0x52')][_0x3d9eee('0x6f')]({'where':{'id':_0x1021b3[_0x3d9eee('0x5f')]['id']}})[_0x3d9eee('0x37')](function(_0x58b626){const _0x903e6=_0x3d9eee;return db[_0x903e6('0x71')][_0x903e6('0x27')](function(_0x363ce2){const _0x278a2d=_0x903e6;return _0x58b626[_0x278a2d('0x34')](_0x4bec0f,{'transaction':_0x363ce2})[_0x278a2d('0x37')](function(){const _0x52a770=_0x278a2d;return Promise[_0x52a770('0x74')](_0xfbc532,function(_0x272fb8){const _0x3600be=_0x52a770;return db[_0x3600be('0x6d')][_0x3600be('0xf')]({'where':{'UserId':_0x272fb8['id'],'WhatsappQueueId':_0x1021b3[_0x3600be('0x5f')]['id']},'transaction':_0x363ce2});});})[_0x278a2d('0x37')](function(){_0xfbc532['forEach'](function(_0x438882){const _0x568614=a808_0x4fe4;socket[_0x568614('0x4a')](_0x568614('0x66'),{'UserId':_0x438882['id'],'WhatsappQueueId':_0x58b626['id']});});});});});}})[_0x17c436('0x37')](respondWithStatusCode(_0x10993a,null))[_0x17c436('0x2b')](handleError(_0x10993a,null));},exports[_0x29acfd('0x19')]=function(_0x570d3b,_0xd68b55){const _0x5a72de=_0x29acfd;return db[_0x5a72de('0x2a')]['findAll']({'where':{'id':_0x570d3b['query']['ids']},'attributes':['id'],'include':[{'model':db[_0x5a72de('0x33')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x5a72de('0x37')](handleEntityNotFound(_0xd68b55,null))['then'](function(_0x26c0c8){const _0x59e5a4=_0x5a72de,_0x39f427=_[_0x59e5a4('0x36')](_0x26c0c8,'id');let _0x1e9086=[];const _0x2d4a9d=[],_0x3082cf=squel[_0x59e5a4('0x1')]();_0x3082cf['field'](_0x59e5a4('0xe'))[_0x59e5a4('0x1a')](_0x59e5a4('0x3c'),'tq')['join']('user_has_teams','ut',_0x59e5a4('0x10'))[_0x59e5a4('0xa')](_0x59e5a4('0x46'),_0x570d3b[_0x59e5a4('0x5f')]['id']);for(let _0xb8fc32=0x0;_0xb8fc32<_0x26c0c8[_0x59e5a4('0x56')];_0xb8fc32+=0x1){const _0x4b7333=_0x26c0c8[_0xb8fc32];for(let _0x6b7eb9=0x0;_0x6b7eb9<_0x4b7333[_0x59e5a4('0x49')]['length'];_0x6b7eb9+=0x1){const _0x58328e=_0x4b7333[_0x59e5a4('0x49')][_0x6b7eb9],_0x149bb0=_0x3082cf[_0x59e5a4('0x2c')]();_0x149bb0[_0x59e5a4('0xa')](_0x59e5a4('0x1d'),_0x58328e['id']),_0x2d4a9d[_0x59e5a4('0x23')](db[_0x59e5a4('0x71')]['query'](_0x149bb0[_0x59e5a4('0x13')](),{'type':QueryTypes['SELECT']})['then'](function(_0x376263){const _0x52afbf=_0x59e5a4;if(_0x376263[_0x52afbf('0x56')]===0x1)return _0x58328e['id'];else{const _0x5b005a=_[_0x52afbf('0x65')](_[_0x52afbf('0x36')](_0x376263,_0x52afbf('0x7')),function(_0x1dfaf3){const _0x1c25ff=_0x52afbf;return _[_0x1c25ff('0x59')](_0x39f427,_0x1dfaf3);});if(_0x5b005a)return _0x58328e['id'];}}));}}return Promise[_0x59e5a4('0x28')](_0x2d4a9d)[_0x59e5a4('0x37')](function(_0x17c026){const _0xd9c09f=_0x59e5a4;return _0x1e9086=_(_0x1e9086)[_0xd9c09f('0x51')](_0x17c026)[_0xd9c09f('0x67')]()[_0xd9c09f('0x9')](),db['WhatsappQueue'][_0xd9c09f('0x6f')]({'where':{'id':_0x570d3b[_0xd9c09f('0x5f')]['id']}})[_0xd9c09f('0x37')](function(_0x193d04){const _0x25d678=_0xd9c09f;return db[_0x25d678('0x71')][_0x25d678('0x27')](function(_0x1e1bb2){const _0x2429c0=_0x25d678;return _0x193d04['removeTeams'](_0x570d3b[_0x2429c0('0x38')][_0x2429c0('0x3f')],{'transaction':_0x1e1bb2})[_0x2429c0('0x37')](function(){const _0x4c40db=_0x2429c0;if(!_[_0x4c40db('0x4b')](_0x1e9086))return _0x193d04[_0x4c40db('0x0')](_0x1e9086,{'transaction':_0x1e1bb2});})[_0x2429c0('0x37')](function(){const _0x12a7b1=_0x2429c0;_0x1e9086[_0x12a7b1('0x5c')](function(_0x12fc70){const _0x5108dc=_0x12a7b1;socket[_0x5108dc('0x4a')](_0x5108dc('0x2e'),{'UserId':_0x12fc70,'WhatsappQueueId':_0x193d04['id']});});});});});});})[_0x5a72de('0x37')](respondWithStatusCode(_0xd68b55,null))['catch'](handleError(_0xd68b55,null));},exports[_0x29acfd('0xd')]=function(_0x7bffe4,_0x1ea100){const _0xa9b45d=_0x29acfd;return db[_0xa9b45d('0x52')][_0xa9b45d('0x6f')]({'where':{'id':_0x7bffe4[_0xa9b45d('0x5f')]['id']}})['then'](function(_0xc09140){const _0x32878f=_0xa9b45d;if(_0xc09140)return _0xc09140['addAgents'](_0x7bffe4[_0x32878f('0x2f')][_0x32878f('0x3f')],{'through':_[_0x32878f('0x15')](_0x7bffe4['body'],[_0x32878f('0x3f'),'id'])})[_0x32878f('0x37')](function(_0x4a5c0e){const _0x3c6295=_0x32878f;for(let _0x2232f7=0x0;_0x2232f7<_0x7bffe4[_0x3c6295('0x2f')]['ids'][_0x3c6295('0x56')];_0x2232f7+=0x1){socket[_0x3c6295('0x4a')](_0x3c6295('0x66'),{'UserId':_0x7bffe4['body'][_0x3c6295('0x3f')][_0x2232f7],'WhatsappQueueId':_0x7bffe4[_0x3c6295('0x5f')]['id']});}return _0x4a5c0e;});})['then'](respondWithResult(_0x1ea100,null))[_0xa9b45d('0x2b')](handleError(_0x1ea100,null));},exports['removeAgents']=function(_0x18b0ed,_0x2272b2){const _0x2eca7f=_0x29acfd;return db[_0x2eca7f('0x52')][_0x2eca7f('0x6f')]({'where':{'id':_0x18b0ed[_0x2eca7f('0x5f')]['id']}})['then'](handleEntityNotFound(_0x2272b2,null))['then'](function(_0xad1c53){const _0x50c86f=_0x2eca7f;if(_0xad1c53)return _0xad1c53[_0x50c86f('0x0')](_0x18b0ed[_0x50c86f('0x38')]['ids'])[_0x50c86f('0x37')](function(){const _0x993139=_0x50c86f;if(_[_0x993139('0x31')](_0x18b0ed['query'][_0x993139('0x3f')]))for(let _0x549bb5=0x0;_0x549bb5<_0x18b0ed[_0x993139('0x38')]['ids'][_0x993139('0x56')];_0x549bb5+=0x1){socket[_0x993139('0x4a')](_0x993139('0x2e'),{'UserId':Number(_0x18b0ed[_0x993139('0x38')][_0x993139('0x3f')][_0x549bb5]),'WhatsappQueueId':Number(_0x18b0ed['params']['id'])});}else socket[_0x993139('0x4a')]('userWhatsappQueue:remove',{'UserId':Number(_0x18b0ed['query'][_0x993139('0x3f')]),'WhatsappQueueId':Number(_0x18b0ed[_0x993139('0x5f')]['id'])});});})['then'](respondWithStatusCode(_0x2272b2,null))[_0x2eca7f('0x2b')](handleError(_0x2272b2,null));},exports[_0x29acfd('0x3b')]=function(_0x380748,_0xd1321d){const _0x3af799=_0x29acfd;let _0x4a6ac4={};const _0x4a3994={};let _0x25ca2f,_0x3e22a4;return db['WhatsappQueue']['findOne']({'where':{'id':_0x380748[_0x3af799('0x5f')]['id']}})[_0x3af799('0x37')](handleEntityNotFound(_0xd1321d,null))[_0x3af799('0x37')](function(_0x3250a7){const _0x1e0afb=_0x3af799;if(_0x3250a7)return _0x25ca2f=_0x3250a7,_0x4a3994['model']=_[_0x1e0afb('0x4d')](db[_0x1e0afb('0x33')]['rawAttributes']),_0x4a3994[_0x1e0afb('0x38')]=_[_0x1e0afb('0x4d')](_0x380748[_0x1e0afb('0x38')]),_0x4a3994[_0x1e0afb('0x54')]=_[_0x1e0afb('0x39')](_0x4a3994[_0x1e0afb('0x58')],_0x4a3994[_0x1e0afb('0x38')]),_0x4a6ac4[_0x1e0afb('0x70')]=_[_0x1e0afb('0x39')](_0x4a3994[_0x1e0afb('0x58')],qs['fields'](_0x380748[_0x1e0afb('0x38')]['fields'])),_0x4a6ac4['attributes']=_0x4a6ac4['attributes'][_0x1e0afb('0x56')]?_0x4a6ac4[_0x1e0afb('0x70')]:_0x4a3994[_0x1e0afb('0x58')],_0x4a6ac4['order']=qs[_0x1e0afb('0x40')](_0x380748[_0x1e0afb('0x38')][_0x1e0afb('0x40')]),_0x4a6ac4['where']=qs['filters'](_[_0x1e0afb('0x63')](_0x380748['query'],_0x4a3994[_0x1e0afb('0x54')])),_0x380748[_0x1e0afb('0x38')][_0x1e0afb('0x50')]&&(_0x4a6ac4[_0x1e0afb('0xa')]=_['merge'](_0x4a6ac4[_0x1e0afb('0xa')],{[Op['or']]:_[_0x1e0afb('0x36')](_0x4a6ac4[_0x1e0afb('0x70')],function(_0x603e3e){const _0x275fb5={};return _0x275fb5[_0x603e3e]={[Op['like']]:'%'+_0x380748['query']['filter']+'%'},_0x275fb5;})})),_0x4a6ac4=_[_0x1e0afb('0x5e')]({},_0x4a6ac4,_0x380748['options']),_0x25ca2f[_0x1e0afb('0x3b')](_0x4a6ac4);})['then'](function(_0x2e4db3){const _0x448984=_0x3af799;if(_0x2e4db3)return _0x3e22a4=_0x2e4db3[_0x448984('0x56')],typeof _0x380748[_0x448984('0x38')]['nolimit']===_0x448984('0x26')&&(_0x4a6ac4[_0x448984('0x73')]=qs[_0x448984('0x73')](_0x380748[_0x448984('0x38')][_0x448984('0x73')]),_0x4a6ac4[_0x448984('0x14')]=qs['offset'](_0x380748['query'][_0x448984('0x14')])),_0x25ca2f[_0x448984('0x3b')](_0x4a6ac4);})['then'](function(_0xed3b3){if(_0xed3b3)return _0xed3b3?{'count':_0x3e22a4,'rows':_0xed3b3}:null;})[_0x3af799('0x37')](respondWithResult(_0xd1321d,null))['catch'](handleError(_0xd1321d,null));};
\ No newline at end of file
+const a808_0x350e=['error','limit','online','rawAttributes','removeAgents','value','select','sequelize','register','interface','clone','getAgents','WhatsappQueue','show','end','create','UserProfileSection','emit','order','agent','then','userWhatsappQueue:remove','addTeams','role','format','options','forEach','union','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','autoAssociation','squel','rows','each','describe','../../mysqldb','fields','model','user_has_teams','filters','User','body','catch','UserWhatsappQueue','SIP','offset','update','destroy','every','where','filter','status','sort','name','like','util','index','userWhatsappQueue:save','get','TeamId','length','pick','count','getMembers','key','ut.UserId\x20=\x20?','fieldName','map','Team','WhatsappQueueId','whatsappPause','../../config/logger','UserId','toString','attributes','team_has_whatsapp_queues','Unable\x20to\x20retrieve\x20the\x20current\x20user','push','nolimit','stack','isArray','json','WhatsappQueueId\x20=\x20?','user','merge','keys','transaction','type','isEmpty','../../components/parsers/qs','VIRTUAL','tq.TeamId','query','send','ids','findAndCountAll','createdAt','includeAll','api','findAll','sendStatus','removeTeams','params','addAgents','findOne','getTeams','Agents','undefined','Content-Range','intersection','flatMap'];(function(_0x16941d,_0x350e91){const _0x2bc853=function(_0x2c2c79){while(--_0x2c2c79){_0x16941d['push'](_0x16941d['shift']());}};_0x2bc853(++_0x350e91);}(a808_0x350e,0x150));const a808_0x2bc8=function(_0x16941d,_0x350e91){_0x16941d=_0x16941d-0x0;let _0x2bc853=a808_0x350e[_0x16941d];return _0x2bc853;};const _0x1f8d06=a808_0x2bc8;'use strict';const util=require(_0x1f8d06('0x30')),_=require('lodash'),squel=require(_0x1f8d06('0x18')),qs=require(_0x1f8d06('0x52')),logger=require(_0x1f8d06('0x40'))(_0x1f8d06('0x5b')),{getSocket}=require('../../rediscache'),socket=getSocket(),db=require(_0x1f8d06('0x1c'))['db'],{Op,QueryTypes}=require(_0x1f8d06('0x1'));require('./whatsappQueue.socket')[_0x1f8d06('0x2')](socket);function respondWithStatusCode(_0x2c2c79,_0x401b24){return _0x401b24=_0x401b24||0xcc,function(_0x41137e){const _0x4126e6=a808_0x2bc8;if(_0x41137e)return _0x2c2c79[_0x4126e6('0x5d')](_0x401b24);return _0x2c2c79[_0x4126e6('0x2c')](_0x401b24)[_0x4126e6('0x8')]();};}function respondWithResult(_0x57d2d3,_0x4bb74f){return _0x4bb74f=_0x4bb74f||0xc8,function(_0x2a9e9c){const _0x50fad2=a808_0x2bc8;if(_0x2a9e9c)return _0x57d2d3[_0x50fad2('0x2c')](_0x4bb74f)[_0x50fad2('0x4a')](_0x2a9e9c);};}function respondWithFilteredResult(_0x2f2afe,_0xb7a0e){return function(_0xd2983a){const _0xf87146=a808_0x2bc8;if(_0xd2983a){const _0x58d589=_0xd2983a[_0xf87146('0x37')],_0x433f7e=_0xb7a0e['offset'];let _0x142b1e=_0xb7a0e[_0xf87146('0x26')]+_0xb7a0e[_0xf87146('0x69')],_0x480f48;return _0x142b1e>=_0x58d589?(_0x142b1e=_0x58d589,_0x480f48=0xc8):_0x480f48=0xce,_0x2f2afe[_0xf87146('0x2c')](_0x480f48),_0x2f2afe['set'](_0xf87146('0x65'),_0x433f7e+'-'+_0x142b1e+'/'+_0x58d589)[_0xf87146('0x4a')](_0xd2983a);}return null;};}function saveUpdates(_0x139e76){return function(_0x107165){const _0x154dca=a808_0x2bc8;if(_0x107165)return _0x107165[_0x154dca('0x27')](_0x139e76)[_0x154dca('0xe')](function(_0x1e1c6e){return _0x1e1c6e;});return null;};}function removeEntity(_0x434983){return function(_0x5911da){const _0x5aa997=a808_0x2bc8;if(_0x5911da)return _0x5911da[_0x5aa997('0x28')]()['then'](function(){const _0x8a6032=_0x5aa997,_0x218122=_0x5911da[_0x8a6032('0x33')]({'plain':!![]}),_0x552d41='WhatsappQueues';return db['UserProfileResource'][_0x8a6032('0x28')]({'where':{'type':_0x552d41,'resourceId':_0x218122['id']}})[_0x8a6032('0xe')](function(){return _0x5911da;});})['then'](function(){const _0x1481e8=_0x5aa997;_0x434983['status'](0xcc)[_0x1481e8('0x8')]();});};}function handleEntityNotFound(_0x9433d){return function(_0x5f0e70){const _0x461a15=a808_0x2bc8;return!_0x5f0e70&&_0x9433d[_0x461a15('0x5d')](0x194),_0x5f0e70;};}function handleError(_0x42e7de,_0x3b3c8b){return _0x3b3c8b=_0x3b3c8b||0x1f4,function(_0x15dcf5){const _0x1250ab=a808_0x2bc8;logger['error'](_0x15dcf5[_0x1250ab('0x48')]),_0x15dcf5['name']&&delete _0x15dcf5[_0x1250ab('0x2e')],_0x42e7de[_0x1250ab('0x2c')](_0x3b3c8b)[_0x1250ab('0x56')](_0x15dcf5);};}exports[_0x1f8d06('0x31')]=function(_0x1a955a,_0x3ef9f3){const _0x150c4c=_0x1f8d06;let _0x3f3050={};const _0xe5ad0d={},_0x4034f4={'count':0x0,'rows':[]},_0x44be71=_[_0x150c4c('0x3c')](db[_0x150c4c('0x6')]['rawAttributes'],function(_0x299727){const _0x1d6312=_0x150c4c;return{'name':_0x299727[_0x1d6312('0x3b')],'type':_0x299727['type'][_0x1d6312('0x39')]};});_0xe5ad0d['model']=_[_0x150c4c('0x3c')](_0x44be71,_0x150c4c('0x2e')),_0xe5ad0d['query']=_['keys'](_0x1a955a[_0x150c4c('0x55')]),_0xe5ad0d[_0x150c4c('0x20')]=_[_0x150c4c('0x66')](_0xe5ad0d[_0x150c4c('0x1e')],_0xe5ad0d['query']),_0x3f3050['attributes']=_[_0x150c4c('0x66')](_0xe5ad0d['model'],qs[_0x150c4c('0x1d')](_0x1a955a[_0x150c4c('0x55')][_0x150c4c('0x1d')])),_0x3f3050[_0x150c4c('0x43')]=_0x3f3050[_0x150c4c('0x43')]['length']?_0x3f3050['attributes']:_0xe5ad0d[_0x150c4c('0x1e')];typeof _0x1a955a[_0x150c4c('0x55')][_0x150c4c('0x47')]===_0x150c4c('0x64')&&(_0x3f3050[_0x150c4c('0x69')]=qs[_0x150c4c('0x69')](_0x1a955a[_0x150c4c('0x55')]['limit']),_0x3f3050[_0x150c4c('0x26')]=qs[_0x150c4c('0x26')](_0x1a955a[_0x150c4c('0x55')]['offset']));_0x3f3050['order']=qs['sort'](_0x1a955a[_0x150c4c('0x55')][_0x150c4c('0x2d')]),_0x3f3050['where']=qs['filters'](_[_0x150c4c('0x36')](_0x1a955a[_0x150c4c('0x55')],_0xe5ad0d['filters']),_0x44be71);_0x1a955a['query'][_0x150c4c('0x2b')]&&(_0x3f3050[_0x150c4c('0x2a')]=_[_0x150c4c('0x4d')](_0x3f3050[_0x150c4c('0x2a')],{[Op['or']]:_['map'](_0x44be71,function(_0x24ce27){const _0x305460=_0x150c4c;if(_0x24ce27[_0x305460('0x50')]!==_0x305460('0x53')){const _0x5d12a7={};return _0x5d12a7[_0x24ce27[_0x305460('0x2e')]]={[Op[_0x305460('0x2f')]]:'%'+_0x1a955a[_0x305460('0x55')][_0x305460('0x2b')]+'%'},_0x5d12a7;}})}));_0x3f3050=_[_0x150c4c('0x4d')]({},_0x3f3050,_0x1a955a[_0x150c4c('0x13')]);const _0x9bae65={'where':_0x3f3050[_0x150c4c('0x2a')]};return db[_0x150c4c('0x6')][_0x150c4c('0x37')](_0x9bae65)[_0x150c4c('0xe')](function(_0x44bad6){const _0x5f49bc=_0x150c4c;return _0x4034f4[_0x5f49bc('0x37')]=_0x44bad6,_0x1a955a[_0x5f49bc('0x55')][_0x5f49bc('0x5a')]&&(_0x3f3050['include']=[{'all':!![]}]),db[_0x5f49bc('0x6')]['findAll'](_0x3f3050);})[_0x150c4c('0xe')](function(_0xf9461a){const _0x36817f=_0x150c4c;return _0x4034f4[_0x36817f('0x19')]=_0xf9461a,_0x4034f4;})[_0x150c4c('0xe')](respondWithFilteredResult(_0x3ef9f3,_0x3f3050))[_0x150c4c('0x23')](handleError(_0x3ef9f3,null));},exports[_0x1f8d06('0x7')]=function(_0x28c4b7,_0x39604a){const _0x146d8d=_0x1f8d06;let _0x2270a0={'raw':!![],'where':{'id':_0x28c4b7[_0x146d8d('0x5f')]['id']}};const _0x392c37={};return _0x392c37['model']=_[_0x146d8d('0x4e')](db[_0x146d8d('0x6')][_0x146d8d('0x6b')]),_0x392c37['query']=_[_0x146d8d('0x4e')](_0x28c4b7[_0x146d8d('0x55')]),_0x392c37['filters']=_[_0x146d8d('0x66')](_0x392c37[_0x146d8d('0x1e')],_0x392c37['query']),_0x2270a0[_0x146d8d('0x43')]=_[_0x146d8d('0x66')](_0x392c37[_0x146d8d('0x1e')],qs[_0x146d8d('0x1d')](_0x28c4b7[_0x146d8d('0x55')][_0x146d8d('0x1d')])),_0x2270a0[_0x146d8d('0x43')]=_0x2270a0[_0x146d8d('0x43')][_0x146d8d('0x35')]?_0x2270a0['attributes']:_0x392c37[_0x146d8d('0x1e')],_0x28c4b7[_0x146d8d('0x55')][_0x146d8d('0x5a')]&&(_0x2270a0['include']=[{'all':!![]}]),_0x2270a0=_['merge']({},_0x2270a0,_0x28c4b7[_0x146d8d('0x13')]),db[_0x146d8d('0x6')]['findOne'](_0x2270a0)[_0x146d8d('0xe')](handleEntityNotFound(_0x39604a,null))[_0x146d8d('0xe')](respondWithResult(_0x39604a,null))['catch'](handleError(_0x39604a,null));},exports['create']=function(_0x11d5a0,_0x5e43a8){const _0x223dd3=_0x1f8d06;return db[_0x223dd3('0x6')][_0x223dd3('0x9')](_0x11d5a0['body'],{})['then'](function(_0x101a9b){const _0x2c68d4=_0x223dd3,_0x26e2f0=_0x11d5a0[_0x2c68d4('0x4c')]['get']({'plain':!![]});if(!_0x26e2f0)throw new Error(_0x2c68d4('0x45'));if(_0x26e2f0[_0x2c68d4('0x11')]==='user'){const _0x4f4610=_0x101a9b[_0x2c68d4('0x33')]({'plain':!![]}),_0x1bb0e5='WhatsappQueues';return db[_0x2c68d4('0xa')]['findOne']({'where':{'name':_0x1bb0e5,'userProfileId':_0x26e2f0['userProfileId']},'raw':!![]})['then'](function(_0x3caf01){const _0x8bd787=_0x2c68d4;return _0x3caf01&&_0x3caf01[_0x8bd787('0x17')]===0x0?db['UserProfileResource'][_0x8bd787('0x9')]({'name':_0x4f4610[_0x8bd787('0x2e')],'resourceId':_0x4f4610['id'],'type':_0x3caf01[_0x8bd787('0x2e')],'sectionId':_0x3caf01['id']},{})['then'](function(){return _0x101a9b;}):_0x101a9b;})['catch'](function(_0x18db9f){const _0x591232=_0x2c68d4;logger[_0x591232('0x68')](_0x591232('0x16'),_0x18db9f);throw _0x18db9f;});}return _0x101a9b;})[_0x223dd3('0xe')](respondWithResult(_0x5e43a8,0xc9))['catch'](handleError(_0x5e43a8,null));},exports[_0x1f8d06('0x27')]=function(_0x23892a,_0x5bce47){const _0x217e9b=_0x1f8d06;return _0x23892a[_0x217e9b('0x22')]['id']&&delete _0x23892a[_0x217e9b('0x22')]['id'],db[_0x217e9b('0x6')]['findOne']({'where':{'id':_0x23892a['params']['id']}})[_0x217e9b('0xe')](handleEntityNotFound(_0x5bce47,null))[_0x217e9b('0xe')](saveUpdates(_0x23892a[_0x217e9b('0x22')],null))[_0x217e9b('0xe')](respondWithResult(_0x5bce47,null))['catch'](handleError(_0x5bce47,null));},exports[_0x1f8d06('0x28')]=function(_0x3e3250,_0x16309d){const _0x1c3b0a=_0x1f8d06;return db[_0x1c3b0a('0x6')][_0x1c3b0a('0x61')]({'where':{'id':_0x3e3250[_0x1c3b0a('0x5f')]['id']}})[_0x1c3b0a('0xe')](handleEntityNotFound(_0x16309d,null))['then'](removeEntity(_0x16309d,null))[_0x1c3b0a('0x23')](handleError(_0x16309d,null));},exports[_0x1f8d06('0x1b')]=function(_0x18c570,_0x160520){const _0x3aba94=_0x1f8d06;return db[_0x3aba94('0x6')][_0x3aba94('0x1b')]()[_0x3aba94('0xe')](respondWithResult(_0x160520,null))[_0x3aba94('0x23')](handleError(_0x160520,null));},exports[_0x1f8d06('0x38')]=function(_0x13a1d6,_0x573711){const _0x3b64ca=_0x1f8d06;let _0x549bd7={'raw':!![],'where':{}};const _0x46a214={};let _0xfd5f27;return db[_0x3b64ca('0x6')][_0x3b64ca('0x61')]({'where':{'id':_0x13a1d6[_0x3b64ca('0x5f')]['id']}})[_0x3b64ca('0xe')](handleEntityNotFound(_0x573711,null))['then'](function(_0x319d28){const _0x3ee497=_0x3b64ca;if(_0x319d28)return _0xfd5f27=_0x319d28[_0x3ee497('0x33')]({'plain':!![]}),_0x46a214[_0x3ee497('0x1e')]=_[_0x3ee497('0x4e')](db[_0x3ee497('0x24')][_0x3ee497('0x6b')]),_0x46a214['query']=_[_0x3ee497('0x4e')](_0x13a1d6[_0x3ee497('0x55')]),_0x46a214[_0x3ee497('0x20')]=_[_0x3ee497('0x66')](_0x46a214[_0x3ee497('0x1e')],_0x46a214[_0x3ee497('0x55')]),_0x549bd7['attributes']=_[_0x3ee497('0x66')](_0x46a214['model'],qs['fields'](_0x13a1d6['query'][_0x3ee497('0x1d')])),_0x549bd7[_0x3ee497('0x43')]=_0x549bd7[_0x3ee497('0x43')][_0x3ee497('0x35')]?_0x549bd7[_0x3ee497('0x43')]:_0x46a214['model'],typeof _0x13a1d6[_0x3ee497('0x55')][_0x3ee497('0x47')]===_0x3ee497('0x64')&&(_0x549bd7[_0x3ee497('0x69')]=qs['limit'](_0x13a1d6[_0x3ee497('0x55')][_0x3ee497('0x69')]),_0x549bd7[_0x3ee497('0x26')]=qs[_0x3ee497('0x26')](_0x13a1d6[_0x3ee497('0x55')][_0x3ee497('0x26')])),_0x549bd7[_0x3ee497('0xc')]=qs[_0x3ee497('0x2d')](_0x13a1d6['query'][_0x3ee497('0x2d')]),_0x549bd7['where']=qs[_0x3ee497('0x20')](_[_0x3ee497('0x36')](_0x13a1d6[_0x3ee497('0x55')],_0x46a214['filters'])),_0x549bd7[_0x3ee497('0x2a')][_0x3ee497('0x3e')]=_0x319d28['id'],_0x13a1d6['query']['filter']&&(_0x549bd7[_0x3ee497('0x2a')]=_[_0x3ee497('0x4d')](_0x549bd7['where'],{[Op['or']]:_[_0x3ee497('0x3c')](_0x549bd7[_0x3ee497('0x43')],function(_0x59f5a3){const _0x16512f=_0x3ee497,_0xdbf17a={};return _0xdbf17a[_0x59f5a3]={[Op[_0x16512f('0x2f')]]:'%'+_0x13a1d6[_0x16512f('0x55')][_0x16512f('0x2b')]+'%'},_0xdbf17a;})})),_0x549bd7=_[_0x3ee497('0x4d')]({},_0x549bd7,_0x13a1d6['options']),db[_0x3ee497('0x24')][_0x3ee497('0x5c')](_0x549bd7);})['then'](function(_0x50492f){const _0x533900=_0x3b64ca;if(_0x50492f)return db[_0x533900('0x21')][_0x533900('0x58')]({'where':{'id':_['map'](_0x50492f,_0x533900('0x41')),'role':_0x533900('0xd')},'attributes':['id',_0x533900('0x2e'),_0x533900('0x3f'),'updatedAt',_0x533900('0x59')]});})['then'](function(_0xb13bb2){const _0x943314=_0x3b64ca;return _0xb13bb2?{'count':_0xb13bb2[_0x943314('0x37')],'rows':_[_0x943314('0x3c')](_0xb13bb2[_0x943314('0x19')],function(_0x5cfcf4){const _0x175c43=_0x943314;return{'membername':_0x5cfcf4[_0x175c43('0x2e')],'UserId':_0x5cfcf4['id'],'queue_name':_0xfd5f27[_0x175c43('0x2e')],'WhatsappQueueId':_0xfd5f27['id'],'interface':util[_0x175c43('0x12')]('%s/%s',_0x175c43('0x25'),_0x5cfcf4[_0x175c43('0x2e')]),'penalty':0x0,'paused':_0x5cfcf4[_0x175c43('0x3f')],'createdAt':_0x5cfcf4['createdAt'],'updatedAt':_0x5cfcf4['updatedAt']};})}:{'count':0x0,'rows':[]};})[_0x3b64ca('0xe')](respondWithFilteredResult(_0x573711,_0x549bd7))[_0x3b64ca('0x23')](handleError(_0x573711,null));},exports[_0x1f8d06('0x62')]=function(_0x1a486b,_0x47e218){const _0x4bc690=_0x1f8d06;let _0x2777bf={};const _0x45ec71={};let _0x2b2cac,_0x53b836;return db['WhatsappQueue']['findOne']({'where':{'id':_0x1a486b[_0x4bc690('0x5f')]['id']}})[_0x4bc690('0xe')](handleEntityNotFound(_0x47e218,null))[_0x4bc690('0xe')](function(_0xa09d58){const _0x4c9331=_0x4bc690;if(_0xa09d58)return _0x2b2cac=_0xa09d58,_0x45ec71[_0x4c9331('0x1e')]=_[_0x4c9331('0x4e')](db['Team'][_0x4c9331('0x6b')]),_0x45ec71[_0x4c9331('0x55')]=_[_0x4c9331('0x4e')](_0x1a486b[_0x4c9331('0x55')]),_0x45ec71[_0x4c9331('0x20')]=_[_0x4c9331('0x66')](_0x45ec71[_0x4c9331('0x1e')],_0x45ec71[_0x4c9331('0x55')]),_0x2777bf[_0x4c9331('0x43')]=_[_0x4c9331('0x66')](_0x45ec71[_0x4c9331('0x1e')],qs['fields'](_0x1a486b[_0x4c9331('0x55')][_0x4c9331('0x1d')])),_0x2777bf[_0x4c9331('0x43')]=_0x2777bf['attributes']['length']?_0x2777bf[_0x4c9331('0x43')]:_0x45ec71[_0x4c9331('0x1e')],_0x2777bf[_0x4c9331('0xc')]=qs[_0x4c9331('0x2d')](_0x1a486b['query'][_0x4c9331('0x2d')]),_0x2777bf['where']=qs['filters'](_['pick'](_0x1a486b['query'],_0x45ec71[_0x4c9331('0x20')])),_0x1a486b[_0x4c9331('0x55')][_0x4c9331('0x2b')]&&(_0x2777bf[_0x4c9331('0x2a')]=_[_0x4c9331('0x4d')](_0x2777bf['where'],{[Op['or']]:_[_0x4c9331('0x3c')](_0x2777bf['attributes'],function(_0x3a0dca){const _0xd8f65b=_0x4c9331,_0x36f25d={};return _0x36f25d[_0x3a0dca]={[Op[_0xd8f65b('0x2f')]]:'%'+_0x1a486b[_0xd8f65b('0x55')][_0xd8f65b('0x2b')]+'%'},_0x36f25d;})})),_0x2777bf=_[_0x4c9331('0x4d')]({},_0x2777bf,_0x1a486b[_0x4c9331('0x13')]),_0x2b2cac[_0x4c9331('0x62')](_0x2777bf);})[_0x4bc690('0xe')](function(_0x2bae69){const _0x1558a8=_0x4bc690;if(_0x2bae69)return _0x53b836=_0x2bae69[_0x1558a8('0x35')],typeof _0x1a486b['query'][_0x1558a8('0x47')]==='undefined'&&(_0x2777bf[_0x1558a8('0x69')]=qs[_0x1558a8('0x69')](_0x1a486b[_0x1558a8('0x55')][_0x1558a8('0x69')]),_0x2777bf[_0x1558a8('0x26')]=qs[_0x1558a8('0x26')](_0x1a486b['query']['offset'])),_0x2b2cac[_0x1558a8('0x62')](_0x2777bf);})[_0x4bc690('0xe')](function(_0x32b2f3){if(_0x32b2f3)return _0x32b2f3?{'count':_0x53b836,'rows':_0x32b2f3}:null;})['then'](respondWithResult(_0x47e218,null))[_0x4bc690('0x23')](handleError(_0x47e218,null));},exports[_0x1f8d06('0x10')]=function(_0x1e38d6,_0x531d7b){const _0x138da7=_0x1f8d06,_0x375cb6=_0x1e38d6[_0x138da7('0x22')][_0x138da7('0x57')];return db[_0x138da7('0x3d')]['findAll']({'where':{'id':_0x375cb6},'attributes':['id'],'include':[{'model':db[_0x138da7('0x21')],'as':_0x138da7('0x63'),'attributes':['id',_0x138da7('0x2e'),_0x138da7('0x6a'),'voicePause',_0x138da7('0x3')],'raw':!![]}]})[_0x138da7('0xe')](function(_0x1cbcc2){const _0x242810=_0x138da7;if(_0x1cbcc2){const _0x3ff0fb=_[_0x242810('0x67')](_0x1cbcc2,function(_0x591ac8){const _0x21b9a6=_0x242810,_0x461bc0=_0x591ac8[_0x21b9a6('0x33')]({'plain':!![]});return _0x461bc0['Agents'];});return db[_0x242810('0x6')][_0x242810('0x61')]({'where':{'id':_0x1e38d6[_0x242810('0x5f')]['id']}})[_0x242810('0xe')](function(_0x2bd48b){const _0x16c000=_0x242810;return db[_0x16c000('0x1')][_0x16c000('0x4f')](function(_0x11d07f){const _0x3db1b1=_0x16c000;return _0x2bd48b[_0x3db1b1('0x10')](_0x375cb6,{'transaction':_0x11d07f})[_0x3db1b1('0xe')](function(){const _0xe8e4f3=_0x3db1b1;return Promise[_0xe8e4f3('0x1a')](_0x3ff0fb,function(_0x24c8e7){const _0x5dffc3=_0xe8e4f3;return db['UserWhatsappQueue']['findOrCreate']({'where':{'UserId':_0x24c8e7['id'],'WhatsappQueueId':_0x1e38d6[_0x5dffc3('0x5f')]['id']},'transaction':_0x11d07f});});})[_0x3db1b1('0xe')](function(){const _0x51b9e7=_0x3db1b1;_0x3ff0fb[_0x51b9e7('0x14')](function(_0x2f3860){const _0x3f9c1e=_0x51b9e7;socket[_0x3f9c1e('0xb')](_0x3f9c1e('0x32'),{'UserId':_0x2f3860['id'],'WhatsappQueueId':_0x2bd48b['id']});});});});});}})[_0x138da7('0xe')](respondWithStatusCode(_0x531d7b,null))[_0x138da7('0x23')](handleError(_0x531d7b,null));},exports[_0x1f8d06('0x5e')]=function(_0x227e10,_0x380598){const _0x38f572=_0x1f8d06;return db[_0x38f572('0x3d')][_0x38f572('0x5c')]({'where':{'id':_0x227e10[_0x38f572('0x55')]['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':_0x38f572('0x63'),'attributes':['id'],'raw':!![]}]})[_0x38f572('0xe')](handleEntityNotFound(_0x380598,null))['then'](function(_0x38ef05){const _0x1deca5=_0x38f572,_0x35e5f6=_[_0x1deca5('0x3c')](_0x38ef05,'id');let _0x54660d=[];const _0x418fd9=[],_0x1525d2=squel[_0x1deca5('0x0')]();_0x1525d2['field'](_0x1deca5('0x54'))['from'](_0x1deca5('0x44'),'tq')['join'](_0x1deca5('0x1f'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x1deca5('0x2a')](_0x1deca5('0x4b'),_0x227e10[_0x1deca5('0x5f')]['id']);for(let _0x4e2c87=0x0;_0x4e2c87<_0x38ef05[_0x1deca5('0x35')];_0x4e2c87+=0x1){const _0x27b04d=_0x38ef05[_0x4e2c87];for(let _0x39d760=0x0;_0x39d760<_0x27b04d[_0x1deca5('0x63')][_0x1deca5('0x35')];_0x39d760+=0x1){const _0x5ca9a8=_0x27b04d[_0x1deca5('0x63')][_0x39d760],_0x4fd99b=_0x1525d2[_0x1deca5('0x4')]();_0x4fd99b['where'](_0x1deca5('0x3a'),_0x5ca9a8['id']),_0x418fd9[_0x1deca5('0x46')](db[_0x1deca5('0x1')][_0x1deca5('0x55')](_0x4fd99b[_0x1deca5('0x42')](),{'type':QueryTypes['SELECT']})['then'](function(_0x17bfd3){const _0x995603=_0x1deca5;if(_0x17bfd3[_0x995603('0x35')]===0x1)return _0x5ca9a8['id'];else{const _0x40ea05=_[_0x995603('0x29')](_[_0x995603('0x3c')](_0x17bfd3,_0x995603('0x34')),function(_0x29821a){return _['includes'](_0x35e5f6,_0x29821a);});if(_0x40ea05)return _0x5ca9a8['id'];}}));}}return Promise['all'](_0x418fd9)[_0x1deca5('0xe')](function(_0x3122a7){const _0x19cdfc=_0x1deca5;return _0x54660d=_(_0x54660d)[_0x19cdfc('0x15')](_0x3122a7)['compact']()[_0x19cdfc('0x6d')](),db['WhatsappQueue'][_0x19cdfc('0x61')]({'where':{'id':_0x227e10['params']['id']}})['then'](function(_0x1d1d6a){const _0x381d1f=_0x19cdfc;return db[_0x381d1f('0x1')]['transaction'](function(_0x3bc882){const _0x27f639=_0x381d1f;return _0x1d1d6a[_0x27f639('0x5e')](_0x227e10[_0x27f639('0x55')][_0x27f639('0x57')],{'transaction':_0x3bc882})['then'](function(){const _0x51b7e4=_0x27f639;if(!_[_0x51b7e4('0x51')](_0x54660d))return _0x1d1d6a[_0x51b7e4('0x6c')](_0x54660d,{'transaction':_0x3bc882});})[_0x27f639('0xe')](function(){const _0x120959=_0x27f639;_0x54660d[_0x120959('0x14')](function(_0xcafb46){const _0x3e4c6a=_0x120959;socket[_0x3e4c6a('0xb')](_0x3e4c6a('0xf'),{'UserId':_0xcafb46,'WhatsappQueueId':_0x1d1d6a['id']});});});});});});})['then'](respondWithStatusCode(_0x380598,null))[_0x38f572('0x23')](handleError(_0x380598,null));},exports[_0x1f8d06('0x60')]=function(_0x5d1611,_0x49bcce){const _0xd39af2=_0x1f8d06;return db[_0xd39af2('0x6')][_0xd39af2('0x61')]({'where':{'id':_0x5d1611[_0xd39af2('0x5f')]['id']}})['then'](function(_0x5c74c1){const _0x36bcb3=_0xd39af2;if(_0x5c74c1)return _0x5c74c1[_0x36bcb3('0x60')](_0x5d1611['body'][_0x36bcb3('0x57')],{'through':_['omit'](_0x5d1611[_0x36bcb3('0x22')],[_0x36bcb3('0x57'),'id'])})[_0x36bcb3('0xe')](function(_0x18d2a3){const _0x4c2db0=_0x36bcb3;for(let _0x34632e=0x0;_0x34632e<_0x5d1611[_0x4c2db0('0x22')][_0x4c2db0('0x57')]['length'];_0x34632e+=0x1){socket[_0x4c2db0('0xb')](_0x4c2db0('0x32'),{'UserId':_0x5d1611[_0x4c2db0('0x22')]['ids'][_0x34632e],'WhatsappQueueId':_0x5d1611[_0x4c2db0('0x5f')]['id']});}return _0x18d2a3;});})[_0xd39af2('0xe')](respondWithResult(_0x49bcce,null))[_0xd39af2('0x23')](handleError(_0x49bcce,null));},exports[_0x1f8d06('0x6c')]=function(_0x3c13e8,_0x204d16){const _0x283dcc=_0x1f8d06;return db[_0x283dcc('0x6')][_0x283dcc('0x61')]({'where':{'id':_0x3c13e8[_0x283dcc('0x5f')]['id']}})['then'](handleEntityNotFound(_0x204d16,null))[_0x283dcc('0xe')](function(_0x1f80cd){const _0x3305e0=_0x283dcc;if(_0x1f80cd)return _0x1f80cd[_0x3305e0('0x6c')](_0x3c13e8[_0x3305e0('0x55')]['ids'])[_0x3305e0('0xe')](function(){const _0x52bebd=_0x3305e0;if(_[_0x52bebd('0x49')](_0x3c13e8['query'][_0x52bebd('0x57')]))for(let _0xb8b02d=0x0;_0xb8b02d<_0x3c13e8[_0x52bebd('0x55')]['ids'][_0x52bebd('0x35')];_0xb8b02d+=0x1){socket[_0x52bebd('0xb')](_0x52bebd('0xf'),{'UserId':Number(_0x3c13e8['query'][_0x52bebd('0x57')][_0xb8b02d]),'WhatsappQueueId':Number(_0x3c13e8['params']['id'])});}else socket[_0x52bebd('0xb')](_0x52bebd('0xf'),{'UserId':Number(_0x3c13e8[_0x52bebd('0x55')][_0x52bebd('0x57')]),'WhatsappQueueId':Number(_0x3c13e8[_0x52bebd('0x5f')]['id'])});});})['then'](respondWithStatusCode(_0x204d16,null))[_0x283dcc('0x23')](handleError(_0x204d16,null));},exports['getAgents']=function(_0x3d591b,_0xd66fe1){const _0x1453a7=_0x1f8d06;let _0x53668e={};const _0x350a46={};let _0xadedac,_0xd28234;return db[_0x1453a7('0x6')]['findOne']({'where':{'id':_0x3d591b[_0x1453a7('0x5f')]['id']}})['then'](handleEntityNotFound(_0xd66fe1,null))[_0x1453a7('0xe')](function(_0x4cb419){const _0x3f8763=_0x1453a7;if(_0x4cb419)return _0xadedac=_0x4cb419,_0x350a46[_0x3f8763('0x1e')]=_[_0x3f8763('0x4e')](db['User'][_0x3f8763('0x6b')]),_0x350a46['query']=_['keys'](_0x3d591b[_0x3f8763('0x55')]),_0x350a46[_0x3f8763('0x20')]=_[_0x3f8763('0x66')](_0x350a46['model'],_0x350a46[_0x3f8763('0x55')]),_0x53668e[_0x3f8763('0x43')]=_[_0x3f8763('0x66')](_0x350a46['model'],qs[_0x3f8763('0x1d')](_0x3d591b[_0x3f8763('0x55')][_0x3f8763('0x1d')])),_0x53668e[_0x3f8763('0x43')]=_0x53668e['attributes'][_0x3f8763('0x35')]?_0x53668e[_0x3f8763('0x43')]:_0x350a46['model'],_0x53668e[_0x3f8763('0xc')]=qs[_0x3f8763('0x2d')](_0x3d591b[_0x3f8763('0x55')]['sort']),_0x53668e[_0x3f8763('0x2a')]=qs[_0x3f8763('0x20')](_[_0x3f8763('0x36')](_0x3d591b['query'],_0x350a46[_0x3f8763('0x20')])),_0x3d591b[_0x3f8763('0x55')][_0x3f8763('0x2b')]&&(_0x53668e[_0x3f8763('0x2a')]=_[_0x3f8763('0x4d')](_0x53668e[_0x3f8763('0x2a')],{[Op['or']]:_['map'](_0x53668e[_0x3f8763('0x43')],function(_0x559852){const _0xc3187=_0x3f8763,_0x2db89a={};return _0x2db89a[_0x559852]={[Op[_0xc3187('0x2f')]]:'%'+_0x3d591b[_0xc3187('0x55')]['filter']+'%'},_0x2db89a;})})),_0x53668e=_[_0x3f8763('0x4d')]({},_0x53668e,_0x3d591b[_0x3f8763('0x13')]),_0xadedac[_0x3f8763('0x5')](_0x53668e);})[_0x1453a7('0xe')](function(_0x21b954){const _0x37960e=_0x1453a7;if(_0x21b954)return _0xd28234=_0x21b954[_0x37960e('0x35')],typeof _0x3d591b['query'][_0x37960e('0x47')]===_0x37960e('0x64')&&(_0x53668e['limit']=qs[_0x37960e('0x69')](_0x3d591b[_0x37960e('0x55')][_0x37960e('0x69')]),_0x53668e['offset']=qs[_0x37960e('0x26')](_0x3d591b[_0x37960e('0x55')]['offset'])),_0xadedac['getAgents'](_0x53668e);})['then'](function(_0x59450c){if(_0x59450c)return _0x59450c?{'count':_0xd28234,'rows':_0x59450c}:null;})[_0x1453a7('0xe')](respondWithResult(_0xd66fe1,null))[_0x1453a7('0x23')](handleError(_0xd66fe1,null));};
\ No newline at end of file