Built motion from commit 5fcd269f5146f10cf3129722d518881dfac64576. Version 3.0.0...
[motion-next.git] / server / api / mailQueue / mailQueue.controller.js
1 const a420_0x3975=['ids','removeTeams','team_has_mail_queues','mailPause','./mailQueue.socket','SELECT','isEmpty','where','keys','../../rediscache','register','merge','MailQueue','name','sendStatus','MailQueues','Content-Range','UserProfileResource','fieldName','field','limit','rawAttributes','send','type','User','pick','compact','rows','stack','count','Team','status','params','userProfileId','undefined','select','json','all','includes','filter','like','destroy','filters','api','omit','then','online','length','catch','updatedAt','getAgents','set','describe','query','MailQueueId\x20=\x20?','options','sequelize','body','nolimit','sort','forEach','UserProfileSection','clone','user_has_teams','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','UserMailQueue','squel','model','flatMap','ut.TeamId\x20=\x20tq.TeamId','format','end','findAll','error','index','join','removeAgents','create','fields','findOrCreate','userMailQueue:save','get','userMailQueue:remove','../../mysqldb','../../components/parsers/qs','every','include','emit','SIP','createdAt','toString','findAndCountAll','agent','intersection','value','isArray','offset','lodash','addAgents','role','order','addTeams','findOne','voicePause','map','attributes','transaction','Agents','includeAll','%s/%s','user','getTeams','VIRTUAL','TeamId','autoAssociation'];(function(_0x16dad0,_0x397571){const _0x4ff898=function(_0x5595d0){while(--_0x5595d0){_0x16dad0['push'](_0x16dad0['shift']());}};_0x4ff898(++_0x397571);}(a420_0x3975,0xaf));const a420_0x4ff8=function(_0x16dad0,_0x397571){_0x16dad0=_0x16dad0-0x0;let _0x4ff898=a420_0x3975[_0x16dad0];return _0x4ff898;};const _0x127cb1=a420_0x4ff8;'use strict';const util=require('util'),_=require(_0x127cb1('0x25')),squel=require(_0x127cb1('0x6')),qs=require(_0x127cb1('0x18')),logger=require('../../config/logger')(_0x127cb1('0x62')),{getSocket}=require(_0x127cb1('0x40')),socket=getSocket(),db=require(_0x127cb1('0x17'))['db'],{Op,QueryTypes}=require(_0x127cb1('0x6f'));require(_0x127cb1('0x3b'))[_0x127cb1('0x41')](socket);function respondWithStatusCode(_0x5595d0,_0xa21f17){return _0xa21f17=_0xa21f17||0xcc,function(_0x1812e2){const _0x390218=a420_0x4ff8;if(_0x1812e2)return _0x5595d0[_0x390218('0x45')](_0xa21f17);return _0x5595d0['status'](_0xa21f17)[_0x390218('0xb')]();};}function respondWithResult(_0x454303,_0x3f19a4){return _0x3f19a4=_0x3f19a4||0xc8,function(_0x2b681e){const _0x17096a=a420_0x4ff8;if(_0x2b681e)return _0x454303[_0x17096a('0x56')](_0x3f19a4)['json'](_0x2b681e);};}function respondWithFilteredResult(_0x32ddeb,_0x34dcd6){return function(_0x270449){const _0x48a119=a420_0x4ff8;if(_0x270449){const _0x2f447a=_0x270449[_0x48a119('0x54')],_0xc7d718=_0x34dcd6[_0x48a119('0x24')];let _0xcd456e=_0x34dcd6[_0x48a119('0x24')]+_0x34dcd6['limit'],_0x59a671;return _0xcd456e>=_0x2f447a?(_0xcd456e=_0x2f447a,_0x59a671=0xc8):_0x59a671=0xce,_0x32ddeb['status'](_0x59a671),_0x32ddeb[_0x48a119('0x6a')](_0x48a119('0x47'),_0xc7d718+'-'+_0xcd456e+'/'+_0x2f447a)[_0x48a119('0x5b')](_0x270449);}return null;};}function saveUpdates(_0x3fdff7){return function(_0x6b1b35){const _0x42c93e=a420_0x4ff8;if(_0x6b1b35)return _0x6b1b35['update'](_0x3fdff7)[_0x42c93e('0x64')](function(_0x1ec57e){return _0x1ec57e;});return null;};}function removeEntity(_0x47dc14){return function(_0xc2f4f8){const _0x4763e2=a420_0x4ff8;if(_0xc2f4f8)return _0xc2f4f8['destroy']()[_0x4763e2('0x64')](function(){const _0x2a2e29=_0x4763e2,_0x13697e=_0xc2f4f8[_0x2a2e29('0x15')]({'plain':!![]}),_0x998aad='MailQueues';return db[_0x2a2e29('0x48')][_0x2a2e29('0x60')]({'where':{'type':_0x998aad,'resourceId':_0x13697e['id']}})[_0x2a2e29('0x64')](function(){return _0xc2f4f8;});})[_0x4763e2('0x64')](function(){const _0x3d9004=_0x4763e2;_0x47dc14[_0x3d9004('0x56')](0xcc)['end']();});};}function handleEntityNotFound(_0xd7dca0){return function(_0x266f62){const _0x5da056=a420_0x4ff8;return!_0x266f62&&_0xd7dca0[_0x5da056('0x45')](0x194),_0x266f62;};}function handleError(_0x1c542d,_0x2df4ae){return _0x2df4ae=_0x2df4ae||0x1f4,function(_0x378f76){const _0x109e95=a420_0x4ff8;logger[_0x109e95('0xd')](_0x378f76[_0x109e95('0x53')]),_0x378f76[_0x109e95('0x44')]&&delete _0x378f76['name'],_0x1c542d[_0x109e95('0x56')](_0x2df4ae)[_0x109e95('0x4d')](_0x378f76);};}exports[_0x127cb1('0xe')]=function(_0x1844a7,_0x510c5e){const _0x3d3384=_0x127cb1;let _0x9d1bf={};const _0x5218cf={},_0x5f4bd8={'count':0x0,'rows':[]},_0x15632b=_[_0x3d3384('0x2c')](db[_0x3d3384('0x43')][_0x3d3384('0x4c')],function(_0x4dae61){const _0x3ae5ce=_0x3d3384;return{'name':_0x4dae61[_0x3ae5ce('0x49')],'type':_0x4dae61[_0x3ae5ce('0x4e')]['key']};});_0x5218cf[_0x3d3384('0x7')]=_[_0x3d3384('0x2c')](_0x15632b,_0x3d3384('0x44')),_0x5218cf[_0x3d3384('0x6c')]=_[_0x3d3384('0x3f')](_0x1844a7[_0x3d3384('0x6c')]),_0x5218cf[_0x3d3384('0x61')]=_[_0x3d3384('0x21')](_0x5218cf[_0x3d3384('0x7')],_0x5218cf[_0x3d3384('0x6c')]),_0x9d1bf[_0x3d3384('0x2d')]=_[_0x3d3384('0x21')](_0x5218cf[_0x3d3384('0x7')],qs[_0x3d3384('0x12')](_0x1844a7['query']['fields'])),_0x9d1bf[_0x3d3384('0x2d')]=_0x9d1bf[_0x3d3384('0x2d')]['length']?_0x9d1bf[_0x3d3384('0x2d')]:_0x5218cf[_0x3d3384('0x7')];typeof _0x1844a7['query'][_0x3d3384('0x71')]==='undefined'&&(_0x9d1bf['limit']=qs[_0x3d3384('0x4b')](_0x1844a7[_0x3d3384('0x6c')][_0x3d3384('0x4b')]),_0x9d1bf['offset']=qs[_0x3d3384('0x24')](_0x1844a7[_0x3d3384('0x6c')]['offset']));_0x9d1bf['order']=qs[_0x3d3384('0x72')](_0x1844a7['query'][_0x3d3384('0x72')]),_0x9d1bf[_0x3d3384('0x3e')]=qs[_0x3d3384('0x61')](_['pick'](_0x1844a7[_0x3d3384('0x6c')],_0x5218cf[_0x3d3384('0x61')]),_0x15632b);_0x1844a7[_0x3d3384('0x6c')][_0x3d3384('0x5e')]&&(_0x9d1bf[_0x3d3384('0x3e')]=_[_0x3d3384('0x42')](_0x9d1bf['where'],{[Op['or']]:_['map'](_0x15632b,function(_0x1a40f6){const _0x9608b6=_0x3d3384;if(_0x1a40f6[_0x9608b6('0x4e')]!==_0x9608b6('0x34')){const _0x2e9c5a={};return _0x2e9c5a[_0x1a40f6['name']]={[Op['like']]:'%'+_0x1844a7[_0x9608b6('0x6c')][_0x9608b6('0x5e')]+'%'},_0x2e9c5a;}})}));_0x9d1bf=_[_0x3d3384('0x42')]({},_0x9d1bf,_0x1844a7[_0x3d3384('0x6e')]);const _0x4375ba={'where':_0x9d1bf[_0x3d3384('0x3e')]};return db[_0x3d3384('0x43')][_0x3d3384('0x54')](_0x4375ba)[_0x3d3384('0x64')](function(_0x245310){const _0x27f462=_0x3d3384;return _0x5f4bd8[_0x27f462('0x54')]=_0x245310,_0x1844a7['query'][_0x27f462('0x30')]&&(_0x9d1bf[_0x27f462('0x1a')]=[{'all':!![]}]),db[_0x27f462('0x43')][_0x27f462('0xc')](_0x9d1bf);})[_0x3d3384('0x64')](function(_0x5be1d8){const _0x68d9cd=_0x3d3384;return _0x5f4bd8[_0x68d9cd('0x52')]=_0x5be1d8,_0x5f4bd8;})[_0x3d3384('0x64')](respondWithFilteredResult(_0x510c5e,_0x9d1bf))['catch'](handleError(_0x510c5e,null));},exports['show']=function(_0x26b281,_0x42b59e){const _0x3922db=_0x127cb1;let _0x2bbcc5={'raw':!![],'where':{'id':_0x26b281[_0x3922db('0x57')]['id']}};const _0x5e9995={};return _0x5e9995[_0x3922db('0x7')]=_[_0x3922db('0x3f')](db['MailQueue']['rawAttributes']),_0x5e9995[_0x3922db('0x6c')]=_[_0x3922db('0x3f')](_0x26b281[_0x3922db('0x6c')]),_0x5e9995['filters']=_['intersection'](_0x5e9995['model'],_0x5e9995[_0x3922db('0x6c')]),_0x2bbcc5['attributes']=_[_0x3922db('0x21')](_0x5e9995[_0x3922db('0x7')],qs['fields'](_0x26b281[_0x3922db('0x6c')][_0x3922db('0x12')])),_0x2bbcc5['attributes']=_0x2bbcc5[_0x3922db('0x2d')][_0x3922db('0x66')]?_0x2bbcc5['attributes']:_0x5e9995['model'],_0x26b281[_0x3922db('0x6c')][_0x3922db('0x30')]&&(_0x2bbcc5[_0x3922db('0x1a')]=[{'all':!![]}]),_0x2bbcc5=_[_0x3922db('0x42')]({},_0x2bbcc5,_0x26b281['options']),db[_0x3922db('0x43')][_0x3922db('0x2a')](_0x2bbcc5)[_0x3922db('0x64')](handleEntityNotFound(_0x42b59e,null))[_0x3922db('0x64')](respondWithResult(_0x42b59e,null))['catch'](handleError(_0x42b59e,null));},exports[_0x127cb1('0x11')]=function(_0x2b130f,_0x595a25){const _0x3cca1b=_0x127cb1;return db[_0x3cca1b('0x43')][_0x3cca1b('0x11')](_0x2b130f[_0x3cca1b('0x70')],{})['then'](function(_0x39a308){const _0xb61355=_0x3cca1b,_0x5db7d3=_0x2b130f['user']['get']({'plain':!![]});if(!_0x5db7d3)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5db7d3[_0xb61355('0x27')]===_0xb61355('0x32')){const _0x55f160=_0x39a308['get']({'plain':!![]}),_0x4f1835=_0xb61355('0x46');return db[_0xb61355('0x1')][_0xb61355('0x2a')]({'where':{'name':_0x4f1835,'userProfileId':_0x5db7d3[_0xb61355('0x58')]},'raw':!![]})[_0xb61355('0x64')](function(_0x52d552){const _0x51eb48=_0xb61355;return _0x52d552&&_0x52d552[_0x51eb48('0x36')]===0x0?db[_0x51eb48('0x48')][_0x51eb48('0x11')]({'name':_0x55f160[_0x51eb48('0x44')],'resourceId':_0x55f160['id'],'type':_0x52d552['name'],'sectionId':_0x52d552['id']},{})['then'](function(){return _0x39a308;}):_0x39a308;})[_0xb61355('0x67')](function(_0x2b94aa){const _0x4d797d=_0xb61355;logger[_0x4d797d('0xd')](_0x4d797d('0x4'),_0x2b94aa);throw _0x2b94aa;});}return _0x39a308;})[_0x3cca1b('0x64')](respondWithResult(_0x595a25,0xc9))[_0x3cca1b('0x67')](handleError(_0x595a25,null));},exports['update']=function(_0x3d4a8c,_0x199198){const _0x3aee0a=_0x127cb1;return _0x3d4a8c[_0x3aee0a('0x70')]['id']&&delete _0x3d4a8c[_0x3aee0a('0x70')]['id'],db['MailQueue']['findOne']({'where':{'id':_0x3d4a8c[_0x3aee0a('0x57')]['id']}})['then'](handleEntityNotFound(_0x199198,null))[_0x3aee0a('0x64')](saveUpdates(_0x3d4a8c[_0x3aee0a('0x70')],null))[_0x3aee0a('0x64')](respondWithResult(_0x199198,null))[_0x3aee0a('0x67')](handleError(_0x199198,null));},exports[_0x127cb1('0x60')]=function(_0x4b7751,_0xc41f08){const _0x4fa7ba=_0x127cb1;return db['MailQueue']['findOne']({'where':{'id':_0x4b7751[_0x4fa7ba('0x57')]['id']}})[_0x4fa7ba('0x64')](handleEntityNotFound(_0xc41f08,null))['then'](removeEntity(_0xc41f08,null))[_0x4fa7ba('0x67')](handleError(_0xc41f08,null));},exports[_0x127cb1('0x6b')]=function(_0x4686f5,_0x54b6d6){const _0x178364=_0x127cb1;return db[_0x178364('0x43')][_0x178364('0x6b')]()['then'](respondWithResult(_0x54b6d6,null))[_0x178364('0x67')](handleError(_0x54b6d6,null));},exports['getMembers']=function(_0x251339,_0x1246b0){const _0x922a3e=_0x127cb1;let _0x3e2b48={'raw':!![],'where':{}};const _0x19ea87={};let _0x1a6818;return db[_0x922a3e('0x43')][_0x922a3e('0x2a')]({'where':{'id':_0x251339[_0x922a3e('0x57')]['id']}})[_0x922a3e('0x64')](handleEntityNotFound(_0x1246b0,null))[_0x922a3e('0x64')](function(_0x20fd38){const _0x53f400=_0x922a3e;if(_0x20fd38)return _0x1a6818=_0x20fd38[_0x53f400('0x15')]({'plain':!![]}),_0x19ea87[_0x53f400('0x7')]=_[_0x53f400('0x3f')](db[_0x53f400('0x5')]['rawAttributes']),_0x19ea87[_0x53f400('0x6c')]=_['keys'](_0x251339[_0x53f400('0x6c')]),_0x19ea87[_0x53f400('0x61')]=_[_0x53f400('0x21')](_0x19ea87[_0x53f400('0x7')],_0x19ea87[_0x53f400('0x6c')]),_0x3e2b48['attributes']=_[_0x53f400('0x21')](_0x19ea87[_0x53f400('0x7')],qs[_0x53f400('0x12')](_0x251339[_0x53f400('0x6c')][_0x53f400('0x12')])),_0x3e2b48[_0x53f400('0x2d')]=_0x3e2b48[_0x53f400('0x2d')][_0x53f400('0x66')]?_0x3e2b48[_0x53f400('0x2d')]:_0x19ea87[_0x53f400('0x7')],typeof _0x251339[_0x53f400('0x6c')]['nolimit']===_0x53f400('0x59')&&(_0x3e2b48[_0x53f400('0x4b')]=qs['limit'](_0x251339[_0x53f400('0x6c')][_0x53f400('0x4b')]),_0x3e2b48[_0x53f400('0x24')]=qs[_0x53f400('0x24')](_0x251339[_0x53f400('0x6c')][_0x53f400('0x24')])),_0x3e2b48['order']=qs[_0x53f400('0x72')](_0x251339['query'][_0x53f400('0x72')]),_0x3e2b48[_0x53f400('0x3e')]=qs['filters'](_[_0x53f400('0x50')](_0x251339[_0x53f400('0x6c')],_0x19ea87[_0x53f400('0x61')])),_0x3e2b48[_0x53f400('0x3e')]['MailQueueId']=_0x20fd38['id'],_0x251339[_0x53f400('0x6c')]['filter']&&(_0x3e2b48['where']=_[_0x53f400('0x42')](_0x3e2b48[_0x53f400('0x3e')],{[Op['or']]:_[_0x53f400('0x2c')](_0x3e2b48[_0x53f400('0x2d')],function(_0xfb222f){const _0x25ae89=_0x53f400,_0x55fdf1={};return _0x55fdf1[_0xfb222f]={[Op[_0x25ae89('0x5f')]]:'%'+_0x251339[_0x25ae89('0x6c')][_0x25ae89('0x5e')]+'%'},_0x55fdf1;})})),_0x3e2b48=_['merge']({},_0x3e2b48,_0x251339[_0x53f400('0x6e')]),db['UserMailQueue'][_0x53f400('0xc')](_0x3e2b48);})[_0x922a3e('0x64')](function(_0x15dad4){const _0x6cd93a=_0x922a3e;if(_0x15dad4)return db['User'][_0x6cd93a('0x1f')]({'where':{'id':_[_0x6cd93a('0x2c')](_0x15dad4,'UserId'),'role':_0x6cd93a('0x20')},'attributes':['id',_0x6cd93a('0x44'),_0x6cd93a('0x3a'),_0x6cd93a('0x68'),_0x6cd93a('0x1d')]});})[_0x922a3e('0x64')](function(_0x5bdc82){const _0x35e0a0=_0x922a3e;return _0x5bdc82?{'count':_0x5bdc82[_0x35e0a0('0x54')],'rows':_[_0x35e0a0('0x2c')](_0x5bdc82['rows'],function(_0x90fc2f){const _0x5ec960=_0x35e0a0;return{'membername':_0x90fc2f['name'],'UserId':_0x90fc2f['id'],'queue_name':_0x1a6818[_0x5ec960('0x44')],'MailQueueId':_0x1a6818['id'],'interface':util[_0x5ec960('0xa')](_0x5ec960('0x31'),_0x5ec960('0x1c'),_0x90fc2f[_0x5ec960('0x44')]),'penalty':0x0,'paused':_0x90fc2f[_0x5ec960('0x3a')],'createdAt':_0x90fc2f['createdAt'],'updatedAt':_0x90fc2f[_0x5ec960('0x68')]};})}:{'count':0x0,'rows':[]};})['then'](respondWithFilteredResult(_0x1246b0,_0x3e2b48))[_0x922a3e('0x67')](handleError(_0x1246b0,null));},exports[_0x127cb1('0x33')]=function(_0x1c3eff,_0xa4ab89){const _0x35ae2b=_0x127cb1;let _0x55d6a4={};const _0x5c0f7e={};let _0x45f59c,_0xcaa563;return db[_0x35ae2b('0x43')][_0x35ae2b('0x2a')]({'where':{'id':_0x1c3eff[_0x35ae2b('0x57')]['id']}})['then'](handleEntityNotFound(_0xa4ab89,null))[_0x35ae2b('0x64')](function(_0x4a099d){const _0x29bb0e=_0x35ae2b;if(_0x4a099d)return _0x45f59c=_0x4a099d,_0x5c0f7e[_0x29bb0e('0x7')]=_['keys'](db[_0x29bb0e('0x55')][_0x29bb0e('0x4c')]),_0x5c0f7e[_0x29bb0e('0x6c')]=_[_0x29bb0e('0x3f')](_0x1c3eff['query']),_0x5c0f7e[_0x29bb0e('0x61')]=_['intersection'](_0x5c0f7e[_0x29bb0e('0x7')],_0x5c0f7e[_0x29bb0e('0x6c')]),_0x55d6a4[_0x29bb0e('0x2d')]=_[_0x29bb0e('0x21')](_0x5c0f7e[_0x29bb0e('0x7')],qs[_0x29bb0e('0x12')](_0x1c3eff[_0x29bb0e('0x6c')][_0x29bb0e('0x12')])),_0x55d6a4['attributes']=_0x55d6a4[_0x29bb0e('0x2d')][_0x29bb0e('0x66')]?_0x55d6a4[_0x29bb0e('0x2d')]:_0x5c0f7e[_0x29bb0e('0x7')],_0x55d6a4[_0x29bb0e('0x28')]=qs[_0x29bb0e('0x72')](_0x1c3eff[_0x29bb0e('0x6c')][_0x29bb0e('0x72')]),_0x55d6a4[_0x29bb0e('0x3e')]=qs['filters'](_[_0x29bb0e('0x50')](_0x1c3eff[_0x29bb0e('0x6c')],_0x5c0f7e[_0x29bb0e('0x61')])),_0x1c3eff[_0x29bb0e('0x6c')][_0x29bb0e('0x5e')]&&(_0x55d6a4[_0x29bb0e('0x3e')]=_[_0x29bb0e('0x42')](_0x55d6a4[_0x29bb0e('0x3e')],{[Op['or']]:_['map'](_0x55d6a4[_0x29bb0e('0x2d')],function(_0x6c2b88){const _0x33b49b=_0x29bb0e,_0x4df625={};return _0x4df625[_0x6c2b88]={[Op[_0x33b49b('0x5f')]]:'%'+_0x1c3eff[_0x33b49b('0x6c')][_0x33b49b('0x5e')]+'%'},_0x4df625;})})),_0x55d6a4=_[_0x29bb0e('0x42')]({},_0x55d6a4,_0x1c3eff[_0x29bb0e('0x6e')]),_0x45f59c[_0x29bb0e('0x33')](_0x55d6a4);})[_0x35ae2b('0x64')](function(_0x56b85c){const _0xf81dca=_0x35ae2b;if(_0x56b85c)return _0xcaa563=_0x56b85c[_0xf81dca('0x66')],typeof _0x1c3eff['query'][_0xf81dca('0x71')]===_0xf81dca('0x59')&&(_0x55d6a4[_0xf81dca('0x4b')]=qs['limit'](_0x1c3eff['query']['limit']),_0x55d6a4[_0xf81dca('0x24')]=qs[_0xf81dca('0x24')](_0x1c3eff[_0xf81dca('0x6c')]['offset'])),_0x45f59c['getTeams'](_0x55d6a4);})[_0x35ae2b('0x64')](function(_0xedd603){if(_0xedd603)return _0xedd603?{'count':_0xcaa563,'rows':_0xedd603}:null;})[_0x35ae2b('0x64')](respondWithResult(_0xa4ab89,null))[_0x35ae2b('0x67')](handleError(_0xa4ab89,null));},exports[_0x127cb1('0x29')]=function(_0x54a95b,_0x24494c){const _0xf51cd8=_0x127cb1,_0x343a45=_0x54a95b[_0xf51cd8('0x70')][_0xf51cd8('0x37')];return db[_0xf51cd8('0x55')]['findAll']({'where':{'id':_0x343a45},'attributes':['id'],'include':[{'model':db[_0xf51cd8('0x4f')],'as':'Agents','attributes':['id',_0xf51cd8('0x44'),_0xf51cd8('0x65'),_0xf51cd8('0x2b'),'interface'],'raw':!![]}]})[_0xf51cd8('0x64')](function(_0x27ff5d){const _0x37f548=_0xf51cd8;if(_0x27ff5d){const _0x3ed10b=_[_0x37f548('0x8')](_0x27ff5d,function(_0x1499db){const _0x1e319b=_0x37f548,_0x19094d=_0x1499db[_0x1e319b('0x15')]({'plain':!![]});return _0x19094d[_0x1e319b('0x2f')];});return db[_0x37f548('0x43')]['findOne']({'where':{'id':_0x54a95b['params']['id']}})['then'](function(_0x34ad6f){const _0x429258=_0x37f548;return db[_0x429258('0x6f')][_0x429258('0x2e')](function(_0x492b5a){const _0x5ae344=_0x429258;return _0x34ad6f[_0x5ae344('0x29')](_0x343a45,{'transaction':_0x492b5a})[_0x5ae344('0x64')](function(){const _0x91d756=_0x5ae344;return Promise[_0x91d756('0x5c')](_0x3ed10b[_0x91d756('0x2c')](_0x4e606e=>{const _0x383104=_0x91d756;return db[_0x383104('0x5')][_0x383104('0x13')]({'where':{'UserId':_0x4e606e['id'],'MailQueueId':_0x54a95b['params']['id']},'transaction':_0x492b5a});}));})[_0x5ae344('0x64')](function(){const _0x22fc67=_0x5ae344;_0x3ed10b[_0x22fc67('0x0')](function(_0x1a775e){const _0x1ddf19=_0x22fc67;socket[_0x1ddf19('0x1b')](_0x1ddf19('0x14'),{'UserId':_0x1a775e['id'],'MailQueueId':_0x34ad6f['id']});});});});});}})[_0xf51cd8('0x64')](respondWithStatusCode(_0x24494c,null))[_0xf51cd8('0x67')](handleError(_0x24494c,null));},exports[_0x127cb1('0x38')]=function(_0x2ee48c,_0x4bbeda){const _0x5aac98=_0x127cb1;return db[_0x5aac98('0x55')][_0x5aac98('0xc')]({'where':{'id':_0x2ee48c[_0x5aac98('0x6c')]['ids']},'attributes':['id'],'include':[{'model':db[_0x5aac98('0x4f')],'as':_0x5aac98('0x2f'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x4bbeda,null))[_0x5aac98('0x64')](function(_0x509c83){const _0x47e80c=_0x5aac98,_0x4acbb9=_[_0x47e80c('0x2c')](_0x509c83,'id');let _0x161208=[];const _0x3a5f9b=[],_0x1ac83d=squel[_0x47e80c('0x5a')]();_0x1ac83d[_0x47e80c('0x4a')]('tq.TeamId')['from'](_0x47e80c('0x39'),'tq')[_0x47e80c('0xf')](_0x47e80c('0x3'),'ut',_0x47e80c('0x9'))['where'](_0x47e80c('0x6d'),_0x2ee48c[_0x47e80c('0x57')]['id']);for(let _0x40c1c7=0x0;_0x40c1c7<_0x509c83['length'];_0x40c1c7+=0x1){const _0x32e417=_0x509c83[_0x40c1c7];for(let _0x435ea3=0x0;_0x435ea3<_0x32e417[_0x47e80c('0x2f')]['length'];_0x435ea3+=0x1){const _0x29c183=_0x32e417[_0x47e80c('0x2f')][_0x435ea3],_0x204469=_0x1ac83d[_0x47e80c('0x2')]();_0x204469['where']('ut.UserId\x20=\x20?',_0x29c183['id']),_0x3a5f9b['push'](db[_0x47e80c('0x6f')]['query'](_0x204469[_0x47e80c('0x1e')](),{'type':QueryTypes[_0x47e80c('0x3c')]})['then'](function(_0xb30670){const _0x56367d=_0x47e80c;if(_0xb30670[_0x56367d('0x66')]===0x1)return _0x29c183['id'];else{const _0x288713=_[_0x56367d('0x19')](_[_0x56367d('0x2c')](_0xb30670,_0x56367d('0x35')),function(_0x21d060){const _0x5e128a=_0x56367d;return _[_0x5e128a('0x5d')](_0x4acbb9,_0x21d060);});if(_0x288713)return _0x29c183['id'];}}));}}return Promise['all'](_0x3a5f9b)['then'](function(_0x5515d8){const _0x1834ef=_0x47e80c;return _0x161208=_(_0x161208)['union'](_0x5515d8)[_0x1834ef('0x51')]()[_0x1834ef('0x22')](),db[_0x1834ef('0x43')]['findOne']({'where':{'id':_0x2ee48c[_0x1834ef('0x57')]['id']}})['then'](function(_0x3fad45){const _0x43c262=_0x1834ef;return db[_0x43c262('0x6f')]['transaction'](function(_0x49f745){const _0x500303=_0x43c262;return _0x3fad45['removeTeams'](_0x2ee48c[_0x500303('0x6c')][_0x500303('0x37')],{'transaction':_0x49f745})[_0x500303('0x64')](function(){const _0x814f0=_0x500303;if(!_[_0x814f0('0x3d')](_0x161208))return _0x3fad45['removeAgents'](_0x161208,{'transaction':_0x49f745});})[_0x500303('0x64')](function(){const _0x4cad11=_0x500303;_0x161208[_0x4cad11('0x0')](function(_0x466256){const _0x5e57db=_0x4cad11;socket[_0x5e57db('0x1b')]('userMailQueue:remove',{'UserId':_0x466256,'MailQueueId':_0x3fad45['id']});});});});});});})[_0x5aac98('0x64')](respondWithStatusCode(_0x4bbeda,null))[_0x5aac98('0x67')](handleError(_0x4bbeda,null));},exports[_0x127cb1('0x26')]=function(_0x4cb292,_0x4a5523){const _0x248fcd=_0x127cb1;return db[_0x248fcd('0x43')][_0x248fcd('0x2a')]({'where':{'id':_0x4cb292[_0x248fcd('0x57')]['id']}})['then'](function(_0x43a623){const _0x32ca09=_0x248fcd;if(_0x43a623)return _0x43a623['addAgents'](_0x4cb292[_0x32ca09('0x70')][_0x32ca09('0x37')],{'through':_[_0x32ca09('0x63')](_0x4cb292['body'],['ids','id'])})[_0x32ca09('0x64')](function(_0xdad9c6){const _0x192fc6=_0x32ca09;for(let _0x4dc4bd=0x0;_0x4dc4bd<_0x4cb292[_0x192fc6('0x70')][_0x192fc6('0x37')]['length'];_0x4dc4bd+=0x1){socket['emit'](_0x192fc6('0x14'),{'UserId':_0x4cb292['body'][_0x192fc6('0x37')][_0x4dc4bd],'MailQueueId':_0x4cb292[_0x192fc6('0x57')]['id']});}return _0xdad9c6;});})['then'](respondWithResult(_0x4a5523,null))['catch'](handleError(_0x4a5523,null));},exports[_0x127cb1('0x10')]=function(_0x5dec5e,_0x3c355b){const _0x382966=_0x127cb1;return db[_0x382966('0x43')][_0x382966('0x2a')]({'where':{'id':_0x5dec5e[_0x382966('0x57')]['id']}})['then'](handleEntityNotFound(_0x3c355b,null))['then'](function(_0x4bcd21){const _0x50ffa3=_0x382966;if(_0x4bcd21)return _0x4bcd21['removeAgents'](_0x5dec5e[_0x50ffa3('0x6c')]['ids'])[_0x50ffa3('0x64')](function(){const _0x4317e5=_0x50ffa3;if(_[_0x4317e5('0x23')](_0x5dec5e[_0x4317e5('0x6c')][_0x4317e5('0x37')]))for(let _0x16c486=0x0;_0x16c486<_0x5dec5e[_0x4317e5('0x6c')][_0x4317e5('0x37')][_0x4317e5('0x66')];_0x16c486+=0x1){socket[_0x4317e5('0x1b')](_0x4317e5('0x16'),{'UserId':Number(_0x5dec5e[_0x4317e5('0x6c')][_0x4317e5('0x37')][_0x16c486]),'MailQueueId':Number(_0x5dec5e[_0x4317e5('0x57')]['id'])});}else socket[_0x4317e5('0x1b')]('userMailQueue:remove',{'UserId':Number(_0x5dec5e[_0x4317e5('0x6c')][_0x4317e5('0x37')]),'MailQueueId':Number(_0x5dec5e[_0x4317e5('0x57')]['id'])});});})['then'](respondWithStatusCode(_0x3c355b,null))['catch'](handleError(_0x3c355b,null));},exports[_0x127cb1('0x69')]=function(_0x208f68,_0x2767e3){const _0x1a2116=_0x127cb1;let _0x3e4606={};const _0x314058={};let _0xbdf1c0,_0x280015;return db[_0x1a2116('0x43')][_0x1a2116('0x2a')]({'where':{'id':_0x208f68[_0x1a2116('0x57')]['id']}})[_0x1a2116('0x64')](handleEntityNotFound(_0x2767e3,null))[_0x1a2116('0x64')](function(_0x171a1a){const _0x493fa8=_0x1a2116;if(_0x171a1a)return _0xbdf1c0=_0x171a1a,_0x314058[_0x493fa8('0x7')]=_[_0x493fa8('0x3f')](db[_0x493fa8('0x4f')]['rawAttributes']),_0x314058[_0x493fa8('0x6c')]=_[_0x493fa8('0x3f')](_0x208f68[_0x493fa8('0x6c')]),_0x314058['filters']=_[_0x493fa8('0x21')](_0x314058[_0x493fa8('0x7')],_0x314058['query']),_0x3e4606[_0x493fa8('0x2d')]=_['intersection'](_0x314058[_0x493fa8('0x7')],qs[_0x493fa8('0x12')](_0x208f68[_0x493fa8('0x6c')][_0x493fa8('0x12')])),_0x3e4606[_0x493fa8('0x2d')]=_0x3e4606['attributes']['length']?_0x3e4606['attributes']:_0x314058[_0x493fa8('0x7')],_0x3e4606[_0x493fa8('0x28')]=qs[_0x493fa8('0x72')](_0x208f68['query']['sort']),_0x3e4606[_0x493fa8('0x3e')]=qs[_0x493fa8('0x61')](_[_0x493fa8('0x50')](_0x208f68[_0x493fa8('0x6c')],_0x314058['filters'])),_0x208f68[_0x493fa8('0x6c')][_0x493fa8('0x5e')]&&(_0x3e4606[_0x493fa8('0x3e')]=_[_0x493fa8('0x42')](_0x3e4606['where'],{[Op['or']]:_[_0x493fa8('0x2c')](_0x3e4606[_0x493fa8('0x2d')],function(_0x5d6baa){const _0x13a175=_0x493fa8,_0x8d17dd={};return _0x8d17dd[_0x5d6baa]={[Op['like']]:'%'+_0x208f68[_0x13a175('0x6c')][_0x13a175('0x5e')]+'%'},_0x8d17dd;})})),_0x3e4606=_[_0x493fa8('0x42')]({},_0x3e4606,_0x208f68[_0x493fa8('0x6e')]),_0xbdf1c0[_0x493fa8('0x69')](_0x3e4606);})[_0x1a2116('0x64')](function(_0xa2d972){const _0x16dc6a=_0x1a2116;if(_0xa2d972)return _0x280015=_0xa2d972['length'],typeof _0x208f68[_0x16dc6a('0x6c')][_0x16dc6a('0x71')]==='undefined'&&(_0x3e4606[_0x16dc6a('0x4b')]=qs[_0x16dc6a('0x4b')](_0x208f68[_0x16dc6a('0x6c')]['limit']),_0x3e4606[_0x16dc6a('0x24')]=qs['offset'](_0x208f68[_0x16dc6a('0x6c')][_0x16dc6a('0x24')])),_0xbdf1c0['getAgents'](_0x3e4606);})[_0x1a2116('0x64')](function(_0x7c4f84){if(_0x7c4f84)return _0x7c4f84?{'count':_0x280015,'rows':_0x7c4f84}:null;})['then'](respondWithResult(_0x2767e3,null))[_0x1a2116('0x67')](handleError(_0x2767e3,null));};