Built motion from commit ded33658aad58fc8de845a8299a9db59a88cc353. Version 3.0.0...
[motion-next.git] / server / api / whatsappQueue / whatsappQueue.controller.js
index 7682f01..9f1672d 100644 (file)
@@ -1 +1 @@
-const a808_0x4d1a=['agent','includeAll','catch','intersection','addTeams','sendStatus','Agents','where','UserWhatsappQueue','isArray','online','undefined','isEmpty','error','push','../../config/logger','index','model','params','addAgents','tq.TeamId','compact','json','join','rows','like','merge','offset','sequelize','TeamId','autoAssociation','order','user','all','WhatsappQueueId\x20=\x20?','ids','sort','keys','getTeams','emit','limit','show','squel','removeAgents','value','from','getAgents','pick','stack','Team','fieldName','select','findOne','findAll','update','api','interface','include','util','key','transaction','filters','toString','end','set','query','%s/%s','userWhatsappQueue:save','WhatsappQueueId','attributes','format','UserId','name','clone','status','User','get','userWhatsappQueue:remove','WhatsappQueues','nolimit','filter','register','destroy','includes','WhatsappQueue','../../mysqldb','VIRTUAL','map','whatsappPause','then','every','count','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','flatMap','describe','body','options','length','role','forEach','field','team_has_whatsapp_queues','each','ut.TeamId\x20=\x20tq.TeamId','fields','SIP','UserProfileSection','createdAt','findAndCountAll','Content-Range','removeTeams','Unable\x20to\x20retrieve\x20the\x20current\x20user','../../components/parsers/qs','type','create','rawAttributes'];(function(_0x4a7166,_0x4d1a5f){const _0x37a1f7=function(_0x776ea9){while(--_0x776ea9){_0x4a7166['push'](_0x4a7166['shift']());}};_0x37a1f7(++_0x4d1a5f);}(a808_0x4d1a,0x125));const a808_0x37a1=function(_0x4a7166,_0x4d1a5f){_0x4a7166=_0x4a7166-0x0;let _0x37a1f7=a808_0x4d1a[_0x4a7166];return _0x37a1f7;};const _0x3006a2=a808_0x37a1;'use strict';const util=require(_0x3006a2('0x71')),_=require('lodash'),squel=require(_0x3006a2('0x61')),qs=require(_0x3006a2('0x33')),logger=require(_0x3006a2('0x46'))(_0x3006a2('0x6e')),{getSocket}=require('../../rediscache'),socket=getSocket(),db=require(_0x3006a2('0x18'))['db'],{Op,QueryTypes}=require('sequelize');require('./whatsappQueue.socket')[_0x3006a2('0x14')](socket);function respondWithStatusCode(_0x776ea9,_0x1534d7){return _0x1534d7=_0x1534d7||0xcc,function(_0x372b53){const _0x52bcc6=a808_0x37a1;if(_0x372b53)return _0x776ea9['sendStatus'](_0x1534d7);return _0x776ea9[_0x52bcc6('0xd')](_0x1534d7)[_0x52bcc6('0x2')]();};}function respondWithResult(_0x3025ae,_0x322215){return _0x322215=_0x322215||0xc8,function(_0x434865){const _0x1dbcb5=a808_0x37a1;if(_0x434865)return _0x3025ae[_0x1dbcb5('0xd')](_0x322215)[_0x1dbcb5('0x4d')](_0x434865);};}function respondWithFilteredResult(_0x1c326c,_0x5c2a30){return function(_0x4c4382){const _0x287490=a808_0x37a1;if(_0x4c4382){const _0x2d81f6=_0x4c4382[_0x287490('0x1e')],_0x40157c=_0x5c2a30['offset'];let _0x2088c6=_0x5c2a30[_0x287490('0x52')]+_0x5c2a30[_0x287490('0x5f')],_0x554f1c;return _0x2088c6>=_0x2d81f6?(_0x2088c6=_0x2d81f6,_0x554f1c=0xc8):_0x554f1c=0xce,_0x1c326c[_0x287490('0xd')](_0x554f1c),_0x1c326c[_0x287490('0x3')](_0x287490('0x30'),_0x40157c+'-'+_0x2088c6+'/'+_0x2d81f6)[_0x287490('0x4d')](_0x4c4382);}return null;};}function saveUpdates(_0x2cf07d){return function(_0x43a4df){const _0x3e0243=a808_0x37a1;if(_0x43a4df)return _0x43a4df[_0x3e0243('0x6d')](_0x2cf07d)['then'](function(_0x5d8343){return _0x5d8343;});return null;};}function removeEntity(_0xf4a107){return function(_0x435c29){const _0x1a7168=a808_0x37a1;if(_0x435c29)return _0x435c29[_0x1a7168('0x15')]()['then'](function(){const _0x251b25=_0x1a7168,_0x4d1f4b=_0x435c29[_0x251b25('0xf')]({'plain':!![]}),_0x40bd49=_0x251b25('0x11');return db['UserProfileResource'][_0x251b25('0x15')]({'where':{'type':_0x40bd49,'resourceId':_0x4d1f4b['id']}})[_0x251b25('0x1c')](function(){return _0x435c29;});})[_0x1a7168('0x1c')](function(){const _0x1b6cf2=_0x1a7168;_0xf4a107[_0x1b6cf2('0xd')](0xcc)[_0x1b6cf2('0x2')]();});};}function handleEntityNotFound(_0x14aba3){return function(_0x294e62){const _0x16a2ce=a808_0x37a1;return!_0x294e62&&_0x14aba3[_0x16a2ce('0x3c')](0x194),_0x294e62;};}function handleError(_0x46be44,_0x411564){return _0x411564=_0x411564||0x1f4,function(_0x239c60){const _0x92e881=a808_0x37a1;logger[_0x92e881('0x44')](_0x239c60[_0x92e881('0x67')]),_0x239c60[_0x92e881('0xb')]&&delete _0x239c60[_0x92e881('0xb')],_0x46be44['status'](_0x411564)['send'](_0x239c60);};}exports[_0x3006a2('0x47')]=function(_0x320132,_0x1acd82){const _0xdc16dc=_0x3006a2;let _0x1a73aa={};const _0x54a6ed={},_0x57db47={'count':0x0,'rows':[]},_0x309a29=_[_0xdc16dc('0x1a')](db[_0xdc16dc('0x17')][_0xdc16dc('0x36')],function(_0x2d0aa3){const _0x3731a8=_0xdc16dc;return{'name':_0x2d0aa3[_0x3731a8('0x69')],'type':_0x2d0aa3[_0x3731a8('0x34')][_0x3731a8('0x72')]};});_0x54a6ed[_0xdc16dc('0x48')]=_[_0xdc16dc('0x1a')](_0x309a29,_0xdc16dc('0xb')),_0x54a6ed[_0xdc16dc('0x4')]=_[_0xdc16dc('0x5c')](_0x320132[_0xdc16dc('0x4')]),_0x54a6ed[_0xdc16dc('0x0')]=_[_0xdc16dc('0x3a')](_0x54a6ed[_0xdc16dc('0x48')],_0x54a6ed[_0xdc16dc('0x4')]),_0x1a73aa[_0xdc16dc('0x8')]=_[_0xdc16dc('0x3a')](_0x54a6ed[_0xdc16dc('0x48')],qs['fields'](_0x320132[_0xdc16dc('0x4')][_0xdc16dc('0x2b')])),_0x1a73aa[_0xdc16dc('0x8')]=_0x1a73aa['attributes']['length']?_0x1a73aa['attributes']:_0x54a6ed[_0xdc16dc('0x48')];typeof _0x320132[_0xdc16dc('0x4')][_0xdc16dc('0x12')]===_0xdc16dc('0x42')&&(_0x1a73aa[_0xdc16dc('0x5f')]=qs[_0xdc16dc('0x5f')](_0x320132[_0xdc16dc('0x4')][_0xdc16dc('0x5f')]),_0x1a73aa[_0xdc16dc('0x52')]=qs[_0xdc16dc('0x52')](_0x320132['query'][_0xdc16dc('0x52')]));_0x1a73aa[_0xdc16dc('0x56')]=qs['sort'](_0x320132[_0xdc16dc('0x4')][_0xdc16dc('0x5b')]),_0x1a73aa['where']=qs[_0xdc16dc('0x0')](_['pick'](_0x320132[_0xdc16dc('0x4')],_0x54a6ed[_0xdc16dc('0x0')]),_0x309a29);_0x320132[_0xdc16dc('0x4')][_0xdc16dc('0x13')]&&(_0x1a73aa[_0xdc16dc('0x3e')]=_[_0xdc16dc('0x51')](_0x1a73aa[_0xdc16dc('0x3e')],{[Op['or']]:_[_0xdc16dc('0x1a')](_0x309a29,function(_0x50a4aa){const _0x583320=_0xdc16dc;if(_0x50a4aa[_0x583320('0x34')]!==_0x583320('0x19')){const _0x268c9a={};return _0x268c9a[_0x50a4aa[_0x583320('0xb')]]={[Op['like']]:'%'+_0x320132[_0x583320('0x4')]['filter']+'%'},_0x268c9a;}})}));_0x1a73aa=_[_0xdc16dc('0x51')]({},_0x1a73aa,_0x320132[_0xdc16dc('0x23')]);const _0x2a4018={'where':_0x1a73aa['where']};return db[_0xdc16dc('0x17')][_0xdc16dc('0x1e')](_0x2a4018)['then'](function(_0x4fe91c){const _0x3ca6bc=_0xdc16dc;return _0x57db47['count']=_0x4fe91c,_0x320132[_0x3ca6bc('0x4')][_0x3ca6bc('0x38')]&&(_0x1a73aa[_0x3ca6bc('0x70')]=[{'all':!![]}]),db[_0x3ca6bc('0x17')]['findAll'](_0x1a73aa);})[_0xdc16dc('0x1c')](function(_0x363439){const _0x4cb19d=_0xdc16dc;return _0x57db47[_0x4cb19d('0x4f')]=_0x363439,_0x57db47;})[_0xdc16dc('0x1c')](respondWithFilteredResult(_0x1acd82,_0x1a73aa))[_0xdc16dc('0x39')](handleError(_0x1acd82,null));},exports[_0x3006a2('0x60')]=function(_0xa9fe9d,_0x56e0c9){const _0x47373f=_0x3006a2;let _0x399209={'raw':!![],'where':{'id':_0xa9fe9d[_0x47373f('0x49')]['id']}};const _0x11d690={};return _0x11d690[_0x47373f('0x48')]=_[_0x47373f('0x5c')](db['WhatsappQueue']['rawAttributes']),_0x11d690[_0x47373f('0x4')]=_[_0x47373f('0x5c')](_0xa9fe9d[_0x47373f('0x4')]),_0x11d690[_0x47373f('0x0')]=_[_0x47373f('0x3a')](_0x11d690[_0x47373f('0x48')],_0x11d690['query']),_0x399209[_0x47373f('0x8')]=_['intersection'](_0x11d690['model'],qs[_0x47373f('0x2b')](_0xa9fe9d[_0x47373f('0x4')][_0x47373f('0x2b')])),_0x399209[_0x47373f('0x8')]=_0x399209[_0x47373f('0x8')][_0x47373f('0x24')]?_0x399209['attributes']:_0x11d690[_0x47373f('0x48')],_0xa9fe9d[_0x47373f('0x4')][_0x47373f('0x38')]&&(_0x399209[_0x47373f('0x70')]=[{'all':!![]}]),_0x399209=_['merge']({},_0x399209,_0xa9fe9d[_0x47373f('0x23')]),db['WhatsappQueue']['findOne'](_0x399209)[_0x47373f('0x1c')](handleEntityNotFound(_0x56e0c9,null))['then'](respondWithResult(_0x56e0c9,null))[_0x47373f('0x39')](handleError(_0x56e0c9,null));},exports['create']=function(_0x1bcf9d,_0x21149e){const _0x4f6804=_0x3006a2;return db[_0x4f6804('0x17')][_0x4f6804('0x35')](_0x1bcf9d[_0x4f6804('0x22')],{})[_0x4f6804('0x1c')](function(_0x52c227){const _0x32c4f3=_0x4f6804,_0x409dd9=_0x1bcf9d['user'][_0x32c4f3('0xf')]({'plain':!![]});if(!_0x409dd9)throw new Error(_0x32c4f3('0x32'));if(_0x409dd9[_0x32c4f3('0x25')]===_0x32c4f3('0x57')){const _0x5a0663=_0x52c227[_0x32c4f3('0xf')]({'plain':!![]}),_0x3c4aa6=_0x32c4f3('0x11');return db[_0x32c4f3('0x2d')][_0x32c4f3('0x6b')]({'where':{'name':_0x3c4aa6,'userProfileId':_0x409dd9['userProfileId']},'raw':!![]})['then'](function(_0x3010f3){const _0x41110c=_0x32c4f3;return _0x3010f3&&_0x3010f3[_0x41110c('0x55')]===0x0?db['UserProfileResource'][_0x41110c('0x35')]({'name':_0x5a0663[_0x41110c('0xb')],'resourceId':_0x5a0663['id'],'type':_0x3010f3['name'],'sectionId':_0x3010f3['id']},{})[_0x41110c('0x1c')](function(){return _0x52c227;}):_0x52c227;})['catch'](function(_0x48eb03){const _0x4cefca=_0x32c4f3;logger[_0x4cefca('0x44')](_0x4cefca('0x1f'),_0x48eb03);throw _0x48eb03;});}return _0x52c227;})[_0x4f6804('0x1c')](respondWithResult(_0x21149e,0xc9))[_0x4f6804('0x39')](handleError(_0x21149e,null));},exports[_0x3006a2('0x6d')]=function(_0x556e27,_0x11ea77){const _0xd5a24e=_0x3006a2;return _0x556e27[_0xd5a24e('0x22')]['id']&&delete _0x556e27[_0xd5a24e('0x22')]['id'],db[_0xd5a24e('0x17')][_0xd5a24e('0x6b')]({'where':{'id':_0x556e27[_0xd5a24e('0x49')]['id']}})[_0xd5a24e('0x1c')](handleEntityNotFound(_0x11ea77,null))['then'](saveUpdates(_0x556e27['body'],null))[_0xd5a24e('0x1c')](respondWithResult(_0x11ea77,null))['catch'](handleError(_0x11ea77,null));},exports[_0x3006a2('0x15')]=function(_0x24e05a,_0x2930a1){const _0x4595b3=_0x3006a2;return db[_0x4595b3('0x17')]['findOne']({'where':{'id':_0x24e05a[_0x4595b3('0x49')]['id']}})[_0x4595b3('0x1c')](handleEntityNotFound(_0x2930a1,null))[_0x4595b3('0x1c')](removeEntity(_0x2930a1,null))[_0x4595b3('0x39')](handleError(_0x2930a1,null));},exports[_0x3006a2('0x21')]=function(_0x419084,_0x5a5ef0){const _0x3a138b=_0x3006a2;return db[_0x3a138b('0x17')][_0x3a138b('0x21')]()['then'](respondWithResult(_0x5a5ef0,null))[_0x3a138b('0x39')](handleError(_0x5a5ef0,null));},exports['getMembers']=function(_0x75c55d,_0x5eb314){const _0x95e5f6=_0x3006a2;let _0x4b4da1={'raw':!![],'where':{}};const _0x16a690={};let _0x28df9e;return db['WhatsappQueue']['findOne']({'where':{'id':_0x75c55d[_0x95e5f6('0x49')]['id']}})[_0x95e5f6('0x1c')](handleEntityNotFound(_0x5eb314,null))[_0x95e5f6('0x1c')](function(_0x3103c1){const _0x5ec0f2=_0x95e5f6;if(_0x3103c1)return _0x28df9e=_0x3103c1['get']({'plain':!![]}),_0x16a690['model']=_[_0x5ec0f2('0x5c')](db[_0x5ec0f2('0x3f')][_0x5ec0f2('0x36')]),_0x16a690[_0x5ec0f2('0x4')]=_[_0x5ec0f2('0x5c')](_0x75c55d[_0x5ec0f2('0x4')]),_0x16a690[_0x5ec0f2('0x0')]=_['intersection'](_0x16a690['model'],_0x16a690[_0x5ec0f2('0x4')]),_0x4b4da1[_0x5ec0f2('0x8')]=_['intersection'](_0x16a690[_0x5ec0f2('0x48')],qs[_0x5ec0f2('0x2b')](_0x75c55d[_0x5ec0f2('0x4')][_0x5ec0f2('0x2b')])),_0x4b4da1[_0x5ec0f2('0x8')]=_0x4b4da1[_0x5ec0f2('0x8')][_0x5ec0f2('0x24')]?_0x4b4da1['attributes']:_0x16a690[_0x5ec0f2('0x48')],typeof _0x75c55d[_0x5ec0f2('0x4')][_0x5ec0f2('0x12')]===_0x5ec0f2('0x42')&&(_0x4b4da1[_0x5ec0f2('0x5f')]=qs['limit'](_0x75c55d[_0x5ec0f2('0x4')][_0x5ec0f2('0x5f')]),_0x4b4da1[_0x5ec0f2('0x52')]=qs['offset'](_0x75c55d[_0x5ec0f2('0x4')][_0x5ec0f2('0x52')])),_0x4b4da1['order']=qs[_0x5ec0f2('0x5b')](_0x75c55d[_0x5ec0f2('0x4')][_0x5ec0f2('0x5b')]),_0x4b4da1['where']=qs[_0x5ec0f2('0x0')](_[_0x5ec0f2('0x66')](_0x75c55d[_0x5ec0f2('0x4')],_0x16a690[_0x5ec0f2('0x0')])),_0x4b4da1['where'][_0x5ec0f2('0x7')]=_0x3103c1['id'],_0x75c55d[_0x5ec0f2('0x4')][_0x5ec0f2('0x13')]&&(_0x4b4da1[_0x5ec0f2('0x3e')]=_['merge'](_0x4b4da1[_0x5ec0f2('0x3e')],{[Op['or']]:_[_0x5ec0f2('0x1a')](_0x4b4da1[_0x5ec0f2('0x8')],function(_0x4783d1){const _0x2bce32=_0x5ec0f2,_0x515980={};return _0x515980[_0x4783d1]={[Op[_0x2bce32('0x50')]]:'%'+_0x75c55d[_0x2bce32('0x4')][_0x2bce32('0x13')]+'%'},_0x515980;})})),_0x4b4da1=_[_0x5ec0f2('0x51')]({},_0x4b4da1,_0x75c55d[_0x5ec0f2('0x23')]),db['UserWhatsappQueue'][_0x5ec0f2('0x6c')](_0x4b4da1);})['then'](function(_0x2c40df){const _0x4d1c50=_0x95e5f6;if(_0x2c40df)return db['User'][_0x4d1c50('0x2f')]({'where':{'id':_[_0x4d1c50('0x1a')](_0x2c40df,_0x4d1c50('0xa')),'role':_0x4d1c50('0x37')},'attributes':['id',_0x4d1c50('0xb'),_0x4d1c50('0x1b'),'updatedAt',_0x4d1c50('0x2e')]});})[_0x95e5f6('0x1c')](function(_0x1c2b93){const _0x47e56b=_0x95e5f6;return _0x1c2b93?{'count':_0x1c2b93[_0x47e56b('0x1e')],'rows':_[_0x47e56b('0x1a')](_0x1c2b93['rows'],function(_0xe4f05e){const _0x2c8012=_0x47e56b;return{'membername':_0xe4f05e[_0x2c8012('0xb')],'UserId':_0xe4f05e['id'],'queue_name':_0x28df9e[_0x2c8012('0xb')],'WhatsappQueueId':_0x28df9e['id'],'interface':util[_0x2c8012('0x9')](_0x2c8012('0x5'),_0x2c8012('0x2c'),_0xe4f05e[_0x2c8012('0xb')]),'penalty':0x0,'paused':_0xe4f05e[_0x2c8012('0x1b')],'createdAt':_0xe4f05e[_0x2c8012('0x2e')],'updatedAt':_0xe4f05e['updatedAt']};})}:{'count':0x0,'rows':[]};})[_0x95e5f6('0x1c')](respondWithFilteredResult(_0x5eb314,_0x4b4da1))['catch'](handleError(_0x5eb314,null));},exports[_0x3006a2('0x5d')]=function(_0x1f866a,_0x3c13e4){const _0x3afc6e=_0x3006a2;let _0x3badb9={};const _0x2b5bae={};let _0x43b972,_0x5bf3e1;return db[_0x3afc6e('0x17')][_0x3afc6e('0x6b')]({'where':{'id':_0x1f866a['params']['id']}})[_0x3afc6e('0x1c')](handleEntityNotFound(_0x3c13e4,null))['then'](function(_0x31ae43){const _0x4ff3ce=_0x3afc6e;if(_0x31ae43)return _0x43b972=_0x31ae43,_0x2b5bae[_0x4ff3ce('0x48')]=_[_0x4ff3ce('0x5c')](db[_0x4ff3ce('0x68')][_0x4ff3ce('0x36')]),_0x2b5bae[_0x4ff3ce('0x4')]=_['keys'](_0x1f866a[_0x4ff3ce('0x4')]),_0x2b5bae['filters']=_['intersection'](_0x2b5bae[_0x4ff3ce('0x48')],_0x2b5bae[_0x4ff3ce('0x4')]),_0x3badb9['attributes']=_[_0x4ff3ce('0x3a')](_0x2b5bae[_0x4ff3ce('0x48')],qs['fields'](_0x1f866a[_0x4ff3ce('0x4')]['fields'])),_0x3badb9['attributes']=_0x3badb9['attributes'][_0x4ff3ce('0x24')]?_0x3badb9[_0x4ff3ce('0x8')]:_0x2b5bae[_0x4ff3ce('0x48')],_0x3badb9[_0x4ff3ce('0x56')]=qs[_0x4ff3ce('0x5b')](_0x1f866a[_0x4ff3ce('0x4')]['sort']),_0x3badb9[_0x4ff3ce('0x3e')]=qs[_0x4ff3ce('0x0')](_[_0x4ff3ce('0x66')](_0x1f866a['query'],_0x2b5bae[_0x4ff3ce('0x0')])),_0x1f866a['query'][_0x4ff3ce('0x13')]&&(_0x3badb9[_0x4ff3ce('0x3e')]=_['merge'](_0x3badb9[_0x4ff3ce('0x3e')],{[Op['or']]:_[_0x4ff3ce('0x1a')](_0x3badb9[_0x4ff3ce('0x8')],function(_0x2c9a15){const _0x151dd3=_0x4ff3ce,_0x544b98={};return _0x544b98[_0x2c9a15]={[Op[_0x151dd3('0x50')]]:'%'+_0x1f866a['query'][_0x151dd3('0x13')]+'%'},_0x544b98;})})),_0x3badb9=_['merge']({},_0x3badb9,_0x1f866a['options']),_0x43b972[_0x4ff3ce('0x5d')](_0x3badb9);})[_0x3afc6e('0x1c')](function(_0x2c76a0){const _0x4a3930=_0x3afc6e;if(_0x2c76a0)return _0x5bf3e1=_0x2c76a0[_0x4a3930('0x24')],typeof _0x1f866a[_0x4a3930('0x4')][_0x4a3930('0x12')]===_0x4a3930('0x42')&&(_0x3badb9[_0x4a3930('0x5f')]=qs[_0x4a3930('0x5f')](_0x1f866a[_0x4a3930('0x4')][_0x4a3930('0x5f')]),_0x3badb9['offset']=qs['offset'](_0x1f866a[_0x4a3930('0x4')][_0x4a3930('0x52')])),_0x43b972['getTeams'](_0x3badb9);})['then'](function(_0x51d4fa){if(_0x51d4fa)return _0x51d4fa?{'count':_0x5bf3e1,'rows':_0x51d4fa}:null;})[_0x3afc6e('0x1c')](respondWithResult(_0x3c13e4,null))['catch'](handleError(_0x3c13e4,null));},exports[_0x3006a2('0x3b')]=function(_0x38dbb5,_0x29ee9f){const _0x34fadf=_0x3006a2,_0x2e7299=_0x38dbb5[_0x34fadf('0x22')]['ids'];return db[_0x34fadf('0x68')]['findAll']({'where':{'id':_0x2e7299},'attributes':['id'],'include':[{'model':db[_0x34fadf('0xe')],'as':_0x34fadf('0x3d'),'attributes':['id',_0x34fadf('0xb'),_0x34fadf('0x41'),'voicePause',_0x34fadf('0x6f')],'raw':!![]}]})[_0x34fadf('0x1c')](function(_0x44b553){const _0x44b066=_0x34fadf;if(_0x44b553){const _0x1a032d=_[_0x44b066('0x20')](_0x44b553,function(_0x5a9873){const _0x35d807=_0x44b066,_0x5211dc=_0x5a9873[_0x35d807('0xf')]({'plain':!![]});return _0x5211dc[_0x35d807('0x3d')];});return db['WhatsappQueue']['findOne']({'where':{'id':_0x38dbb5[_0x44b066('0x49')]['id']}})[_0x44b066('0x1c')](function(_0x5e9075){const _0x9f3076=_0x44b066;return db[_0x9f3076('0x53')][_0x9f3076('0x73')](function(_0x100a79){const _0x3583fd=_0x9f3076;return _0x5e9075[_0x3583fd('0x3b')](_0x2e7299,{'transaction':_0x100a79})[_0x3583fd('0x1c')](function(){const _0x50282f=_0x3583fd;return Promise[_0x50282f('0x29')](_0x1a032d,function(_0x58f912){const _0x581f8f=_0x50282f;return db[_0x581f8f('0x3f')]['findOrCreate']({'where':{'UserId':_0x58f912['id'],'WhatsappQueueId':_0x38dbb5[_0x581f8f('0x49')]['id']},'transaction':_0x100a79});});})[_0x3583fd('0x1c')](function(){const _0x2dda4d=_0x3583fd;_0x1a032d[_0x2dda4d('0x26')](function(_0x1fdcfc){const _0x4494ea=_0x2dda4d;socket[_0x4494ea('0x5e')](_0x4494ea('0x6'),{'UserId':_0x1fdcfc['id'],'WhatsappQueueId':_0x5e9075['id']});});});});});}})[_0x34fadf('0x1c')](respondWithStatusCode(_0x29ee9f,null))['catch'](handleError(_0x29ee9f,null));},exports['removeTeams']=function(_0x491188,_0x967a40){const _0x6a2fda=_0x3006a2;return db[_0x6a2fda('0x68')][_0x6a2fda('0x6c')]({'where':{'id':_0x491188[_0x6a2fda('0x4')][_0x6a2fda('0x5a')]},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x6a2fda('0x1c')](handleEntityNotFound(_0x967a40,null))[_0x6a2fda('0x1c')](function(_0x21c271){const _0x5af685=_0x6a2fda,_0x201a96=_[_0x5af685('0x1a')](_0x21c271,'id');let _0x181830=[];const _0x5563fb=[],_0x213f8b=squel[_0x5af685('0x6a')]();_0x213f8b[_0x5af685('0x27')](_0x5af685('0x4b'))[_0x5af685('0x64')](_0x5af685('0x28'),'tq')[_0x5af685('0x4e')]('user_has_teams','ut',_0x5af685('0x2a'))[_0x5af685('0x3e')](_0x5af685('0x59'),_0x491188[_0x5af685('0x49')]['id']);for(let _0x7b21c6=0x0;_0x7b21c6<_0x21c271[_0x5af685('0x24')];_0x7b21c6+=0x1){const _0x24ff8d=_0x21c271[_0x7b21c6];for(let _0x525682=0x0;_0x525682<_0x24ff8d[_0x5af685('0x3d')][_0x5af685('0x24')];_0x525682+=0x1){const _0x5b44a0=_0x24ff8d['Agents'][_0x525682],_0x3facf4=_0x213f8b[_0x5af685('0xc')]();_0x3facf4[_0x5af685('0x3e')]('ut.UserId\x20=\x20?',_0x5b44a0['id']),_0x5563fb[_0x5af685('0x45')](db[_0x5af685('0x53')]['query'](_0x3facf4[_0x5af685('0x1')](),{'type':QueryTypes['SELECT']})['then'](function(_0x165008){const _0x264eb5=_0x5af685;if(_0x165008['length']===0x1)return _0x5b44a0['id'];else{const _0x17b8d8=_[_0x264eb5('0x1d')](_['map'](_0x165008,_0x264eb5('0x54')),function(_0x49faa8){const _0x498862=_0x264eb5;return _[_0x498862('0x16')](_0x201a96,_0x49faa8);});if(_0x17b8d8)return _0x5b44a0['id'];}}));}}return Promise[_0x5af685('0x58')](_0x5563fb)[_0x5af685('0x1c')](function(_0x41fec4){const _0x19daaa=_0x5af685;return _0x181830=_(_0x181830)['union'](_0x41fec4)[_0x19daaa('0x4c')]()[_0x19daaa('0x63')](),db[_0x19daaa('0x17')][_0x19daaa('0x6b')]({'where':{'id':_0x491188[_0x19daaa('0x49')]['id']}})[_0x19daaa('0x1c')](function(_0xe4de85){const _0x4a9d7b=_0x19daaa;return db[_0x4a9d7b('0x53')][_0x4a9d7b('0x73')](function(_0x8d567b){const _0x44a889=_0x4a9d7b;return _0xe4de85[_0x44a889('0x31')](_0x491188['query']['ids'],{'transaction':_0x8d567b})[_0x44a889('0x1c')](function(){const _0x430548=_0x44a889;if(!_[_0x430548('0x43')](_0x181830))return _0xe4de85[_0x430548('0x62')](_0x181830,{'transaction':_0x8d567b});})[_0x44a889('0x1c')](function(){const _0xb15945=_0x44a889;_0x181830[_0xb15945('0x26')](function(_0x3965d8){const _0x3d1b9d=_0xb15945;socket[_0x3d1b9d('0x5e')]('userWhatsappQueue:remove',{'UserId':_0x3965d8,'WhatsappQueueId':_0xe4de85['id']});});});});});});})[_0x6a2fda('0x1c')](respondWithStatusCode(_0x967a40,null))[_0x6a2fda('0x39')](handleError(_0x967a40,null));},exports[_0x3006a2('0x4a')]=function(_0x118918,_0x47871b){const _0xf67e1=_0x3006a2;return db[_0xf67e1('0x17')]['findOne']({'where':{'id':_0x118918[_0xf67e1('0x49')]['id']}})[_0xf67e1('0x1c')](function(_0x5589a6){const _0x209451=_0xf67e1;if(_0x5589a6)return _0x5589a6[_0x209451('0x4a')](_0x118918[_0x209451('0x22')][_0x209451('0x5a')],{'through':_['omit'](_0x118918['body'],[_0x209451('0x5a'),'id'])})[_0x209451('0x1c')](function(_0x5de1b3){const _0x1e60db=_0x209451;for(let _0x356967=0x0;_0x356967<_0x118918[_0x1e60db('0x22')][_0x1e60db('0x5a')][_0x1e60db('0x24')];_0x356967+=0x1){socket['emit'](_0x1e60db('0x6'),{'UserId':_0x118918['body']['ids'][_0x356967],'WhatsappQueueId':_0x118918[_0x1e60db('0x49')]['id']});}return _0x5de1b3;});})['then'](respondWithResult(_0x47871b,null))['catch'](handleError(_0x47871b,null));},exports[_0x3006a2('0x62')]=function(_0x195606,_0xb469d9){const _0x467e2a=_0x3006a2;return db[_0x467e2a('0x17')][_0x467e2a('0x6b')]({'where':{'id':_0x195606[_0x467e2a('0x49')]['id']}})[_0x467e2a('0x1c')](handleEntityNotFound(_0xb469d9,null))[_0x467e2a('0x1c')](function(_0x23cd63){const _0x4e35ef=_0x467e2a;if(_0x23cd63)return _0x23cd63['removeAgents'](_0x195606[_0x4e35ef('0x4')][_0x4e35ef('0x5a')])[_0x4e35ef('0x1c')](function(){const _0x3d2625=_0x4e35ef;if(_[_0x3d2625('0x40')](_0x195606[_0x3d2625('0x4')][_0x3d2625('0x5a')]))for(let _0xa86120=0x0;_0xa86120<_0x195606[_0x3d2625('0x4')]['ids']['length'];_0xa86120+=0x1){socket[_0x3d2625('0x5e')](_0x3d2625('0x10'),{'UserId':Number(_0x195606[_0x3d2625('0x4')][_0x3d2625('0x5a')][_0xa86120]),'WhatsappQueueId':Number(_0x195606[_0x3d2625('0x49')]['id'])});}else socket[_0x3d2625('0x5e')](_0x3d2625('0x10'),{'UserId':Number(_0x195606[_0x3d2625('0x4')][_0x3d2625('0x5a')]),'WhatsappQueueId':Number(_0x195606[_0x3d2625('0x49')]['id'])});});})[_0x467e2a('0x1c')](respondWithStatusCode(_0xb469d9,null))['catch'](handleError(_0xb469d9,null));},exports[_0x3006a2('0x65')]=function(_0x400958,_0x462508){const _0x34411b=_0x3006a2;let _0x2c38e1={};const _0x5ad190={};let _0x442478,_0x11a674;return db[_0x34411b('0x17')][_0x34411b('0x6b')]({'where':{'id':_0x400958[_0x34411b('0x49')]['id']}})['then'](handleEntityNotFound(_0x462508,null))[_0x34411b('0x1c')](function(_0x12d6af){const _0x45a67c=_0x34411b;if(_0x12d6af)return _0x442478=_0x12d6af,_0x5ad190[_0x45a67c('0x48')]=_[_0x45a67c('0x5c')](db[_0x45a67c('0xe')][_0x45a67c('0x36')]),_0x5ad190[_0x45a67c('0x4')]=_['keys'](_0x400958['query']),_0x5ad190[_0x45a67c('0x0')]=_[_0x45a67c('0x3a')](_0x5ad190[_0x45a67c('0x48')],_0x5ad190[_0x45a67c('0x4')]),_0x2c38e1[_0x45a67c('0x8')]=_[_0x45a67c('0x3a')](_0x5ad190['model'],qs['fields'](_0x400958['query'][_0x45a67c('0x2b')])),_0x2c38e1[_0x45a67c('0x8')]=_0x2c38e1['attributes'][_0x45a67c('0x24')]?_0x2c38e1[_0x45a67c('0x8')]:_0x5ad190[_0x45a67c('0x48')],_0x2c38e1[_0x45a67c('0x56')]=qs[_0x45a67c('0x5b')](_0x400958[_0x45a67c('0x4')][_0x45a67c('0x5b')]),_0x2c38e1[_0x45a67c('0x3e')]=qs[_0x45a67c('0x0')](_['pick'](_0x400958[_0x45a67c('0x4')],_0x5ad190[_0x45a67c('0x0')])),_0x400958[_0x45a67c('0x4')][_0x45a67c('0x13')]&&(_0x2c38e1[_0x45a67c('0x3e')]=_['merge'](_0x2c38e1['where'],{[Op['or']]:_[_0x45a67c('0x1a')](_0x2c38e1[_0x45a67c('0x8')],function(_0x3454a9){const _0x1da07a=_0x45a67c,_0xa3ed29={};return _0xa3ed29[_0x3454a9]={[Op[_0x1da07a('0x50')]]:'%'+_0x400958[_0x1da07a('0x4')][_0x1da07a('0x13')]+'%'},_0xa3ed29;})})),_0x2c38e1=_[_0x45a67c('0x51')]({},_0x2c38e1,_0x400958[_0x45a67c('0x23')]),_0x442478[_0x45a67c('0x65')](_0x2c38e1);})[_0x34411b('0x1c')](function(_0xc2f6fc){const _0x2a6381=_0x34411b;if(_0xc2f6fc)return _0x11a674=_0xc2f6fc[_0x2a6381('0x24')],typeof _0x400958[_0x2a6381('0x4')][_0x2a6381('0x12')]===_0x2a6381('0x42')&&(_0x2c38e1['limit']=qs['limit'](_0x400958[_0x2a6381('0x4')][_0x2a6381('0x5f')]),_0x2c38e1[_0x2a6381('0x52')]=qs['offset'](_0x400958[_0x2a6381('0x4')][_0x2a6381('0x52')])),_0x442478[_0x2a6381('0x65')](_0x2c38e1);})['then'](function(_0x3ed7c7){if(_0x3ed7c7)return _0x3ed7c7?{'count':_0x11a674,'rows':_0x3ed7c7}:null;})[_0x34411b('0x1c')](respondWithResult(_0x462508,null))[_0x34411b('0x39')](handleError(_0x462508,null));};
\ No newline at end of file
+const a808_0x35d4=['error','transaction','toString','addAgents','squel','rows','flatMap','options','get','role','sequelize','each','findOrCreate','then','WhatsappQueueId','length','../../rediscache','catch','../../components/parsers/qs','getTeams','field','findOne','../../config/logger','removeTeams','whatsappPause','addTeams','offset','interface','voicePause','limit','keys','TeamId','attributes','union','User','join','model','online','Content-Range','forEach','fields','include','util','push','set','status','select','type','UserId','UserProfileResource','SIP','map','like','filters','removeAgents','order','params','userWhatsappQueue:save','emit','getMembers','updatedAt','end','show','clone','team_has_whatsapp_queues','compact','destroy','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','format','count','isArray','UserProfileSection','includes','all','VIRTUAL','Agents','describe','json','query','autoAssociation','ids','agent','sort','nolimit','Unable\x20to\x20retrieve\x20the\x20current\x20user','findAll','filter','merge','sendStatus','from','getAgents','stack','api','pick','tq.TeamId','index','SELECT','body','UserWhatsappQueue','name','fieldName','rawAttributes','create','userProfileId','intersection','findAndCountAll','lodash','Team','undefined','includeAll','WhatsappQueue','createdAt','where','user'];(function(_0x1296ea,_0x35d4c0){const _0x22a2d8=function(_0x4d72ff){while(--_0x4d72ff){_0x1296ea['push'](_0x1296ea['shift']());}};_0x22a2d8(++_0x35d4c0);}(a808_0x35d4,0x1c4));const a808_0x22a2=function(_0x1296ea,_0x35d4c0){_0x1296ea=_0x1296ea-0x0;let _0x22a2d8=a808_0x35d4[_0x1296ea];return _0x22a2d8;};const _0x3240e5=a808_0x22a2;'use strict';const util=require(_0x3240e5('0x2e')),_=require(_0x3240e5('0x6e')),squel=require(_0x3240e5('0x8')),qs=require(_0x3240e5('0x16')),logger=require(_0x3240e5('0x1a'))(_0x3240e5('0x60')),{getSocket}=require(_0x3240e5('0x14')),socket=getSocket(),db=require('../../mysqldb')['db'],{Op,QueryTypes}=require(_0x3240e5('0xe'));require('./whatsappQueue.socket')['register'](socket);function respondWithStatusCode(_0x4d72ff,_0x2478ad){return _0x2478ad=_0x2478ad||0xcc,function(_0x30c402){const _0x9c4298=a808_0x22a2;if(_0x30c402)return _0x4d72ff[_0x9c4298('0x5c')](_0x2478ad);return _0x4d72ff[_0x9c4298('0x31')](_0x2478ad)[_0x9c4298('0x41')]();};}function respondWithResult(_0x4b874d,_0x448e0c){return _0x448e0c=_0x448e0c||0xc8,function(_0x4b90e8){const _0x1b3f02=a808_0x22a2;if(_0x4b90e8)return _0x4b874d[_0x1b3f02('0x31')](_0x448e0c)['json'](_0x4b90e8);};}function respondWithFilteredResult(_0x2fd7d7,_0x4c0ece){return function(_0xbab835){const _0x222570=a808_0x22a2;if(_0xbab835){const _0x1d3981=_0xbab835['count'],_0x55f9b9=_0x4c0ece[_0x222570('0x1e')];let _0x590850=_0x4c0ece[_0x222570('0x1e')]+_0x4c0ece[_0x222570('0x21')],_0x27999f;return _0x590850>=_0x1d3981?(_0x590850=_0x1d3981,_0x27999f=0xc8):_0x27999f=0xce,_0x2fd7d7[_0x222570('0x31')](_0x27999f),_0x2fd7d7[_0x222570('0x30')](_0x222570('0x2a'),_0x55f9b9+'-'+_0x590850+'/'+_0x1d3981)[_0x222570('0x51')](_0xbab835);}return null;};}function saveUpdates(_0x74157d){return function(_0x195c18){const _0xf17f83=a808_0x22a2;if(_0x195c18)return _0x195c18['update'](_0x74157d)[_0xf17f83('0x11')](function(_0x759254){return _0x759254;});return null;};}function removeEntity(_0x4cd677){return function(_0x489a89){const _0x5f3427=a808_0x22a2;if(_0x489a89)return _0x489a89['destroy']()[_0x5f3427('0x11')](function(){const _0x320cc9=_0x5f3427,_0x48e987=_0x489a89[_0x320cc9('0xc')]({'plain':!![]}),_0x521ae9='WhatsappQueues';return db[_0x320cc9('0x35')][_0x320cc9('0x46')]({'where':{'type':_0x521ae9,'resourceId':_0x48e987['id']}})[_0x320cc9('0x11')](function(){return _0x489a89;});})[_0x5f3427('0x11')](function(){const _0x81c900=_0x5f3427;_0x4cd677[_0x81c900('0x31')](0xcc)[_0x81c900('0x41')]();});};}function handleEntityNotFound(_0x13f7b9){return function(_0x3ca791){return!_0x3ca791&&_0x13f7b9['sendStatus'](0x194),_0x3ca791;};}function handleError(_0x57b897,_0x40f40d){return _0x40f40d=_0x40f40d||0x1f4,function(_0x284e09){const _0x5465cd=a808_0x22a2;logger[_0x5465cd('0x4')](_0x284e09[_0x5465cd('0x5f')]),_0x284e09[_0x5465cd('0x67')]&&delete _0x284e09[_0x5465cd('0x67')],_0x57b897[_0x5465cd('0x31')](_0x40f40d)['send'](_0x284e09);};}exports[_0x3240e5('0x63')]=function(_0x440a6e,_0x981f1){const _0x15bb63=_0x3240e5;let _0x5d948f={};const _0xda0eff={},_0x5d9c1e={'count':0x0,'rows':[]},_0x162c62=_[_0x15bb63('0x37')](db[_0x15bb63('0x0')]['rawAttributes'],function(_0x377ea7){const _0x5c6693=_0x15bb63;return{'name':_0x377ea7[_0x5c6693('0x68')],'type':_0x377ea7[_0x5c6693('0x33')]['key']};});_0xda0eff['model']=_[_0x15bb63('0x37')](_0x162c62,'name'),_0xda0eff[_0x15bb63('0x52')]=_[_0x15bb63('0x22')](_0x440a6e['query']),_0xda0eff[_0x15bb63('0x39')]=_['intersection'](_0xda0eff['model'],_0xda0eff[_0x15bb63('0x52')]),_0x5d948f[_0x15bb63('0x24')]=_[_0x15bb63('0x6c')](_0xda0eff[_0x15bb63('0x28')],qs[_0x15bb63('0x2c')](_0x440a6e[_0x15bb63('0x52')]['fields'])),_0x5d948f['attributes']=_0x5d948f[_0x15bb63('0x24')][_0x15bb63('0x13')]?_0x5d948f[_0x15bb63('0x24')]:_0xda0eff[_0x15bb63('0x28')];typeof _0x440a6e['query'][_0x15bb63('0x57')]==='undefined'&&(_0x5d948f['limit']=qs[_0x15bb63('0x21')](_0x440a6e[_0x15bb63('0x52')][_0x15bb63('0x21')]),_0x5d948f[_0x15bb63('0x1e')]=qs[_0x15bb63('0x1e')](_0x440a6e[_0x15bb63('0x52')][_0x15bb63('0x1e')]));_0x5d948f[_0x15bb63('0x3b')]=qs[_0x15bb63('0x56')](_0x440a6e[_0x15bb63('0x52')]['sort']),_0x5d948f[_0x15bb63('0x2')]=qs[_0x15bb63('0x39')](_[_0x15bb63('0x61')](_0x440a6e[_0x15bb63('0x52')],_0xda0eff['filters']),_0x162c62);_0x440a6e[_0x15bb63('0x52')][_0x15bb63('0x5a')]&&(_0x5d948f[_0x15bb63('0x2')]=_[_0x15bb63('0x5b')](_0x5d948f[_0x15bb63('0x2')],{[Op['or']]:_[_0x15bb63('0x37')](_0x162c62,function(_0x2cc3be){const _0x28376e=_0x15bb63;if(_0x2cc3be[_0x28376e('0x33')]!==_0x28376e('0x4e')){const _0x352822={};return _0x352822[_0x2cc3be['name']]={[Op[_0x28376e('0x38')]]:'%'+_0x440a6e[_0x28376e('0x52')][_0x28376e('0x5a')]+'%'},_0x352822;}})}));_0x5d948f=_['merge']({},_0x5d948f,_0x440a6e[_0x15bb63('0xb')]);const _0x3e90b2={'where':_0x5d948f[_0x15bb63('0x2')]};return db[_0x15bb63('0x0')][_0x15bb63('0x49')](_0x3e90b2)[_0x15bb63('0x11')](function(_0x3b0dfb){const _0x26bf9d=_0x15bb63;return _0x5d9c1e[_0x26bf9d('0x49')]=_0x3b0dfb,_0x440a6e[_0x26bf9d('0x52')][_0x26bf9d('0x71')]&&(_0x5d948f['include']=[{'all':!![]}]),db['WhatsappQueue'][_0x26bf9d('0x59')](_0x5d948f);})[_0x15bb63('0x11')](function(_0x1f26af){const _0x5db290=_0x15bb63;return _0x5d9c1e[_0x5db290('0x9')]=_0x1f26af,_0x5d9c1e;})[_0x15bb63('0x11')](respondWithFilteredResult(_0x981f1,_0x5d948f))[_0x15bb63('0x15')](handleError(_0x981f1,null));},exports[_0x3240e5('0x42')]=function(_0x5f5cce,_0x134091){const _0x505886=_0x3240e5;let _0x252c12={'raw':!![],'where':{'id':_0x5f5cce[_0x505886('0x3c')]['id']}};const _0x5ed0ac={};return _0x5ed0ac[_0x505886('0x28')]=_[_0x505886('0x22')](db[_0x505886('0x0')][_0x505886('0x69')]),_0x5ed0ac[_0x505886('0x52')]=_[_0x505886('0x22')](_0x5f5cce[_0x505886('0x52')]),_0x5ed0ac[_0x505886('0x39')]=_['intersection'](_0x5ed0ac[_0x505886('0x28')],_0x5ed0ac[_0x505886('0x52')]),_0x252c12[_0x505886('0x24')]=_[_0x505886('0x6c')](_0x5ed0ac[_0x505886('0x28')],qs[_0x505886('0x2c')](_0x5f5cce['query'][_0x505886('0x2c')])),_0x252c12[_0x505886('0x24')]=_0x252c12[_0x505886('0x24')]['length']?_0x252c12[_0x505886('0x24')]:_0x5ed0ac[_0x505886('0x28')],_0x5f5cce[_0x505886('0x52')][_0x505886('0x71')]&&(_0x252c12[_0x505886('0x2d')]=[{'all':!![]}]),_0x252c12=_[_0x505886('0x5b')]({},_0x252c12,_0x5f5cce[_0x505886('0xb')]),db['WhatsappQueue'][_0x505886('0x19')](_0x252c12)[_0x505886('0x11')](handleEntityNotFound(_0x134091,null))[_0x505886('0x11')](respondWithResult(_0x134091,null))[_0x505886('0x15')](handleError(_0x134091,null));},exports[_0x3240e5('0x6a')]=function(_0x1ef267,_0x3fcae7){const _0x20fdeb=_0x3240e5;return db[_0x20fdeb('0x0')][_0x20fdeb('0x6a')](_0x1ef267[_0x20fdeb('0x65')],{})[_0x20fdeb('0x11')](function(_0x3de2cd){const _0x5ecea5=_0x20fdeb,_0x1ea46e=_0x1ef267['user'][_0x5ecea5('0xc')]({'plain':!![]});if(!_0x1ea46e)throw new Error(_0x5ecea5('0x58'));if(_0x1ea46e[_0x5ecea5('0xd')]===_0x5ecea5('0x3')){const _0x2aefc4=_0x3de2cd['get']({'plain':!![]}),_0x58f4b7='WhatsappQueues';return db[_0x5ecea5('0x4b')]['findOne']({'where':{'name':_0x58f4b7,'userProfileId':_0x1ea46e[_0x5ecea5('0x6b')]},'raw':!![]})[_0x5ecea5('0x11')](function(_0x2ba8ed){const _0xb81f8=_0x5ecea5;return _0x2ba8ed&&_0x2ba8ed[_0xb81f8('0x53')]===0x0?db[_0xb81f8('0x35')][_0xb81f8('0x6a')]({'name':_0x2aefc4[_0xb81f8('0x67')],'resourceId':_0x2aefc4['id'],'type':_0x2ba8ed[_0xb81f8('0x67')],'sectionId':_0x2ba8ed['id']},{})[_0xb81f8('0x11')](function(){return _0x3de2cd;}):_0x3de2cd;})[_0x5ecea5('0x15')](function(_0x3861b5){const _0x9aef69=_0x5ecea5;logger[_0x9aef69('0x4')](_0x9aef69('0x47'),_0x3861b5);throw _0x3861b5;});}return _0x3de2cd;})[_0x20fdeb('0x11')](respondWithResult(_0x3fcae7,0xc9))[_0x20fdeb('0x15')](handleError(_0x3fcae7,null));},exports['update']=function(_0x5f4f13,_0x2134c7){const _0x48b950=_0x3240e5;return _0x5f4f13[_0x48b950('0x65')]['id']&&delete _0x5f4f13[_0x48b950('0x65')]['id'],db[_0x48b950('0x0')][_0x48b950('0x19')]({'where':{'id':_0x5f4f13[_0x48b950('0x3c')]['id']}})[_0x48b950('0x11')](handleEntityNotFound(_0x2134c7,null))['then'](saveUpdates(_0x5f4f13['body'],null))[_0x48b950('0x11')](respondWithResult(_0x2134c7,null))[_0x48b950('0x15')](handleError(_0x2134c7,null));},exports[_0x3240e5('0x46')]=function(_0x59014b,_0x1243f5){const _0x114aa9=_0x3240e5;return db[_0x114aa9('0x0')][_0x114aa9('0x19')]({'where':{'id':_0x59014b['params']['id']}})[_0x114aa9('0x11')](handleEntityNotFound(_0x1243f5,null))[_0x114aa9('0x11')](removeEntity(_0x1243f5,null))[_0x114aa9('0x15')](handleError(_0x1243f5,null));},exports[_0x3240e5('0x50')]=function(_0x52a575,_0x133287){const _0x2ef4f0=_0x3240e5;return db[_0x2ef4f0('0x0')][_0x2ef4f0('0x50')]()[_0x2ef4f0('0x11')](respondWithResult(_0x133287,null))[_0x2ef4f0('0x15')](handleError(_0x133287,null));},exports[_0x3240e5('0x3f')]=function(_0x1c2c9b,_0x52909b){const _0x20b67b=_0x3240e5;let _0x28fb23={'raw':!![],'where':{}};const _0x3fded2={};let _0x25cc98;return db[_0x20b67b('0x0')][_0x20b67b('0x19')]({'where':{'id':_0x1c2c9b[_0x20b67b('0x3c')]['id']}})[_0x20b67b('0x11')](handleEntityNotFound(_0x52909b,null))[_0x20b67b('0x11')](function(_0x160fa6){const _0x45ea8a=_0x20b67b;if(_0x160fa6)return _0x25cc98=_0x160fa6[_0x45ea8a('0xc')]({'plain':!![]}),_0x3fded2[_0x45ea8a('0x28')]=_[_0x45ea8a('0x22')](db[_0x45ea8a('0x66')][_0x45ea8a('0x69')]),_0x3fded2['query']=_[_0x45ea8a('0x22')](_0x1c2c9b[_0x45ea8a('0x52')]),_0x3fded2[_0x45ea8a('0x39')]=_[_0x45ea8a('0x6c')](_0x3fded2[_0x45ea8a('0x28')],_0x3fded2[_0x45ea8a('0x52')]),_0x28fb23[_0x45ea8a('0x24')]=_[_0x45ea8a('0x6c')](_0x3fded2[_0x45ea8a('0x28')],qs[_0x45ea8a('0x2c')](_0x1c2c9b['query']['fields'])),_0x28fb23[_0x45ea8a('0x24')]=_0x28fb23[_0x45ea8a('0x24')][_0x45ea8a('0x13')]?_0x28fb23[_0x45ea8a('0x24')]:_0x3fded2['model'],typeof _0x1c2c9b[_0x45ea8a('0x52')]['nolimit']===_0x45ea8a('0x70')&&(_0x28fb23[_0x45ea8a('0x21')]=qs[_0x45ea8a('0x21')](_0x1c2c9b[_0x45ea8a('0x52')][_0x45ea8a('0x21')]),_0x28fb23[_0x45ea8a('0x1e')]=qs[_0x45ea8a('0x1e')](_0x1c2c9b['query']['offset'])),_0x28fb23[_0x45ea8a('0x3b')]=qs[_0x45ea8a('0x56')](_0x1c2c9b[_0x45ea8a('0x52')][_0x45ea8a('0x56')]),_0x28fb23[_0x45ea8a('0x2')]=qs[_0x45ea8a('0x39')](_[_0x45ea8a('0x61')](_0x1c2c9b['query'],_0x3fded2[_0x45ea8a('0x39')])),_0x28fb23[_0x45ea8a('0x2')][_0x45ea8a('0x12')]=_0x160fa6['id'],_0x1c2c9b[_0x45ea8a('0x52')]['filter']&&(_0x28fb23[_0x45ea8a('0x2')]=_[_0x45ea8a('0x5b')](_0x28fb23[_0x45ea8a('0x2')],{[Op['or']]:_[_0x45ea8a('0x37')](_0x28fb23[_0x45ea8a('0x24')],function(_0x215376){const _0x3401d3=_0x45ea8a,_0x322cf5={};return _0x322cf5[_0x215376]={[Op[_0x3401d3('0x38')]]:'%'+_0x1c2c9b[_0x3401d3('0x52')][_0x3401d3('0x5a')]+'%'},_0x322cf5;})})),_0x28fb23=_[_0x45ea8a('0x5b')]({},_0x28fb23,_0x1c2c9b[_0x45ea8a('0xb')]),db[_0x45ea8a('0x66')][_0x45ea8a('0x59')](_0x28fb23);})['then'](function(_0x27cfea){const _0x1c3b39=_0x20b67b;if(_0x27cfea)return db[_0x1c3b39('0x26')][_0x1c3b39('0x6d')]({'where':{'id':_['map'](_0x27cfea,_0x1c3b39('0x34')),'role':_0x1c3b39('0x55')},'attributes':['id',_0x1c3b39('0x67'),_0x1c3b39('0x1c'),_0x1c3b39('0x40'),'createdAt']});})[_0x20b67b('0x11')](function(_0x15fddc){const _0x4f17d0=_0x20b67b;return _0x15fddc?{'count':_0x15fddc[_0x4f17d0('0x49')],'rows':_[_0x4f17d0('0x37')](_0x15fddc[_0x4f17d0('0x9')],function(_0xa140fd){const _0xb2807a=_0x4f17d0;return{'membername':_0xa140fd['name'],'UserId':_0xa140fd['id'],'queue_name':_0x25cc98[_0xb2807a('0x67')],'WhatsappQueueId':_0x25cc98['id'],'interface':util[_0xb2807a('0x48')]('%s/%s',_0xb2807a('0x36'),_0xa140fd['name']),'penalty':0x0,'paused':_0xa140fd[_0xb2807a('0x1c')],'createdAt':_0xa140fd[_0xb2807a('0x1')],'updatedAt':_0xa140fd[_0xb2807a('0x40')]};})}:{'count':0x0,'rows':[]};})['then'](respondWithFilteredResult(_0x52909b,_0x28fb23))[_0x20b67b('0x15')](handleError(_0x52909b,null));},exports[_0x3240e5('0x17')]=function(_0x5644d7,_0x48a704){const _0x33f0c5=_0x3240e5;let _0x57339a={};const _0x326084={};let _0xa4fa63,_0x80b5ac;return db[_0x33f0c5('0x0')][_0x33f0c5('0x19')]({'where':{'id':_0x5644d7[_0x33f0c5('0x3c')]['id']}})[_0x33f0c5('0x11')](handleEntityNotFound(_0x48a704,null))[_0x33f0c5('0x11')](function(_0xb01df8){const _0x8f9e8f=_0x33f0c5;if(_0xb01df8)return _0xa4fa63=_0xb01df8,_0x326084[_0x8f9e8f('0x28')]=_[_0x8f9e8f('0x22')](db[_0x8f9e8f('0x6f')][_0x8f9e8f('0x69')]),_0x326084[_0x8f9e8f('0x52')]=_[_0x8f9e8f('0x22')](_0x5644d7[_0x8f9e8f('0x52')]),_0x326084[_0x8f9e8f('0x39')]=_[_0x8f9e8f('0x6c')](_0x326084[_0x8f9e8f('0x28')],_0x326084[_0x8f9e8f('0x52')]),_0x57339a['attributes']=_['intersection'](_0x326084['model'],qs['fields'](_0x5644d7[_0x8f9e8f('0x52')][_0x8f9e8f('0x2c')])),_0x57339a[_0x8f9e8f('0x24')]=_0x57339a[_0x8f9e8f('0x24')][_0x8f9e8f('0x13')]?_0x57339a['attributes']:_0x326084[_0x8f9e8f('0x28')],_0x57339a[_0x8f9e8f('0x3b')]=qs[_0x8f9e8f('0x56')](_0x5644d7[_0x8f9e8f('0x52')][_0x8f9e8f('0x56')]),_0x57339a[_0x8f9e8f('0x2')]=qs[_0x8f9e8f('0x39')](_[_0x8f9e8f('0x61')](_0x5644d7[_0x8f9e8f('0x52')],_0x326084[_0x8f9e8f('0x39')])),_0x5644d7[_0x8f9e8f('0x52')]['filter']&&(_0x57339a[_0x8f9e8f('0x2')]=_[_0x8f9e8f('0x5b')](_0x57339a[_0x8f9e8f('0x2')],{[Op['or']]:_[_0x8f9e8f('0x37')](_0x57339a[_0x8f9e8f('0x24')],function(_0x44a765){const _0x39d18a=_0x8f9e8f,_0x4a9c48={};return _0x4a9c48[_0x44a765]={[Op[_0x39d18a('0x38')]]:'%'+_0x5644d7['query'][_0x39d18a('0x5a')]+'%'},_0x4a9c48;})})),_0x57339a=_['merge']({},_0x57339a,_0x5644d7[_0x8f9e8f('0xb')]),_0xa4fa63['getTeams'](_0x57339a);})[_0x33f0c5('0x11')](function(_0x45d7b5){const _0xb7335e=_0x33f0c5;if(_0x45d7b5)return _0x80b5ac=_0x45d7b5[_0xb7335e('0x13')],typeof _0x5644d7[_0xb7335e('0x52')]['nolimit']===_0xb7335e('0x70')&&(_0x57339a['limit']=qs[_0xb7335e('0x21')](_0x5644d7[_0xb7335e('0x52')][_0xb7335e('0x21')]),_0x57339a[_0xb7335e('0x1e')]=qs[_0xb7335e('0x1e')](_0x5644d7[_0xb7335e('0x52')][_0xb7335e('0x1e')])),_0xa4fa63[_0xb7335e('0x17')](_0x57339a);})[_0x33f0c5('0x11')](function(_0x49ec9c){if(_0x49ec9c)return _0x49ec9c?{'count':_0x80b5ac,'rows':_0x49ec9c}:null;})['then'](respondWithResult(_0x48a704,null))[_0x33f0c5('0x15')](handleError(_0x48a704,null));},exports['addTeams']=function(_0xf5570,_0x385152){const _0x50faea=_0x3240e5,_0x1704b2=_0xf5570[_0x50faea('0x65')][_0x50faea('0x54')];return db[_0x50faea('0x6f')][_0x50faea('0x59')]({'where':{'id':_0x1704b2},'attributes':['id'],'include':[{'model':db[_0x50faea('0x26')],'as':_0x50faea('0x4f'),'attributes':['id','name',_0x50faea('0x29'),_0x50faea('0x20'),_0x50faea('0x1f')],'raw':!![]}]})[_0x50faea('0x11')](function(_0x2a1cb0){const _0x4026ee=_0x50faea;if(_0x2a1cb0){const _0x6283b9=_[_0x4026ee('0xa')](_0x2a1cb0,function(_0x3449da){const _0x233dc1=_0x4026ee,_0x2c8c4f=_0x3449da[_0x233dc1('0xc')]({'plain':!![]});return _0x2c8c4f[_0x233dc1('0x4f')];});return db[_0x4026ee('0x0')][_0x4026ee('0x19')]({'where':{'id':_0xf5570['params']['id']}})[_0x4026ee('0x11')](function(_0x5a0b22){const _0x4c81f5=_0x4026ee;return db[_0x4c81f5('0xe')][_0x4c81f5('0x5')](function(_0x131462){const _0x5707b7=_0x4c81f5;return _0x5a0b22[_0x5707b7('0x1d')](_0x1704b2,{'transaction':_0x131462})['then'](function(){const _0x1a6b63=_0x5707b7;return Promise[_0x1a6b63('0xf')](_0x6283b9,function(_0x3fac5d){const _0x487d77=_0x1a6b63;return db[_0x487d77('0x66')][_0x487d77('0x10')]({'where':{'UserId':_0x3fac5d['id'],'WhatsappQueueId':_0xf5570['params']['id']},'transaction':_0x131462});});})[_0x5707b7('0x11')](function(){const _0x421cfb=_0x5707b7;_0x6283b9[_0x421cfb('0x2b')](function(_0x3cc3bb){const _0x59b4fa=_0x421cfb;socket[_0x59b4fa('0x3e')]('userWhatsappQueue:save',{'UserId':_0x3cc3bb['id'],'WhatsappQueueId':_0x5a0b22['id']});});});});});}})[_0x50faea('0x11')](respondWithStatusCode(_0x385152,null))['catch'](handleError(_0x385152,null));},exports[_0x3240e5('0x1b')]=function(_0x2d0c88,_0x2cb321){const _0x757864=_0x3240e5;return db[_0x757864('0x6f')][_0x757864('0x59')]({'where':{'id':_0x2d0c88['query'][_0x757864('0x54')]},'attributes':['id'],'include':[{'model':db[_0x757864('0x26')],'as':_0x757864('0x4f'),'attributes':['id'],'raw':!![]}]})[_0x757864('0x11')](handleEntityNotFound(_0x2cb321,null))[_0x757864('0x11')](function(_0x2c3701){const _0x4789c9=_0x757864,_0x3c22ff=_[_0x4789c9('0x37')](_0x2c3701,'id');let _0x4b21b6=[];const _0x10dec8=[],_0x231aad=squel[_0x4789c9('0x32')]();_0x231aad[_0x4789c9('0x18')](_0x4789c9('0x62'))[_0x4789c9('0x5d')](_0x4789c9('0x44'),'tq')[_0x4789c9('0x27')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0x4789c9('0x2')]('WhatsappQueueId\x20=\x20?',_0x2d0c88[_0x4789c9('0x3c')]['id']);for(let _0x316fed=0x0;_0x316fed<_0x2c3701[_0x4789c9('0x13')];_0x316fed+=0x1){const _0xf4409b=_0x2c3701[_0x316fed];for(let _0x1f4783=0x0;_0x1f4783<_0xf4409b[_0x4789c9('0x4f')][_0x4789c9('0x13')];_0x1f4783+=0x1){const _0x4835e6=_0xf4409b[_0x4789c9('0x4f')][_0x1f4783],_0x28923f=_0x231aad[_0x4789c9('0x43')]();_0x28923f[_0x4789c9('0x2')]('ut.UserId\x20=\x20?',_0x4835e6['id']),_0x10dec8[_0x4789c9('0x2f')](db[_0x4789c9('0xe')][_0x4789c9('0x52')](_0x28923f[_0x4789c9('0x6')](),{'type':QueryTypes[_0x4789c9('0x64')]})[_0x4789c9('0x11')](function(_0x57d4f7){const _0x31f766=_0x4789c9;if(_0x57d4f7[_0x31f766('0x13')]===0x1)return _0x4835e6['id'];else{const _0x5a4d8d=_['every'](_[_0x31f766('0x37')](_0x57d4f7,_0x31f766('0x23')),function(_0x3d74fe){const _0x58f03a=_0x31f766;return _[_0x58f03a('0x4c')](_0x3c22ff,_0x3d74fe);});if(_0x5a4d8d)return _0x4835e6['id'];}}));}}return Promise[_0x4789c9('0x4d')](_0x10dec8)[_0x4789c9('0x11')](function(_0x20e8b0){const _0x7344fa=_0x4789c9;return _0x4b21b6=_(_0x4b21b6)[_0x7344fa('0x25')](_0x20e8b0)[_0x7344fa('0x45')]()['value'](),db[_0x7344fa('0x0')]['findOne']({'where':{'id':_0x2d0c88[_0x7344fa('0x3c')]['id']}})[_0x7344fa('0x11')](function(_0x27f11a){const _0x35882e=_0x7344fa;return db[_0x35882e('0xe')]['transaction'](function(_0x3b1e79){const _0x2f85d7=_0x35882e;return _0x27f11a['removeTeams'](_0x2d0c88[_0x2f85d7('0x52')][_0x2f85d7('0x54')],{'transaction':_0x3b1e79})[_0x2f85d7('0x11')](function(){if(!_['isEmpty'](_0x4b21b6))return _0x27f11a['removeAgents'](_0x4b21b6,{'transaction':_0x3b1e79});})['then'](function(){const _0x179347=_0x2f85d7;_0x4b21b6[_0x179347('0x2b')](function(_0x186734){const _0xe02d95=_0x179347;socket[_0xe02d95('0x3e')]('userWhatsappQueue:remove',{'UserId':_0x186734,'WhatsappQueueId':_0x27f11a['id']});});});});});});})[_0x757864('0x11')](respondWithStatusCode(_0x2cb321,null))[_0x757864('0x15')](handleError(_0x2cb321,null));},exports['addAgents']=function(_0x563485,_0xd2f430){const _0x344a5a=_0x3240e5;return db[_0x344a5a('0x0')][_0x344a5a('0x19')]({'where':{'id':_0x563485[_0x344a5a('0x3c')]['id']}})[_0x344a5a('0x11')](function(_0x5f14e4){const _0x3ed8d6=_0x344a5a;if(_0x5f14e4)return _0x5f14e4[_0x3ed8d6('0x7')](_0x563485[_0x3ed8d6('0x65')]['ids'],{'through':_['omit'](_0x563485['body'],[_0x3ed8d6('0x54'),'id'])})[_0x3ed8d6('0x11')](function(_0x2b457e){const _0x1beb41=_0x3ed8d6;for(let _0x162de4=0x0;_0x162de4<_0x563485[_0x1beb41('0x65')][_0x1beb41('0x54')][_0x1beb41('0x13')];_0x162de4+=0x1){socket[_0x1beb41('0x3e')](_0x1beb41('0x3d'),{'UserId':_0x563485[_0x1beb41('0x65')][_0x1beb41('0x54')][_0x162de4],'WhatsappQueueId':_0x563485[_0x1beb41('0x3c')]['id']});}return _0x2b457e;});})['then'](respondWithResult(_0xd2f430,null))[_0x344a5a('0x15')](handleError(_0xd2f430,null));},exports[_0x3240e5('0x3a')]=function(_0x1eff38,_0x4fd7e6){const _0x5859b1=_0x3240e5;return db[_0x5859b1('0x0')][_0x5859b1('0x19')]({'where':{'id':_0x1eff38[_0x5859b1('0x3c')]['id']}})[_0x5859b1('0x11')](handleEntityNotFound(_0x4fd7e6,null))[_0x5859b1('0x11')](function(_0x34e099){const _0x1ab972=_0x5859b1;if(_0x34e099)return _0x34e099['removeAgents'](_0x1eff38['query'][_0x1ab972('0x54')])[_0x1ab972('0x11')](function(){const _0x3f1745=_0x1ab972;if(_[_0x3f1745('0x4a')](_0x1eff38[_0x3f1745('0x52')]['ids']))for(let _0x16792f=0x0;_0x16792f<_0x1eff38['query']['ids'][_0x3f1745('0x13')];_0x16792f+=0x1){socket['emit']('userWhatsappQueue:remove',{'UserId':Number(_0x1eff38[_0x3f1745('0x52')]['ids'][_0x16792f]),'WhatsappQueueId':Number(_0x1eff38[_0x3f1745('0x3c')]['id'])});}else socket[_0x3f1745('0x3e')]('userWhatsappQueue:remove',{'UserId':Number(_0x1eff38[_0x3f1745('0x52')][_0x3f1745('0x54')]),'WhatsappQueueId':Number(_0x1eff38[_0x3f1745('0x3c')]['id'])});});})[_0x5859b1('0x11')](respondWithStatusCode(_0x4fd7e6,null))[_0x5859b1('0x15')](handleError(_0x4fd7e6,null));},exports[_0x3240e5('0x5e')]=function(_0x297221,_0x2111bc){const _0x12ebf0=_0x3240e5;let _0x12fe40={};const _0x5bdd6f={};let _0x17fcf1,_0x2b6a03;return db[_0x12ebf0('0x0')][_0x12ebf0('0x19')]({'where':{'id':_0x297221[_0x12ebf0('0x3c')]['id']}})[_0x12ebf0('0x11')](handleEntityNotFound(_0x2111bc,null))[_0x12ebf0('0x11')](function(_0x28f716){const _0x520041=_0x12ebf0;if(_0x28f716)return _0x17fcf1=_0x28f716,_0x5bdd6f[_0x520041('0x28')]=_['keys'](db[_0x520041('0x26')][_0x520041('0x69')]),_0x5bdd6f[_0x520041('0x52')]=_[_0x520041('0x22')](_0x297221[_0x520041('0x52')]),_0x5bdd6f[_0x520041('0x39')]=_[_0x520041('0x6c')](_0x5bdd6f['model'],_0x5bdd6f[_0x520041('0x52')]),_0x12fe40[_0x520041('0x24')]=_[_0x520041('0x6c')](_0x5bdd6f[_0x520041('0x28')],qs[_0x520041('0x2c')](_0x297221[_0x520041('0x52')][_0x520041('0x2c')])),_0x12fe40[_0x520041('0x24')]=_0x12fe40[_0x520041('0x24')]['length']?_0x12fe40[_0x520041('0x24')]:_0x5bdd6f[_0x520041('0x28')],_0x12fe40[_0x520041('0x3b')]=qs[_0x520041('0x56')](_0x297221[_0x520041('0x52')][_0x520041('0x56')]),_0x12fe40[_0x520041('0x2')]=qs[_0x520041('0x39')](_[_0x520041('0x61')](_0x297221[_0x520041('0x52')],_0x5bdd6f[_0x520041('0x39')])),_0x297221[_0x520041('0x52')][_0x520041('0x5a')]&&(_0x12fe40['where']=_[_0x520041('0x5b')](_0x12fe40[_0x520041('0x2')],{[Op['or']]:_['map'](_0x12fe40[_0x520041('0x24')],function(_0xc05d5d){const _0x297a7e=_0x520041,_0x354574={};return _0x354574[_0xc05d5d]={[Op[_0x297a7e('0x38')]]:'%'+_0x297221[_0x297a7e('0x52')]['filter']+'%'},_0x354574;})})),_0x12fe40=_['merge']({},_0x12fe40,_0x297221[_0x520041('0xb')]),_0x17fcf1[_0x520041('0x5e')](_0x12fe40);})[_0x12ebf0('0x11')](function(_0x43b940){const _0x2ee7d3=_0x12ebf0;if(_0x43b940)return _0x2b6a03=_0x43b940[_0x2ee7d3('0x13')],typeof _0x297221[_0x2ee7d3('0x52')]['nolimit']==='undefined'&&(_0x12fe40[_0x2ee7d3('0x21')]=qs[_0x2ee7d3('0x21')](_0x297221[_0x2ee7d3('0x52')]['limit']),_0x12fe40[_0x2ee7d3('0x1e')]=qs[_0x2ee7d3('0x1e')](_0x297221[_0x2ee7d3('0x52')][_0x2ee7d3('0x1e')])),_0x17fcf1[_0x2ee7d3('0x5e')](_0x12fe40);})[_0x12ebf0('0x11')](function(_0xd16470){if(_0xd16470)return _0xd16470?{'count':_0x2b6a03,'rows':_0xd16470}:null;})['then'](respondWithResult(_0x2111bc,null))[_0x12ebf0('0x15')](handleError(_0x2111bc,null));};
\ No newline at end of file