Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 7c8cad5..496f0ac 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 _0x3f48=['socket.io-emitter','./mailQueue.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','get','MailQueues','UserProfileResource','error','send','index','map','MailQueue','rawAttributes','type','model','name','keys','query','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','options','includeAll','include','rows','catch','show','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','UserMailQueue','MailQueueId','merge','findAll','User','findAndCountAll','updatedAt','createdAt','format','%s/%s','mailPause','getTeams','findOne','Team','ids','Agents','flatMap','transaction','addTeams','each','findOrCreate','forEach','emit','userMailQueue:save','tq.TeamId','from','team_has_mail_queues','join','user_has_teams','MailQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','QueryTypes','every','TeamId','includes','all','compact','value','isEmpty','removeAgents','addAgents','omit','spread','isArray','userMailQueue:remove','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','defaults','redis','localhost'];(function(_0x7200b4,_0x3c4b55){var _0xb19924=function(_0x3430b3){while(--_0x3430b3){_0x7200b4['push'](_0x7200b4['shift']());}};_0xb19924(++_0x3c4b55);}(_0x3f48,0x17c));var _0x83f4=function(_0x26b98a,_0x24ee21){_0x26b98a=_0x26b98a-0x0;var _0x5bc294=_0x3f48[_0x26b98a];return _0x5bc294;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x83f4('0x0'));var zipdir=require(_0x83f4('0x1'));var jsonpatch=require(_0x83f4('0x2'));var rp=require(_0x83f4('0x3'));var moment=require('moment');var BPromise=require(_0x83f4('0x4'));var Mustache=require(_0x83f4('0x5'));var util=require('util');var path=require(_0x83f4('0x6'));var sox=require('sox');var csv=require(_0x83f4('0x7'));var ejs=require(_0x83f4('0x8'));var fs=require('fs');var _=require(_0x83f4('0x9'));var squel=require(_0x83f4('0xa'));var crypto=require(_0x83f4('0xb'));var jsforce=require(_0x83f4('0xc'));var deskjs=require(_0x83f4('0xd'));var toCsv=require(_0x83f4('0x7'));var querystring=require('querystring');var Papa=require(_0x83f4('0xe'));var Redis=require(_0x83f4('0xf'));var authService=require(_0x83f4('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x83f4('0x11'))(_0x83f4('0x12'));var utils=require(_0x83f4('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0x83f4('0x14'));var db=require(_0x83f4('0x15'))['db'];config['redis']=_[_0x83f4('0x16')](config[_0x83f4('0x17')],{'host':_0x83f4('0x18'),'port':0x18eb});var socket=require(_0x83f4('0x19'))(new Redis(config[_0x83f4('0x17')]));require(_0x83f4('0x1a'))[_0x83f4('0x1b')](socket);function respondWithStatusCode(_0x48944b,_0x310374){_0x310374=_0x310374||0xcc;return function(_0x18c56d){if(_0x18c56d){return _0x48944b[_0x83f4('0x1c')](_0x310374);}return _0x48944b[_0x83f4('0x1d')](_0x310374)[_0x83f4('0x1e')]();};}function respondWithResult(_0x11dc6d,_0x4f0f62){_0x4f0f62=_0x4f0f62||0xc8;return function(_0x1b5626){if(_0x1b5626){return _0x11dc6d[_0x83f4('0x1d')](_0x4f0f62)[_0x83f4('0x1f')](_0x1b5626);}};}function respondWithFilteredResult(_0x202511,_0x10f04c){return function(_0x5db794){if(_0x5db794){var _0x1b4702=_0x5db794[_0x83f4('0x20')],_0x495305=_0x10f04c[_0x83f4('0x21')],_0x302089=_0x10f04c[_0x83f4('0x21')]+_0x10f04c[_0x83f4('0x22')],_0x3b08d8;if(_0x302089>=_0x1b4702){_0x302089=_0x1b4702;_0x3b08d8=0xc8;}else{_0x3b08d8=0xce;}_0x202511['status'](_0x3b08d8);return _0x202511[_0x83f4('0x23')](_0x83f4('0x24'),_0x495305+'-'+_0x302089+'/'+_0x1b4702)[_0x83f4('0x1f')](_0x5db794);}return null;};}function patchUpdates(_0x3e70ff){return function(_0x5bb5f1){try{jsonpatch['apply'](_0x5bb5f1,_0x3e70ff,!![]);}catch(_0x2522da){return BPromise[_0x83f4('0x25')](_0x2522da);}return _0x5bb5f1[_0x83f4('0x26')]();};}function saveUpdates(_0x3cfc10,_0x487262){return function(_0x362b6b){if(_0x362b6b){return _0x362b6b[_0x83f4('0x27')](_0x3cfc10)[_0x83f4('0x28')](function(_0x10c3b8){return _0x10c3b8;});}return null;};}function removeEntity(_0x5e4f28,_0x1ff942){return function(_0x570ec3){if(_0x570ec3){return _0x570ec3[_0x83f4('0x29')]()[_0x83f4('0x28')](function(){var _0x224d63=_0x570ec3[_0x83f4('0x2a')]({'plain':!![]});var _0x27623d=_0x83f4('0x2b');return db[_0x83f4('0x2c')][_0x83f4('0x29')]({'where':{'type':_0x27623d,'resourceId':_0x224d63['id']}})[_0x83f4('0x28')](function(){return _0x570ec3;});})[_0x83f4('0x28')](function(){_0x5e4f28[_0x83f4('0x1d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2530be,_0x4eeab6){return function(_0x5d260d){if(!_0x5d260d){_0x2530be[_0x83f4('0x1c')](0x194);}return _0x5d260d;};}function handleError(_0x5f17f5,_0x250693){_0x250693=_0x250693||0x1f4;return function(_0xbc819e){logger[_0x83f4('0x2d')](_0xbc819e['stack']);if(_0xbc819e['name']){delete _0xbc819e['name'];}_0x5f17f5[_0x83f4('0x1d')](_0x250693)[_0x83f4('0x2e')](_0xbc819e);};}exports[_0x83f4('0x2f')]=function(_0x1b48fa,_0x57fd72){var _0x29350b={},_0xb60421={},_0x28521e={'count':0x0,'rows':[]};var _0x14f6b8=_[_0x83f4('0x30')](db[_0x83f4('0x31')][_0x83f4('0x32')],function(_0x162f06){return{'name':_0x162f06['fieldName'],'type':_0x162f06[_0x83f4('0x33')]['key']};});_0xb60421[_0x83f4('0x34')]=_['map'](_0x14f6b8,_0x83f4('0x35'));_0xb60421['query']=_[_0x83f4('0x36')](_0x1b48fa[_0x83f4('0x37')]);_0xb60421['filters']=_[_0x83f4('0x38')](_0xb60421['model'],_0xb60421[_0x83f4('0x37')]);_0x29350b['attributes']=_[_0x83f4('0x38')](_0xb60421['model'],qs[_0x83f4('0x39')](_0x1b48fa[_0x83f4('0x37')][_0x83f4('0x39')]));_0x29350b[_0x83f4('0x3a')]=_0x29350b[_0x83f4('0x3a')][_0x83f4('0x3b')]?_0x29350b['attributes']:_0xb60421[_0x83f4('0x34')];if(!_0x1b48fa[_0x83f4('0x37')][_0x83f4('0x3c')](_0x83f4('0x3d'))){_0x29350b[_0x83f4('0x22')]=qs[_0x83f4('0x22')](_0x1b48fa[_0x83f4('0x37')][_0x83f4('0x22')]);_0x29350b[_0x83f4('0x21')]=qs[_0x83f4('0x21')](_0x1b48fa[_0x83f4('0x37')][_0x83f4('0x21')]);}_0x29350b[_0x83f4('0x3e')]=qs[_0x83f4('0x3f')](_0x1b48fa[_0x83f4('0x37')][_0x83f4('0x3f')]);_0x29350b[_0x83f4('0x40')]=qs[_0x83f4('0x41')](_[_0x83f4('0x42')](_0x1b48fa[_0x83f4('0x37')],_0xb60421[_0x83f4('0x41')]),_0x14f6b8);if(_0x1b48fa['query'][_0x83f4('0x43')]){_0x29350b['where']=_['merge'](_0x29350b[_0x83f4('0x40')],{'$or':_[_0x83f4('0x30')](_0x14f6b8,function(_0x452cc6){if(_0x452cc6[_0x83f4('0x33')]!=='VIRTUAL'){var _0x20566f={};_0x20566f[_0x452cc6[_0x83f4('0x35')]]={'$like':'%'+_0x1b48fa[_0x83f4('0x37')][_0x83f4('0x43')]+'%'};return _0x20566f;}})});}_0x29350b=_['merge']({},_0x29350b,_0x1b48fa[_0x83f4('0x44')]);var _0x24b091={'where':_0x29350b[_0x83f4('0x40')]};return db[_0x83f4('0x31')][_0x83f4('0x20')](_0x24b091)[_0x83f4('0x28')](function(_0x3bbdae){_0x28521e[_0x83f4('0x20')]=_0x3bbdae;if(_0x1b48fa['query'][_0x83f4('0x45')]){_0x29350b[_0x83f4('0x46')]=[{'all':!![]}];}return db['MailQueue']['findAll'](_0x29350b);})[_0x83f4('0x28')](function(_0x39a9a9){_0x28521e[_0x83f4('0x47')]=_0x39a9a9;return _0x28521e;})[_0x83f4('0x28')](respondWithFilteredResult(_0x57fd72,_0x29350b))[_0x83f4('0x48')](handleError(_0x57fd72,null));};exports[_0x83f4('0x49')]=function(_0x205881,_0x3564ce){var _0x543974={'raw':!![],'where':{'id':_0x205881['params']['id']}},_0x8a0029={};_0x8a0029[_0x83f4('0x34')]=_[_0x83f4('0x36')](db[_0x83f4('0x31')][_0x83f4('0x32')]);_0x8a0029[_0x83f4('0x37')]=_['keys'](_0x205881['query']);_0x8a0029[_0x83f4('0x41')]=_[_0x83f4('0x38')](_0x8a0029[_0x83f4('0x34')],_0x8a0029[_0x83f4('0x37')]);_0x543974[_0x83f4('0x3a')]=_['intersection'](_0x8a0029[_0x83f4('0x34')],qs[_0x83f4('0x39')](_0x205881[_0x83f4('0x37')][_0x83f4('0x39')]));_0x543974[_0x83f4('0x3a')]=_0x543974['attributes'][_0x83f4('0x3b')]?_0x543974[_0x83f4('0x3a')]:_0x8a0029[_0x83f4('0x34')];if(_0x205881['query'][_0x83f4('0x45')]){_0x543974['include']=[{'all':!![]}];}_0x543974=_['merge']({},_0x543974,_0x205881['options']);return db[_0x83f4('0x31')][_0x83f4('0x4a')](_0x543974)[_0x83f4('0x28')](handleEntityNotFound(_0x3564ce,null))[_0x83f4('0x28')](respondWithResult(_0x3564ce,null))[_0x83f4('0x48')](handleError(_0x3564ce,null));};exports[_0x83f4('0x4b')]=function(_0x48d265,_0xa35ad9){return db[_0x83f4('0x31')][_0x83f4('0x4b')](_0x48d265[_0x83f4('0x4c')],{})['then'](function(_0x47bb2d){var _0x49e769=_0x48d265[_0x83f4('0x4d')][_0x83f4('0x2a')]({'plain':!![]});if(!_0x49e769)throw new Error(_0x83f4('0x4e'));if(_0x49e769[_0x83f4('0x4f')]==='user'){var _0x3d5d61=_0x47bb2d[_0x83f4('0x2a')]({'plain':!![]});var _0x5e4d7b='MailQueues';return db[_0x83f4('0x50')][_0x83f4('0x4a')]({'where':{'name':_0x5e4d7b,'userProfileId':_0x49e769['userProfileId']},'raw':!![]})[_0x83f4('0x28')](function(_0x1bfd81){if(_0x1bfd81&&_0x1bfd81[_0x83f4('0x51')]===0x0){return db['UserProfileResource'][_0x83f4('0x4b')]({'name':_0x3d5d61[_0x83f4('0x35')],'resourceId':_0x3d5d61['id'],'type':_0x1bfd81[_0x83f4('0x35')],'sectionId':_0x1bfd81['id']},{})[_0x83f4('0x28')](function(){return _0x47bb2d;});}else{return _0x47bb2d;}})[_0x83f4('0x48')](function(_0x2e2b2f){logger[_0x83f4('0x2d')](_0x83f4('0x52'),_0x2e2b2f);throw _0x2e2b2f;});}return _0x47bb2d;})['then'](respondWithResult(_0xa35ad9,0xc9))['catch'](handleError(_0xa35ad9,null));};exports[_0x83f4('0x27')]=function(_0x113590,_0xfce4a4){if(_0x113590[_0x83f4('0x4c')]['id']){delete _0x113590['body']['id'];}return db[_0x83f4('0x31')][_0x83f4('0x4a')]({'where':{'id':_0x113590['params']['id']}})['then'](handleEntityNotFound(_0xfce4a4,null))['then'](saveUpdates(_0x113590[_0x83f4('0x4c')],null))[_0x83f4('0x28')](respondWithResult(_0xfce4a4,null))[_0x83f4('0x48')](handleError(_0xfce4a4,null));};exports[_0x83f4('0x29')]=function(_0x272691,_0x4af554){return db[_0x83f4('0x31')][_0x83f4('0x4a')]({'where':{'id':_0x272691[_0x83f4('0x53')]['id']}})['then'](handleEntityNotFound(_0x4af554,null))[_0x83f4('0x28')](removeEntity(_0x4af554,null))[_0x83f4('0x48')](handleError(_0x4af554,null));};exports[_0x83f4('0x54')]=function(_0x5f25a1,_0x587b02){return db[_0x83f4('0x31')][_0x83f4('0x54')]()['then'](respondWithResult(_0x587b02,null))[_0x83f4('0x48')](handleError(_0x587b02,null));};exports[_0x83f4('0x55')]=function(_0x2e84db,_0x52888b,_0x360396){var _0x42a1ea={'raw':!![],'where':{}},_0x301292={},_0x552621;return db[_0x83f4('0x31')]['findOne']({'where':{'id':_0x2e84db[_0x83f4('0x53')]['id']}})[_0x83f4('0x28')](handleEntityNotFound(_0x52888b,null))[_0x83f4('0x28')](function(_0x36b804){if(_0x36b804){_0x552621=_0x36b804[_0x83f4('0x2a')]({'plain':!![]});_0x301292[_0x83f4('0x34')]=_[_0x83f4('0x36')](db[_0x83f4('0x56')][_0x83f4('0x32')]);_0x301292[_0x83f4('0x37')]=_[_0x83f4('0x36')](_0x2e84db[_0x83f4('0x37')]);_0x301292[_0x83f4('0x41')]=_['intersection'](_0x301292[_0x83f4('0x34')],_0x301292['query']);_0x42a1ea['attributes']=_[_0x83f4('0x38')](_0x301292[_0x83f4('0x34')],qs['fields'](_0x2e84db[_0x83f4('0x37')][_0x83f4('0x39')]));_0x42a1ea[_0x83f4('0x3a')]=_0x42a1ea[_0x83f4('0x3a')]['length']?_0x42a1ea[_0x83f4('0x3a')]:_0x301292[_0x83f4('0x34')];if(!_0x2e84db[_0x83f4('0x37')][_0x83f4('0x3c')](_0x83f4('0x3d'))){_0x42a1ea[_0x83f4('0x22')]=qs[_0x83f4('0x22')](_0x2e84db[_0x83f4('0x37')][_0x83f4('0x22')]);_0x42a1ea['offset']=qs[_0x83f4('0x21')](_0x2e84db['query'][_0x83f4('0x21')]);}_0x42a1ea[_0x83f4('0x3e')]=qs[_0x83f4('0x3f')](_0x2e84db[_0x83f4('0x37')]['sort']);_0x42a1ea['where']=qs[_0x83f4('0x41')](_[_0x83f4('0x42')](_0x2e84db[_0x83f4('0x37')],_0x301292[_0x83f4('0x41')]));_0x42a1ea[_0x83f4('0x40')][_0x83f4('0x57')]=_0x36b804['id'];if(_0x2e84db[_0x83f4('0x37')][_0x83f4('0x43')]){_0x42a1ea[_0x83f4('0x40')]=_[_0x83f4('0x58')](_0x42a1ea[_0x83f4('0x40')],{'$or':_[_0x83f4('0x30')](_0x42a1ea[_0x83f4('0x3a')],function(_0x3b1a50){var _0xfa522c={};_0xfa522c[_0x3b1a50]={'$like':'%'+_0x2e84db['query'][_0x83f4('0x43')]+'%'};return _0xfa522c;})});}_0x42a1ea=_[_0x83f4('0x58')]({},_0x42a1ea,_0x2e84db[_0x83f4('0x44')]);return db[_0x83f4('0x56')][_0x83f4('0x59')](_0x42a1ea);}})[_0x83f4('0x28')](function(_0x4e9096){if(_0x4e9096){return db[_0x83f4('0x5a')][_0x83f4('0x5b')]({'where':{'id':_[_0x83f4('0x30')](_0x4e9096,'UserId'),'role':'agent'},'attributes':['id',_0x83f4('0x35'),'mailPause',_0x83f4('0x5c'),_0x83f4('0x5d')]});}})['then'](function(_0x299552){if(_0x299552){return{'count':_0x299552[_0x83f4('0x20')],'rows':_[_0x83f4('0x30')](_0x299552[_0x83f4('0x47')],function(_0x1312fb){return{'membername':_0x1312fb[_0x83f4('0x35')],'UserId':_0x1312fb['id'],'queue_name':_0x552621[_0x83f4('0x35')],'MailQueueId':_0x552621['id'],'interface':util[_0x83f4('0x5e')](_0x83f4('0x5f'),'SIP',_0x1312fb[_0x83f4('0x35')]),'penalty':0x0,'paused':_0x1312fb[_0x83f4('0x60')],'createdAt':_0x1312fb['createdAt'],'updatedAt':_0x1312fb['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x83f4('0x28')](respondWithFilteredResult(_0x52888b,_0x42a1ea))[_0x83f4('0x48')](handleError(_0x52888b,null));};exports[_0x83f4('0x61')]=function(_0x44c26f,_0x4d518e,_0x1b3666){var _0xca39ce={};var _0x259fa2={};var _0x12efd8;var _0x5a88c8;return db[_0x83f4('0x31')][_0x83f4('0x62')]({'where':{'id':_0x44c26f[_0x83f4('0x53')]['id']}})[_0x83f4('0x28')](handleEntityNotFound(_0x4d518e,null))['then'](function(_0xa337a1){if(_0xa337a1){_0x12efd8=_0xa337a1;_0x259fa2[_0x83f4('0x34')]=_[_0x83f4('0x36')](db[_0x83f4('0x63')][_0x83f4('0x32')]);_0x259fa2[_0x83f4('0x37')]=_[_0x83f4('0x36')](_0x44c26f['query']);_0x259fa2[_0x83f4('0x41')]=_[_0x83f4('0x38')](_0x259fa2[_0x83f4('0x34')],_0x259fa2['query']);_0xca39ce[_0x83f4('0x3a')]=_[_0x83f4('0x38')](_0x259fa2[_0x83f4('0x34')],qs[_0x83f4('0x39')](_0x44c26f[_0x83f4('0x37')][_0x83f4('0x39')]));_0xca39ce[_0x83f4('0x3a')]=_0xca39ce['attributes'][_0x83f4('0x3b')]?_0xca39ce[_0x83f4('0x3a')]:_0x259fa2[_0x83f4('0x34')];_0xca39ce[_0x83f4('0x3e')]=qs['sort'](_0x44c26f[_0x83f4('0x37')][_0x83f4('0x3f')]);_0xca39ce[_0x83f4('0x40')]=qs['filters'](_['pick'](_0x44c26f['query'],_0x259fa2[_0x83f4('0x41')]));if(_0x44c26f['query']['filter']){_0xca39ce[_0x83f4('0x40')]=_[_0x83f4('0x58')](_0xca39ce[_0x83f4('0x40')],{'$or':_[_0x83f4('0x30')](_0xca39ce[_0x83f4('0x3a')],function(_0x44202a){var _0x2a42dd={};_0x2a42dd[_0x44202a]={'$like':'%'+_0x44c26f[_0x83f4('0x37')][_0x83f4('0x43')]+'%'};return _0x2a42dd;})});}_0xca39ce=_['merge']({},_0xca39ce,_0x44c26f[_0x83f4('0x44')]);return _0x12efd8[_0x83f4('0x61')](_0xca39ce);}})[_0x83f4('0x28')](function(_0x3a1355){if(_0x3a1355){_0x5a88c8=_0x3a1355[_0x83f4('0x3b')];if(!_0x44c26f[_0x83f4('0x37')][_0x83f4('0x3c')]('nolimit')){_0xca39ce[_0x83f4('0x22')]=qs[_0x83f4('0x22')](_0x44c26f[_0x83f4('0x37')][_0x83f4('0x22')]);_0xca39ce['offset']=qs['offset'](_0x44c26f['query']['offset']);}return _0x12efd8[_0x83f4('0x61')](_0xca39ce);}})[_0x83f4('0x28')](function(_0x49f63e){if(_0x49f63e){return _0x49f63e?{'count':_0x5a88c8,'rows':_0x49f63e}:null;}})[_0x83f4('0x28')](respondWithResult(_0x4d518e,null))[_0x83f4('0x48')](handleError(_0x4d518e,null));};exports['addTeams']=function(_0x1b381c,_0x19d65e,_0x13035c){var _0x40100c=_0x1b381c[_0x83f4('0x4c')][_0x83f4('0x64')];return db[_0x83f4('0x63')][_0x83f4('0x59')]({'where':{'id':_0x40100c},'attributes':['id'],'include':[{'model':db[_0x83f4('0x5a')],'as':_0x83f4('0x65'),'attributes':['id',_0x83f4('0x35'),'online','voicePause','interface'],'raw':!![]}]})['then'](function(_0x553e09){if(_0x553e09){var _0x538fbb=_[_0x83f4('0x66')](_0x553e09,function(_0x385816){var _0x1f1245=_0x385816[_0x83f4('0x2a')]({'plain':!![]});return _0x1f1245[_0x83f4('0x65')];});return db[_0x83f4('0x31')]['find']({'where':{'id':_0x1b381c[_0x83f4('0x53')]['id']}})[_0x83f4('0x28')](function(_0xb8f2c4){return db['sequelize'][_0x83f4('0x67')](function(_0x571032){return _0xb8f2c4[_0x83f4('0x68')](_0x40100c,{'transaction':_0x571032})[_0x83f4('0x28')](function(){return BPromise[_0x83f4('0x69')](_0x538fbb,function(_0x2b3201){return db[_0x83f4('0x56')][_0x83f4('0x6a')]({'where':{'UserId':_0x2b3201['id'],'MailQueueId':_0x1b381c[_0x83f4('0x53')]['id']},'transaction':_0x571032});});})['then'](function(){_0x538fbb[_0x83f4('0x6b')](function(_0x5cf383){socket[_0x83f4('0x6c')](_0x83f4('0x6d'),{'UserId':_0x5cf383['id'],'MailQueueId':_0xb8f2c4['id']});});});});});}})[_0x83f4('0x28')](respondWithStatusCode(_0x19d65e,null))[_0x83f4('0x48')](handleError(_0x19d65e,null));};exports['removeTeams']=function(_0x58156e,_0x5d75e0,_0x475dfd){return db[_0x83f4('0x63')][_0x83f4('0x59')]({'where':{'id':_0x58156e[_0x83f4('0x37')]['ids']},'attributes':['id'],'include':[{'model':db[_0x83f4('0x5a')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x5d75e0,null))[_0x83f4('0x28')](function(_0x2cc4b7){var _0x46247b=_[_0x83f4('0x30')](_0x2cc4b7,'id');var _0x513e9f=[];var _0xa6afd=[];var _0x12b7fd=squel['select']();_0x12b7fd['field'](_0x83f4('0x6e'))[_0x83f4('0x6f')](_0x83f4('0x70'),'tq')[_0x83f4('0x71')](_0x83f4('0x72'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x83f4('0x40')](_0x83f4('0x73'),_0x58156e[_0x83f4('0x53')]['id']);for(var _0x331b4a=0x0;_0x331b4a<_0x2cc4b7[_0x83f4('0x3b')];_0x331b4a+=0x1){let _0x2d755a=_0x2cc4b7[_0x331b4a];for(var _0x59acd4=0x0;_0x59acd4<_0x2d755a[_0x83f4('0x65')][_0x83f4('0x3b')];_0x59acd4+=0x1){let _0x24e3d3=_0x2d755a[_0x83f4('0x65')][_0x59acd4];var _0xbfa991=_0x12b7fd[_0x83f4('0x74')]();_0xbfa991[_0x83f4('0x40')](_0x83f4('0x75'),_0x24e3d3['id']);_0xa6afd[_0x83f4('0x76')](db['sequelize']['query'](_0xbfa991['toString'](),{'type':db[_0x83f4('0x77')][_0x83f4('0x78')]['SELECT']})[_0x83f4('0x28')](function(_0xbb170d){if(_0xbb170d['length']===0x1){return _0x24e3d3['id'];}else{var _0x2a2499=_[_0x83f4('0x79')](_[_0x83f4('0x30')](_0xbb170d,_0x83f4('0x7a')),function(_0x5f2bee){return _[_0x83f4('0x7b')](_0x46247b,_0x5f2bee);});if(_0x2a2499){return _0x24e3d3['id'];}}}));}}return BPromise[_0x83f4('0x7c')](_0xa6afd)[_0x83f4('0x28')](function(_0x22aef0){_0x513e9f=_(_0x513e9f)['union'](_0x22aef0)[_0x83f4('0x7d')]()[_0x83f4('0x7e')]();return db['MailQueue'][_0x83f4('0x4a')]({'where':{'id':_0x58156e[_0x83f4('0x53')]['id']}})[_0x83f4('0x28')](function(_0x57007f){return db[_0x83f4('0x77')][_0x83f4('0x67')](function(_0x4e9aaf){return _0x57007f['removeTeams'](_0x58156e[_0x83f4('0x37')][_0x83f4('0x64')],{'transaction':_0x4e9aaf})[_0x83f4('0x28')](function(){if(!_[_0x83f4('0x7f')](_0x513e9f)){return _0x57007f[_0x83f4('0x80')](_0x513e9f,{'transaction':_0x4e9aaf});}})[_0x83f4('0x28')](function(){_0x513e9f['forEach'](function(_0x3248e4){socket['emit']('userMailQueue:remove',{'UserId':_0x3248e4,'MailQueueId':_0x57007f['id']});});});});});});})[_0x83f4('0x28')](respondWithStatusCode(_0x5d75e0,null))[_0x83f4('0x48')](handleError(_0x5d75e0,null));};exports[_0x83f4('0x81')]=function(_0x236535,_0x4cf16c,_0x10ac91){return db[_0x83f4('0x31')][_0x83f4('0x4a')]({'where':{'id':_0x236535[_0x83f4('0x53')]['id']}})[_0x83f4('0x28')](handleEntityNotFound(_0x4cf16c,null))[_0x83f4('0x28')](function(_0x3dea5f){if(_0x3dea5f){return _0x3dea5f[_0x83f4('0x81')](_0x236535[_0x83f4('0x4c')][_0x83f4('0x64')],_[_0x83f4('0x82')](_0x236535['body'],['ids','id'])||{})[_0x83f4('0x83')](function(_0x4d2276){for(var _0x368063=0x0;_0x368063<_0x236535[_0x83f4('0x4c')][_0x83f4('0x64')][_0x83f4('0x3b')];_0x368063+=0x1){socket['emit']('userMailQueue:save',{'UserId':_0x236535[_0x83f4('0x4c')][_0x83f4('0x64')][_0x368063],'MailQueueId':_0x236535[_0x83f4('0x53')]['id']});}return _0x4d2276;});}})[_0x83f4('0x28')](respondWithResult(_0x4cf16c,null))[_0x83f4('0x48')](handleError(_0x4cf16c,null));};exports['removeAgents']=function(_0x379060,_0x215030,_0x1fd8c3){return db['MailQueue'][_0x83f4('0x4a')]({'where':{'id':_0x379060[_0x83f4('0x53')]['id']}})[_0x83f4('0x28')](handleEntityNotFound(_0x215030,null))[_0x83f4('0x28')](function(_0x1c47b9){if(_0x1c47b9){return _0x1c47b9[_0x83f4('0x80')](_0x379060[_0x83f4('0x37')][_0x83f4('0x64')])['then'](function(){if(_[_0x83f4('0x84')](_0x379060[_0x83f4('0x37')][_0x83f4('0x64')])){for(var _0x398cee=0x0;_0x398cee<_0x379060[_0x83f4('0x37')][_0x83f4('0x64')]['length'];_0x398cee+=0x1){socket[_0x83f4('0x6c')]('userMailQueue:remove',{'UserId':Number(_0x379060[_0x83f4('0x37')][_0x83f4('0x64')][_0x398cee]),'MailQueueId':Number(_0x379060[_0x83f4('0x53')]['id'])});}}else{socket[_0x83f4('0x6c')](_0x83f4('0x85'),{'UserId':Number(_0x379060[_0x83f4('0x37')][_0x83f4('0x64')]),'MailQueueId':Number(_0x379060[_0x83f4('0x53')]['id'])});}});}})[_0x83f4('0x28')](respondWithStatusCode(_0x215030,null))['catch'](handleError(_0x215030,null));};exports[_0x83f4('0x86')]=function(_0x218d8f,_0x4ba3c8,_0x1081b0){var _0x335450={};var _0x2b8e6e={};var _0x597014;var _0x52eaf6;return db[_0x83f4('0x31')][_0x83f4('0x62')]({'where':{'id':_0x218d8f[_0x83f4('0x53')]['id']}})['then'](handleEntityNotFound(_0x4ba3c8,null))[_0x83f4('0x28')](function(_0x106944){if(_0x106944){_0x597014=_0x106944;_0x2b8e6e[_0x83f4('0x34')]=_['keys'](db[_0x83f4('0x5a')][_0x83f4('0x32')]);_0x2b8e6e[_0x83f4('0x37')]=_[_0x83f4('0x36')](_0x218d8f['query']);_0x2b8e6e[_0x83f4('0x41')]=_[_0x83f4('0x38')](_0x2b8e6e['model'],_0x2b8e6e[_0x83f4('0x37')]);_0x335450['attributes']=_[_0x83f4('0x38')](_0x2b8e6e[_0x83f4('0x34')],qs[_0x83f4('0x39')](_0x218d8f[_0x83f4('0x37')][_0x83f4('0x39')]));_0x335450[_0x83f4('0x3a')]=_0x335450[_0x83f4('0x3a')][_0x83f4('0x3b')]?_0x335450[_0x83f4('0x3a')]:_0x2b8e6e[_0x83f4('0x34')];_0x335450[_0x83f4('0x3e')]=qs[_0x83f4('0x3f')](_0x218d8f['query'][_0x83f4('0x3f')]);_0x335450['where']=qs[_0x83f4('0x41')](_[_0x83f4('0x42')](_0x218d8f['query'],_0x2b8e6e[_0x83f4('0x41')]));if(_0x218d8f[_0x83f4('0x37')]['filter']){_0x335450['where']=_[_0x83f4('0x58')](_0x335450[_0x83f4('0x40')],{'$or':_['map'](_0x335450[_0x83f4('0x3a')],function(_0xf77b12){var _0x3e38cc={};_0x3e38cc[_0xf77b12]={'$like':'%'+_0x218d8f['query'][_0x83f4('0x43')]+'%'};return _0x3e38cc;})});}_0x335450=_[_0x83f4('0x58')]({},_0x335450,_0x218d8f[_0x83f4('0x44')]);return _0x597014[_0x83f4('0x86')](_0x335450);}})[_0x83f4('0x28')](function(_0x19089e){if(_0x19089e){_0x52eaf6=_0x19089e[_0x83f4('0x3b')];if(!_0x218d8f[_0x83f4('0x37')][_0x83f4('0x3c')](_0x83f4('0x3d'))){_0x335450[_0x83f4('0x22')]=qs['limit'](_0x218d8f[_0x83f4('0x37')][_0x83f4('0x22')]);_0x335450[_0x83f4('0x21')]=qs[_0x83f4('0x21')](_0x218d8f[_0x83f4('0x37')][_0x83f4('0x21')]);}return _0x597014['getAgents'](_0x335450);}})[_0x83f4('0x28')](function(_0x176013){if(_0x176013){return _0x176013?{'count':_0x52eaf6,'rows':_0x176013}:null;}})[_0x83f4('0x28')](respondWithResult(_0x4ba3c8,null))[_0x83f4('0x48')](handleError(_0x4ba3c8,null));};
\ No newline at end of file