Built motion from commit 4d4d9a88.|2.6.26
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 60773f7..f10f367 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x17fc=['filter','User','UserId','agent','mailPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','nolimit','addTeams','ids','Agents','online','interface','flatMap','each','forEach','emit','userMailQueue:save','select','field','tq.TeamId','team_has_mail_queues','join','user_has_teams','push','sequelize','toString','QueryTypes','every','includes','all','union','compact','value','removeTeams','isEmpty','userMailQueue:remove','addAgents','omit','spread','removeAgents','isArray','getAgents','bluebird','lodash','ioredis','../../components/parsers/qs','../../config/logger','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./mailQueue.socket','register','sendStatus','status','end','json','undefined','limit','count','offset','Content-Range','update','then','get','error','stack','name','send','map','MailQueue','rawAttributes','type','key','getOptions','where','include','findAll','rows','catch','params','model','query','keys','filters','intersection','attributes','fields','length','includeAll','merge','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','MailQueues','UserProfileSection','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','describe','getMembers','findOne','UserMailQueue','hasOwnProperty','order','sort','pick','MailQueueId'];(function(_0x144d9c,_0x3ec497){var _0x54db44=function(_0x11bbc3){while(--_0x11bbc3){_0x144d9c['push'](_0x144d9c['shift']());}};_0x54db44(++_0x3ec497);}(_0x17fc,0x192));var _0xc17f=function(_0x56ed68,_0x5921d9){_0x56ed68=_0x56ed68-0x0;var _0xd29dbf=_0x17fc[_0x56ed68];return _0xd29dbf;};'use strict';var BPromise=require(_0xc17f('0x0'));var util=require('util');var _=require(_0xc17f('0x1'));var squel=require('squel');var Redis=require(_0xc17f('0x2'));var qs=require(_0xc17f('0x3'));var logger=require(_0xc17f('0x4'))('api');var config=require(_0xc17f('0x5'));var db=require(_0xc17f('0x6'))['db'];config[_0xc17f('0x7')]=_['defaults'](config[_0xc17f('0x7')],{'host':_0xc17f('0x8'),'port':0x18eb});var socket=require(_0xc17f('0x9'))(new Redis(config[_0xc17f('0x7')]));require(_0xc17f('0xa'))[_0xc17f('0xb')](socket);function respondWithStatusCode(_0x377dd4,_0x2f6035){_0x2f6035=_0x2f6035||0xcc;return function(_0x39584f){if(_0x39584f){return _0x377dd4[_0xc17f('0xc')](_0x2f6035);}return _0x377dd4[_0xc17f('0xd')](_0x2f6035)[_0xc17f('0xe')]();};}function respondWithResult(_0x3a2793,_0x2888d){_0x2888d=_0x2888d||0xc8;return function(_0x268019){if(_0x268019){return _0x3a2793['status'](_0x2888d)[_0xc17f('0xf')](_0x268019);}};}function respondWithFilteredResult(_0x59ada3,_0x129660){return function(_0x433969){if(_0x433969){var _0x13d85f=typeof _0x129660['offset']===_0xc17f('0x10')&&typeof _0x129660[_0xc17f('0x11')]==='undefined';var _0x27e294=_0x433969[_0xc17f('0x12')];var _0x4e95ec=_0x13d85f?0x0:_0x129660[_0xc17f('0x13')];var _0xcb384f=_0x13d85f?_0x433969[_0xc17f('0x12')]:_0x129660[_0xc17f('0x13')]+_0x129660['limit'];var _0x72f5a3;if(_0xcb384f>=_0x27e294){_0xcb384f=_0x27e294;_0x72f5a3=0xc8;}else{_0x72f5a3=0xce;}_0x59ada3['status'](_0x72f5a3);return _0x59ada3['set'](_0xc17f('0x14'),_0x4e95ec+'-'+_0xcb384f+'/'+_0x27e294)[_0xc17f('0xf')](_0x433969);}return null;};}function saveUpdates(_0x847e84){return function(_0xbd7050){if(_0xbd7050){return _0xbd7050[_0xc17f('0x15')](_0x847e84)['then'](function(_0x146bbb){return _0x146bbb;});}return null;};}function removeEntity(_0xf4e141){return function(_0x4262d4){if(_0x4262d4){return _0x4262d4['destroy']()[_0xc17f('0x16')](function(){var _0x4b3fe6=_0x4262d4[_0xc17f('0x17')]({'plain':!![]});var _0x46b3c1='MailQueues';return db['UserProfileResource']['destroy']({'where':{'type':_0x46b3c1,'resourceId':_0x4b3fe6['id']}})['then'](function(){return _0x4262d4;});})[_0xc17f('0x16')](function(){_0xf4e141[_0xc17f('0xd')](0xcc)['end']();});}};}function handleEntityNotFound(_0x25a97e){return function(_0x14b6c8){if(!_0x14b6c8){_0x25a97e[_0xc17f('0xc')](0x194);}return _0x14b6c8;};}function handleError(_0x66501f,_0x4a3166){_0x4a3166=_0x4a3166||0x1f4;return function(_0x5b7c8a){logger[_0xc17f('0x18')](_0x5b7c8a[_0xc17f('0x19')]);if(_0x5b7c8a[_0xc17f('0x1a')]){delete _0x5b7c8a[_0xc17f('0x1a')];}_0x66501f['status'](_0x4a3166)[_0xc17f('0x1b')](_0x5b7c8a);};}exports['index']=function(_0x571416,_0x4e9ea4){var _0x49d062={};var _0x35be0e={'count':0x0,'rows':[]};var _0x5333fd=_[_0xc17f('0x1c')](db[_0xc17f('0x1d')][_0xc17f('0x1e')],function(_0x1985c3){return{'name':_0x1985c3['fieldName'],'type':_0x1985c3[_0xc17f('0x1f')][_0xc17f('0x20')]};});_0x49d062=qs[_0xc17f('0x21')](_0x5333fd,_0x571416);var _0x5303c4={'where':_0x49d062[_0xc17f('0x22')]};return db['MailQueue'][_0xc17f('0x12')](_0x5303c4)['then'](function(_0x219d1c){_0x35be0e[_0xc17f('0x12')]=_0x219d1c;_0x49d062[_0xc17f('0x23')]=qs[_0xc17f('0x23')](_0x571416['query']);return db[_0xc17f('0x1d')][_0xc17f('0x24')](_0x49d062);})[_0xc17f('0x16')](function(_0x330856){_0x35be0e[_0xc17f('0x25')]=_0x330856;return _0x35be0e;})[_0xc17f('0x16')](respondWithFilteredResult(_0x4e9ea4,_0x49d062))[_0xc17f('0x26')](handleError(_0x4e9ea4,null));};exports['show']=function(_0x1c6be4,_0x131a6d){var _0x139af8={'raw':!![],'where':{'id':_0x1c6be4[_0xc17f('0x27')]['id']}},_0x2b20f9={};_0x2b20f9[_0xc17f('0x28')]=_['keys'](db['MailQueue'][_0xc17f('0x1e')]);_0x2b20f9[_0xc17f('0x29')]=_[_0xc17f('0x2a')](_0x1c6be4[_0xc17f('0x29')]);_0x2b20f9[_0xc17f('0x2b')]=_[_0xc17f('0x2c')](_0x2b20f9[_0xc17f('0x28')],_0x2b20f9['query']);_0x139af8[_0xc17f('0x2d')]=_[_0xc17f('0x2c')](_0x2b20f9[_0xc17f('0x28')],qs[_0xc17f('0x2e')](_0x1c6be4[_0xc17f('0x29')][_0xc17f('0x2e')]));_0x139af8[_0xc17f('0x2d')]=_0x139af8['attributes'][_0xc17f('0x2f')]?_0x139af8[_0xc17f('0x2d')]:_0x2b20f9[_0xc17f('0x28')];if(_0x1c6be4[_0xc17f('0x29')][_0xc17f('0x30')]){_0x139af8[_0xc17f('0x23')]=[{'all':!![]}];}_0x139af8=_[_0xc17f('0x31')]({},_0x139af8,_0x1c6be4[_0xc17f('0x32')]);return db[_0xc17f('0x1d')][_0xc17f('0x33')](_0x139af8)[_0xc17f('0x16')](handleEntityNotFound(_0x131a6d,null))['then'](respondWithResult(_0x131a6d,null))[_0xc17f('0x26')](handleError(_0x131a6d,null));};exports[_0xc17f('0x34')]=function(_0x5ab6cb,_0x4aa2e0){return db[_0xc17f('0x1d')][_0xc17f('0x34')](_0x5ab6cb[_0xc17f('0x35')],{})[_0xc17f('0x16')](function(_0x95c8ca){var _0x350d09=_0x5ab6cb[_0xc17f('0x36')][_0xc17f('0x17')]({'plain':!![]});if(!_0x350d09)throw new Error(_0xc17f('0x37'));if(_0x350d09['role']===_0xc17f('0x36')){var _0x2cc407=_0x95c8ca[_0xc17f('0x17')]({'plain':!![]});var _0xb57fb2=_0xc17f('0x38');return db[_0xc17f('0x39')][_0xc17f('0x33')]({'where':{'name':_0xb57fb2,'userProfileId':_0x350d09['userProfileId']},'raw':!![]})[_0xc17f('0x16')](function(_0x2f0ffc){if(_0x2f0ffc&&_0x2f0ffc['autoAssociation']===0x0){return db[_0xc17f('0x3a')][_0xc17f('0x34')]({'name':_0x2cc407[_0xc17f('0x1a')],'resourceId':_0x2cc407['id'],'type':_0x2f0ffc['name'],'sectionId':_0x2f0ffc['id']},{})['then'](function(){return _0x95c8ca;});}else{return _0x95c8ca;}})[_0xc17f('0x26')](function(_0xf5c735){logger[_0xc17f('0x18')](_0xc17f('0x3b'),_0xf5c735);throw _0xf5c735;});}return _0x95c8ca;})[_0xc17f('0x16')](respondWithResult(_0x4aa2e0,0xc9))['catch'](handleError(_0x4aa2e0,null));};exports[_0xc17f('0x15')]=function(_0x1af9ab,_0x317308){if(_0x1af9ab[_0xc17f('0x35')]['id']){delete _0x1af9ab[_0xc17f('0x35')]['id'];}return db[_0xc17f('0x1d')][_0xc17f('0x33')]({'where':{'id':_0x1af9ab['params']['id']}})['then'](handleEntityNotFound(_0x317308,null))[_0xc17f('0x16')](saveUpdates(_0x1af9ab[_0xc17f('0x35')],null))['then'](respondWithResult(_0x317308,null))['catch'](handleError(_0x317308,null));};exports[_0xc17f('0x3c')]=function(_0x4ce1d7,_0x5521c4){return db[_0xc17f('0x1d')][_0xc17f('0x33')]({'where':{'id':_0x4ce1d7['params']['id']}})[_0xc17f('0x16')](handleEntityNotFound(_0x5521c4,null))[_0xc17f('0x16')](removeEntity(_0x5521c4,null))['catch'](handleError(_0x5521c4,null));};exports[_0xc17f('0x3d')]=function(_0x24c0d7,_0x16a29f){return db[_0xc17f('0x1d')][_0xc17f('0x3d')]()['then'](respondWithResult(_0x16a29f,null))['catch'](handleError(_0x16a29f,null));};exports[_0xc17f('0x3e')]=function(_0x58c0fa,_0x5cceb3){var _0x2f0318={'raw':!![],'where':{}},_0x1d7a25={},_0x26ad41;return db[_0xc17f('0x1d')][_0xc17f('0x3f')]({'where':{'id':_0x58c0fa[_0xc17f('0x27')]['id']}})[_0xc17f('0x16')](handleEntityNotFound(_0x5cceb3,null))[_0xc17f('0x16')](function(_0x5bd34d){if(_0x5bd34d){_0x26ad41=_0x5bd34d[_0xc17f('0x17')]({'plain':!![]});_0x1d7a25['model']=_['keys'](db[_0xc17f('0x40')][_0xc17f('0x1e')]);_0x1d7a25['query']=_[_0xc17f('0x2a')](_0x58c0fa['query']);_0x1d7a25[_0xc17f('0x2b')]=_['intersection'](_0x1d7a25['model'],_0x1d7a25[_0xc17f('0x29')]);_0x2f0318['attributes']=_[_0xc17f('0x2c')](_0x1d7a25['model'],qs[_0xc17f('0x2e')](_0x58c0fa[_0xc17f('0x29')][_0xc17f('0x2e')]));_0x2f0318[_0xc17f('0x2d')]=_0x2f0318[_0xc17f('0x2d')][_0xc17f('0x2f')]?_0x2f0318[_0xc17f('0x2d')]:_0x1d7a25['model'];if(!_0x58c0fa['query'][_0xc17f('0x41')]('nolimit')){_0x2f0318[_0xc17f('0x11')]=qs[_0xc17f('0x11')](_0x58c0fa[_0xc17f('0x29')][_0xc17f('0x11')]);_0x2f0318[_0xc17f('0x13')]=qs['offset'](_0x58c0fa['query'][_0xc17f('0x13')]);}_0x2f0318[_0xc17f('0x42')]=qs[_0xc17f('0x43')](_0x58c0fa['query'][_0xc17f('0x43')]);_0x2f0318[_0xc17f('0x22')]=qs[_0xc17f('0x2b')](_[_0xc17f('0x44')](_0x58c0fa[_0xc17f('0x29')],_0x1d7a25['filters']));_0x2f0318[_0xc17f('0x22')][_0xc17f('0x45')]=_0x5bd34d['id'];if(_0x58c0fa[_0xc17f('0x29')][_0xc17f('0x46')]){_0x2f0318['where']=_['merge'](_0x2f0318['where'],{'$or':_[_0xc17f('0x1c')](_0x2f0318['attributes'],function(_0x1bbc87){var _0x4a04e8={};_0x4a04e8[_0x1bbc87]={'$like':'%'+_0x58c0fa[_0xc17f('0x29')][_0xc17f('0x46')]+'%'};return _0x4a04e8;})});}_0x2f0318=_[_0xc17f('0x31')]({},_0x2f0318,_0x58c0fa[_0xc17f('0x32')]);return db[_0xc17f('0x40')]['findAll'](_0x2f0318);}})[_0xc17f('0x16')](function(_0x3a6375){if(_0x3a6375){return db[_0xc17f('0x47')]['findAndCountAll']({'where':{'id':_[_0xc17f('0x1c')](_0x3a6375,_0xc17f('0x48')),'role':_0xc17f('0x49')},'attributes':['id','name',_0xc17f('0x4a'),_0xc17f('0x4b'),_0xc17f('0x4c')]});}})[_0xc17f('0x16')](function(_0x412932){if(_0x412932){return{'count':_0x412932[_0xc17f('0x12')],'rows':_[_0xc17f('0x1c')](_0x412932[_0xc17f('0x25')],function(_0x1daef5){return{'membername':_0x1daef5['name'],'UserId':_0x1daef5['id'],'queue_name':_0x26ad41[_0xc17f('0x1a')],'MailQueueId':_0x26ad41['id'],'interface':util[_0xc17f('0x4d')](_0xc17f('0x4e'),_0xc17f('0x4f'),_0x1daef5[_0xc17f('0x1a')]),'penalty':0x0,'paused':_0x1daef5[_0xc17f('0x4a')],'createdAt':_0x1daef5[_0xc17f('0x4c')],'updatedAt':_0x1daef5[_0xc17f('0x4b')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xc17f('0x16')](respondWithFilteredResult(_0x5cceb3,_0x2f0318))['catch'](handleError(_0x5cceb3,null));};exports[_0xc17f('0x50')]=function(_0x4b2f9a,_0x2216cd){var _0x2776de={};var _0x5f44d5={};var _0x218e31;var _0x33e692;return db[_0xc17f('0x1d')][_0xc17f('0x3f')]({'where':{'id':_0x4b2f9a[_0xc17f('0x27')]['id']}})[_0xc17f('0x16')](handleEntityNotFound(_0x2216cd,null))[_0xc17f('0x16')](function(_0x19e513){if(_0x19e513){_0x218e31=_0x19e513;_0x5f44d5['model']=_[_0xc17f('0x2a')](db[_0xc17f('0x51')]['rawAttributes']);_0x5f44d5[_0xc17f('0x29')]=_[_0xc17f('0x2a')](_0x4b2f9a[_0xc17f('0x29')]);_0x5f44d5[_0xc17f('0x2b')]=_[_0xc17f('0x2c')](_0x5f44d5[_0xc17f('0x28')],_0x5f44d5[_0xc17f('0x29')]);_0x2776de[_0xc17f('0x2d')]=_['intersection'](_0x5f44d5[_0xc17f('0x28')],qs[_0xc17f('0x2e')](_0x4b2f9a[_0xc17f('0x29')]['fields']));_0x2776de['attributes']=_0x2776de['attributes'][_0xc17f('0x2f')]?_0x2776de[_0xc17f('0x2d')]:_0x5f44d5[_0xc17f('0x28')];_0x2776de[_0xc17f('0x42')]=qs[_0xc17f('0x43')](_0x4b2f9a[_0xc17f('0x29')]['sort']);_0x2776de[_0xc17f('0x22')]=qs['filters'](_[_0xc17f('0x44')](_0x4b2f9a[_0xc17f('0x29')],_0x5f44d5[_0xc17f('0x2b')]));if(_0x4b2f9a[_0xc17f('0x29')][_0xc17f('0x46')]){_0x2776de[_0xc17f('0x22')]=_[_0xc17f('0x31')](_0x2776de[_0xc17f('0x22')],{'$or':_[_0xc17f('0x1c')](_0x2776de['attributes'],function(_0x492f32){var _0x17cbb5={};_0x17cbb5[_0x492f32]={'$like':'%'+_0x4b2f9a[_0xc17f('0x29')][_0xc17f('0x46')]+'%'};return _0x17cbb5;})});}_0x2776de=_['merge']({},_0x2776de,_0x4b2f9a[_0xc17f('0x32')]);return _0x218e31[_0xc17f('0x50')](_0x2776de);}})[_0xc17f('0x16')](function(_0x53482e){if(_0x53482e){_0x33e692=_0x53482e[_0xc17f('0x2f')];if(!_0x4b2f9a[_0xc17f('0x29')][_0xc17f('0x41')](_0xc17f('0x52'))){_0x2776de[_0xc17f('0x11')]=qs[_0xc17f('0x11')](_0x4b2f9a[_0xc17f('0x29')]['limit']);_0x2776de['offset']=qs[_0xc17f('0x13')](_0x4b2f9a[_0xc17f('0x29')][_0xc17f('0x13')]);}return _0x218e31[_0xc17f('0x50')](_0x2776de);}})['then'](function(_0x243b81){if(_0x243b81){return _0x243b81?{'count':_0x33e692,'rows':_0x243b81}:null;}})[_0xc17f('0x16')](respondWithResult(_0x2216cd,null))[_0xc17f('0x26')](handleError(_0x2216cd,null));};exports[_0xc17f('0x53')]=function(_0x4cac81,_0x14aa4e){var _0x362671=_0x4cac81[_0xc17f('0x35')][_0xc17f('0x54')];return db['Team'][_0xc17f('0x24')]({'where':{'id':_0x362671},'attributes':['id'],'include':[{'model':db[_0xc17f('0x47')],'as':_0xc17f('0x55'),'attributes':['id',_0xc17f('0x1a'),_0xc17f('0x56'),'voicePause',_0xc17f('0x57')],'raw':!![]}]})[_0xc17f('0x16')](function(_0x4b90ee){if(_0x4b90ee){var _0x5d5706=_[_0xc17f('0x58')](_0x4b90ee,function(_0x5010f2){var _0x464bbc=_0x5010f2['get']({'plain':!![]});return _0x464bbc[_0xc17f('0x55')];});return db['MailQueue'][_0xc17f('0x33')]({'where':{'id':_0x4cac81[_0xc17f('0x27')]['id']}})['then'](function(_0xf80141){return db['sequelize']['transaction'](function(_0x391847){return _0xf80141[_0xc17f('0x53')](_0x362671,{'transaction':_0x391847})[_0xc17f('0x16')](function(){return BPromise[_0xc17f('0x59')](_0x5d5706,function(_0x162407){return db[_0xc17f('0x40')]['findOrCreate']({'where':{'UserId':_0x162407['id'],'MailQueueId':_0x4cac81[_0xc17f('0x27')]['id']},'transaction':_0x391847});});})[_0xc17f('0x16')](function(){_0x5d5706[_0xc17f('0x5a')](function(_0x51b4e1){socket[_0xc17f('0x5b')](_0xc17f('0x5c'),{'UserId':_0x51b4e1['id'],'MailQueueId':_0xf80141['id']});});});});});}})[_0xc17f('0x16')](respondWithStatusCode(_0x14aa4e,null))[_0xc17f('0x26')](handleError(_0x14aa4e,null));};exports['removeTeams']=function(_0x3f3c9f,_0x3524c1){return db[_0xc17f('0x51')][_0xc17f('0x24')]({'where':{'id':_0x3f3c9f[_0xc17f('0x29')][_0xc17f('0x54')]},'attributes':['id'],'include':[{'model':db[_0xc17f('0x47')],'as':_0xc17f('0x55'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x3524c1,null))['then'](function(_0x397e1f){var _0x1cfffa=_[_0xc17f('0x1c')](_0x397e1f,'id');var _0x3df5f9=[];var _0x51cf07=[];var _0x108276=squel[_0xc17f('0x5d')]();_0x108276[_0xc17f('0x5e')](_0xc17f('0x5f'))['from'](_0xc17f('0x60'),'tq')[_0xc17f('0x61')](_0xc17f('0x62'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0xc17f('0x22')]('MailQueueId\x20=\x20?',_0x3f3c9f[_0xc17f('0x27')]['id']);for(var _0x58b4eb=0x0;_0x58b4eb<_0x397e1f[_0xc17f('0x2f')];_0x58b4eb+=0x1){let _0x4e1aa0=_0x397e1f[_0x58b4eb];for(var _0x4ab325=0x0;_0x4ab325<_0x4e1aa0[_0xc17f('0x55')]['length'];_0x4ab325+=0x1){let _0x2909bb=_0x4e1aa0[_0xc17f('0x55')][_0x4ab325];var _0x6607c1=_0x108276['clone']();_0x6607c1[_0xc17f('0x22')]('ut.UserId\x20=\x20?',_0x2909bb['id']);_0x51cf07[_0xc17f('0x63')](db[_0xc17f('0x64')][_0xc17f('0x29')](_0x6607c1[_0xc17f('0x65')](),{'type':db[_0xc17f('0x64')][_0xc17f('0x66')]['SELECT']})[_0xc17f('0x16')](function(_0x349ee5){if(_0x349ee5[_0xc17f('0x2f')]===0x1){return _0x2909bb['id'];}else{var _0x39c5c7=_[_0xc17f('0x67')](_[_0xc17f('0x1c')](_0x349ee5,'TeamId'),function(_0x2cb617){return _[_0xc17f('0x68')](_0x1cfffa,_0x2cb617);});if(_0x39c5c7){return _0x2909bb['id'];}}}));}}return BPromise[_0xc17f('0x69')](_0x51cf07)[_0xc17f('0x16')](function(_0x52d60f){_0x3df5f9=_(_0x3df5f9)[_0xc17f('0x6a')](_0x52d60f)[_0xc17f('0x6b')]()[_0xc17f('0x6c')]();return db[_0xc17f('0x1d')][_0xc17f('0x33')]({'where':{'id':_0x3f3c9f['params']['id']}})['then'](function(_0x2fb71a){return db[_0xc17f('0x64')]['transaction'](function(_0x3e066e){return _0x2fb71a[_0xc17f('0x6d')](_0x3f3c9f[_0xc17f('0x29')][_0xc17f('0x54')],{'transaction':_0x3e066e})[_0xc17f('0x16')](function(){if(!_[_0xc17f('0x6e')](_0x3df5f9)){return _0x2fb71a['removeAgents'](_0x3df5f9,{'transaction':_0x3e066e});}})[_0xc17f('0x16')](function(){_0x3df5f9['forEach'](function(_0x38a1b3){socket['emit'](_0xc17f('0x6f'),{'UserId':_0x38a1b3,'MailQueueId':_0x2fb71a['id']});});});});});});})[_0xc17f('0x16')](respondWithStatusCode(_0x3524c1,null))[_0xc17f('0x26')](handleError(_0x3524c1,null));};exports[_0xc17f('0x70')]=function(_0x542693,_0x1bd2e1){return db['MailQueue'][_0xc17f('0x33')]({'where':{'id':_0x542693['params']['id']}})['then'](handleEntityNotFound(_0x1bd2e1,null))[_0xc17f('0x16')](function(_0x5490b7){if(_0x5490b7){return _0x5490b7[_0xc17f('0x70')](_0x542693[_0xc17f('0x35')][_0xc17f('0x54')],_[_0xc17f('0x71')](_0x542693[_0xc17f('0x35')],['ids','id'])||{})[_0xc17f('0x72')](function(_0x41e71c){for(var _0x981247=0x0;_0x981247<_0x542693['body'][_0xc17f('0x54')][_0xc17f('0x2f')];_0x981247+=0x1){socket['emit'](_0xc17f('0x5c'),{'UserId':Number(_0x542693[_0xc17f('0x35')]['ids'][_0x981247]),'MailQueueId':Number(_0x542693[_0xc17f('0x27')]['id'])});}return _0x41e71c;});}})[_0xc17f('0x16')](respondWithResult(_0x1bd2e1,null))[_0xc17f('0x26')](handleError(_0x1bd2e1,null));};exports[_0xc17f('0x73')]=function(_0x6690d7,_0xfe9df4){return db['MailQueue'][_0xc17f('0x33')]({'where':{'id':_0x6690d7[_0xc17f('0x27')]['id']}})[_0xc17f('0x16')](handleEntityNotFound(_0xfe9df4,null))[_0xc17f('0x16')](function(_0x482469){if(_0x482469){return _0x482469[_0xc17f('0x73')](_0x6690d7[_0xc17f('0x29')][_0xc17f('0x54')])[_0xc17f('0x16')](function(){if(_[_0xc17f('0x74')](_0x6690d7[_0xc17f('0x29')][_0xc17f('0x54')])){for(var _0x2ac4c2=0x0;_0x2ac4c2<_0x6690d7[_0xc17f('0x29')][_0xc17f('0x54')]['length'];_0x2ac4c2+=0x1){socket[_0xc17f('0x5b')]('userMailQueue:remove',{'UserId':Number(_0x6690d7[_0xc17f('0x29')][_0xc17f('0x54')][_0x2ac4c2]),'MailQueueId':Number(_0x6690d7[_0xc17f('0x27')]['id'])});}}else{socket[_0xc17f('0x5b')]('userMailQueue:remove',{'UserId':Number(_0x6690d7['query'][_0xc17f('0x54')]),'MailQueueId':Number(_0x6690d7[_0xc17f('0x27')]['id'])});}});}})[_0xc17f('0x16')](respondWithStatusCode(_0xfe9df4,null))[_0xc17f('0x26')](handleError(_0xfe9df4,null));};exports[_0xc17f('0x75')]=function(_0x10f147,_0x3ae764){var _0x3ff464={};var _0x1bafca={};var _0x4eaf40;var _0x12ba01;return db[_0xc17f('0x1d')]['findOne']({'where':{'id':_0x10f147[_0xc17f('0x27')]['id']}})[_0xc17f('0x16')](handleEntityNotFound(_0x3ae764,null))[_0xc17f('0x16')](function(_0x11fc5b){if(_0x11fc5b){_0x4eaf40=_0x11fc5b;_0x1bafca['model']=_['keys'](db[_0xc17f('0x47')][_0xc17f('0x1e')]);_0x1bafca['query']=_[_0xc17f('0x2a')](_0x10f147[_0xc17f('0x29')]);_0x1bafca[_0xc17f('0x2b')]=_[_0xc17f('0x2c')](_0x1bafca['model'],_0x1bafca['query']);_0x3ff464[_0xc17f('0x2d')]=_[_0xc17f('0x2c')](_0x1bafca[_0xc17f('0x28')],qs[_0xc17f('0x2e')](_0x10f147[_0xc17f('0x29')][_0xc17f('0x2e')]));_0x3ff464[_0xc17f('0x2d')]=_0x3ff464[_0xc17f('0x2d')]['length']?_0x3ff464['attributes']:_0x1bafca[_0xc17f('0x28')];_0x3ff464[_0xc17f('0x42')]=qs[_0xc17f('0x43')](_0x10f147['query'][_0xc17f('0x43')]);_0x3ff464[_0xc17f('0x22')]=qs['filters'](_['pick'](_0x10f147[_0xc17f('0x29')],_0x1bafca[_0xc17f('0x2b')]));if(_0x10f147[_0xc17f('0x29')]['filter']){_0x3ff464[_0xc17f('0x22')]=_[_0xc17f('0x31')](_0x3ff464[_0xc17f('0x22')],{'$or':_[_0xc17f('0x1c')](_0x3ff464[_0xc17f('0x2d')],function(_0x31c2fe){var _0x3aea43={};_0x3aea43[_0x31c2fe]={'$like':'%'+_0x10f147[_0xc17f('0x29')]['filter']+'%'};return _0x3aea43;})});}_0x3ff464=_[_0xc17f('0x31')]({},_0x3ff464,_0x10f147[_0xc17f('0x32')]);return _0x4eaf40[_0xc17f('0x75')](_0x3ff464);}})[_0xc17f('0x16')](function(_0x3c12d8){if(_0x3c12d8){_0x12ba01=_0x3c12d8['length'];if(!_0x10f147[_0xc17f('0x29')][_0xc17f('0x41')](_0xc17f('0x52'))){_0x3ff464[_0xc17f('0x11')]=qs[_0xc17f('0x11')](_0x10f147['query'][_0xc17f('0x11')]);_0x3ff464[_0xc17f('0x13')]=qs[_0xc17f('0x13')](_0x10f147[_0xc17f('0x29')][_0xc17f('0x13')]);}return _0x4eaf40[_0xc17f('0x75')](_0x3ff464);}})[_0xc17f('0x16')](function(_0x4e71a0){if(_0x4e71a0){return _0x4e71a0?{'count':_0x12ba01,'rows':_0x4e71a0}:null;}})[_0xc17f('0x16')](respondWithResult(_0x3ae764,null))[_0xc17f('0x26')](handleError(_0x3ae764,null));};
\ No newline at end of file
+var _0x28f7=['defaults','localhost','socket.io-emitter','./mailQueue.socket','register','sendStatus','status','json','undefined','count','offset','limit','set','Content-Range','update','then','UserProfileResource','destroy','stack','name','send','index','map','MailQueue','rawAttributes','fieldName','type','key','getOptions','where','include','query','findAll','rows','catch','params','model','keys','filters','intersection','attributes','fields','length','includeAll','merge','options','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','MailQueues','UserProfileSection','find','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserMailQueue','hasOwnProperty','sort','pick','filter','User','findAndCountAll','UserId','mailPause','updatedAt','createdAt','format','SIP','getTeams','Team','order','addTeams','ids','online','voicePause','interface','flatMap','Agents','transaction','each','findOrCreate','forEach','userMailQueue:save','removeTeams','select','field','from','team_has_mail_queues','join','user_has_teams','clone','ut.UserId\x20=\x20?','push','toString','sequelize','SELECT','every','TeamId','includes','compact','isEmpty','userMailQueue:remove','addAgents','omit','spread','emit','removeAgents','getAgents','nolimit','util','lodash','squel','ioredis','../../components/parsers/qs','../../config/logger','api','redis'];(function(_0x1d2520,_0x105606){var _0x22fd54=function(_0x2c3123){while(--_0x2c3123){_0x1d2520['push'](_0x1d2520['shift']());}};_0x22fd54(++_0x105606);}(_0x28f7,0xea));var _0x728f=function(_0x1f4f18,_0x525ce3){_0x1f4f18=_0x1f4f18-0x0;var _0x73b1e4=_0x28f7[_0x1f4f18];return _0x73b1e4;};'use strict';var BPromise=require('bluebird');var util=require(_0x728f('0x0'));var _=require(_0x728f('0x1'));var squel=require(_0x728f('0x2'));var Redis=require(_0x728f('0x3'));var qs=require(_0x728f('0x4'));var logger=require(_0x728f('0x5'))(_0x728f('0x6'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0x728f('0x7')]=_[_0x728f('0x8')](config['redis'],{'host':_0x728f('0x9'),'port':0x18eb});var socket=require(_0x728f('0xa'))(new Redis(config['redis']));require(_0x728f('0xb'))[_0x728f('0xc')](socket);function respondWithStatusCode(_0x2f4d00,_0x555b58){_0x555b58=_0x555b58||0xcc;return function(_0x340d4c){if(_0x340d4c){return _0x2f4d00[_0x728f('0xd')](_0x555b58);}return _0x2f4d00[_0x728f('0xe')](_0x555b58)['end']();};}function respondWithResult(_0x37dce2,_0x5e7f30){_0x5e7f30=_0x5e7f30||0xc8;return function(_0x42d1a6){if(_0x42d1a6){return _0x37dce2['status'](_0x5e7f30)[_0x728f('0xf')](_0x42d1a6);}};}function respondWithFilteredResult(_0x42f562,_0x3b2038){return function(_0x404cd6){if(_0x404cd6){var _0x577681=typeof _0x3b2038['offset']===_0x728f('0x10')&&typeof _0x3b2038['limit']==='undefined';var _0x20370e=_0x404cd6[_0x728f('0x11')];var _0x43b092=_0x577681?0x0:_0x3b2038[_0x728f('0x12')];var _0x70b34a=_0x577681?_0x404cd6[_0x728f('0x11')]:_0x3b2038[_0x728f('0x12')]+_0x3b2038[_0x728f('0x13')];var _0x1fc067;if(_0x70b34a>=_0x20370e){_0x70b34a=_0x20370e;_0x1fc067=0xc8;}else{_0x1fc067=0xce;}_0x42f562[_0x728f('0xe')](_0x1fc067);return _0x42f562[_0x728f('0x14')](_0x728f('0x15'),_0x43b092+'-'+_0x70b34a+'/'+_0x20370e)[_0x728f('0xf')](_0x404cd6);}return null;};}function saveUpdates(_0x3bf48d){return function(_0x368575){if(_0x368575){return _0x368575[_0x728f('0x16')](_0x3bf48d)[_0x728f('0x17')](function(_0x1571a6){return _0x1571a6;});}return null;};}function removeEntity(_0x371764){return function(_0x6fffe5){if(_0x6fffe5){return _0x6fffe5['destroy']()[_0x728f('0x17')](function(){var _0x1d79b9=_0x6fffe5['get']({'plain':!![]});var _0x3e3dc9='MailQueues';return db[_0x728f('0x18')][_0x728f('0x19')]({'where':{'type':_0x3e3dc9,'resourceId':_0x1d79b9['id']}})[_0x728f('0x17')](function(){return _0x6fffe5;});})[_0x728f('0x17')](function(){_0x371764[_0x728f('0xe')](0xcc)['end']();});}};}function handleEntityNotFound(_0xe3ead9){return function(_0x5174f5){if(!_0x5174f5){_0xe3ead9[_0x728f('0xd')](0x194);}return _0x5174f5;};}function handleError(_0x251785,_0x470d8c){_0x470d8c=_0x470d8c||0x1f4;return function(_0x1b3cfe){logger['error'](_0x1b3cfe[_0x728f('0x1a')]);if(_0x1b3cfe[_0x728f('0x1b')]){delete _0x1b3cfe[_0x728f('0x1b')];}_0x251785['status'](_0x470d8c)[_0x728f('0x1c')](_0x1b3cfe);};}exports[_0x728f('0x1d')]=function(_0x490ad2,_0x4f744c){var _0x4b19a0={};var _0x36dd3f={'count':0x0,'rows':[]};var _0x1baa10=_[_0x728f('0x1e')](db[_0x728f('0x1f')][_0x728f('0x20')],function(_0x7ebbe9){return{'name':_0x7ebbe9[_0x728f('0x21')],'type':_0x7ebbe9[_0x728f('0x22')][_0x728f('0x23')]};});_0x4b19a0=qs[_0x728f('0x24')](_0x1baa10,_0x490ad2);var _0x26c18d={'where':_0x4b19a0[_0x728f('0x25')]};return db[_0x728f('0x1f')][_0x728f('0x11')](_0x26c18d)['then'](function(_0x43b235){_0x36dd3f[_0x728f('0x11')]=_0x43b235;_0x4b19a0[_0x728f('0x26')]=qs[_0x728f('0x26')](_0x490ad2[_0x728f('0x27')]);return db[_0x728f('0x1f')][_0x728f('0x28')](_0x4b19a0);})['then'](function(_0x27947c){_0x36dd3f[_0x728f('0x29')]=_0x27947c;return _0x36dd3f;})[_0x728f('0x17')](respondWithFilteredResult(_0x4f744c,_0x4b19a0))[_0x728f('0x2a')](handleError(_0x4f744c,null));};exports['show']=function(_0x210856,_0x5118a1){var _0x3ad293={'raw':!![],'where':{'id':_0x210856[_0x728f('0x2b')]['id']}},_0xac0c3b={};_0xac0c3b[_0x728f('0x2c')]=_[_0x728f('0x2d')](db[_0x728f('0x1f')][_0x728f('0x20')]);_0xac0c3b[_0x728f('0x27')]=_[_0x728f('0x2d')](_0x210856['query']);_0xac0c3b[_0x728f('0x2e')]=_[_0x728f('0x2f')](_0xac0c3b[_0x728f('0x2c')],_0xac0c3b['query']);_0x3ad293[_0x728f('0x30')]=_['intersection'](_0xac0c3b[_0x728f('0x2c')],qs[_0x728f('0x31')](_0x210856[_0x728f('0x27')]['fields']));_0x3ad293['attributes']=_0x3ad293['attributes'][_0x728f('0x32')]?_0x3ad293['attributes']:_0xac0c3b[_0x728f('0x2c')];if(_0x210856[_0x728f('0x27')][_0x728f('0x33')]){_0x3ad293['include']=[{'all':!![]}];}_0x3ad293=_[_0x728f('0x34')]({},_0x3ad293,_0x210856[_0x728f('0x35')]);return db['MailQueue']['find'](_0x3ad293)[_0x728f('0x17')](handleEntityNotFound(_0x5118a1,null))[_0x728f('0x17')](respondWithResult(_0x5118a1,null))[_0x728f('0x2a')](handleError(_0x5118a1,null));};exports['create']=function(_0x54f18b,_0x1e798b){return db['MailQueue'][_0x728f('0x36')](_0x54f18b[_0x728f('0x37')],{})['then'](function(_0x5182db){var _0x40a992=_0x54f18b['user'][_0x728f('0x38')]({'plain':!![]});if(!_0x40a992)throw new Error(_0x728f('0x39'));if(_0x40a992[_0x728f('0x3a')]==='user'){var _0x494333=_0x5182db['get']({'plain':!![]});var _0x522759=_0x728f('0x3b');return db[_0x728f('0x3c')][_0x728f('0x3d')]({'where':{'name':_0x522759,'userProfileId':_0x40a992[_0x728f('0x3e')]},'raw':!![]})[_0x728f('0x17')](function(_0x5adddf){if(_0x5adddf&&_0x5adddf['autoAssociation']===0x0){return db[_0x728f('0x18')][_0x728f('0x36')]({'name':_0x494333[_0x728f('0x1b')],'resourceId':_0x494333['id'],'type':_0x5adddf[_0x728f('0x1b')],'sectionId':_0x5adddf['id']},{})[_0x728f('0x17')](function(){return _0x5182db;});}else{return _0x5182db;}})[_0x728f('0x2a')](function(_0x411043){logger['error'](_0x728f('0x3f'),_0x411043);throw _0x411043;});}return _0x5182db;})[_0x728f('0x17')](respondWithResult(_0x1e798b,0xc9))[_0x728f('0x2a')](handleError(_0x1e798b,null));};exports['update']=function(_0x16f0ab,_0x350847){if(_0x16f0ab[_0x728f('0x37')]['id']){delete _0x16f0ab['body']['id'];}return db[_0x728f('0x1f')][_0x728f('0x3d')]({'where':{'id':_0x16f0ab[_0x728f('0x2b')]['id']}})[_0x728f('0x17')](handleEntityNotFound(_0x350847,null))[_0x728f('0x17')](saveUpdates(_0x16f0ab[_0x728f('0x37')],null))['then'](respondWithResult(_0x350847,null))['catch'](handleError(_0x350847,null));};exports['destroy']=function(_0x39f3c2,_0x16ac57){return db[_0x728f('0x1f')][_0x728f('0x3d')]({'where':{'id':_0x39f3c2[_0x728f('0x2b')]['id']}})[_0x728f('0x17')](handleEntityNotFound(_0x16ac57,null))[_0x728f('0x17')](removeEntity(_0x16ac57,null))['catch'](handleError(_0x16ac57,null));};exports['describe']=function(_0x3c92e5,_0x58f8a4){return db[_0x728f('0x1f')][_0x728f('0x40')]()['then'](respondWithResult(_0x58f8a4,null))[_0x728f('0x2a')](handleError(_0x58f8a4,null));};exports[_0x728f('0x41')]=function(_0x5f28e9,_0x279d4e){var _0x3d625f={'raw':!![],'where':{}},_0x54f6eb={},_0x3aa234;return db[_0x728f('0x1f')][_0x728f('0x42')]({'where':{'id':_0x5f28e9[_0x728f('0x2b')]['id']}})[_0x728f('0x17')](handleEntityNotFound(_0x279d4e,null))[_0x728f('0x17')](function(_0x19fac1){if(_0x19fac1){_0x3aa234=_0x19fac1[_0x728f('0x38')]({'plain':!![]});_0x54f6eb[_0x728f('0x2c')]=_[_0x728f('0x2d')](db[_0x728f('0x43')][_0x728f('0x20')]);_0x54f6eb[_0x728f('0x27')]=_[_0x728f('0x2d')](_0x5f28e9[_0x728f('0x27')]);_0x54f6eb['filters']=_[_0x728f('0x2f')](_0x54f6eb['model'],_0x54f6eb[_0x728f('0x27')]);_0x3d625f[_0x728f('0x30')]=_[_0x728f('0x2f')](_0x54f6eb[_0x728f('0x2c')],qs['fields'](_0x5f28e9['query']['fields']));_0x3d625f[_0x728f('0x30')]=_0x3d625f[_0x728f('0x30')]['length']?_0x3d625f[_0x728f('0x30')]:_0x54f6eb['model'];if(!_0x5f28e9['query'][_0x728f('0x44')]('nolimit')){_0x3d625f[_0x728f('0x13')]=qs['limit'](_0x5f28e9[_0x728f('0x27')]['limit']);_0x3d625f[_0x728f('0x12')]=qs['offset'](_0x5f28e9['query'][_0x728f('0x12')]);}_0x3d625f['order']=qs[_0x728f('0x45')](_0x5f28e9[_0x728f('0x27')][_0x728f('0x45')]);_0x3d625f['where']=qs[_0x728f('0x2e')](_[_0x728f('0x46')](_0x5f28e9['query'],_0x54f6eb[_0x728f('0x2e')]));_0x3d625f['where']['MailQueueId']=_0x19fac1['id'];if(_0x5f28e9[_0x728f('0x27')][_0x728f('0x47')]){_0x3d625f[_0x728f('0x25')]=_[_0x728f('0x34')](_0x3d625f['where'],{'$or':_[_0x728f('0x1e')](_0x3d625f['attributes'],function(_0x186c1b){var _0x81ac10={};_0x81ac10[_0x186c1b]={'$like':'%'+_0x5f28e9[_0x728f('0x27')][_0x728f('0x47')]+'%'};return _0x81ac10;})});}_0x3d625f=_['merge']({},_0x3d625f,_0x5f28e9['options']);return db['UserMailQueue'][_0x728f('0x28')](_0x3d625f);}})[_0x728f('0x17')](function(_0x5594ac){if(_0x5594ac){return db[_0x728f('0x48')][_0x728f('0x49')]({'where':{'id':_[_0x728f('0x1e')](_0x5594ac,_0x728f('0x4a')),'role':'agent'},'attributes':['id',_0x728f('0x1b'),_0x728f('0x4b'),_0x728f('0x4c'),_0x728f('0x4d')]});}})[_0x728f('0x17')](function(_0x12dc35){if(_0x12dc35){return{'count':_0x12dc35[_0x728f('0x11')],'rows':_[_0x728f('0x1e')](_0x12dc35[_0x728f('0x29')],function(_0x30620e){return{'membername':_0x30620e[_0x728f('0x1b')],'UserId':_0x30620e['id'],'queue_name':_0x3aa234[_0x728f('0x1b')],'MailQueueId':_0x3aa234['id'],'interface':util[_0x728f('0x4e')]('%s/%s',_0x728f('0x4f'),_0x30620e[_0x728f('0x1b')]),'penalty':0x0,'paused':_0x30620e[_0x728f('0x4b')],'createdAt':_0x30620e['createdAt'],'updatedAt':_0x30620e[_0x728f('0x4c')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x728f('0x17')](respondWithFilteredResult(_0x279d4e,_0x3d625f))[_0x728f('0x2a')](handleError(_0x279d4e,null));};exports[_0x728f('0x50')]=function(_0x4c1f1f,_0x298f6c){var _0x4682d4={};var _0x3b6116={};var _0x3ea94f;var _0x423872;return db[_0x728f('0x1f')]['findOne']({'where':{'id':_0x4c1f1f[_0x728f('0x2b')]['id']}})[_0x728f('0x17')](handleEntityNotFound(_0x298f6c,null))[_0x728f('0x17')](function(_0x28bcce){if(_0x28bcce){_0x3ea94f=_0x28bcce;_0x3b6116[_0x728f('0x2c')]=_[_0x728f('0x2d')](db[_0x728f('0x51')][_0x728f('0x20')]);_0x3b6116['query']=_[_0x728f('0x2d')](_0x4c1f1f[_0x728f('0x27')]);_0x3b6116[_0x728f('0x2e')]=_[_0x728f('0x2f')](_0x3b6116[_0x728f('0x2c')],_0x3b6116['query']);_0x4682d4[_0x728f('0x30')]=_['intersection'](_0x3b6116['model'],qs[_0x728f('0x31')](_0x4c1f1f[_0x728f('0x27')][_0x728f('0x31')]));_0x4682d4[_0x728f('0x30')]=_0x4682d4[_0x728f('0x30')][_0x728f('0x32')]?_0x4682d4[_0x728f('0x30')]:_0x3b6116['model'];_0x4682d4[_0x728f('0x52')]=qs[_0x728f('0x45')](_0x4c1f1f['query'][_0x728f('0x45')]);_0x4682d4[_0x728f('0x25')]=qs[_0x728f('0x2e')](_[_0x728f('0x46')](_0x4c1f1f[_0x728f('0x27')],_0x3b6116[_0x728f('0x2e')]));if(_0x4c1f1f['query'][_0x728f('0x47')]){_0x4682d4[_0x728f('0x25')]=_[_0x728f('0x34')](_0x4682d4[_0x728f('0x25')],{'$or':_[_0x728f('0x1e')](_0x4682d4[_0x728f('0x30')],function(_0xd0cc20){var _0x7b8909={};_0x7b8909[_0xd0cc20]={'$like':'%'+_0x4c1f1f[_0x728f('0x27')][_0x728f('0x47')]+'%'};return _0x7b8909;})});}_0x4682d4=_[_0x728f('0x34')]({},_0x4682d4,_0x4c1f1f[_0x728f('0x35')]);return _0x3ea94f[_0x728f('0x50')](_0x4682d4);}})[_0x728f('0x17')](function(_0x2c1759){if(_0x2c1759){_0x423872=_0x2c1759['length'];if(!_0x4c1f1f[_0x728f('0x27')]['hasOwnProperty']('nolimit')){_0x4682d4[_0x728f('0x13')]=qs[_0x728f('0x13')](_0x4c1f1f[_0x728f('0x27')][_0x728f('0x13')]);_0x4682d4[_0x728f('0x12')]=qs[_0x728f('0x12')](_0x4c1f1f['query']['offset']);}return _0x3ea94f['getTeams'](_0x4682d4);}})[_0x728f('0x17')](function(_0x12496c){if(_0x12496c){return _0x12496c?{'count':_0x423872,'rows':_0x12496c}:null;}})[_0x728f('0x17')](respondWithResult(_0x298f6c,null))[_0x728f('0x2a')](handleError(_0x298f6c,null));};exports[_0x728f('0x53')]=function(_0x5ad363,_0x4c781b){var _0x478c07=_0x5ad363['body'][_0x728f('0x54')];return db['Team'][_0x728f('0x28')]({'where':{'id':_0x478c07},'attributes':['id'],'include':[{'model':db[_0x728f('0x48')],'as':'Agents','attributes':['id',_0x728f('0x1b'),_0x728f('0x55'),_0x728f('0x56'),_0x728f('0x57')],'raw':!![]}]})[_0x728f('0x17')](function(_0x360c45){if(_0x360c45){var _0x447c5b=_[_0x728f('0x58')](_0x360c45,function(_0x4dc5e1){var _0x25db78=_0x4dc5e1[_0x728f('0x38')]({'plain':!![]});return _0x25db78[_0x728f('0x59')];});return db[_0x728f('0x1f')][_0x728f('0x3d')]({'where':{'id':_0x5ad363[_0x728f('0x2b')]['id']}})[_0x728f('0x17')](function(_0x4e4d26){return db['sequelize'][_0x728f('0x5a')](function(_0x49f809){return _0x4e4d26[_0x728f('0x53')](_0x478c07,{'transaction':_0x49f809})['then'](function(){return BPromise[_0x728f('0x5b')](_0x447c5b,function(_0x393c22){return db[_0x728f('0x43')][_0x728f('0x5c')]({'where':{'UserId':_0x393c22['id'],'MailQueueId':_0x5ad363[_0x728f('0x2b')]['id']},'transaction':_0x49f809});});})['then'](function(){_0x447c5b[_0x728f('0x5d')](function(_0x321705){socket['emit'](_0x728f('0x5e'),{'UserId':_0x321705['id'],'MailQueueId':_0x4e4d26['id']});});});});});}})['then'](respondWithStatusCode(_0x4c781b,null))[_0x728f('0x2a')](handleError(_0x4c781b,null));};exports[_0x728f('0x5f')]=function(_0x1bb9b9,_0x40cb4c){return db['Team'][_0x728f('0x28')]({'where':{'id':_0x1bb9b9[_0x728f('0x27')][_0x728f('0x54')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x728f('0x59'),'attributes':['id'],'raw':!![]}]})[_0x728f('0x17')](handleEntityNotFound(_0x40cb4c,null))['then'](function(_0x5728f2){var _0x3d4305=_[_0x728f('0x1e')](_0x5728f2,'id');var _0x3ec73d=[];var _0x178145=[];var _0x246f34=squel[_0x728f('0x60')]();_0x246f34[_0x728f('0x61')]('tq.TeamId')[_0x728f('0x62')](_0x728f('0x63'),'tq')[_0x728f('0x64')](_0x728f('0x65'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where']('MailQueueId\x20=\x20?',_0x1bb9b9[_0x728f('0x2b')]['id']);for(var _0x5dc9a4=0x0;_0x5dc9a4<_0x5728f2[_0x728f('0x32')];_0x5dc9a4+=0x1){let _0x2d6fa5=_0x5728f2[_0x5dc9a4];for(var _0x5126d0=0x0;_0x5126d0<_0x2d6fa5[_0x728f('0x59')][_0x728f('0x32')];_0x5126d0+=0x1){let _0x3ef9eb=_0x2d6fa5[_0x728f('0x59')][_0x5126d0];var _0xdaf8e9=_0x246f34[_0x728f('0x66')]();_0xdaf8e9[_0x728f('0x25')](_0x728f('0x67'),_0x3ef9eb['id']);_0x178145[_0x728f('0x68')](db['sequelize'][_0x728f('0x27')](_0xdaf8e9[_0x728f('0x69')](),{'type':db[_0x728f('0x6a')]['QueryTypes'][_0x728f('0x6b')]})[_0x728f('0x17')](function(_0x1b1eef){if(_0x1b1eef['length']===0x1){return _0x3ef9eb['id'];}else{var _0x31b93f=_[_0x728f('0x6c')](_[_0x728f('0x1e')](_0x1b1eef,_0x728f('0x6d')),function(_0x1104cb){return _[_0x728f('0x6e')](_0x3d4305,_0x1104cb);});if(_0x31b93f){return _0x3ef9eb['id'];}}}));}}return BPromise['all'](_0x178145)['then'](function(_0x372151){_0x3ec73d=_(_0x3ec73d)['union'](_0x372151)[_0x728f('0x6f')]()['value']();return db['MailQueue'][_0x728f('0x3d')]({'where':{'id':_0x1bb9b9[_0x728f('0x2b')]['id']}})[_0x728f('0x17')](function(_0x11e149){return db[_0x728f('0x6a')][_0x728f('0x5a')](function(_0x28df23){return _0x11e149[_0x728f('0x5f')](_0x1bb9b9[_0x728f('0x27')][_0x728f('0x54')],{'transaction':_0x28df23})[_0x728f('0x17')](function(){if(!_[_0x728f('0x70')](_0x3ec73d)){return _0x11e149['removeAgents'](_0x3ec73d,{'transaction':_0x28df23});}})['then'](function(){_0x3ec73d['forEach'](function(_0x4bb3ef){socket['emit'](_0x728f('0x71'),{'UserId':_0x4bb3ef,'MailQueueId':_0x11e149['id']});});});});});});})[_0x728f('0x17')](respondWithStatusCode(_0x40cb4c,null))['catch'](handleError(_0x40cb4c,null));};exports[_0x728f('0x72')]=function(_0xdc30e3,_0x1d2379){return db[_0x728f('0x1f')][_0x728f('0x3d')]({'where':{'id':_0xdc30e3[_0x728f('0x2b')]['id']}})['then'](handleEntityNotFound(_0x1d2379,null))[_0x728f('0x17')](function(_0x517bae){if(_0x517bae){return _0x517bae[_0x728f('0x72')](_0xdc30e3['body']['ids'],_[_0x728f('0x73')](_0xdc30e3[_0x728f('0x37')],[_0x728f('0x54'),'id'])||{})[_0x728f('0x74')](function(_0x15a3b1){for(var _0x38f9b2=0x0;_0x38f9b2<_0xdc30e3['body'][_0x728f('0x54')][_0x728f('0x32')];_0x38f9b2+=0x1){socket[_0x728f('0x75')]('userMailQueue:save',{'UserId':Number(_0xdc30e3[_0x728f('0x37')][_0x728f('0x54')][_0x38f9b2]),'MailQueueId':Number(_0xdc30e3['params']['id'])});}return _0x15a3b1;});}})[_0x728f('0x17')](respondWithResult(_0x1d2379,null))[_0x728f('0x2a')](handleError(_0x1d2379,null));};exports[_0x728f('0x76')]=function(_0x199c3a,_0x46f6cd){return db[_0x728f('0x1f')][_0x728f('0x3d')]({'where':{'id':_0x199c3a[_0x728f('0x2b')]['id']}})[_0x728f('0x17')](handleEntityNotFound(_0x46f6cd,null))['then'](function(_0x5b382e){if(_0x5b382e){return _0x5b382e[_0x728f('0x76')](_0x199c3a[_0x728f('0x27')][_0x728f('0x54')])[_0x728f('0x17')](function(){if(_['isArray'](_0x199c3a[_0x728f('0x27')][_0x728f('0x54')])){for(var _0x101cff=0x0;_0x101cff<_0x199c3a[_0x728f('0x27')][_0x728f('0x54')]['length'];_0x101cff+=0x1){socket[_0x728f('0x75')](_0x728f('0x71'),{'UserId':Number(_0x199c3a[_0x728f('0x27')][_0x728f('0x54')][_0x101cff]),'MailQueueId':Number(_0x199c3a[_0x728f('0x2b')]['id'])});}}else{socket[_0x728f('0x75')](_0x728f('0x71'),{'UserId':Number(_0x199c3a['query'][_0x728f('0x54')]),'MailQueueId':Number(_0x199c3a[_0x728f('0x2b')]['id'])});}});}})['then'](respondWithStatusCode(_0x46f6cd,null))['catch'](handleError(_0x46f6cd,null));};exports[_0x728f('0x77')]=function(_0x13e66c,_0x4c331d){var _0x4d624e={};var _0x396b20={};var _0x5d6aac;var _0x7949ea;return db[_0x728f('0x1f')][_0x728f('0x42')]({'where':{'id':_0x13e66c[_0x728f('0x2b')]['id']}})['then'](handleEntityNotFound(_0x4c331d,null))[_0x728f('0x17')](function(_0x29b3ea){if(_0x29b3ea){_0x5d6aac=_0x29b3ea;_0x396b20[_0x728f('0x2c')]=_[_0x728f('0x2d')](db[_0x728f('0x48')][_0x728f('0x20')]);_0x396b20[_0x728f('0x27')]=_['keys'](_0x13e66c['query']);_0x396b20[_0x728f('0x2e')]=_[_0x728f('0x2f')](_0x396b20[_0x728f('0x2c')],_0x396b20['query']);_0x4d624e[_0x728f('0x30')]=_[_0x728f('0x2f')](_0x396b20[_0x728f('0x2c')],qs[_0x728f('0x31')](_0x13e66c[_0x728f('0x27')][_0x728f('0x31')]));_0x4d624e['attributes']=_0x4d624e[_0x728f('0x30')][_0x728f('0x32')]?_0x4d624e[_0x728f('0x30')]:_0x396b20[_0x728f('0x2c')];_0x4d624e['order']=qs[_0x728f('0x45')](_0x13e66c[_0x728f('0x27')][_0x728f('0x45')]);_0x4d624e[_0x728f('0x25')]=qs[_0x728f('0x2e')](_[_0x728f('0x46')](_0x13e66c[_0x728f('0x27')],_0x396b20[_0x728f('0x2e')]));if(_0x13e66c[_0x728f('0x27')][_0x728f('0x47')]){_0x4d624e[_0x728f('0x25')]=_[_0x728f('0x34')](_0x4d624e[_0x728f('0x25')],{'$or':_[_0x728f('0x1e')](_0x4d624e['attributes'],function(_0x3a101e){var _0x330272={};_0x330272[_0x3a101e]={'$like':'%'+_0x13e66c[_0x728f('0x27')][_0x728f('0x47')]+'%'};return _0x330272;})});}_0x4d624e=_[_0x728f('0x34')]({},_0x4d624e,_0x13e66c[_0x728f('0x35')]);return _0x5d6aac['getAgents'](_0x4d624e);}})[_0x728f('0x17')](function(_0x389918){if(_0x389918){_0x7949ea=_0x389918['length'];if(!_0x13e66c['query'][_0x728f('0x44')](_0x728f('0x78'))){_0x4d624e[_0x728f('0x13')]=qs['limit'](_0x13e66c[_0x728f('0x27')][_0x728f('0x13')]);_0x4d624e[_0x728f('0x12')]=qs['offset'](_0x13e66c[_0x728f('0x27')][_0x728f('0x12')]);}return _0x5d6aac[_0x728f('0x77')](_0x4d624e);}})[_0x728f('0x17')](function(_0x28b8ac){if(_0x28b8ac){return _0x28b8ac?{'count':_0x7949ea,'rows':_0x28b8ac}:null;}})[_0x728f('0x17')](respondWithResult(_0x4c331d,null))[_0x728f('0x2a')](handleError(_0x4c331d,null));};
\ No newline at end of file