Built motion from commit 1ea47bf4.|2.6.34
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index ac02718..6df5dee 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0ace=['send','map','MailQueue','rawAttributes','fieldName','type','key','getOptions','where','include','query','findAll','rows','catch','show','keys','filters','intersection','model','attributes','fields','length','merge','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','MailQueues','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','describe','getMembers','hasOwnProperty','nolimit','order','sort','pick','MailQueueId','filter','findAndCountAll','UserId','mailPause','updatedAt','createdAt','format','SIP','getTeams','findOne','Team','addTeams','ids','Agents','voicePause','interface','flatMap','transaction','each','findOrCreate','forEach','removeTeams','User','select','field','team_has_mail_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','SELECT','every','includes','all','union','isEmpty','removeAgents','userMailQueue:remove','addAgents','omit','spread','emit','userMailQueue:save','isArray','getAgents','bluebird','util','lodash','ioredis','../../components/parsers/qs','redis','defaults','localhost','socket.io-emitter','./mailQueue.socket','register','status','json','offset','undefined','limit','count','set','then','destroy','get','UserProfileResource','end','sendStatus','stack','name'];(function(_0x558951,_0x41fe79){var _0x3244fb=function(_0x19c16c){while(--_0x19c16c){_0x558951['push'](_0x558951['shift']());}};_0x3244fb(++_0x41fe79);}(_0x0ace,0x1c6));var _0xe0ac=function(_0x136e17,_0x4cc300){_0x136e17=_0x136e17-0x0;var _0x5099c9=_0x0ace[_0x136e17];return _0x5099c9;};'use strict';var BPromise=require(_0xe0ac('0x0'));var util=require(_0xe0ac('0x1'));var _=require(_0xe0ac('0x2'));var squel=require('squel');var Redis=require(_0xe0ac('0x3'));var qs=require(_0xe0ac('0x4'));var logger=require('../../config/logger')('api');var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0xe0ac('0x5')]=_[_0xe0ac('0x6')](config[_0xe0ac('0x5')],{'host':_0xe0ac('0x7'),'port':0x18eb});var socket=require(_0xe0ac('0x8'))(new Redis(config[_0xe0ac('0x5')]));require(_0xe0ac('0x9'))[_0xe0ac('0xa')](socket);function respondWithStatusCode(_0x12fad2,_0x4d0475){_0x4d0475=_0x4d0475||0xcc;return function(_0xb06525){if(_0xb06525){return _0x12fad2['sendStatus'](_0x4d0475);}return _0x12fad2[_0xe0ac('0xb')](_0x4d0475)['end']();};}function respondWithResult(_0x21c98e,_0x54c190){_0x54c190=_0x54c190||0xc8;return function(_0x3bc477){if(_0x3bc477){return _0x21c98e[_0xe0ac('0xb')](_0x54c190)[_0xe0ac('0xc')](_0x3bc477);}};}function respondWithFilteredResult(_0xa183ac,_0xbc330e){return function(_0x573cb2){if(_0x573cb2){var _0x26e326=typeof _0xbc330e[_0xe0ac('0xd')]===_0xe0ac('0xe')&&typeof _0xbc330e[_0xe0ac('0xf')]==='undefined';var _0x15021c=_0x573cb2[_0xe0ac('0x10')];var _0x12a41c=_0x26e326?0x0:_0xbc330e['offset'];var _0x8eff1d=_0x26e326?_0x573cb2[_0xe0ac('0x10')]:_0xbc330e[_0xe0ac('0xd')]+_0xbc330e['limit'];var _0x34ed17;if(_0x8eff1d>=_0x15021c){_0x8eff1d=_0x15021c;_0x34ed17=0xc8;}else{_0x34ed17=0xce;}_0xa183ac['status'](_0x34ed17);return _0xa183ac[_0xe0ac('0x11')]('Content-Range',_0x12a41c+'-'+_0x8eff1d+'/'+_0x15021c)[_0xe0ac('0xc')](_0x573cb2);}return null;};}function saveUpdates(_0x327adf){return function(_0x14b04a){if(_0x14b04a){return _0x14b04a['update'](_0x327adf)[_0xe0ac('0x12')](function(_0x2f471a){return _0x2f471a;});}return null;};}function removeEntity(_0x1158f1){return function(_0x4fc656){if(_0x4fc656){return _0x4fc656[_0xe0ac('0x13')]()[_0xe0ac('0x12')](function(){var _0x379942=_0x4fc656[_0xe0ac('0x14')]({'plain':!![]});var _0x1a8987='MailQueues';return db[_0xe0ac('0x15')][_0xe0ac('0x13')]({'where':{'type':_0x1a8987,'resourceId':_0x379942['id']}})[_0xe0ac('0x12')](function(){return _0x4fc656;});})[_0xe0ac('0x12')](function(){_0x1158f1[_0xe0ac('0xb')](0xcc)[_0xe0ac('0x16')]();});}};}function handleEntityNotFound(_0x23bc8b){return function(_0x5ad0ce){if(!_0x5ad0ce){_0x23bc8b[_0xe0ac('0x17')](0x194);}return _0x5ad0ce;};}function handleError(_0x47e3be,_0x2f0112){_0x2f0112=_0x2f0112||0x1f4;return function(_0x5ea3e9){logger['error'](_0x5ea3e9[_0xe0ac('0x18')]);if(_0x5ea3e9[_0xe0ac('0x19')]){delete _0x5ea3e9[_0xe0ac('0x19')];}_0x47e3be[_0xe0ac('0xb')](_0x2f0112)[_0xe0ac('0x1a')](_0x5ea3e9);};}exports['index']=function(_0x2f1d8d,_0x2a4375){var _0x2f1062={};var _0x4f2649={'count':0x0,'rows':[]};var _0x7f3329=_[_0xe0ac('0x1b')](db[_0xe0ac('0x1c')][_0xe0ac('0x1d')],function(_0x5ea905){return{'name':_0x5ea905[_0xe0ac('0x1e')],'type':_0x5ea905[_0xe0ac('0x1f')][_0xe0ac('0x20')]};});_0x2f1062=qs[_0xe0ac('0x21')](_0x7f3329,_0x2f1d8d);var _0x335050={'where':_0x2f1062[_0xe0ac('0x22')]};return db[_0xe0ac('0x1c')][_0xe0ac('0x10')](_0x335050)[_0xe0ac('0x12')](function(_0x260311){_0x4f2649[_0xe0ac('0x10')]=_0x260311;_0x2f1062['include']=qs[_0xe0ac('0x23')](_0x2f1d8d[_0xe0ac('0x24')]);return db[_0xe0ac('0x1c')][_0xe0ac('0x25')](_0x2f1062);})['then'](function(_0x4d96cf){_0x4f2649[_0xe0ac('0x26')]=_0x4d96cf;return _0x4f2649;})['then'](respondWithFilteredResult(_0x2a4375,_0x2f1062))[_0xe0ac('0x27')](handleError(_0x2a4375,null));};exports[_0xe0ac('0x28')]=function(_0xcc0068,_0x44e2c4){var _0x1e293f={'raw':!![],'where':{'id':_0xcc0068['params']['id']}},_0x29bd8d={};_0x29bd8d['model']=_[_0xe0ac('0x29')](db[_0xe0ac('0x1c')]['rawAttributes']);_0x29bd8d[_0xe0ac('0x24')]=_[_0xe0ac('0x29')](_0xcc0068[_0xe0ac('0x24')]);_0x29bd8d[_0xe0ac('0x2a')]=_[_0xe0ac('0x2b')](_0x29bd8d[_0xe0ac('0x2c')],_0x29bd8d[_0xe0ac('0x24')]);_0x1e293f[_0xe0ac('0x2d')]=_[_0xe0ac('0x2b')](_0x29bd8d[_0xe0ac('0x2c')],qs[_0xe0ac('0x2e')](_0xcc0068[_0xe0ac('0x24')][_0xe0ac('0x2e')]));_0x1e293f['attributes']=_0x1e293f[_0xe0ac('0x2d')][_0xe0ac('0x2f')]?_0x1e293f[_0xe0ac('0x2d')]:_0x29bd8d['model'];if(_0xcc0068[_0xe0ac('0x24')]['includeAll']){_0x1e293f[_0xe0ac('0x23')]=[{'all':!![]}];}_0x1e293f=_[_0xe0ac('0x30')]({},_0x1e293f,_0xcc0068[_0xe0ac('0x31')]);return db[_0xe0ac('0x1c')][_0xe0ac('0x32')](_0x1e293f)[_0xe0ac('0x12')](handleEntityNotFound(_0x44e2c4,null))[_0xe0ac('0x12')](respondWithResult(_0x44e2c4,null))[_0xe0ac('0x27')](handleError(_0x44e2c4,null));};exports[_0xe0ac('0x33')]=function(_0x292c69,_0x56c995){return db[_0xe0ac('0x1c')][_0xe0ac('0x33')](_0x292c69[_0xe0ac('0x34')],{})[_0xe0ac('0x12')](function(_0x18d7c3){var _0x570895=_0x292c69[_0xe0ac('0x35')][_0xe0ac('0x14')]({'plain':!![]});if(!_0x570895)throw new Error(_0xe0ac('0x36'));if(_0x570895['role']===_0xe0ac('0x35')){var _0x50009e=_0x18d7c3[_0xe0ac('0x14')]({'plain':!![]});var _0x43d95f=_0xe0ac('0x37');return db[_0xe0ac('0x38')][_0xe0ac('0x32')]({'where':{'name':_0x43d95f,'userProfileId':_0x570895[_0xe0ac('0x39')]},'raw':!![]})[_0xe0ac('0x12')](function(_0x17cd39){if(_0x17cd39&&_0x17cd39[_0xe0ac('0x3a')]===0x0){return db['UserProfileResource']['create']({'name':_0x50009e['name'],'resourceId':_0x50009e['id'],'type':_0x17cd39[_0xe0ac('0x19')],'sectionId':_0x17cd39['id']},{})['then'](function(){return _0x18d7c3;});}else{return _0x18d7c3;}})[_0xe0ac('0x27')](function(_0x944be1){logger['error'](_0xe0ac('0x3b'),_0x944be1);throw _0x944be1;});}return _0x18d7c3;})[_0xe0ac('0x12')](respondWithResult(_0x56c995,0xc9))[_0xe0ac('0x27')](handleError(_0x56c995,null));};exports[_0xe0ac('0x3c')]=function(_0x292936,_0x3edc38){if(_0x292936[_0xe0ac('0x34')]['id']){delete _0x292936['body']['id'];}return db['MailQueue'][_0xe0ac('0x32')]({'where':{'id':_0x292936[_0xe0ac('0x3d')]['id']}})[_0xe0ac('0x12')](handleEntityNotFound(_0x3edc38,null))[_0xe0ac('0x12')](saveUpdates(_0x292936[_0xe0ac('0x34')],null))[_0xe0ac('0x12')](respondWithResult(_0x3edc38,null))[_0xe0ac('0x27')](handleError(_0x3edc38,null));};exports[_0xe0ac('0x13')]=function(_0x4ea59b,_0x5a3878){return db['MailQueue'][_0xe0ac('0x32')]({'where':{'id':_0x4ea59b[_0xe0ac('0x3d')]['id']}})[_0xe0ac('0x12')](handleEntityNotFound(_0x5a3878,null))['then'](removeEntity(_0x5a3878,null))[_0xe0ac('0x27')](handleError(_0x5a3878,null));};exports[_0xe0ac('0x3e')]=function(_0x106861,_0x30234f){return db[_0xe0ac('0x1c')][_0xe0ac('0x3e')]()[_0xe0ac('0x12')](respondWithResult(_0x30234f,null))[_0xe0ac('0x27')](handleError(_0x30234f,null));};exports[_0xe0ac('0x3f')]=function(_0x46054d,_0x46048d){var _0x396051={'raw':!![],'where':{}},_0x3a9122={},_0x5e3b0e;return db[_0xe0ac('0x1c')]['findOne']({'where':{'id':_0x46054d['params']['id']}})[_0xe0ac('0x12')](handleEntityNotFound(_0x46048d,null))[_0xe0ac('0x12')](function(_0x2ea188){if(_0x2ea188){_0x5e3b0e=_0x2ea188[_0xe0ac('0x14')]({'plain':!![]});_0x3a9122[_0xe0ac('0x2c')]=_[_0xe0ac('0x29')](db['UserMailQueue'][_0xe0ac('0x1d')]);_0x3a9122[_0xe0ac('0x24')]=_[_0xe0ac('0x29')](_0x46054d[_0xe0ac('0x24')]);_0x3a9122['filters']=_['intersection'](_0x3a9122[_0xe0ac('0x2c')],_0x3a9122[_0xe0ac('0x24')]);_0x396051[_0xe0ac('0x2d')]=_[_0xe0ac('0x2b')](_0x3a9122['model'],qs[_0xe0ac('0x2e')](_0x46054d[_0xe0ac('0x24')][_0xe0ac('0x2e')]));_0x396051[_0xe0ac('0x2d')]=_0x396051[_0xe0ac('0x2d')][_0xe0ac('0x2f')]?_0x396051[_0xe0ac('0x2d')]:_0x3a9122['model'];if(!_0x46054d[_0xe0ac('0x24')][_0xe0ac('0x40')](_0xe0ac('0x41'))){_0x396051[_0xe0ac('0xf')]=qs[_0xe0ac('0xf')](_0x46054d[_0xe0ac('0x24')][_0xe0ac('0xf')]);_0x396051[_0xe0ac('0xd')]=qs[_0xe0ac('0xd')](_0x46054d[_0xe0ac('0x24')][_0xe0ac('0xd')]);}_0x396051[_0xe0ac('0x42')]=qs[_0xe0ac('0x43')](_0x46054d['query']['sort']);_0x396051['where']=qs[_0xe0ac('0x2a')](_[_0xe0ac('0x44')](_0x46054d[_0xe0ac('0x24')],_0x3a9122['filters']));_0x396051[_0xe0ac('0x22')][_0xe0ac('0x45')]=_0x2ea188['id'];if(_0x46054d['query'][_0xe0ac('0x46')]){_0x396051['where']=_[_0xe0ac('0x30')](_0x396051[_0xe0ac('0x22')],{'$or':_[_0xe0ac('0x1b')](_0x396051[_0xe0ac('0x2d')],function(_0x11090c){var _0x54afe5={};_0x54afe5[_0x11090c]={'$like':'%'+_0x46054d[_0xe0ac('0x24')][_0xe0ac('0x46')]+'%'};return _0x54afe5;})});}_0x396051=_[_0xe0ac('0x30')]({},_0x396051,_0x46054d[_0xe0ac('0x31')]);return db['UserMailQueue'][_0xe0ac('0x25')](_0x396051);}})[_0xe0ac('0x12')](function(_0x14d1ca){if(_0x14d1ca){return db['User'][_0xe0ac('0x47')]({'where':{'id':_[_0xe0ac('0x1b')](_0x14d1ca,_0xe0ac('0x48')),'role':'agent'},'attributes':['id',_0xe0ac('0x19'),_0xe0ac('0x49'),_0xe0ac('0x4a'),_0xe0ac('0x4b')]});}})['then'](function(_0x21c796){if(_0x21c796){return{'count':_0x21c796[_0xe0ac('0x10')],'rows':_[_0xe0ac('0x1b')](_0x21c796['rows'],function(_0x361761){return{'membername':_0x361761[_0xe0ac('0x19')],'UserId':_0x361761['id'],'queue_name':_0x5e3b0e[_0xe0ac('0x19')],'MailQueueId':_0x5e3b0e['id'],'interface':util[_0xe0ac('0x4c')]('%s/%s',_0xe0ac('0x4d'),_0x361761[_0xe0ac('0x19')]),'penalty':0x0,'paused':_0x361761[_0xe0ac('0x49')],'createdAt':_0x361761['createdAt'],'updatedAt':_0x361761[_0xe0ac('0x4a')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xe0ac('0x12')](respondWithFilteredResult(_0x46048d,_0x396051))[_0xe0ac('0x27')](handleError(_0x46048d,null));};exports[_0xe0ac('0x4e')]=function(_0x30c3e0,_0x5b21ad){var _0x6b4643={};var _0x57b7d5={};var _0x240714;var _0x3c6232;return db['MailQueue'][_0xe0ac('0x4f')]({'where':{'id':_0x30c3e0[_0xe0ac('0x3d')]['id']}})['then'](handleEntityNotFound(_0x5b21ad,null))['then'](function(_0x351866){if(_0x351866){_0x240714=_0x351866;_0x57b7d5['model']=_['keys'](db[_0xe0ac('0x50')]['rawAttributes']);_0x57b7d5[_0xe0ac('0x24')]=_['keys'](_0x30c3e0[_0xe0ac('0x24')]);_0x57b7d5[_0xe0ac('0x2a')]=_[_0xe0ac('0x2b')](_0x57b7d5['model'],_0x57b7d5[_0xe0ac('0x24')]);_0x6b4643[_0xe0ac('0x2d')]=_[_0xe0ac('0x2b')](_0x57b7d5[_0xe0ac('0x2c')],qs[_0xe0ac('0x2e')](_0x30c3e0[_0xe0ac('0x24')][_0xe0ac('0x2e')]));_0x6b4643[_0xe0ac('0x2d')]=_0x6b4643[_0xe0ac('0x2d')][_0xe0ac('0x2f')]?_0x6b4643[_0xe0ac('0x2d')]:_0x57b7d5[_0xe0ac('0x2c')];_0x6b4643[_0xe0ac('0x42')]=qs['sort'](_0x30c3e0[_0xe0ac('0x24')][_0xe0ac('0x43')]);_0x6b4643[_0xe0ac('0x22')]=qs[_0xe0ac('0x2a')](_['pick'](_0x30c3e0['query'],_0x57b7d5[_0xe0ac('0x2a')]));if(_0x30c3e0[_0xe0ac('0x24')][_0xe0ac('0x46')]){_0x6b4643[_0xe0ac('0x22')]=_[_0xe0ac('0x30')](_0x6b4643['where'],{'$or':_['map'](_0x6b4643[_0xe0ac('0x2d')],function(_0x3486f5){var _0x5b61d0={};_0x5b61d0[_0x3486f5]={'$like':'%'+_0x30c3e0['query'][_0xe0ac('0x46')]+'%'};return _0x5b61d0;})});}_0x6b4643=_[_0xe0ac('0x30')]({},_0x6b4643,_0x30c3e0[_0xe0ac('0x31')]);return _0x240714[_0xe0ac('0x4e')](_0x6b4643);}})[_0xe0ac('0x12')](function(_0x4fbe80){if(_0x4fbe80){_0x3c6232=_0x4fbe80['length'];if(!_0x30c3e0[_0xe0ac('0x24')][_0xe0ac('0x40')](_0xe0ac('0x41'))){_0x6b4643[_0xe0ac('0xf')]=qs[_0xe0ac('0xf')](_0x30c3e0[_0xe0ac('0x24')][_0xe0ac('0xf')]);_0x6b4643['offset']=qs[_0xe0ac('0xd')](_0x30c3e0[_0xe0ac('0x24')]['offset']);}return _0x240714['getTeams'](_0x6b4643);}})[_0xe0ac('0x12')](function(_0x24b0ed){if(_0x24b0ed){return _0x24b0ed?{'count':_0x3c6232,'rows':_0x24b0ed}:null;}})['then'](respondWithResult(_0x5b21ad,null))[_0xe0ac('0x27')](handleError(_0x5b21ad,null));};exports[_0xe0ac('0x51')]=function(_0x27ffcb,_0x30e410){var _0x3eacd7=_0x27ffcb[_0xe0ac('0x34')][_0xe0ac('0x52')];return db['Team'][_0xe0ac('0x25')]({'where':{'id':_0x3eacd7},'attributes':['id'],'include':[{'model':db['User'],'as':_0xe0ac('0x53'),'attributes':['id',_0xe0ac('0x19'),'online',_0xe0ac('0x54'),_0xe0ac('0x55')],'raw':!![]}]})[_0xe0ac('0x12')](function(_0x33c4ae){if(_0x33c4ae){var _0x3764c2=_[_0xe0ac('0x56')](_0x33c4ae,function(_0x183fcf){var _0x27d9c8=_0x183fcf['get']({'plain':!![]});return _0x27d9c8['Agents'];});return db[_0xe0ac('0x1c')]['find']({'where':{'id':_0x27ffcb[_0xe0ac('0x3d')]['id']}})[_0xe0ac('0x12')](function(_0x37cafc){return db['sequelize'][_0xe0ac('0x57')](function(_0x1e5434){return _0x37cafc['addTeams'](_0x3eacd7,{'transaction':_0x1e5434})['then'](function(){return BPromise[_0xe0ac('0x58')](_0x3764c2,function(_0x488f4f){return db['UserMailQueue'][_0xe0ac('0x59')]({'where':{'UserId':_0x488f4f['id'],'MailQueueId':_0x27ffcb[_0xe0ac('0x3d')]['id']},'transaction':_0x1e5434});});})[_0xe0ac('0x12')](function(){_0x3764c2[_0xe0ac('0x5a')](function(_0xfa985d){socket['emit']('userMailQueue:save',{'UserId':_0xfa985d['id'],'MailQueueId':_0x37cafc['id']});});});});});}})[_0xe0ac('0x12')](respondWithStatusCode(_0x30e410,null))[_0xe0ac('0x27')](handleError(_0x30e410,null));};exports[_0xe0ac('0x5b')]=function(_0x4cd52b,_0x2d5dda){return db['Team']['findAll']({'where':{'id':_0x4cd52b[_0xe0ac('0x24')][_0xe0ac('0x52')]},'attributes':['id'],'include':[{'model':db[_0xe0ac('0x5c')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xe0ac('0x12')](handleEntityNotFound(_0x2d5dda,null))[_0xe0ac('0x12')](function(_0x2b9a37){var _0x4fbff1=_[_0xe0ac('0x1b')](_0x2b9a37,'id');var _0x549411=[];var _0x39bacd=[];var _0x324ef0=squel[_0xe0ac('0x5d')]();_0x324ef0[_0xe0ac('0x5e')]('tq.TeamId')['from'](_0xe0ac('0x5f'),'tq')[_0xe0ac('0x60')](_0xe0ac('0x61'),'ut',_0xe0ac('0x62'))['where'](_0xe0ac('0x63'),_0x4cd52b['params']['id']);for(var _0x452bd0=0x0;_0x452bd0<_0x2b9a37[_0xe0ac('0x2f')];_0x452bd0+=0x1){let _0x57b210=_0x2b9a37[_0x452bd0];for(var _0xce312d=0x0;_0xce312d<_0x57b210[_0xe0ac('0x53')][_0xe0ac('0x2f')];_0xce312d+=0x1){let _0x146a79=_0x57b210[_0xe0ac('0x53')][_0xce312d];var _0x5292f3=_0x324ef0['clone']();_0x5292f3[_0xe0ac('0x22')](_0xe0ac('0x64'),_0x146a79['id']);_0x39bacd[_0xe0ac('0x65')](db[_0xe0ac('0x66')]['query'](_0x5292f3[_0xe0ac('0x67')](),{'type':db[_0xe0ac('0x66')][_0xe0ac('0x68')][_0xe0ac('0x69')]})[_0xe0ac('0x12')](function(_0x44bcd5){if(_0x44bcd5[_0xe0ac('0x2f')]===0x1){return _0x146a79['id'];}else{var _0x215539=_[_0xe0ac('0x6a')](_['map'](_0x44bcd5,'TeamId'),function(_0x4e9b0a){return _[_0xe0ac('0x6b')](_0x4fbff1,_0x4e9b0a);});if(_0x215539){return _0x146a79['id'];}}}));}}return BPromise[_0xe0ac('0x6c')](_0x39bacd)[_0xe0ac('0x12')](function(_0x27f3b7){_0x549411=_(_0x549411)[_0xe0ac('0x6d')](_0x27f3b7)['compact']()['value']();return db[_0xe0ac('0x1c')][_0xe0ac('0x32')]({'where':{'id':_0x4cd52b[_0xe0ac('0x3d')]['id']}})[_0xe0ac('0x12')](function(_0x4eabad){return db[_0xe0ac('0x66')][_0xe0ac('0x57')](function(_0x2f75ab){return _0x4eabad[_0xe0ac('0x5b')](_0x4cd52b[_0xe0ac('0x24')][_0xe0ac('0x52')],{'transaction':_0x2f75ab})['then'](function(){if(!_[_0xe0ac('0x6e')](_0x549411)){return _0x4eabad[_0xe0ac('0x6f')](_0x549411,{'transaction':_0x2f75ab});}})['then'](function(){_0x549411['forEach'](function(_0x7f4e51){socket['emit'](_0xe0ac('0x70'),{'UserId':_0x7f4e51,'MailQueueId':_0x4eabad['id']});});});});});});})['then'](respondWithStatusCode(_0x2d5dda,null))[_0xe0ac('0x27')](handleError(_0x2d5dda,null));};exports[_0xe0ac('0x71')]=function(_0x455a65,_0x4d2a2d){return db[_0xe0ac('0x1c')][_0xe0ac('0x32')]({'where':{'id':_0x455a65[_0xe0ac('0x3d')]['id']}})[_0xe0ac('0x12')](handleEntityNotFound(_0x4d2a2d,null))[_0xe0ac('0x12')](function(_0x233bfe){if(_0x233bfe){return _0x233bfe[_0xe0ac('0x71')](_0x455a65['body']['ids'],_[_0xe0ac('0x72')](_0x455a65['body'],[_0xe0ac('0x52'),'id'])||{})[_0xe0ac('0x73')](function(_0x2fc65e){for(var _0x821eec=0x0;_0x821eec<_0x455a65[_0xe0ac('0x34')][_0xe0ac('0x52')][_0xe0ac('0x2f')];_0x821eec+=0x1){socket[_0xe0ac('0x74')](_0xe0ac('0x75'),{'UserId':Number(_0x455a65[_0xe0ac('0x34')][_0xe0ac('0x52')][_0x821eec]),'MailQueueId':Number(_0x455a65[_0xe0ac('0x3d')]['id'])});}return _0x2fc65e;});}})['then'](respondWithResult(_0x4d2a2d,null))[_0xe0ac('0x27')](handleError(_0x4d2a2d,null));};exports[_0xe0ac('0x6f')]=function(_0x4f24b1,_0x9006ad){return db['MailQueue'][_0xe0ac('0x32')]({'where':{'id':_0x4f24b1[_0xe0ac('0x3d')]['id']}})[_0xe0ac('0x12')](handleEntityNotFound(_0x9006ad,null))[_0xe0ac('0x12')](function(_0x588889){if(_0x588889){return _0x588889[_0xe0ac('0x6f')](_0x4f24b1[_0xe0ac('0x24')][_0xe0ac('0x52')])[_0xe0ac('0x12')](function(){if(_[_0xe0ac('0x76')](_0x4f24b1[_0xe0ac('0x24')][_0xe0ac('0x52')])){for(var _0x2eb748=0x0;_0x2eb748<_0x4f24b1[_0xe0ac('0x24')][_0xe0ac('0x52')][_0xe0ac('0x2f')];_0x2eb748+=0x1){socket['emit'](_0xe0ac('0x70'),{'UserId':Number(_0x4f24b1[_0xe0ac('0x24')][_0xe0ac('0x52')][_0x2eb748]),'MailQueueId':Number(_0x4f24b1[_0xe0ac('0x3d')]['id'])});}}else{socket['emit'](_0xe0ac('0x70'),{'UserId':Number(_0x4f24b1['query']['ids']),'MailQueueId':Number(_0x4f24b1[_0xe0ac('0x3d')]['id'])});}});}})[_0xe0ac('0x12')](respondWithStatusCode(_0x9006ad,null))['catch'](handleError(_0x9006ad,null));};exports[_0xe0ac('0x77')]=function(_0x5ed9d6,_0x2d763f){var _0x2db91d={};var _0x42ae6d={};var _0x3dd251;var _0x5f7d4f;return db['MailQueue'][_0xe0ac('0x4f')]({'where':{'id':_0x5ed9d6[_0xe0ac('0x3d')]['id']}})[_0xe0ac('0x12')](handleEntityNotFound(_0x2d763f,null))[_0xe0ac('0x12')](function(_0x447702){if(_0x447702){_0x3dd251=_0x447702;_0x42ae6d[_0xe0ac('0x2c')]=_['keys'](db[_0xe0ac('0x5c')][_0xe0ac('0x1d')]);_0x42ae6d['query']=_[_0xe0ac('0x29')](_0x5ed9d6[_0xe0ac('0x24')]);_0x42ae6d['filters']=_[_0xe0ac('0x2b')](_0x42ae6d['model'],_0x42ae6d[_0xe0ac('0x24')]);_0x2db91d[_0xe0ac('0x2d')]=_[_0xe0ac('0x2b')](_0x42ae6d[_0xe0ac('0x2c')],qs[_0xe0ac('0x2e')](_0x5ed9d6[_0xe0ac('0x24')][_0xe0ac('0x2e')]));_0x2db91d[_0xe0ac('0x2d')]=_0x2db91d[_0xe0ac('0x2d')][_0xe0ac('0x2f')]?_0x2db91d[_0xe0ac('0x2d')]:_0x42ae6d['model'];_0x2db91d[_0xe0ac('0x42')]=qs[_0xe0ac('0x43')](_0x5ed9d6[_0xe0ac('0x24')][_0xe0ac('0x43')]);_0x2db91d['where']=qs[_0xe0ac('0x2a')](_[_0xe0ac('0x44')](_0x5ed9d6[_0xe0ac('0x24')],_0x42ae6d[_0xe0ac('0x2a')]));if(_0x5ed9d6[_0xe0ac('0x24')][_0xe0ac('0x46')]){_0x2db91d[_0xe0ac('0x22')]=_[_0xe0ac('0x30')](_0x2db91d[_0xe0ac('0x22')],{'$or':_[_0xe0ac('0x1b')](_0x2db91d['attributes'],function(_0x16c280){var _0xbfba5={};_0xbfba5[_0x16c280]={'$like':'%'+_0x5ed9d6['query'][_0xe0ac('0x46')]+'%'};return _0xbfba5;})});}_0x2db91d=_['merge']({},_0x2db91d,_0x5ed9d6['options']);return _0x3dd251[_0xe0ac('0x77')](_0x2db91d);}})[_0xe0ac('0x12')](function(_0x25972a){if(_0x25972a){_0x5f7d4f=_0x25972a['length'];if(!_0x5ed9d6[_0xe0ac('0x24')]['hasOwnProperty'](_0xe0ac('0x41'))){_0x2db91d[_0xe0ac('0xf')]=qs[_0xe0ac('0xf')](_0x5ed9d6[_0xe0ac('0x24')][_0xe0ac('0xf')]);_0x2db91d[_0xe0ac('0xd')]=qs[_0xe0ac('0xd')](_0x5ed9d6[_0xe0ac('0x24')][_0xe0ac('0xd')]);}return _0x3dd251[_0xe0ac('0x77')](_0x2db91d);}})[_0xe0ac('0x12')](function(_0x2f56eb){if(_0x2f56eb){return _0x2f56eb?{'count':_0x5f7d4f,'rows':_0x2f56eb}:null;}})[_0xe0ac('0x12')](respondWithResult(_0x2d763f,null))[_0xe0ac('0x27')](handleError(_0x2d763f,null));};
\ No newline at end of file
+var _0xc90f=['../../mysqldb','redis','defaults','localhost','socket.io-emitter','./mailQueue.socket','sendStatus','status','offset','limit','undefined','count','set','Content-Range','json','update','destroy','then','get','MailQueues','UserProfileResource','end','stack','name','index','map','MailQueue','rawAttributes','fieldName','type','getOptions','where','include','query','findAll','catch','show','model','keys','filters','intersection','attributes','fields','length','merge','options','find','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','getMembers','findOne','UserMailQueue','hasOwnProperty','order','sort','pick','filter','User','findAndCountAll','UserId','mailPause','createdAt','rows','format','%s/%s','SIP','updatedAt','getTeams','Team','nolimit','addTeams','ids','Agents','online','voicePause','interface','sequelize','transaction','findOrCreate','forEach','emit','userMailQueue:save','select','field','team_has_mail_queues','join','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','includes','all','union','compact','removeTeams','isEmpty','removeAgents','userMailQueue:remove','addAgents','spread','getAgents','bluebird','util','lodash','squel','ioredis','../../components/parsers/qs','api','../../config/environment'];(function(_0x5083da,_0x174589){var _0x5c3887=function(_0x571048){while(--_0x571048){_0x5083da['push'](_0x5083da['shift']());}};_0x5c3887(++_0x174589);}(_0xc90f,0xea));var _0xfc90=function(_0x4c12ec,_0x2e9103){_0x4c12ec=_0x4c12ec-0x0;var _0x3ae42c=_0xc90f[_0x4c12ec];return _0x3ae42c;};'use strict';var BPromise=require(_0xfc90('0x0'));var util=require(_0xfc90('0x1'));var _=require(_0xfc90('0x2'));var squel=require(_0xfc90('0x3'));var Redis=require(_0xfc90('0x4'));var qs=require(_0xfc90('0x5'));var logger=require('../../config/logger')(_0xfc90('0x6'));var config=require(_0xfc90('0x7'));var db=require(_0xfc90('0x8'))['db'];config[_0xfc90('0x9')]=_[_0xfc90('0xa')](config[_0xfc90('0x9')],{'host':_0xfc90('0xb'),'port':0x18eb});var socket=require(_0xfc90('0xc'))(new Redis(config[_0xfc90('0x9')]));require(_0xfc90('0xd'))['register'](socket);function respondWithStatusCode(_0x10be87,_0x581a6e){_0x581a6e=_0x581a6e||0xcc;return function(_0x1eebc7){if(_0x1eebc7){return _0x10be87[_0xfc90('0xe')](_0x581a6e);}return _0x10be87['status'](_0x581a6e)['end']();};}function respondWithResult(_0x1be89d,_0x51b5a0){_0x51b5a0=_0x51b5a0||0xc8;return function(_0x4b48f3){if(_0x4b48f3){return _0x1be89d[_0xfc90('0xf')](_0x51b5a0)['json'](_0x4b48f3);}};}function respondWithFilteredResult(_0x40c295,_0x5ab13b){return function(_0x26f74f){if(_0x26f74f){var _0x273afd=typeof _0x5ab13b[_0xfc90('0x10')]==='undefined'&&typeof _0x5ab13b[_0xfc90('0x11')]===_0xfc90('0x12');var _0x18cf6f=_0x26f74f['count'];var _0x154683=_0x273afd?0x0:_0x5ab13b[_0xfc90('0x10')];var _0x12b25a=_0x273afd?_0x26f74f[_0xfc90('0x13')]:_0x5ab13b[_0xfc90('0x10')]+_0x5ab13b[_0xfc90('0x11')];var _0x35dc42;if(_0x12b25a>=_0x18cf6f){_0x12b25a=_0x18cf6f;_0x35dc42=0xc8;}else{_0x35dc42=0xce;}_0x40c295['status'](_0x35dc42);return _0x40c295[_0xfc90('0x14')](_0xfc90('0x15'),_0x154683+'-'+_0x12b25a+'/'+_0x18cf6f)[_0xfc90('0x16')](_0x26f74f);}return null;};}function saveUpdates(_0x2bde95){return function(_0x353bd4){if(_0x353bd4){return _0x353bd4[_0xfc90('0x17')](_0x2bde95)['then'](function(_0x29f19d){return _0x29f19d;});}return null;};}function removeEntity(_0x57aa49){return function(_0x5e46cc){if(_0x5e46cc){return _0x5e46cc[_0xfc90('0x18')]()[_0xfc90('0x19')](function(){var _0x110df0=_0x5e46cc[_0xfc90('0x1a')]({'plain':!![]});var _0x1d3b95=_0xfc90('0x1b');return db[_0xfc90('0x1c')][_0xfc90('0x18')]({'where':{'type':_0x1d3b95,'resourceId':_0x110df0['id']}})['then'](function(){return _0x5e46cc;});})[_0xfc90('0x19')](function(){_0x57aa49[_0xfc90('0xf')](0xcc)[_0xfc90('0x1d')]();});}};}function handleEntityNotFound(_0x36a8a6){return function(_0x27277){if(!_0x27277){_0x36a8a6[_0xfc90('0xe')](0x194);}return _0x27277;};}function handleError(_0x40374b,_0x442a4f){_0x442a4f=_0x442a4f||0x1f4;return function(_0x3af31b){logger['error'](_0x3af31b[_0xfc90('0x1e')]);if(_0x3af31b['name']){delete _0x3af31b[_0xfc90('0x1f')];}_0x40374b['status'](_0x442a4f)['send'](_0x3af31b);};}exports[_0xfc90('0x20')]=function(_0x44af1d,_0x50d758){var _0x4a789a={};var _0x2530c3={'count':0x0,'rows':[]};var _0x5df95f=_[_0xfc90('0x21')](db[_0xfc90('0x22')][_0xfc90('0x23')],function(_0x27a6c2){return{'name':_0x27a6c2[_0xfc90('0x24')],'type':_0x27a6c2[_0xfc90('0x25')]['key']};});_0x4a789a=qs[_0xfc90('0x26')](_0x5df95f,_0x44af1d);var _0x44e170={'where':_0x4a789a[_0xfc90('0x27')]};return db[_0xfc90('0x22')][_0xfc90('0x13')](_0x44e170)[_0xfc90('0x19')](function(_0xae65ed){_0x2530c3[_0xfc90('0x13')]=_0xae65ed;_0x4a789a[_0xfc90('0x28')]=qs[_0xfc90('0x28')](_0x44af1d[_0xfc90('0x29')]);return db[_0xfc90('0x22')][_0xfc90('0x2a')](_0x4a789a);})[_0xfc90('0x19')](function(_0x1aecc2){_0x2530c3['rows']=_0x1aecc2;return _0x2530c3;})[_0xfc90('0x19')](respondWithFilteredResult(_0x50d758,_0x4a789a))[_0xfc90('0x2b')](handleError(_0x50d758,null));};exports[_0xfc90('0x2c')]=function(_0x38a252,_0x502970){var _0x4801c5={'raw':!![],'where':{'id':_0x38a252['params']['id']}},_0xf5b811={};_0xf5b811[_0xfc90('0x2d')]=_[_0xfc90('0x2e')](db[_0xfc90('0x22')][_0xfc90('0x23')]);_0xf5b811[_0xfc90('0x29')]=_[_0xfc90('0x2e')](_0x38a252['query']);_0xf5b811[_0xfc90('0x2f')]=_[_0xfc90('0x30')](_0xf5b811[_0xfc90('0x2d')],_0xf5b811[_0xfc90('0x29')]);_0x4801c5[_0xfc90('0x31')]=_[_0xfc90('0x30')](_0xf5b811[_0xfc90('0x2d')],qs[_0xfc90('0x32')](_0x38a252[_0xfc90('0x29')][_0xfc90('0x32')]));_0x4801c5[_0xfc90('0x31')]=_0x4801c5[_0xfc90('0x31')][_0xfc90('0x33')]?_0x4801c5[_0xfc90('0x31')]:_0xf5b811[_0xfc90('0x2d')];if(_0x38a252['query']['includeAll']){_0x4801c5[_0xfc90('0x28')]=[{'all':!![]}];}_0x4801c5=_[_0xfc90('0x34')]({},_0x4801c5,_0x38a252[_0xfc90('0x35')]);return db[_0xfc90('0x22')][_0xfc90('0x36')](_0x4801c5)[_0xfc90('0x19')](handleEntityNotFound(_0x502970,null))[_0xfc90('0x19')](respondWithResult(_0x502970,null))[_0xfc90('0x2b')](handleError(_0x502970,null));};exports[_0xfc90('0x37')]=function(_0x5716cf,_0x5a30f9){return db[_0xfc90('0x22')][_0xfc90('0x37')](_0x5716cf['body'],{})[_0xfc90('0x19')](function(_0x9cc0a3){var _0x43f9ba=_0x5716cf['user'][_0xfc90('0x1a')]({'plain':!![]});if(!_0x43f9ba)throw new Error(_0xfc90('0x38'));if(_0x43f9ba[_0xfc90('0x39')]===_0xfc90('0x3a')){var _0x18bb40=_0x9cc0a3[_0xfc90('0x1a')]({'plain':!![]});var _0x9fe9d9=_0xfc90('0x1b');return db[_0xfc90('0x3b')][_0xfc90('0x36')]({'where':{'name':_0x9fe9d9,'userProfileId':_0x43f9ba[_0xfc90('0x3c')]},'raw':!![]})[_0xfc90('0x19')](function(_0x1e68b4){if(_0x1e68b4&&_0x1e68b4['autoAssociation']===0x0){return db[_0xfc90('0x1c')]['create']({'name':_0x18bb40['name'],'resourceId':_0x18bb40['id'],'type':_0x1e68b4['name'],'sectionId':_0x1e68b4['id']},{})['then'](function(){return _0x9cc0a3;});}else{return _0x9cc0a3;}})['catch'](function(_0x1d9dd6){logger['error'](_0xfc90('0x3d'),_0x1d9dd6);throw _0x1d9dd6;});}return _0x9cc0a3;})[_0xfc90('0x19')](respondWithResult(_0x5a30f9,0xc9))[_0xfc90('0x2b')](handleError(_0x5a30f9,null));};exports[_0xfc90('0x17')]=function(_0x1d0b59,_0x50cddd){if(_0x1d0b59[_0xfc90('0x3e')]['id']){delete _0x1d0b59[_0xfc90('0x3e')]['id'];}return db[_0xfc90('0x22')]['find']({'where':{'id':_0x1d0b59[_0xfc90('0x3f')]['id']}})['then'](handleEntityNotFound(_0x50cddd,null))[_0xfc90('0x19')](saveUpdates(_0x1d0b59[_0xfc90('0x3e')],null))[_0xfc90('0x19')](respondWithResult(_0x50cddd,null))[_0xfc90('0x2b')](handleError(_0x50cddd,null));};exports['destroy']=function(_0x29b40c,_0x3893c8){return db[_0xfc90('0x22')][_0xfc90('0x36')]({'where':{'id':_0x29b40c[_0xfc90('0x3f')]['id']}})[_0xfc90('0x19')](handleEntityNotFound(_0x3893c8,null))[_0xfc90('0x19')](removeEntity(_0x3893c8,null))[_0xfc90('0x2b')](handleError(_0x3893c8,null));};exports[_0xfc90('0x40')]=function(_0x1969da,_0x3ae614){return db['MailQueue'][_0xfc90('0x40')]()['then'](respondWithResult(_0x3ae614,null))[_0xfc90('0x2b')](handleError(_0x3ae614,null));};exports[_0xfc90('0x41')]=function(_0x15208b,_0x34cff5){var _0x5325ff={'raw':!![],'where':{}},_0x3fdf00={},_0x190b4e;return db['MailQueue'][_0xfc90('0x42')]({'where':{'id':_0x15208b[_0xfc90('0x3f')]['id']}})[_0xfc90('0x19')](handleEntityNotFound(_0x34cff5,null))[_0xfc90('0x19')](function(_0x1f598e){if(_0x1f598e){_0x190b4e=_0x1f598e[_0xfc90('0x1a')]({'plain':!![]});_0x3fdf00[_0xfc90('0x2d')]=_[_0xfc90('0x2e')](db[_0xfc90('0x43')][_0xfc90('0x23')]);_0x3fdf00[_0xfc90('0x29')]=_[_0xfc90('0x2e')](_0x15208b[_0xfc90('0x29')]);_0x3fdf00[_0xfc90('0x2f')]=_[_0xfc90('0x30')](_0x3fdf00['model'],_0x3fdf00[_0xfc90('0x29')]);_0x5325ff[_0xfc90('0x31')]=_[_0xfc90('0x30')](_0x3fdf00[_0xfc90('0x2d')],qs[_0xfc90('0x32')](_0x15208b[_0xfc90('0x29')]['fields']));_0x5325ff[_0xfc90('0x31')]=_0x5325ff[_0xfc90('0x31')][_0xfc90('0x33')]?_0x5325ff[_0xfc90('0x31')]:_0x3fdf00[_0xfc90('0x2d')];if(!_0x15208b[_0xfc90('0x29')][_0xfc90('0x44')]('nolimit')){_0x5325ff[_0xfc90('0x11')]=qs[_0xfc90('0x11')](_0x15208b[_0xfc90('0x29')]['limit']);_0x5325ff['offset']=qs[_0xfc90('0x10')](_0x15208b[_0xfc90('0x29')][_0xfc90('0x10')]);}_0x5325ff[_0xfc90('0x45')]=qs[_0xfc90('0x46')](_0x15208b[_0xfc90('0x29')][_0xfc90('0x46')]);_0x5325ff['where']=qs[_0xfc90('0x2f')](_[_0xfc90('0x47')](_0x15208b[_0xfc90('0x29')],_0x3fdf00[_0xfc90('0x2f')]));_0x5325ff[_0xfc90('0x27')]['MailQueueId']=_0x1f598e['id'];if(_0x15208b[_0xfc90('0x29')][_0xfc90('0x48')]){_0x5325ff[_0xfc90('0x27')]=_[_0xfc90('0x34')](_0x5325ff[_0xfc90('0x27')],{'$or':_[_0xfc90('0x21')](_0x5325ff['attributes'],function(_0x63ba76){var _0x2fec89={};_0x2fec89[_0x63ba76]={'$like':'%'+_0x15208b[_0xfc90('0x29')][_0xfc90('0x48')]+'%'};return _0x2fec89;})});}_0x5325ff=_[_0xfc90('0x34')]({},_0x5325ff,_0x15208b[_0xfc90('0x35')]);return db[_0xfc90('0x43')][_0xfc90('0x2a')](_0x5325ff);}})['then'](function(_0x10ace5){if(_0x10ace5){return db[_0xfc90('0x49')][_0xfc90('0x4a')]({'where':{'id':_['map'](_0x10ace5,_0xfc90('0x4b')),'role':'agent'},'attributes':['id',_0xfc90('0x1f'),_0xfc90('0x4c'),'updatedAt',_0xfc90('0x4d')]});}})[_0xfc90('0x19')](function(_0x466fe8){if(_0x466fe8){return{'count':_0x466fe8[_0xfc90('0x13')],'rows':_['map'](_0x466fe8[_0xfc90('0x4e')],function(_0x7a6082){return{'membername':_0x7a6082['name'],'UserId':_0x7a6082['id'],'queue_name':_0x190b4e[_0xfc90('0x1f')],'MailQueueId':_0x190b4e['id'],'interface':util[_0xfc90('0x4f')](_0xfc90('0x50'),_0xfc90('0x51'),_0x7a6082[_0xfc90('0x1f')]),'penalty':0x0,'paused':_0x7a6082[_0xfc90('0x4c')],'createdAt':_0x7a6082[_0xfc90('0x4d')],'updatedAt':_0x7a6082[_0xfc90('0x52')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xfc90('0x19')](respondWithFilteredResult(_0x34cff5,_0x5325ff))[_0xfc90('0x2b')](handleError(_0x34cff5,null));};exports[_0xfc90('0x53')]=function(_0x4c7473,_0x39e4fb){var _0x3afdac={};var _0x59c774={};var _0x2adbda;var _0x274393;return db[_0xfc90('0x22')][_0xfc90('0x42')]({'where':{'id':_0x4c7473[_0xfc90('0x3f')]['id']}})[_0xfc90('0x19')](handleEntityNotFound(_0x39e4fb,null))[_0xfc90('0x19')](function(_0x500c93){if(_0x500c93){_0x2adbda=_0x500c93;_0x59c774[_0xfc90('0x2d')]=_['keys'](db[_0xfc90('0x54')][_0xfc90('0x23')]);_0x59c774['query']=_['keys'](_0x4c7473[_0xfc90('0x29')]);_0x59c774[_0xfc90('0x2f')]=_['intersection'](_0x59c774[_0xfc90('0x2d')],_0x59c774[_0xfc90('0x29')]);_0x3afdac[_0xfc90('0x31')]=_[_0xfc90('0x30')](_0x59c774[_0xfc90('0x2d')],qs['fields'](_0x4c7473[_0xfc90('0x29')][_0xfc90('0x32')]));_0x3afdac['attributes']=_0x3afdac[_0xfc90('0x31')][_0xfc90('0x33')]?_0x3afdac[_0xfc90('0x31')]:_0x59c774['model'];_0x3afdac[_0xfc90('0x45')]=qs[_0xfc90('0x46')](_0x4c7473[_0xfc90('0x29')][_0xfc90('0x46')]);_0x3afdac[_0xfc90('0x27')]=qs['filters'](_[_0xfc90('0x47')](_0x4c7473[_0xfc90('0x29')],_0x59c774[_0xfc90('0x2f')]));if(_0x4c7473['query']['filter']){_0x3afdac[_0xfc90('0x27')]=_[_0xfc90('0x34')](_0x3afdac[_0xfc90('0x27')],{'$or':_[_0xfc90('0x21')](_0x3afdac[_0xfc90('0x31')],function(_0x4e6d18){var _0x2ed314={};_0x2ed314[_0x4e6d18]={'$like':'%'+_0x4c7473['query'][_0xfc90('0x48')]+'%'};return _0x2ed314;})});}_0x3afdac=_[_0xfc90('0x34')]({},_0x3afdac,_0x4c7473[_0xfc90('0x35')]);return _0x2adbda['getTeams'](_0x3afdac);}})[_0xfc90('0x19')](function(_0x1915b1){if(_0x1915b1){_0x274393=_0x1915b1['length'];if(!_0x4c7473[_0xfc90('0x29')]['hasOwnProperty'](_0xfc90('0x55'))){_0x3afdac['limit']=qs[_0xfc90('0x11')](_0x4c7473['query'][_0xfc90('0x11')]);_0x3afdac['offset']=qs['offset'](_0x4c7473[_0xfc90('0x29')][_0xfc90('0x10')]);}return _0x2adbda[_0xfc90('0x53')](_0x3afdac);}})[_0xfc90('0x19')](function(_0xf27f85){if(_0xf27f85){return _0xf27f85?{'count':_0x274393,'rows':_0xf27f85}:null;}})[_0xfc90('0x19')](respondWithResult(_0x39e4fb,null))[_0xfc90('0x2b')](handleError(_0x39e4fb,null));};exports[_0xfc90('0x56')]=function(_0x13847a,_0x5bef67){var _0x1634bd=_0x13847a[_0xfc90('0x3e')][_0xfc90('0x57')];return db[_0xfc90('0x54')]['findAll']({'where':{'id':_0x1634bd},'attributes':['id'],'include':[{'model':db['User'],'as':_0xfc90('0x58'),'attributes':['id',_0xfc90('0x1f'),_0xfc90('0x59'),_0xfc90('0x5a'),_0xfc90('0x5b')],'raw':!![]}]})[_0xfc90('0x19')](function(_0x361864){if(_0x361864){var _0x531acd=_['flatMap'](_0x361864,function(_0x2f4712){var _0x140da6=_0x2f4712['get']({'plain':!![]});return _0x140da6[_0xfc90('0x58')];});return db[_0xfc90('0x22')][_0xfc90('0x36')]({'where':{'id':_0x13847a[_0xfc90('0x3f')]['id']}})[_0xfc90('0x19')](function(_0x6f2260){return db[_0xfc90('0x5c')][_0xfc90('0x5d')](function(_0x3b9723){return _0x6f2260[_0xfc90('0x56')](_0x1634bd,{'transaction':_0x3b9723})[_0xfc90('0x19')](function(){return BPromise['each'](_0x531acd,function(_0x268c90){return db['UserMailQueue'][_0xfc90('0x5e')]({'where':{'UserId':_0x268c90['id'],'MailQueueId':_0x13847a['params']['id']},'transaction':_0x3b9723});});})[_0xfc90('0x19')](function(){_0x531acd[_0xfc90('0x5f')](function(_0x4b3248){socket[_0xfc90('0x60')](_0xfc90('0x61'),{'UserId':_0x4b3248['id'],'MailQueueId':_0x6f2260['id']});});});});});}})[_0xfc90('0x19')](respondWithStatusCode(_0x5bef67,null))[_0xfc90('0x2b')](handleError(_0x5bef67,null));};exports['removeTeams']=function(_0x5b696b,_0x4e1346){return db[_0xfc90('0x54')]['findAll']({'where':{'id':_0x5b696b[_0xfc90('0x29')][_0xfc90('0x57')]},'attributes':['id'],'include':[{'model':db[_0xfc90('0x49')],'as':_0xfc90('0x58'),'attributes':['id'],'raw':!![]}]})[_0xfc90('0x19')](handleEntityNotFound(_0x4e1346,null))[_0xfc90('0x19')](function(_0x5aa470){var _0x2ad2c5=_['map'](_0x5aa470,'id');var _0x5b4dd8=[];var _0x3dda04=[];var _0x462779=squel[_0xfc90('0x62')]();_0x462779[_0xfc90('0x63')]('tq.TeamId')['from'](_0xfc90('0x64'),'tq')[_0xfc90('0x65')]('user_has_teams','ut',_0xfc90('0x66'))[_0xfc90('0x27')](_0xfc90('0x67'),_0x5b696b[_0xfc90('0x3f')]['id']);for(var _0x3ac5e6=0x0;_0x3ac5e6<_0x5aa470['length'];_0x3ac5e6+=0x1){let _0x51010a=_0x5aa470[_0x3ac5e6];for(var _0x4cfdd2=0x0;_0x4cfdd2<_0x51010a[_0xfc90('0x58')][_0xfc90('0x33')];_0x4cfdd2+=0x1){let _0x288b41=_0x51010a[_0xfc90('0x58')][_0x4cfdd2];var _0xfb972b=_0x462779[_0xfc90('0x68')]();_0xfb972b['where'](_0xfc90('0x69'),_0x288b41['id']);_0x3dda04['push'](db[_0xfc90('0x5c')][_0xfc90('0x29')](_0xfb972b[_0xfc90('0x6a')](),{'type':db['sequelize'][_0xfc90('0x6b')][_0xfc90('0x6c')]})['then'](function(_0x4c0850){if(_0x4c0850[_0xfc90('0x33')]===0x1){return _0x288b41['id'];}else{var _0x3a5bb3=_[_0xfc90('0x6d')](_[_0xfc90('0x21')](_0x4c0850,'TeamId'),function(_0x5cf8a3){return _[_0xfc90('0x6e')](_0x2ad2c5,_0x5cf8a3);});if(_0x3a5bb3){return _0x288b41['id'];}}}));}}return BPromise[_0xfc90('0x6f')](_0x3dda04)['then'](function(_0x4911f2){_0x5b4dd8=_(_0x5b4dd8)[_0xfc90('0x70')](_0x4911f2)[_0xfc90('0x71')]()['value']();return db[_0xfc90('0x22')]['find']({'where':{'id':_0x5b696b['params']['id']}})[_0xfc90('0x19')](function(_0x1beca0){return db[_0xfc90('0x5c')][_0xfc90('0x5d')](function(_0xcdead0){return _0x1beca0[_0xfc90('0x72')](_0x5b696b[_0xfc90('0x29')][_0xfc90('0x57')],{'transaction':_0xcdead0})['then'](function(){if(!_[_0xfc90('0x73')](_0x5b4dd8)){return _0x1beca0[_0xfc90('0x74')](_0x5b4dd8,{'transaction':_0xcdead0});}})[_0xfc90('0x19')](function(){_0x5b4dd8[_0xfc90('0x5f')](function(_0x3689eb){socket[_0xfc90('0x60')](_0xfc90('0x75'),{'UserId':_0x3689eb,'MailQueueId':_0x1beca0['id']});});});});});});})['then'](respondWithStatusCode(_0x4e1346,null))[_0xfc90('0x2b')](handleError(_0x4e1346,null));};exports[_0xfc90('0x76')]=function(_0x5a53b5,_0xc7983f){return db[_0xfc90('0x22')][_0xfc90('0x36')]({'where':{'id':_0x5a53b5['params']['id']}})[_0xfc90('0x19')](handleEntityNotFound(_0xc7983f,null))[_0xfc90('0x19')](function(_0x20def1){if(_0x20def1){return _0x20def1[_0xfc90('0x76')](_0x5a53b5[_0xfc90('0x3e')][_0xfc90('0x57')],_['omit'](_0x5a53b5[_0xfc90('0x3e')],[_0xfc90('0x57'),'id'])||{})[_0xfc90('0x77')](function(_0xee95a2){for(var _0x510f79=0x0;_0x510f79<_0x5a53b5[_0xfc90('0x3e')][_0xfc90('0x57')]['length'];_0x510f79+=0x1){socket['emit'](_0xfc90('0x61'),{'UserId':Number(_0x5a53b5[_0xfc90('0x3e')][_0xfc90('0x57')][_0x510f79]),'MailQueueId':Number(_0x5a53b5[_0xfc90('0x3f')]['id'])});}return _0xee95a2;});}})[_0xfc90('0x19')](respondWithResult(_0xc7983f,null))[_0xfc90('0x2b')](handleError(_0xc7983f,null));};exports['removeAgents']=function(_0x43540d,_0x54adef){return db[_0xfc90('0x22')][_0xfc90('0x36')]({'where':{'id':_0x43540d['params']['id']}})[_0xfc90('0x19')](handleEntityNotFound(_0x54adef,null))[_0xfc90('0x19')](function(_0x3cf5ae){if(_0x3cf5ae){return _0x3cf5ae[_0xfc90('0x74')](_0x43540d[_0xfc90('0x29')][_0xfc90('0x57')])[_0xfc90('0x19')](function(){if(_['isArray'](_0x43540d[_0xfc90('0x29')][_0xfc90('0x57')])){for(var _0x26de7=0x0;_0x26de7<_0x43540d['query'][_0xfc90('0x57')][_0xfc90('0x33')];_0x26de7+=0x1){socket[_0xfc90('0x60')]('userMailQueue:remove',{'UserId':Number(_0x43540d[_0xfc90('0x29')]['ids'][_0x26de7]),'MailQueueId':Number(_0x43540d[_0xfc90('0x3f')]['id'])});}}else{socket['emit'](_0xfc90('0x75'),{'UserId':Number(_0x43540d['query']['ids']),'MailQueueId':Number(_0x43540d[_0xfc90('0x3f')]['id'])});}});}})[_0xfc90('0x19')](respondWithStatusCode(_0x54adef,null))[_0xfc90('0x2b')](handleError(_0x54adef,null));};exports[_0xfc90('0x78')]=function(_0x729bc2,_0x11fd82){var _0x30691f={};var _0x22a0d9={};var _0x1e82de;var _0x4179ad;return db[_0xfc90('0x22')][_0xfc90('0x42')]({'where':{'id':_0x729bc2[_0xfc90('0x3f')]['id']}})[_0xfc90('0x19')](handleEntityNotFound(_0x11fd82,null))[_0xfc90('0x19')](function(_0x236d06){if(_0x236d06){_0x1e82de=_0x236d06;_0x22a0d9[_0xfc90('0x2d')]=_[_0xfc90('0x2e')](db[_0xfc90('0x49')][_0xfc90('0x23')]);_0x22a0d9['query']=_[_0xfc90('0x2e')](_0x729bc2[_0xfc90('0x29')]);_0x22a0d9['filters']=_[_0xfc90('0x30')](_0x22a0d9[_0xfc90('0x2d')],_0x22a0d9[_0xfc90('0x29')]);_0x30691f['attributes']=_['intersection'](_0x22a0d9[_0xfc90('0x2d')],qs[_0xfc90('0x32')](_0x729bc2[_0xfc90('0x29')][_0xfc90('0x32')]));_0x30691f[_0xfc90('0x31')]=_0x30691f['attributes'][_0xfc90('0x33')]?_0x30691f['attributes']:_0x22a0d9[_0xfc90('0x2d')];_0x30691f['order']=qs[_0xfc90('0x46')](_0x729bc2[_0xfc90('0x29')]['sort']);_0x30691f[_0xfc90('0x27')]=qs[_0xfc90('0x2f')](_[_0xfc90('0x47')](_0x729bc2[_0xfc90('0x29')],_0x22a0d9[_0xfc90('0x2f')]));if(_0x729bc2[_0xfc90('0x29')][_0xfc90('0x48')]){_0x30691f['where']=_['merge'](_0x30691f[_0xfc90('0x27')],{'$or':_[_0xfc90('0x21')](_0x30691f[_0xfc90('0x31')],function(_0x385383){var _0x4cea5b={};_0x4cea5b[_0x385383]={'$like':'%'+_0x729bc2[_0xfc90('0x29')][_0xfc90('0x48')]+'%'};return _0x4cea5b;})});}_0x30691f=_['merge']({},_0x30691f,_0x729bc2[_0xfc90('0x35')]);return _0x1e82de[_0xfc90('0x78')](_0x30691f);}})['then'](function(_0x2fe5ba){if(_0x2fe5ba){_0x4179ad=_0x2fe5ba[_0xfc90('0x33')];if(!_0x729bc2[_0xfc90('0x29')][_0xfc90('0x44')](_0xfc90('0x55'))){_0x30691f[_0xfc90('0x11')]=qs[_0xfc90('0x11')](_0x729bc2[_0xfc90('0x29')]['limit']);_0x30691f[_0xfc90('0x10')]=qs[_0xfc90('0x10')](_0x729bc2['query'][_0xfc90('0x10')]);}return _0x1e82de[_0xfc90('0x78')](_0x30691f);}})[_0xfc90('0x19')](function(_0x280b22){if(_0x280b22){return _0x280b22?{'count':_0x4179ad,'rows':_0x280b22}:null;}})[_0xfc90('0x19')](respondWithResult(_0x11fd82,null))['catch'](handleError(_0x11fd82,null));};
\ No newline at end of file