Built motion from commit (unavailable).|2.5.16
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 7c8cad5..2f5d044 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf1f9=['clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','transaction','isEmpty','removeAgents','forEach','userMailQueue:remove','addAgents','omit','spread','isArray','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','lodash','squel','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','redis','localhost','socket.io-emitter','./mailQueue.socket','register','status','end','json','count','offset','limit','set','apply','reject','save','destroy','then','get','MailQueues','UserProfileResource','sendStatus','error','stack','name','send','index','MailQueue','rawAttributes','fieldName','type','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','VIRTUAL','filter','merge','options','include','findAll','catch','show','params','includeAll','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','find','describe','getMembers','findOne','UserMailQueue','User','findAndCountAll','agent','updatedAt','createdAt','rows','format','SIP','mailPause','getTeams','Team','ids','Agents','online','interface','flatMap','sequelize','addTeams','each','findOrCreate','emit','userMailQueue:save','removeTeams','field','tq.TeamId','team_has_mail_queues','join','user_has_teams','MailQueueId\x20=\x20?'];(function(_0x554819,_0x3d6eb5){var _0x270117=function(_0x351e20){while(--_0x351e20){_0x554819['push'](_0x554819['shift']());}};_0x270117(++_0x3d6eb5);}(_0xf1f9,0x1cd));var _0x9f1f=function(_0x507703,_0xeabcc2){_0x507703=_0x507703-0x0;var _0x10cb2e=_0xf1f9[_0x507703];return _0x10cb2e;};'use strict';var pdf=require(_0x9f1f('0x0'));var emlformat=require(_0x9f1f('0x1'));var rimraf=require(_0x9f1f('0x2'));var zipdir=require(_0x9f1f('0x3'));var jsonpatch=require(_0x9f1f('0x4'));var rp=require('request-promise');var moment=require(_0x9f1f('0x5'));var BPromise=require(_0x9f1f('0x6'));var Mustache=require(_0x9f1f('0x7'));var util=require(_0x9f1f('0x8'));var path=require(_0x9f1f('0x9'));var sox=require(_0x9f1f('0xa'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x9f1f('0xb'));var squel=require(_0x9f1f('0xc'));var crypto=require(_0x9f1f('0xd'));var jsforce=require(_0x9f1f('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x9f1f('0xf'));var querystring=require(_0x9f1f('0x10'));var Papa=require(_0x9f1f('0x11'));var Redis=require(_0x9f1f('0x12'));var authService=require(_0x9f1f('0x13'));var qs=require(_0x9f1f('0x14'));var as=require(_0x9f1f('0x15'));var hardwareService=require(_0x9f1f('0x16'));var logger=require('../../config/logger')(_0x9f1f('0x17'));var utils=require(_0x9f1f('0x18'));var config=require(_0x9f1f('0x19'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x9f1f('0x1a')]=_['defaults'](config[_0x9f1f('0x1a')],{'host':_0x9f1f('0x1b'),'port':0x18eb});var socket=require(_0x9f1f('0x1c'))(new Redis(config[_0x9f1f('0x1a')]));require(_0x9f1f('0x1d'))[_0x9f1f('0x1e')](socket);function respondWithStatusCode(_0x2503e8,_0x53dbdb){_0x53dbdb=_0x53dbdb||0xcc;return function(_0x3ad27e){if(_0x3ad27e){return _0x2503e8['sendStatus'](_0x53dbdb);}return _0x2503e8[_0x9f1f('0x1f')](_0x53dbdb)[_0x9f1f('0x20')]();};}function respondWithResult(_0x2ada8c,_0x360bad){_0x360bad=_0x360bad||0xc8;return function(_0x2c9304){if(_0x2c9304){return _0x2ada8c['status'](_0x360bad)[_0x9f1f('0x21')](_0x2c9304);}};}function respondWithFilteredResult(_0x462801,_0x15b9d2){return function(_0x5d35a6){if(_0x5d35a6){var _0x23d9c0=_0x5d35a6[_0x9f1f('0x22')],_0x11d55b=_0x15b9d2['offset'],_0x19d3f2=_0x15b9d2[_0x9f1f('0x23')]+_0x15b9d2[_0x9f1f('0x24')],_0x46f71a;if(_0x19d3f2>=_0x23d9c0){_0x19d3f2=_0x23d9c0;_0x46f71a=0xc8;}else{_0x46f71a=0xce;}_0x462801[_0x9f1f('0x1f')](_0x46f71a);return _0x462801[_0x9f1f('0x25')]('Content-Range',_0x11d55b+'-'+_0x19d3f2+'/'+_0x23d9c0)[_0x9f1f('0x21')](_0x5d35a6);}return null;};}function patchUpdates(_0x5048e0){return function(_0x21f25b){try{jsonpatch[_0x9f1f('0x26')](_0x21f25b,_0x5048e0,!![]);}catch(_0x4a45a7){return BPromise[_0x9f1f('0x27')](_0x4a45a7);}return _0x21f25b[_0x9f1f('0x28')]();};}function saveUpdates(_0x294bf1,_0xebaecd){return function(_0x24f5a6){if(_0x24f5a6){return _0x24f5a6['update'](_0x294bf1)['then'](function(_0x51e2e8){return _0x51e2e8;});}return null;};}function removeEntity(_0x57d29f,_0x47db05){return function(_0x42a5ac){if(_0x42a5ac){return _0x42a5ac[_0x9f1f('0x29')]()[_0x9f1f('0x2a')](function(){var _0x5b442f=_0x42a5ac[_0x9f1f('0x2b')]({'plain':!![]});var _0x41c84a=_0x9f1f('0x2c');return db[_0x9f1f('0x2d')][_0x9f1f('0x29')]({'where':{'type':_0x41c84a,'resourceId':_0x5b442f['id']}})[_0x9f1f('0x2a')](function(){return _0x42a5ac;});})[_0x9f1f('0x2a')](function(){_0x57d29f[_0x9f1f('0x1f')](0xcc)[_0x9f1f('0x20')]();});}};}function handleEntityNotFound(_0x2be76b,_0x1bb891){return function(_0x1975d3){if(!_0x1975d3){_0x2be76b[_0x9f1f('0x2e')](0x194);}return _0x1975d3;};}function handleError(_0x1859b2,_0x4e4636){_0x4e4636=_0x4e4636||0x1f4;return function(_0x49656d){logger[_0x9f1f('0x2f')](_0x49656d[_0x9f1f('0x30')]);if(_0x49656d['name']){delete _0x49656d[_0x9f1f('0x31')];}_0x1859b2[_0x9f1f('0x1f')](_0x4e4636)[_0x9f1f('0x32')](_0x49656d);};}exports[_0x9f1f('0x33')]=function(_0x121998,_0x1ac64f){var _0xe690e5={},_0x33e86d={},_0x5b7c22={'count':0x0,'rows':[]};var _0x561079=_['map'](db[_0x9f1f('0x34')][_0x9f1f('0x35')],function(_0xb9b92){return{'name':_0xb9b92[_0x9f1f('0x36')],'type':_0xb9b92[_0x9f1f('0x37')]['key']};});_0x33e86d[_0x9f1f('0x38')]=_[_0x9f1f('0x39')](_0x561079,_0x9f1f('0x31'));_0x33e86d[_0x9f1f('0x3a')]=_[_0x9f1f('0x3b')](_0x121998[_0x9f1f('0x3a')]);_0x33e86d[_0x9f1f('0x3c')]=_[_0x9f1f('0x3d')](_0x33e86d[_0x9f1f('0x38')],_0x33e86d[_0x9f1f('0x3a')]);_0xe690e5[_0x9f1f('0x3e')]=_[_0x9f1f('0x3d')](_0x33e86d[_0x9f1f('0x38')],qs[_0x9f1f('0x3f')](_0x121998[_0x9f1f('0x3a')][_0x9f1f('0x3f')]));_0xe690e5[_0x9f1f('0x3e')]=_0xe690e5['attributes'][_0x9f1f('0x40')]?_0xe690e5['attributes']:_0x33e86d[_0x9f1f('0x38')];if(!_0x121998[_0x9f1f('0x3a')][_0x9f1f('0x41')](_0x9f1f('0x42'))){_0xe690e5[_0x9f1f('0x24')]=qs[_0x9f1f('0x24')](_0x121998[_0x9f1f('0x3a')][_0x9f1f('0x24')]);_0xe690e5[_0x9f1f('0x23')]=qs[_0x9f1f('0x23')](_0x121998[_0x9f1f('0x3a')][_0x9f1f('0x23')]);}_0xe690e5[_0x9f1f('0x43')]=qs['sort'](_0x121998[_0x9f1f('0x3a')][_0x9f1f('0x44')]);_0xe690e5[_0x9f1f('0x45')]=qs[_0x9f1f('0x3c')](_[_0x9f1f('0x46')](_0x121998[_0x9f1f('0x3a')],_0x33e86d[_0x9f1f('0x3c')]),_0x561079);if(_0x121998[_0x9f1f('0x3a')]['filter']){_0xe690e5[_0x9f1f('0x45')]=_['merge'](_0xe690e5[_0x9f1f('0x45')],{'$or':_[_0x9f1f('0x39')](_0x561079,function(_0x326487){if(_0x326487[_0x9f1f('0x37')]!==_0x9f1f('0x47')){var _0x423812={};_0x423812[_0x326487[_0x9f1f('0x31')]]={'$like':'%'+_0x121998['query'][_0x9f1f('0x48')]+'%'};return _0x423812;}})});}_0xe690e5=_[_0x9f1f('0x49')]({},_0xe690e5,_0x121998[_0x9f1f('0x4a')]);var _0x20d5ea={'where':_0xe690e5[_0x9f1f('0x45')]};return db['MailQueue'][_0x9f1f('0x22')](_0x20d5ea)[_0x9f1f('0x2a')](function(_0x52509f){_0x5b7c22[_0x9f1f('0x22')]=_0x52509f;if(_0x121998[_0x9f1f('0x3a')]['includeAll']){_0xe690e5[_0x9f1f('0x4b')]=[{'all':!![]}];}return db[_0x9f1f('0x34')][_0x9f1f('0x4c')](_0xe690e5);})[_0x9f1f('0x2a')](function(_0x21b820){_0x5b7c22['rows']=_0x21b820;return _0x5b7c22;})[_0x9f1f('0x2a')](respondWithFilteredResult(_0x1ac64f,_0xe690e5))[_0x9f1f('0x4d')](handleError(_0x1ac64f,null));};exports[_0x9f1f('0x4e')]=function(_0x1a2f7e,_0x416767){var _0x3dce5f={'raw':!![],'where':{'id':_0x1a2f7e[_0x9f1f('0x4f')]['id']}},_0x2998d3={};_0x2998d3[_0x9f1f('0x38')]=_[_0x9f1f('0x3b')](db[_0x9f1f('0x34')][_0x9f1f('0x35')]);_0x2998d3['query']=_[_0x9f1f('0x3b')](_0x1a2f7e[_0x9f1f('0x3a')]);_0x2998d3[_0x9f1f('0x3c')]=_[_0x9f1f('0x3d')](_0x2998d3[_0x9f1f('0x38')],_0x2998d3[_0x9f1f('0x3a')]);_0x3dce5f[_0x9f1f('0x3e')]=_[_0x9f1f('0x3d')](_0x2998d3[_0x9f1f('0x38')],qs[_0x9f1f('0x3f')](_0x1a2f7e['query'][_0x9f1f('0x3f')]));_0x3dce5f[_0x9f1f('0x3e')]=_0x3dce5f[_0x9f1f('0x3e')][_0x9f1f('0x40')]?_0x3dce5f[_0x9f1f('0x3e')]:_0x2998d3[_0x9f1f('0x38')];if(_0x1a2f7e[_0x9f1f('0x3a')][_0x9f1f('0x50')]){_0x3dce5f[_0x9f1f('0x4b')]=[{'all':!![]}];}_0x3dce5f=_[_0x9f1f('0x49')]({},_0x3dce5f,_0x1a2f7e[_0x9f1f('0x4a')]);return db[_0x9f1f('0x34')]['find'](_0x3dce5f)[_0x9f1f('0x2a')](handleEntityNotFound(_0x416767,null))['then'](respondWithResult(_0x416767,null))['catch'](handleError(_0x416767,null));};exports[_0x9f1f('0x51')]=function(_0x4f4e6e,_0x1fcdde){return db[_0x9f1f('0x34')]['create'](_0x4f4e6e[_0x9f1f('0x52')],{})[_0x9f1f('0x2a')](function(_0x2bd51d){var _0x4aa45e=_0x4f4e6e[_0x9f1f('0x53')][_0x9f1f('0x2b')]({'plain':!![]});if(!_0x4aa45e)throw new Error(_0x9f1f('0x54'));if(_0x4aa45e['role']==='user'){var _0x185c33=_0x2bd51d[_0x9f1f('0x2b')]({'plain':!![]});var _0xd15888=_0x9f1f('0x2c');return db[_0x9f1f('0x55')]['find']({'where':{'name':_0xd15888,'userProfileId':_0x4aa45e[_0x9f1f('0x56')]},'raw':!![]})[_0x9f1f('0x2a')](function(_0xd5bb3e){if(_0xd5bb3e&&_0xd5bb3e['autoAssociation']===0x0){return db[_0x9f1f('0x2d')][_0x9f1f('0x51')]({'name':_0x185c33[_0x9f1f('0x31')],'resourceId':_0x185c33['id'],'type':_0xd5bb3e['name'],'sectionId':_0xd5bb3e['id']},{})[_0x9f1f('0x2a')](function(){return _0x2bd51d;});}else{return _0x2bd51d;}})['catch'](function(_0x3ced4e){logger[_0x9f1f('0x2f')](_0x9f1f('0x57'),_0x3ced4e);throw _0x3ced4e;});}return _0x2bd51d;})['then'](respondWithResult(_0x1fcdde,0xc9))[_0x9f1f('0x4d')](handleError(_0x1fcdde,null));};exports[_0x9f1f('0x58')]=function(_0x285820,_0x1e1691){if(_0x285820[_0x9f1f('0x52')]['id']){delete _0x285820[_0x9f1f('0x52')]['id'];}return db['MailQueue'][_0x9f1f('0x59')]({'where':{'id':_0x285820['params']['id']}})['then'](handleEntityNotFound(_0x1e1691,null))[_0x9f1f('0x2a')](saveUpdates(_0x285820[_0x9f1f('0x52')],null))[_0x9f1f('0x2a')](respondWithResult(_0x1e1691,null))['catch'](handleError(_0x1e1691,null));};exports[_0x9f1f('0x29')]=function(_0x56f24e,_0x1427ca){return db['MailQueue'][_0x9f1f('0x59')]({'where':{'id':_0x56f24e[_0x9f1f('0x4f')]['id']}})[_0x9f1f('0x2a')](handleEntityNotFound(_0x1427ca,null))['then'](removeEntity(_0x1427ca,null))['catch'](handleError(_0x1427ca,null));};exports['describe']=function(_0x3bfc7d,_0x24c677){return db['MailQueue'][_0x9f1f('0x5a')]()[_0x9f1f('0x2a')](respondWithResult(_0x24c677,null))[_0x9f1f('0x4d')](handleError(_0x24c677,null));};exports[_0x9f1f('0x5b')]=function(_0x1b398d,_0x1f1b52,_0x281f60){var _0x20b56b={'raw':!![],'where':{}},_0x2da544={},_0x7b4a01;return db['MailQueue'][_0x9f1f('0x5c')]({'where':{'id':_0x1b398d['params']['id']}})[_0x9f1f('0x2a')](handleEntityNotFound(_0x1f1b52,null))[_0x9f1f('0x2a')](function(_0x5aec3c){if(_0x5aec3c){_0x7b4a01=_0x5aec3c[_0x9f1f('0x2b')]({'plain':!![]});_0x2da544[_0x9f1f('0x38')]=_[_0x9f1f('0x3b')](db[_0x9f1f('0x5d')][_0x9f1f('0x35')]);_0x2da544[_0x9f1f('0x3a')]=_[_0x9f1f('0x3b')](_0x1b398d['query']);_0x2da544[_0x9f1f('0x3c')]=_[_0x9f1f('0x3d')](_0x2da544[_0x9f1f('0x38')],_0x2da544['query']);_0x20b56b[_0x9f1f('0x3e')]=_[_0x9f1f('0x3d')](_0x2da544[_0x9f1f('0x38')],qs['fields'](_0x1b398d[_0x9f1f('0x3a')][_0x9f1f('0x3f')]));_0x20b56b[_0x9f1f('0x3e')]=_0x20b56b[_0x9f1f('0x3e')][_0x9f1f('0x40')]?_0x20b56b[_0x9f1f('0x3e')]:_0x2da544[_0x9f1f('0x38')];if(!_0x1b398d[_0x9f1f('0x3a')][_0x9f1f('0x41')](_0x9f1f('0x42'))){_0x20b56b['limit']=qs['limit'](_0x1b398d[_0x9f1f('0x3a')][_0x9f1f('0x24')]);_0x20b56b[_0x9f1f('0x23')]=qs[_0x9f1f('0x23')](_0x1b398d[_0x9f1f('0x3a')][_0x9f1f('0x23')]);}_0x20b56b[_0x9f1f('0x43')]=qs[_0x9f1f('0x44')](_0x1b398d['query'][_0x9f1f('0x44')]);_0x20b56b[_0x9f1f('0x45')]=qs[_0x9f1f('0x3c')](_[_0x9f1f('0x46')](_0x1b398d['query'],_0x2da544[_0x9f1f('0x3c')]));_0x20b56b[_0x9f1f('0x45')]['MailQueueId']=_0x5aec3c['id'];if(_0x1b398d['query'][_0x9f1f('0x48')]){_0x20b56b[_0x9f1f('0x45')]=_['merge'](_0x20b56b[_0x9f1f('0x45')],{'$or':_[_0x9f1f('0x39')](_0x20b56b[_0x9f1f('0x3e')],function(_0x6092ea){var _0x538f24={};_0x538f24[_0x6092ea]={'$like':'%'+_0x1b398d[_0x9f1f('0x3a')][_0x9f1f('0x48')]+'%'};return _0x538f24;})});}_0x20b56b=_[_0x9f1f('0x49')]({},_0x20b56b,_0x1b398d['options']);return db[_0x9f1f('0x5d')][_0x9f1f('0x4c')](_0x20b56b);}})[_0x9f1f('0x2a')](function(_0xc7c9f2){if(_0xc7c9f2){return db[_0x9f1f('0x5e')][_0x9f1f('0x5f')]({'where':{'id':_['map'](_0xc7c9f2,'UserId'),'role':_0x9f1f('0x60')},'attributes':['id',_0x9f1f('0x31'),'mailPause',_0x9f1f('0x61'),_0x9f1f('0x62')]});}})[_0x9f1f('0x2a')](function(_0x1076fc){if(_0x1076fc){return{'count':_0x1076fc[_0x9f1f('0x22')],'rows':_[_0x9f1f('0x39')](_0x1076fc[_0x9f1f('0x63')],function(_0x5dddce){return{'membername':_0x5dddce[_0x9f1f('0x31')],'UserId':_0x5dddce['id'],'queue_name':_0x7b4a01['name'],'MailQueueId':_0x7b4a01['id'],'interface':util[_0x9f1f('0x64')]('%s/%s',_0x9f1f('0x65'),_0x5dddce[_0x9f1f('0x31')]),'penalty':0x0,'paused':_0x5dddce[_0x9f1f('0x66')],'createdAt':_0x5dddce[_0x9f1f('0x62')],'updatedAt':_0x5dddce[_0x9f1f('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x9f1f('0x2a')](respondWithFilteredResult(_0x1f1b52,_0x20b56b))[_0x9f1f('0x4d')](handleError(_0x1f1b52,null));};exports[_0x9f1f('0x67')]=function(_0x49fc31,_0x4b0518,_0x363f8b){var _0x2b9c89={};var _0x2b8ac0={};var _0x6be9a1;var _0x4f692a;return db[_0x9f1f('0x34')][_0x9f1f('0x5c')]({'where':{'id':_0x49fc31[_0x9f1f('0x4f')]['id']}})[_0x9f1f('0x2a')](handleEntityNotFound(_0x4b0518,null))[_0x9f1f('0x2a')](function(_0x5b139d){if(_0x5b139d){_0x6be9a1=_0x5b139d;_0x2b8ac0[_0x9f1f('0x38')]=_[_0x9f1f('0x3b')](db[_0x9f1f('0x68')][_0x9f1f('0x35')]);_0x2b8ac0[_0x9f1f('0x3a')]=_[_0x9f1f('0x3b')](_0x49fc31['query']);_0x2b8ac0[_0x9f1f('0x3c')]=_[_0x9f1f('0x3d')](_0x2b8ac0[_0x9f1f('0x38')],_0x2b8ac0[_0x9f1f('0x3a')]);_0x2b9c89[_0x9f1f('0x3e')]=_[_0x9f1f('0x3d')](_0x2b8ac0['model'],qs[_0x9f1f('0x3f')](_0x49fc31[_0x9f1f('0x3a')][_0x9f1f('0x3f')]));_0x2b9c89[_0x9f1f('0x3e')]=_0x2b9c89['attributes'][_0x9f1f('0x40')]?_0x2b9c89[_0x9f1f('0x3e')]:_0x2b8ac0[_0x9f1f('0x38')];_0x2b9c89[_0x9f1f('0x43')]=qs[_0x9f1f('0x44')](_0x49fc31[_0x9f1f('0x3a')]['sort']);_0x2b9c89[_0x9f1f('0x45')]=qs[_0x9f1f('0x3c')](_[_0x9f1f('0x46')](_0x49fc31['query'],_0x2b8ac0['filters']));if(_0x49fc31['query'][_0x9f1f('0x48')]){_0x2b9c89['where']=_[_0x9f1f('0x49')](_0x2b9c89[_0x9f1f('0x45')],{'$or':_[_0x9f1f('0x39')](_0x2b9c89[_0x9f1f('0x3e')],function(_0xe98c2a){var _0xd22d4c={};_0xd22d4c[_0xe98c2a]={'$like':'%'+_0x49fc31[_0x9f1f('0x3a')][_0x9f1f('0x48')]+'%'};return _0xd22d4c;})});}_0x2b9c89=_[_0x9f1f('0x49')]({},_0x2b9c89,_0x49fc31[_0x9f1f('0x4a')]);return _0x6be9a1[_0x9f1f('0x67')](_0x2b9c89);}})[_0x9f1f('0x2a')](function(_0x3a3e73){if(_0x3a3e73){_0x4f692a=_0x3a3e73[_0x9f1f('0x40')];if(!_0x49fc31[_0x9f1f('0x3a')]['hasOwnProperty'](_0x9f1f('0x42'))){_0x2b9c89[_0x9f1f('0x24')]=qs[_0x9f1f('0x24')](_0x49fc31[_0x9f1f('0x3a')]['limit']);_0x2b9c89['offset']=qs[_0x9f1f('0x23')](_0x49fc31[_0x9f1f('0x3a')][_0x9f1f('0x23')]);}return _0x6be9a1[_0x9f1f('0x67')](_0x2b9c89);}})[_0x9f1f('0x2a')](function(_0x2eb198){if(_0x2eb198){return _0x2eb198?{'count':_0x4f692a,'rows':_0x2eb198}:null;}})['then'](respondWithResult(_0x4b0518,null))['catch'](handleError(_0x4b0518,null));};exports['addTeams']=function(_0x5c0852,_0x18c686,_0x1cccdb){var _0x15c1e2=_0x5c0852[_0x9f1f('0x52')][_0x9f1f('0x69')];return db['Team'][_0x9f1f('0x4c')]({'where':{'id':_0x15c1e2},'attributes':['id'],'include':[{'model':db[_0x9f1f('0x5e')],'as':_0x9f1f('0x6a'),'attributes':['id',_0x9f1f('0x31'),_0x9f1f('0x6b'),'voicePause',_0x9f1f('0x6c')],'raw':!![]}]})[_0x9f1f('0x2a')](function(_0x39ca1d){if(_0x39ca1d){var _0x4ca838=_[_0x9f1f('0x6d')](_0x39ca1d,function(_0x122cd7){var _0x318580=_0x122cd7[_0x9f1f('0x2b')]({'plain':!![]});return _0x318580['Agents'];});return db[_0x9f1f('0x34')]['find']({'where':{'id':_0x5c0852[_0x9f1f('0x4f')]['id']}})[_0x9f1f('0x2a')](function(_0x376b34){return db[_0x9f1f('0x6e')]['transaction'](function(_0x314a38){return _0x376b34[_0x9f1f('0x6f')](_0x15c1e2,{'transaction':_0x314a38})['then'](function(){return BPromise[_0x9f1f('0x70')](_0x4ca838,function(_0xf00291){return db['UserMailQueue'][_0x9f1f('0x71')]({'where':{'UserId':_0xf00291['id'],'MailQueueId':_0x5c0852[_0x9f1f('0x4f')]['id']},'transaction':_0x314a38});});})[_0x9f1f('0x2a')](function(){_0x4ca838['forEach'](function(_0x2b2213){socket[_0x9f1f('0x72')](_0x9f1f('0x73'),{'UserId':_0x2b2213['id'],'MailQueueId':_0x376b34['id']});});});});});}})[_0x9f1f('0x2a')](respondWithStatusCode(_0x18c686,null))[_0x9f1f('0x4d')](handleError(_0x18c686,null));};exports[_0x9f1f('0x74')]=function(_0x2a753f,_0x43b80f,_0xa3e6b){return db[_0x9f1f('0x68')][_0x9f1f('0x4c')]({'where':{'id':_0x2a753f['query'][_0x9f1f('0x69')]},'attributes':['id'],'include':[{'model':db[_0x9f1f('0x5e')],'as':_0x9f1f('0x6a'),'attributes':['id'],'raw':!![]}]})[_0x9f1f('0x2a')](handleEntityNotFound(_0x43b80f,null))[_0x9f1f('0x2a')](function(_0x30a86e){var _0x1d6be8=_[_0x9f1f('0x39')](_0x30a86e,'id');var _0x2e363e=[];var _0x4e8280=[];var _0x14b0a1=squel['select']();_0x14b0a1[_0x9f1f('0x75')](_0x9f1f('0x76'))['from'](_0x9f1f('0x77'),'tq')[_0x9f1f('0x78')](_0x9f1f('0x79'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x9f1f('0x45')](_0x9f1f('0x7a'),_0x2a753f['params']['id']);for(var _0x39c7de=0x0;_0x39c7de<_0x30a86e['length'];_0x39c7de+=0x1){let _0x4277a7=_0x30a86e[_0x39c7de];for(var _0xe4da01=0x0;_0xe4da01<_0x4277a7[_0x9f1f('0x6a')][_0x9f1f('0x40')];_0xe4da01+=0x1){let _0x528ef3=_0x4277a7[_0x9f1f('0x6a')][_0xe4da01];var _0x2c4ab5=_0x14b0a1[_0x9f1f('0x7b')]();_0x2c4ab5[_0x9f1f('0x45')](_0x9f1f('0x7c'),_0x528ef3['id']);_0x4e8280[_0x9f1f('0x7d')](db[_0x9f1f('0x6e')][_0x9f1f('0x3a')](_0x2c4ab5[_0x9f1f('0x7e')](),{'type':db['sequelize'][_0x9f1f('0x7f')][_0x9f1f('0x80')]})['then'](function(_0x503ac1){if(_0x503ac1[_0x9f1f('0x40')]===0x1){return _0x528ef3['id'];}else{var _0x39dd8b=_[_0x9f1f('0x81')](_['map'](_0x503ac1,_0x9f1f('0x82')),function(_0x34fa60){return _[_0x9f1f('0x83')](_0x1d6be8,_0x34fa60);});if(_0x39dd8b){return _0x528ef3['id'];}}}));}}return BPromise[_0x9f1f('0x84')](_0x4e8280)[_0x9f1f('0x2a')](function(_0x5be8f3){_0x2e363e=_(_0x2e363e)[_0x9f1f('0x85')](_0x5be8f3)[_0x9f1f('0x86')]()[_0x9f1f('0x87')]();return db[_0x9f1f('0x34')][_0x9f1f('0x59')]({'where':{'id':_0x2a753f[_0x9f1f('0x4f')]['id']}})[_0x9f1f('0x2a')](function(_0x5047a8){return db[_0x9f1f('0x6e')][_0x9f1f('0x88')](function(_0x54c7fd){return _0x5047a8[_0x9f1f('0x74')](_0x2a753f[_0x9f1f('0x3a')][_0x9f1f('0x69')],{'transaction':_0x54c7fd})['then'](function(){if(!_[_0x9f1f('0x89')](_0x2e363e)){return _0x5047a8[_0x9f1f('0x8a')](_0x2e363e,{'transaction':_0x54c7fd});}})[_0x9f1f('0x2a')](function(){_0x2e363e[_0x9f1f('0x8b')](function(_0x1aa15b){socket[_0x9f1f('0x72')](_0x9f1f('0x8c'),{'UserId':_0x1aa15b,'MailQueueId':_0x5047a8['id']});});});});});});})[_0x9f1f('0x2a')](respondWithStatusCode(_0x43b80f,null))[_0x9f1f('0x4d')](handleError(_0x43b80f,null));};exports[_0x9f1f('0x8d')]=function(_0x35129a,_0x150a77,_0x59e109){return db[_0x9f1f('0x34')][_0x9f1f('0x59')]({'where':{'id':_0x35129a[_0x9f1f('0x4f')]['id']}})['then'](handleEntityNotFound(_0x150a77,null))[_0x9f1f('0x2a')](function(_0x53bfd5){if(_0x53bfd5){return _0x53bfd5[_0x9f1f('0x8d')](_0x35129a[_0x9f1f('0x52')][_0x9f1f('0x69')],_[_0x9f1f('0x8e')](_0x35129a[_0x9f1f('0x52')],[_0x9f1f('0x69'),'id'])||{})[_0x9f1f('0x8f')](function(_0xc5ccd4){for(var _0xed5df4=0x0;_0xed5df4<_0x35129a['body'][_0x9f1f('0x69')][_0x9f1f('0x40')];_0xed5df4+=0x1){socket['emit'](_0x9f1f('0x73'),{'UserId':_0x35129a['body'][_0x9f1f('0x69')][_0xed5df4],'MailQueueId':_0x35129a[_0x9f1f('0x4f')]['id']});}return _0xc5ccd4;});}})[_0x9f1f('0x2a')](respondWithResult(_0x150a77,null))['catch'](handleError(_0x150a77,null));};exports[_0x9f1f('0x8a')]=function(_0x534c0b,_0x1d031f,_0x359df9){return db[_0x9f1f('0x34')][_0x9f1f('0x59')]({'where':{'id':_0x534c0b['params']['id']}})[_0x9f1f('0x2a')](handleEntityNotFound(_0x1d031f,null))[_0x9f1f('0x2a')](function(_0x135e6b){if(_0x135e6b){return _0x135e6b[_0x9f1f('0x8a')](_0x534c0b['query'][_0x9f1f('0x69')])[_0x9f1f('0x2a')](function(){if(_[_0x9f1f('0x90')](_0x534c0b[_0x9f1f('0x3a')][_0x9f1f('0x69')])){for(var _0x13936d=0x0;_0x13936d<_0x534c0b[_0x9f1f('0x3a')][_0x9f1f('0x69')][_0x9f1f('0x40')];_0x13936d+=0x1){socket[_0x9f1f('0x72')]('userMailQueue:remove',{'UserId':Number(_0x534c0b[_0x9f1f('0x3a')][_0x9f1f('0x69')][_0x13936d]),'MailQueueId':Number(_0x534c0b['params']['id'])});}}else{socket[_0x9f1f('0x72')](_0x9f1f('0x8c'),{'UserId':Number(_0x534c0b[_0x9f1f('0x3a')][_0x9f1f('0x69')]),'MailQueueId':Number(_0x534c0b[_0x9f1f('0x4f')]['id'])});}});}})[_0x9f1f('0x2a')](respondWithStatusCode(_0x1d031f,null))[_0x9f1f('0x4d')](handleError(_0x1d031f,null));};exports[_0x9f1f('0x91')]=function(_0x10cf8f,_0x6de994,_0x491859){var _0x1e98e1={};var _0x76c026={};var _0x3009b1;var _0x37266a;return db[_0x9f1f('0x34')]['findOne']({'where':{'id':_0x10cf8f[_0x9f1f('0x4f')]['id']}})[_0x9f1f('0x2a')](handleEntityNotFound(_0x6de994,null))['then'](function(_0x3f45b6){if(_0x3f45b6){_0x3009b1=_0x3f45b6;_0x76c026[_0x9f1f('0x38')]=_[_0x9f1f('0x3b')](db[_0x9f1f('0x5e')][_0x9f1f('0x35')]);_0x76c026[_0x9f1f('0x3a')]=_[_0x9f1f('0x3b')](_0x10cf8f['query']);_0x76c026[_0x9f1f('0x3c')]=_[_0x9f1f('0x3d')](_0x76c026['model'],_0x76c026[_0x9f1f('0x3a')]);_0x1e98e1[_0x9f1f('0x3e')]=_[_0x9f1f('0x3d')](_0x76c026['model'],qs[_0x9f1f('0x3f')](_0x10cf8f['query'][_0x9f1f('0x3f')]));_0x1e98e1[_0x9f1f('0x3e')]=_0x1e98e1[_0x9f1f('0x3e')][_0x9f1f('0x40')]?_0x1e98e1[_0x9f1f('0x3e')]:_0x76c026[_0x9f1f('0x38')];_0x1e98e1[_0x9f1f('0x43')]=qs['sort'](_0x10cf8f['query'][_0x9f1f('0x44')]);_0x1e98e1[_0x9f1f('0x45')]=qs[_0x9f1f('0x3c')](_[_0x9f1f('0x46')](_0x10cf8f[_0x9f1f('0x3a')],_0x76c026[_0x9f1f('0x3c')]));if(_0x10cf8f[_0x9f1f('0x3a')][_0x9f1f('0x48')]){_0x1e98e1['where']=_['merge'](_0x1e98e1[_0x9f1f('0x45')],{'$or':_[_0x9f1f('0x39')](_0x1e98e1[_0x9f1f('0x3e')],function(_0x717b2f){var _0x3b00b4={};_0x3b00b4[_0x717b2f]={'$like':'%'+_0x10cf8f[_0x9f1f('0x3a')][_0x9f1f('0x48')]+'%'};return _0x3b00b4;})});}_0x1e98e1=_[_0x9f1f('0x49')]({},_0x1e98e1,_0x10cf8f[_0x9f1f('0x4a')]);return _0x3009b1[_0x9f1f('0x91')](_0x1e98e1);}})['then'](function(_0xcc8250){if(_0xcc8250){_0x37266a=_0xcc8250['length'];if(!_0x10cf8f[_0x9f1f('0x3a')][_0x9f1f('0x41')](_0x9f1f('0x42'))){_0x1e98e1['limit']=qs['limit'](_0x10cf8f[_0x9f1f('0x3a')][_0x9f1f('0x24')]);_0x1e98e1[_0x9f1f('0x23')]=qs[_0x9f1f('0x23')](_0x10cf8f['query'][_0x9f1f('0x23')]);}return _0x3009b1[_0x9f1f('0x91')](_0x1e98e1);}})[_0x9f1f('0x2a')](function(_0x325be8){if(_0x325be8){return _0x325be8?{'count':_0x37266a,'rows':_0x325be8}:null;}})[_0x9f1f('0x2a')](respondWithResult(_0x6de994,null))[_0x9f1f('0x4d')](handleError(_0x6de994,null));};
\ No newline at end of file
+var _0xd523=['pick','VIRTUAL','merge','options','MailQueue','rows','catch','show','params','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','nolimit','order','MailQueueId','filter','UserMailQueue','findAll','User','findAndCountAll','UserId','mailPause','updatedAt','createdAt','%s/%s','SIP','Team','getTeams','online','voicePause','interface','sequelize','transaction','findOrCreate','forEach','emit','userMailQueue:save','removeTeams','ids','Agents','field','tq.TeamId','team_has_mail_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','push','QueryTypes','SELECT','every','TeamId','all','union','value','isEmpty','removeAgents','userMailQueue:remove','addAgents','spread','getAgents','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','defaults','redis','./mailQueue.socket','register','sendStatus','status','end','json','count','offset','set','Content-Range','apply','save','update','then','destroy','get','UserProfileResource','error','name','send','map','rawAttributes','type','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','limit','sort','where'];(function(_0x5b8e05,_0x2d81fc){var _0x559d93=function(_0xc1447a){while(--_0xc1447a){_0x5b8e05['push'](_0x5b8e05['shift']());}};_0x559d93(++_0x2d81fc);}(_0xd523,0x153));var _0x3d52=function(_0x55c8f8,_0x1f42d2){_0x55c8f8=_0x55c8f8-0x0;var _0x2132f2=_0xd523[_0x55c8f8];return _0x2132f2;};'use strict';var pdf=require(_0x3d52('0x0'));var emlformat=require(_0x3d52('0x1'));var rimraf=require(_0x3d52('0x2'));var zipdir=require(_0x3d52('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x3d52('0x4'));var moment=require(_0x3d52('0x5'));var BPromise=require(_0x3d52('0x6'));var Mustache=require('mustache');var util=require(_0x3d52('0x7'));var path=require(_0x3d52('0x8'));var sox=require(_0x3d52('0x9'));var csv=require(_0x3d52('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x3d52('0xb'));var crypto=require(_0x3d52('0xc'));var jsforce=require(_0x3d52('0xd'));var deskjs=require(_0x3d52('0xe'));var toCsv=require(_0x3d52('0xa'));var querystring=require(_0x3d52('0xf'));var Papa=require(_0x3d52('0x10'));var Redis=require(_0x3d52('0x11'));var authService=require(_0x3d52('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x3d52('0x13'));var hardwareService=require(_0x3d52('0x14'));var logger=require(_0x3d52('0x15'))(_0x3d52('0x16'));var utils=require(_0x3d52('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x3d52('0x18'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x3d52('0x19')](config[_0x3d52('0x1a')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x3d52('0x1b'))[_0x3d52('0x1c')](socket);function respondWithStatusCode(_0x1430c1,_0x2fd86e){_0x2fd86e=_0x2fd86e||0xcc;return function(_0x336261){if(_0x336261){return _0x1430c1[_0x3d52('0x1d')](_0x2fd86e);}return _0x1430c1[_0x3d52('0x1e')](_0x2fd86e)[_0x3d52('0x1f')]();};}function respondWithResult(_0x2e956d,_0x360659){_0x360659=_0x360659||0xc8;return function(_0x153c89){if(_0x153c89){return _0x2e956d[_0x3d52('0x1e')](_0x360659)[_0x3d52('0x20')](_0x153c89);}};}function respondWithFilteredResult(_0x10ec1e,_0x1dcea9){return function(_0x5bce9a){if(_0x5bce9a){var _0x163d88=_0x5bce9a[_0x3d52('0x21')],_0x3b3451=_0x1dcea9[_0x3d52('0x22')],_0x386cdb=_0x1dcea9[_0x3d52('0x22')]+_0x1dcea9['limit'],_0x54a514;if(_0x386cdb>=_0x163d88){_0x386cdb=_0x163d88;_0x54a514=0xc8;}else{_0x54a514=0xce;}_0x10ec1e[_0x3d52('0x1e')](_0x54a514);return _0x10ec1e[_0x3d52('0x23')](_0x3d52('0x24'),_0x3b3451+'-'+_0x386cdb+'/'+_0x163d88)[_0x3d52('0x20')](_0x5bce9a);}return null;};}function patchUpdates(_0x3bd95f){return function(_0xc0c16e){try{jsonpatch[_0x3d52('0x25')](_0xc0c16e,_0x3bd95f,!![]);}catch(_0x34b572){return BPromise['reject'](_0x34b572);}return _0xc0c16e[_0x3d52('0x26')]();};}function saveUpdates(_0x10f432,_0xd31ce4){return function(_0x5826c9){if(_0x5826c9){return _0x5826c9[_0x3d52('0x27')](_0x10f432)[_0x3d52('0x28')](function(_0x423d33){return _0x423d33;});}return null;};}function removeEntity(_0xc6c76,_0x3816bc){return function(_0x349b30){if(_0x349b30){return _0x349b30[_0x3d52('0x29')]()[_0x3d52('0x28')](function(){var _0x44ba59=_0x349b30[_0x3d52('0x2a')]({'plain':!![]});var _0x1ef6db='MailQueues';return db[_0x3d52('0x2b')][_0x3d52('0x29')]({'where':{'type':_0x1ef6db,'resourceId':_0x44ba59['id']}})[_0x3d52('0x28')](function(){return _0x349b30;});})[_0x3d52('0x28')](function(){_0xc6c76['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x473842,_0x11bf44){return function(_0x28e50d){if(!_0x28e50d){_0x473842['sendStatus'](0x194);}return _0x28e50d;};}function handleError(_0x209cca,_0x4312a7){_0x4312a7=_0x4312a7||0x1f4;return function(_0x2fd0ec){logger[_0x3d52('0x2c')](_0x2fd0ec['stack']);if(_0x2fd0ec[_0x3d52('0x2d')]){delete _0x2fd0ec[_0x3d52('0x2d')];}_0x209cca[_0x3d52('0x1e')](_0x4312a7)[_0x3d52('0x2e')](_0x2fd0ec);};}exports['index']=function(_0x12538a,_0x5a7455){var _0x5f006b={},_0x389582={},_0x45eabe={'count':0x0,'rows':[]};var _0x5e4e7b=_[_0x3d52('0x2f')](db['MailQueue'][_0x3d52('0x30')],function(_0x4c0273){return{'name':_0x4c0273['fieldName'],'type':_0x4c0273[_0x3d52('0x31')][_0x3d52('0x32')]};});_0x389582[_0x3d52('0x33')]=_[_0x3d52('0x2f')](_0x5e4e7b,_0x3d52('0x2d'));_0x389582[_0x3d52('0x34')]=_[_0x3d52('0x35')](_0x12538a[_0x3d52('0x34')]);_0x389582[_0x3d52('0x36')]=_['intersection'](_0x389582[_0x3d52('0x33')],_0x389582[_0x3d52('0x34')]);_0x5f006b[_0x3d52('0x37')]=_[_0x3d52('0x38')](_0x389582['model'],qs[_0x3d52('0x39')](_0x12538a[_0x3d52('0x34')]['fields']));_0x5f006b[_0x3d52('0x37')]=_0x5f006b['attributes'][_0x3d52('0x3a')]?_0x5f006b[_0x3d52('0x37')]:_0x389582[_0x3d52('0x33')];if(!_0x12538a['query'][_0x3d52('0x3b')]('nolimit')){_0x5f006b[_0x3d52('0x3c')]=qs[_0x3d52('0x3c')](_0x12538a[_0x3d52('0x34')]['limit']);_0x5f006b['offset']=qs[_0x3d52('0x22')](_0x12538a[_0x3d52('0x34')][_0x3d52('0x22')]);}_0x5f006b['order']=qs[_0x3d52('0x3d')](_0x12538a[_0x3d52('0x34')][_0x3d52('0x3d')]);_0x5f006b[_0x3d52('0x3e')]=qs['filters'](_[_0x3d52('0x3f')](_0x12538a['query'],_0x389582['filters']),_0x5e4e7b);if(_0x12538a[_0x3d52('0x34')]['filter']){_0x5f006b[_0x3d52('0x3e')]=_['merge'](_0x5f006b[_0x3d52('0x3e')],{'$or':_['map'](_0x5e4e7b,function(_0x576562){if(_0x576562[_0x3d52('0x31')]!==_0x3d52('0x40')){var _0x5cecb5={};_0x5cecb5[_0x576562[_0x3d52('0x2d')]]={'$like':'%'+_0x12538a[_0x3d52('0x34')]['filter']+'%'};return _0x5cecb5;}})});}_0x5f006b=_[_0x3d52('0x41')]({},_0x5f006b,_0x12538a[_0x3d52('0x42')]);var _0x25702d={'where':_0x5f006b[_0x3d52('0x3e')]};return db[_0x3d52('0x43')][_0x3d52('0x21')](_0x25702d)[_0x3d52('0x28')](function(_0x5cf4b9){_0x45eabe['count']=_0x5cf4b9;if(_0x12538a['query']['includeAll']){_0x5f006b['include']=[{'all':!![]}];}return db[_0x3d52('0x43')]['findAll'](_0x5f006b);})[_0x3d52('0x28')](function(_0x49064e){_0x45eabe[_0x3d52('0x44')]=_0x49064e;return _0x45eabe;})[_0x3d52('0x28')](respondWithFilteredResult(_0x5a7455,_0x5f006b))[_0x3d52('0x45')](handleError(_0x5a7455,null));};exports[_0x3d52('0x46')]=function(_0x5cdeb7,_0x394200){var _0x1e0487={'raw':!![],'where':{'id':_0x5cdeb7[_0x3d52('0x47')]['id']}},_0x5dd63c={};_0x5dd63c[_0x3d52('0x33')]=_[_0x3d52('0x35')](db['MailQueue'][_0x3d52('0x30')]);_0x5dd63c['query']=_['keys'](_0x5cdeb7['query']);_0x5dd63c['filters']=_[_0x3d52('0x38')](_0x5dd63c[_0x3d52('0x33')],_0x5dd63c[_0x3d52('0x34')]);_0x1e0487['attributes']=_[_0x3d52('0x38')](_0x5dd63c['model'],qs[_0x3d52('0x39')](_0x5cdeb7[_0x3d52('0x34')]['fields']));_0x1e0487[_0x3d52('0x37')]=_0x1e0487[_0x3d52('0x37')][_0x3d52('0x3a')]?_0x1e0487[_0x3d52('0x37')]:_0x5dd63c['model'];if(_0x5cdeb7['query'][_0x3d52('0x48')]){_0x1e0487['include']=[{'all':!![]}];}_0x1e0487=_[_0x3d52('0x41')]({},_0x1e0487,_0x5cdeb7[_0x3d52('0x42')]);return db[_0x3d52('0x43')][_0x3d52('0x49')](_0x1e0487)['then'](handleEntityNotFound(_0x394200,null))[_0x3d52('0x28')](respondWithResult(_0x394200,null))['catch'](handleError(_0x394200,null));};exports[_0x3d52('0x4a')]=function(_0x2911da,_0x524b9a){return db[_0x3d52('0x43')][_0x3d52('0x4a')](_0x2911da[_0x3d52('0x4b')],{})[_0x3d52('0x28')](function(_0x2b0c0e){var _0x3f4db8=_0x2911da[_0x3d52('0x4c')][_0x3d52('0x2a')]({'plain':!![]});if(!_0x3f4db8)throw new Error(_0x3d52('0x4d'));if(_0x3f4db8['role']===_0x3d52('0x4c')){var _0x380699=_0x2b0c0e['get']({'plain':!![]});var _0x237a6e='MailQueues';return db[_0x3d52('0x4e')][_0x3d52('0x49')]({'where':{'name':_0x237a6e,'userProfileId':_0x3f4db8[_0x3d52('0x4f')]},'raw':!![]})['then'](function(_0x2cb287){if(_0x2cb287&&_0x2cb287[_0x3d52('0x50')]===0x0){return db['UserProfileResource']['create']({'name':_0x380699[_0x3d52('0x2d')],'resourceId':_0x380699['id'],'type':_0x2cb287[_0x3d52('0x2d')],'sectionId':_0x2cb287['id']},{})['then'](function(){return _0x2b0c0e;});}else{return _0x2b0c0e;}})[_0x3d52('0x45')](function(_0x146a5b){logger[_0x3d52('0x2c')](_0x3d52('0x51'),_0x146a5b);throw _0x146a5b;});}return _0x2b0c0e;})[_0x3d52('0x28')](respondWithResult(_0x524b9a,0xc9))[_0x3d52('0x45')](handleError(_0x524b9a,null));};exports['update']=function(_0x2828d2,_0x1783d5){if(_0x2828d2[_0x3d52('0x4b')]['id']){delete _0x2828d2[_0x3d52('0x4b')]['id'];}return db[_0x3d52('0x43')][_0x3d52('0x49')]({'where':{'id':_0x2828d2[_0x3d52('0x47')]['id']}})[_0x3d52('0x28')](handleEntityNotFound(_0x1783d5,null))['then'](saveUpdates(_0x2828d2[_0x3d52('0x4b')],null))['then'](respondWithResult(_0x1783d5,null))[_0x3d52('0x45')](handleError(_0x1783d5,null));};exports[_0x3d52('0x29')]=function(_0x5434ee,_0x4e6d22){return db[_0x3d52('0x43')][_0x3d52('0x49')]({'where':{'id':_0x5434ee[_0x3d52('0x47')]['id']}})[_0x3d52('0x28')](handleEntityNotFound(_0x4e6d22,null))[_0x3d52('0x28')](removeEntity(_0x4e6d22,null))[_0x3d52('0x45')](handleError(_0x4e6d22,null));};exports[_0x3d52('0x52')]=function(_0x3e709b,_0x2f425f){return db['MailQueue'][_0x3d52('0x52')]()['then'](respondWithResult(_0x2f425f,null))[_0x3d52('0x45')](handleError(_0x2f425f,null));};exports[_0x3d52('0x53')]=function(_0x125807,_0x3b1d34,_0x1389c4){var _0x3ace61={'raw':!![],'where':{}},_0x4f4e15={},_0x444296;return db[_0x3d52('0x43')][_0x3d52('0x54')]({'where':{'id':_0x125807[_0x3d52('0x47')]['id']}})['then'](handleEntityNotFound(_0x3b1d34,null))[_0x3d52('0x28')](function(_0x327a3f){if(_0x327a3f){_0x444296=_0x327a3f[_0x3d52('0x2a')]({'plain':!![]});_0x4f4e15[_0x3d52('0x33')]=_[_0x3d52('0x35')](db['UserMailQueue'][_0x3d52('0x30')]);_0x4f4e15['query']=_[_0x3d52('0x35')](_0x125807['query']);_0x4f4e15[_0x3d52('0x36')]=_[_0x3d52('0x38')](_0x4f4e15['model'],_0x4f4e15['query']);_0x3ace61['attributes']=_[_0x3d52('0x38')](_0x4f4e15['model'],qs[_0x3d52('0x39')](_0x125807[_0x3d52('0x34')]['fields']));_0x3ace61[_0x3d52('0x37')]=_0x3ace61[_0x3d52('0x37')][_0x3d52('0x3a')]?_0x3ace61['attributes']:_0x4f4e15[_0x3d52('0x33')];if(!_0x125807[_0x3d52('0x34')][_0x3d52('0x3b')](_0x3d52('0x55'))){_0x3ace61[_0x3d52('0x3c')]=qs[_0x3d52('0x3c')](_0x125807[_0x3d52('0x34')][_0x3d52('0x3c')]);_0x3ace61[_0x3d52('0x22')]=qs[_0x3d52('0x22')](_0x125807[_0x3d52('0x34')][_0x3d52('0x22')]);}_0x3ace61[_0x3d52('0x56')]=qs[_0x3d52('0x3d')](_0x125807[_0x3d52('0x34')][_0x3d52('0x3d')]);_0x3ace61[_0x3d52('0x3e')]=qs[_0x3d52('0x36')](_[_0x3d52('0x3f')](_0x125807['query'],_0x4f4e15[_0x3d52('0x36')]));_0x3ace61['where'][_0x3d52('0x57')]=_0x327a3f['id'];if(_0x125807[_0x3d52('0x34')][_0x3d52('0x58')]){_0x3ace61[_0x3d52('0x3e')]=_['merge'](_0x3ace61[_0x3d52('0x3e')],{'$or':_[_0x3d52('0x2f')](_0x3ace61[_0x3d52('0x37')],function(_0x1d4cca){var _0x2425ae={};_0x2425ae[_0x1d4cca]={'$like':'%'+_0x125807[_0x3d52('0x34')][_0x3d52('0x58')]+'%'};return _0x2425ae;})});}_0x3ace61=_[_0x3d52('0x41')]({},_0x3ace61,_0x125807[_0x3d52('0x42')]);return db[_0x3d52('0x59')][_0x3d52('0x5a')](_0x3ace61);}})[_0x3d52('0x28')](function(_0x46274a){if(_0x46274a){return db[_0x3d52('0x5b')][_0x3d52('0x5c')]({'where':{'id':_[_0x3d52('0x2f')](_0x46274a,_0x3d52('0x5d')),'role':'agent'},'attributes':['id',_0x3d52('0x2d'),_0x3d52('0x5e'),_0x3d52('0x5f'),_0x3d52('0x60')]});}})[_0x3d52('0x28')](function(_0x479b36){if(_0x479b36){return{'count':_0x479b36[_0x3d52('0x21')],'rows':_[_0x3d52('0x2f')](_0x479b36[_0x3d52('0x44')],function(_0x3f8acf){return{'membername':_0x3f8acf[_0x3d52('0x2d')],'UserId':_0x3f8acf['id'],'queue_name':_0x444296[_0x3d52('0x2d')],'MailQueueId':_0x444296['id'],'interface':util['format'](_0x3d52('0x61'),_0x3d52('0x62'),_0x3f8acf['name']),'penalty':0x0,'paused':_0x3f8acf[_0x3d52('0x5e')],'createdAt':_0x3f8acf['createdAt'],'updatedAt':_0x3f8acf[_0x3d52('0x5f')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x3d52('0x28')](respondWithFilteredResult(_0x3b1d34,_0x3ace61))[_0x3d52('0x45')](handleError(_0x3b1d34,null));};exports['getTeams']=function(_0x423e34,_0x5b6e78,_0x2a6ebe){var _0x56f690={};var _0x4120bc={};var _0x13b464;var _0x574f4e;return db[_0x3d52('0x43')][_0x3d52('0x54')]({'where':{'id':_0x423e34['params']['id']}})['then'](handleEntityNotFound(_0x5b6e78,null))[_0x3d52('0x28')](function(_0x3803cf){if(_0x3803cf){_0x13b464=_0x3803cf;_0x4120bc[_0x3d52('0x33')]=_[_0x3d52('0x35')](db[_0x3d52('0x63')]['rawAttributes']);_0x4120bc[_0x3d52('0x34')]=_[_0x3d52('0x35')](_0x423e34['query']);_0x4120bc[_0x3d52('0x36')]=_[_0x3d52('0x38')](_0x4120bc['model'],_0x4120bc[_0x3d52('0x34')]);_0x56f690[_0x3d52('0x37')]=_['intersection'](_0x4120bc[_0x3d52('0x33')],qs['fields'](_0x423e34['query'][_0x3d52('0x39')]));_0x56f690[_0x3d52('0x37')]=_0x56f690['attributes'][_0x3d52('0x3a')]?_0x56f690['attributes']:_0x4120bc['model'];_0x56f690[_0x3d52('0x56')]=qs['sort'](_0x423e34['query']['sort']);_0x56f690['where']=qs[_0x3d52('0x36')](_[_0x3d52('0x3f')](_0x423e34[_0x3d52('0x34')],_0x4120bc[_0x3d52('0x36')]));if(_0x423e34[_0x3d52('0x34')][_0x3d52('0x58')]){_0x56f690[_0x3d52('0x3e')]=_[_0x3d52('0x41')](_0x56f690[_0x3d52('0x3e')],{'$or':_[_0x3d52('0x2f')](_0x56f690['attributes'],function(_0x27ce20){var _0x4d74ef={};_0x4d74ef[_0x27ce20]={'$like':'%'+_0x423e34[_0x3d52('0x34')][_0x3d52('0x58')]+'%'};return _0x4d74ef;})});}_0x56f690=_[_0x3d52('0x41')]({},_0x56f690,_0x423e34[_0x3d52('0x42')]);return _0x13b464['getTeams'](_0x56f690);}})[_0x3d52('0x28')](function(_0x2c6c44){if(_0x2c6c44){_0x574f4e=_0x2c6c44['length'];if(!_0x423e34[_0x3d52('0x34')]['hasOwnProperty']('nolimit')){_0x56f690[_0x3d52('0x3c')]=qs[_0x3d52('0x3c')](_0x423e34['query'][_0x3d52('0x3c')]);_0x56f690[_0x3d52('0x22')]=qs[_0x3d52('0x22')](_0x423e34['query'][_0x3d52('0x22')]);}return _0x13b464[_0x3d52('0x64')](_0x56f690);}})[_0x3d52('0x28')](function(_0x56204f){if(_0x56204f){return _0x56204f?{'count':_0x574f4e,'rows':_0x56204f}:null;}})['then'](respondWithResult(_0x5b6e78,null))['catch'](handleError(_0x5b6e78,null));};exports['addTeams']=function(_0x1eeed3,_0x30b73a,_0x6901eb){var _0x481ada=_0x1eeed3[_0x3d52('0x4b')]['ids'];return db[_0x3d52('0x63')]['findAll']({'where':{'id':_0x481ada},'attributes':['id'],'include':[{'model':db[_0x3d52('0x5b')],'as':'Agents','attributes':['id',_0x3d52('0x2d'),_0x3d52('0x65'),_0x3d52('0x66'),_0x3d52('0x67')],'raw':!![]}]})[_0x3d52('0x28')](function(_0x2c7ad1){if(_0x2c7ad1){var _0x2d3189=_['flatMap'](_0x2c7ad1,function(_0x41bb03){var _0x27f7af=_0x41bb03[_0x3d52('0x2a')]({'plain':!![]});return _0x27f7af['Agents'];});return db[_0x3d52('0x43')][_0x3d52('0x49')]({'where':{'id':_0x1eeed3[_0x3d52('0x47')]['id']}})[_0x3d52('0x28')](function(_0x362d5a){return db[_0x3d52('0x68')][_0x3d52('0x69')](function(_0x10cb0e){return _0x362d5a['addTeams'](_0x481ada,{'transaction':_0x10cb0e})[_0x3d52('0x28')](function(){return BPromise['each'](_0x2d3189,function(_0x2be64e){return db[_0x3d52('0x59')][_0x3d52('0x6a')]({'where':{'UserId':_0x2be64e['id'],'MailQueueId':_0x1eeed3['params']['id']},'transaction':_0x10cb0e});});})['then'](function(){_0x2d3189[_0x3d52('0x6b')](function(_0x530b79){socket[_0x3d52('0x6c')](_0x3d52('0x6d'),{'UserId':_0x530b79['id'],'MailQueueId':_0x362d5a['id']});});});});});}})[_0x3d52('0x28')](respondWithStatusCode(_0x30b73a,null))['catch'](handleError(_0x30b73a,null));};exports[_0x3d52('0x6e')]=function(_0xc4eaad,_0x3dae37,_0x41d3e0){return db[_0x3d52('0x63')][_0x3d52('0x5a')]({'where':{'id':_0xc4eaad['query'][_0x3d52('0x6f')]},'attributes':['id'],'include':[{'model':db[_0x3d52('0x5b')],'as':_0x3d52('0x70'),'attributes':['id'],'raw':!![]}]})[_0x3d52('0x28')](handleEntityNotFound(_0x3dae37,null))[_0x3d52('0x28')](function(_0x5bd92b){var _0x300fab=_[_0x3d52('0x2f')](_0x5bd92b,'id');var _0x2f953d=[];var _0x598d4d=[];var _0x26a581=squel['select']();_0x26a581[_0x3d52('0x71')](_0x3d52('0x72'))['from'](_0x3d52('0x73'),'tq')[_0x3d52('0x74')](_0x3d52('0x75'),'ut',_0x3d52('0x76'))[_0x3d52('0x3e')]('MailQueueId\x20=\x20?',_0xc4eaad['params']['id']);for(var _0x33fc90=0x0;_0x33fc90<_0x5bd92b[_0x3d52('0x3a')];_0x33fc90+=0x1){let _0x19263b=_0x5bd92b[_0x33fc90];for(var _0x4baf8f=0x0;_0x4baf8f<_0x19263b[_0x3d52('0x70')]['length'];_0x4baf8f+=0x1){let _0x51f1ad=_0x19263b['Agents'][_0x4baf8f];var _0x1d91d3=_0x26a581[_0x3d52('0x77')]();_0x1d91d3[_0x3d52('0x3e')]('ut.UserId\x20=\x20?',_0x51f1ad['id']);_0x598d4d[_0x3d52('0x78')](db[_0x3d52('0x68')]['query'](_0x1d91d3['toString'](),{'type':db[_0x3d52('0x68')][_0x3d52('0x79')][_0x3d52('0x7a')]})[_0x3d52('0x28')](function(_0x3df7b5){if(_0x3df7b5[_0x3d52('0x3a')]===0x1){return _0x51f1ad['id'];}else{var _0x3223f7=_[_0x3d52('0x7b')](_[_0x3d52('0x2f')](_0x3df7b5,_0x3d52('0x7c')),function(_0x3f14ac){return _['includes'](_0x300fab,_0x3f14ac);});if(_0x3223f7){return _0x51f1ad['id'];}}}));}}return BPromise[_0x3d52('0x7d')](_0x598d4d)[_0x3d52('0x28')](function(_0x44b6a9){_0x2f953d=_(_0x2f953d)[_0x3d52('0x7e')](_0x44b6a9)['compact']()[_0x3d52('0x7f')]();return db[_0x3d52('0x43')][_0x3d52('0x49')]({'where':{'id':_0xc4eaad[_0x3d52('0x47')]['id']}})[_0x3d52('0x28')](function(_0x4a40c4){return db[_0x3d52('0x68')]['transaction'](function(_0x5d5d2a){return _0x4a40c4[_0x3d52('0x6e')](_0xc4eaad[_0x3d52('0x34')][_0x3d52('0x6f')],{'transaction':_0x5d5d2a})[_0x3d52('0x28')](function(){if(!_[_0x3d52('0x80')](_0x2f953d)){return _0x4a40c4[_0x3d52('0x81')](_0x2f953d,{'transaction':_0x5d5d2a});}})[_0x3d52('0x28')](function(){_0x2f953d[_0x3d52('0x6b')](function(_0x2e141d){socket['emit'](_0x3d52('0x82'),{'UserId':_0x2e141d,'MailQueueId':_0x4a40c4['id']});});});});});});})['then'](respondWithStatusCode(_0x3dae37,null))['catch'](handleError(_0x3dae37,null));};exports[_0x3d52('0x83')]=function(_0x20d53c,_0x18a525,_0x5bad9d){return db[_0x3d52('0x43')][_0x3d52('0x49')]({'where':{'id':_0x20d53c[_0x3d52('0x47')]['id']}})[_0x3d52('0x28')](handleEntityNotFound(_0x18a525,null))[_0x3d52('0x28')](function(_0x5d3e81){if(_0x5d3e81){return _0x5d3e81['addAgents'](_0x20d53c['body'][_0x3d52('0x6f')],_['omit'](_0x20d53c['body'],['ids','id'])||{})[_0x3d52('0x84')](function(_0x22d78e){for(var _0x3b95eb=0x0;_0x3b95eb<_0x20d53c[_0x3d52('0x4b')][_0x3d52('0x6f')][_0x3d52('0x3a')];_0x3b95eb+=0x1){socket[_0x3d52('0x6c')](_0x3d52('0x6d'),{'UserId':_0x20d53c[_0x3d52('0x4b')][_0x3d52('0x6f')][_0x3b95eb],'MailQueueId':_0x20d53c[_0x3d52('0x47')]['id']});}return _0x22d78e;});}})[_0x3d52('0x28')](respondWithResult(_0x18a525,null))['catch'](handleError(_0x18a525,null));};exports['removeAgents']=function(_0x2b1df2,_0x53c3ad,_0x4f06d3){return db[_0x3d52('0x43')]['find']({'where':{'id':_0x2b1df2['params']['id']}})[_0x3d52('0x28')](handleEntityNotFound(_0x53c3ad,null))[_0x3d52('0x28')](function(_0x241836){if(_0x241836){return _0x241836[_0x3d52('0x81')](_0x2b1df2[_0x3d52('0x34')]['ids'])[_0x3d52('0x28')](function(){if(_['isArray'](_0x2b1df2[_0x3d52('0x34')]['ids'])){for(var _0x3d32a3=0x0;_0x3d32a3<_0x2b1df2[_0x3d52('0x34')]['ids'][_0x3d52('0x3a')];_0x3d32a3+=0x1){socket['emit'](_0x3d52('0x82'),{'UserId':Number(_0x2b1df2[_0x3d52('0x34')][_0x3d52('0x6f')][_0x3d32a3]),'MailQueueId':Number(_0x2b1df2[_0x3d52('0x47')]['id'])});}}else{socket[_0x3d52('0x6c')](_0x3d52('0x82'),{'UserId':Number(_0x2b1df2[_0x3d52('0x34')][_0x3d52('0x6f')]),'MailQueueId':Number(_0x2b1df2[_0x3d52('0x47')]['id'])});}});}})[_0x3d52('0x28')](respondWithStatusCode(_0x53c3ad,null))[_0x3d52('0x45')](handleError(_0x53c3ad,null));};exports[_0x3d52('0x85')]=function(_0x53cedc,_0x6140d2,_0xf10bc){var _0x3aaf66={};var _0x153865={};var _0x4fc680;var _0xf59ee;return db[_0x3d52('0x43')][_0x3d52('0x54')]({'where':{'id':_0x53cedc[_0x3d52('0x47')]['id']}})['then'](handleEntityNotFound(_0x6140d2,null))[_0x3d52('0x28')](function(_0x52722c){if(_0x52722c){_0x4fc680=_0x52722c;_0x153865[_0x3d52('0x33')]=_['keys'](db[_0x3d52('0x5b')]['rawAttributes']);_0x153865[_0x3d52('0x34')]=_[_0x3d52('0x35')](_0x53cedc[_0x3d52('0x34')]);_0x153865['filters']=_[_0x3d52('0x38')](_0x153865[_0x3d52('0x33')],_0x153865['query']);_0x3aaf66[_0x3d52('0x37')]=_[_0x3d52('0x38')](_0x153865[_0x3d52('0x33')],qs[_0x3d52('0x39')](_0x53cedc[_0x3d52('0x34')][_0x3d52('0x39')]));_0x3aaf66[_0x3d52('0x37')]=_0x3aaf66[_0x3d52('0x37')]['length']?_0x3aaf66[_0x3d52('0x37')]:_0x153865[_0x3d52('0x33')];_0x3aaf66['order']=qs[_0x3d52('0x3d')](_0x53cedc[_0x3d52('0x34')][_0x3d52('0x3d')]);_0x3aaf66[_0x3d52('0x3e')]=qs[_0x3d52('0x36')](_[_0x3d52('0x3f')](_0x53cedc[_0x3d52('0x34')],_0x153865[_0x3d52('0x36')]));if(_0x53cedc[_0x3d52('0x34')][_0x3d52('0x58')]){_0x3aaf66[_0x3d52('0x3e')]=_['merge'](_0x3aaf66[_0x3d52('0x3e')],{'$or':_[_0x3d52('0x2f')](_0x3aaf66[_0x3d52('0x37')],function(_0xafba2b){var _0x33e299={};_0x33e299[_0xafba2b]={'$like':'%'+_0x53cedc[_0x3d52('0x34')]['filter']+'%'};return _0x33e299;})});}_0x3aaf66=_[_0x3d52('0x41')]({},_0x3aaf66,_0x53cedc['options']);return _0x4fc680[_0x3d52('0x85')](_0x3aaf66);}})[_0x3d52('0x28')](function(_0x361b34){if(_0x361b34){_0xf59ee=_0x361b34['length'];if(!_0x53cedc[_0x3d52('0x34')][_0x3d52('0x3b')](_0x3d52('0x55'))){_0x3aaf66[_0x3d52('0x3c')]=qs['limit'](_0x53cedc['query']['limit']);_0x3aaf66[_0x3d52('0x22')]=qs[_0x3d52('0x22')](_0x53cedc[_0x3d52('0x34')][_0x3d52('0x22')]);}return _0x4fc680['getAgents'](_0x3aaf66);}})['then'](function(_0x4c34e8){if(_0x4c34e8){return _0x4c34e8?{'count':_0xf59ee,'rows':_0x4c34e8}:null;}})[_0x3d52('0x28')](respondWithResult(_0x6140d2,null))['catch'](handleError(_0x6140d2,null));};
\ No newline at end of file