Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index ddc63b2..169b87e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbccf=['params','rawAttributes','length','MailQueue','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','UserMailQueue','nolimit','MailQueueId','filter','User','findAndCountAll','UserId','mailPause','createdAt','format','SIP','updatedAt','getTeams','findOne','Team','addTeams','ids','Agents','voicePause','flatMap','sequelize','forEach','emit','removeTeams','tq.TeamId','team_has_mail_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','SELECT','TeamId','all','union','compact','value','transaction','removeAgents','userMailQueue:remove','addAgents','omit','spread','userMailQueue:save','isArray','getAgents','eml-format','zip-dir','request-promise','moment','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','../../mysqldb','redis','localhost','./mailQueue.socket','register','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','save','update','then','destroy','get','MailQueues','UserProfileResource','sendStatus','error','name','send','index','map','type','key','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','order','sort','where','pick','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show'];(function(_0x33f366,_0x131b8b){var _0x249aa5=function(_0x2b3e91){while(--_0x2b3e91){_0x33f366['push'](_0x33f366['shift']());}};_0x249aa5(++_0x131b8b);}(_0xbccf,0x1d2));var _0xfbcc=function(_0x623e7,_0x1bef7d){_0x623e7=_0x623e7-0x0;var _0x121131=_0xbccf[_0x623e7];return _0x121131;};'use strict';var emlformat=require(_0xfbcc('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xfbcc('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xfbcc('0x2'));var moment=require(_0xfbcc('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xfbcc('0x4'));var path=require(_0xfbcc('0x5'));var sox=require(_0xfbcc('0x6'));var csv=require(_0xfbcc('0x7'));var ejs=require(_0xfbcc('0x8'));var fs=require('fs');var fs_extra=require(_0xfbcc('0x9'));var _=require(_0xfbcc('0xa'));var squel=require(_0xfbcc('0xb'));var crypto=require(_0xfbcc('0xc'));var jsforce=require(_0xfbcc('0xd'));var deskjs=require(_0xfbcc('0xe'));var toCsv=require(_0xfbcc('0x7'));var querystring=require(_0xfbcc('0xf'));var Papa=require(_0xfbcc('0x10'));var Redis=require(_0xfbcc('0x11'));var authService=require(_0xfbcc('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xfbcc('0x13'));var hardwareService=require(_0xfbcc('0x14'));var logger=require('../../config/logger')(_0xfbcc('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xfbcc('0x16'));var db=require(_0xfbcc('0x17'))['db'];config[_0xfbcc('0x18')]=_['defaults'](config[_0xfbcc('0x18')],{'host':_0xfbcc('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xfbcc('0x18')]));require(_0xfbcc('0x1a'))[_0xfbcc('0x1b')](socket);function respondWithStatusCode(_0x42aa92,_0x4d3d5e){_0x4d3d5e=_0x4d3d5e||0xcc;return function(_0xc2e8f8){if(_0xc2e8f8){return _0x42aa92['sendStatus'](_0x4d3d5e);}return _0x42aa92[_0xfbcc('0x1c')](_0x4d3d5e)[_0xfbcc('0x1d')]();};}function respondWithResult(_0x356c05,_0x4e4dd0){_0x4e4dd0=_0x4e4dd0||0xc8;return function(_0x4ef826){if(_0x4ef826){return _0x356c05[_0xfbcc('0x1c')](_0x4e4dd0)[_0xfbcc('0x1e')](_0x4ef826);}};}function respondWithFilteredResult(_0x21f910,_0x3fbaa7){return function(_0x3fe600){if(_0x3fe600){var _0x5d6fcf=typeof _0x3fbaa7[_0xfbcc('0x1f')]===_0xfbcc('0x20')&&typeof _0x3fbaa7[_0xfbcc('0x21')]===_0xfbcc('0x20');var _0x23f0e0=_0x3fe600[_0xfbcc('0x22')];var _0x11cf3d=_0x5d6fcf?0x0:_0x3fbaa7['offset'];var _0x481e6f=_0x5d6fcf?_0x3fe600['count']:_0x3fbaa7['offset']+_0x3fbaa7['limit'];var _0x2c1f80;if(_0x481e6f>=_0x23f0e0){_0x481e6f=_0x23f0e0;_0x2c1f80=0xc8;}else{_0x2c1f80=0xce;}_0x21f910[_0xfbcc('0x1c')](_0x2c1f80);return _0x21f910[_0xfbcc('0x23')](_0xfbcc('0x24'),_0x11cf3d+'-'+_0x481e6f+'/'+_0x23f0e0)[_0xfbcc('0x1e')](_0x3fe600);}return null;};}function patchUpdates(_0x5c9ff4){return function(_0xf5bfd3){try{jsonpatch[_0xfbcc('0x25')](_0xf5bfd3,_0x5c9ff4,!![]);}catch(_0x2c3228){return BPromise['reject'](_0x2c3228);}return _0xf5bfd3[_0xfbcc('0x26')]();};}function saveUpdates(_0x384443,_0x206969){return function(_0x2d6b0c){if(_0x2d6b0c){return _0x2d6b0c[_0xfbcc('0x27')](_0x384443)[_0xfbcc('0x28')](function(_0x56b1fd){return _0x56b1fd;});}return null;};}function removeEntity(_0x48025d,_0xc29958){return function(_0x5cb3e0){if(_0x5cb3e0){return _0x5cb3e0[_0xfbcc('0x29')]()[_0xfbcc('0x28')](function(){var _0x479b0b=_0x5cb3e0[_0xfbcc('0x2a')]({'plain':!![]});var _0x574e63=_0xfbcc('0x2b');return db[_0xfbcc('0x2c')][_0xfbcc('0x29')]({'where':{'type':_0x574e63,'resourceId':_0x479b0b['id']}})[_0xfbcc('0x28')](function(){return _0x5cb3e0;});})[_0xfbcc('0x28')](function(){_0x48025d[_0xfbcc('0x1c')](0xcc)[_0xfbcc('0x1d')]();});}};}function handleEntityNotFound(_0x3bfe8e,_0x31328f){return function(_0x4835cc){if(!_0x4835cc){_0x3bfe8e[_0xfbcc('0x2d')](0x194);}return _0x4835cc;};}function handleError(_0x4af4af,_0x487fea){_0x487fea=_0x487fea||0x1f4;return function(_0x5a9a0a){logger[_0xfbcc('0x2e')](_0x5a9a0a['stack']);if(_0x5a9a0a[_0xfbcc('0x2f')]){delete _0x5a9a0a['name'];}_0x4af4af[_0xfbcc('0x1c')](_0x487fea)[_0xfbcc('0x30')](_0x5a9a0a);};}exports[_0xfbcc('0x31')]=function(_0x511405,_0x4822b6){var _0x4c3fbe={},_0x3ecd37={},_0x3e9a82={'count':0x0,'rows':[]};var _0x417af4=_[_0xfbcc('0x32')](db['MailQueue']['rawAttributes'],function(_0x10363e){return{'name':_0x10363e['fieldName'],'type':_0x10363e[_0xfbcc('0x33')][_0xfbcc('0x34')]};});_0x3ecd37[_0xfbcc('0x35')]=_[_0xfbcc('0x32')](_0x417af4,_0xfbcc('0x2f'));_0x3ecd37[_0xfbcc('0x36')]=_[_0xfbcc('0x37')](_0x511405['query']);_0x3ecd37[_0xfbcc('0x38')]=_[_0xfbcc('0x39')](_0x3ecd37['model'],_0x3ecd37['query']);_0x4c3fbe['attributes']=_['intersection'](_0x3ecd37['model'],qs['fields'](_0x511405[_0xfbcc('0x36')][_0xfbcc('0x3a')]));_0x4c3fbe[_0xfbcc('0x3b')]=_0x4c3fbe[_0xfbcc('0x3b')]['length']?_0x4c3fbe[_0xfbcc('0x3b')]:_0x3ecd37[_0xfbcc('0x35')];if(!_0x511405[_0xfbcc('0x36')][_0xfbcc('0x3c')]('nolimit')){_0x4c3fbe[_0xfbcc('0x21')]=qs[_0xfbcc('0x21')](_0x511405['query'][_0xfbcc('0x21')]);_0x4c3fbe[_0xfbcc('0x1f')]=qs[_0xfbcc('0x1f')](_0x511405[_0xfbcc('0x36')][_0xfbcc('0x1f')]);}_0x4c3fbe[_0xfbcc('0x3d')]=qs[_0xfbcc('0x3e')](_0x511405[_0xfbcc('0x36')][_0xfbcc('0x3e')]);_0x4c3fbe[_0xfbcc('0x3f')]=qs[_0xfbcc('0x38')](_[_0xfbcc('0x40')](_0x511405['query'],_0x3ecd37[_0xfbcc('0x38')]),_0x417af4);if(_0x511405[_0xfbcc('0x36')]['filter']){_0x4c3fbe[_0xfbcc('0x3f')]=_[_0xfbcc('0x41')](_0x4c3fbe['where'],{'$or':_['map'](_0x417af4,function(_0x3d936b){if(_0x3d936b[_0xfbcc('0x33')]!==_0xfbcc('0x42')){var _0x2e8165={};_0x2e8165[_0x3d936b['name']]={'$like':'%'+_0x511405['query']['filter']+'%'};return _0x2e8165;}})});}_0x4c3fbe=_['merge']({},_0x4c3fbe,_0x511405[_0xfbcc('0x43')]);var _0x37e3ee={'where':_0x4c3fbe[_0xfbcc('0x3f')]};return db['MailQueue'][_0xfbcc('0x22')](_0x37e3ee)[_0xfbcc('0x28')](function(_0x6430bc){_0x3e9a82[_0xfbcc('0x22')]=_0x6430bc;if(_0x511405[_0xfbcc('0x36')][_0xfbcc('0x44')]){_0x4c3fbe[_0xfbcc('0x45')]=[{'all':!![]}];}return db['MailQueue'][_0xfbcc('0x46')](_0x4c3fbe);})['then'](function(_0x196409){_0x3e9a82[_0xfbcc('0x47')]=_0x196409;return _0x3e9a82;})['then'](respondWithFilteredResult(_0x4822b6,_0x4c3fbe))[_0xfbcc('0x48')](handleError(_0x4822b6,null));};exports[_0xfbcc('0x49')]=function(_0x216a06,_0x47cc23){var _0x302939={'raw':!![],'where':{'id':_0x216a06[_0xfbcc('0x4a')]['id']}},_0x263822={};_0x263822[_0xfbcc('0x35')]=_['keys'](db['MailQueue'][_0xfbcc('0x4b')]);_0x263822[_0xfbcc('0x36')]=_[_0xfbcc('0x37')](_0x216a06[_0xfbcc('0x36')]);_0x263822[_0xfbcc('0x38')]=_['intersection'](_0x263822[_0xfbcc('0x35')],_0x263822[_0xfbcc('0x36')]);_0x302939[_0xfbcc('0x3b')]=_['intersection'](_0x263822['model'],qs['fields'](_0x216a06[_0xfbcc('0x36')][_0xfbcc('0x3a')]));_0x302939[_0xfbcc('0x3b')]=_0x302939[_0xfbcc('0x3b')][_0xfbcc('0x4c')]?_0x302939['attributes']:_0x263822[_0xfbcc('0x35')];if(_0x216a06['query'][_0xfbcc('0x44')]){_0x302939[_0xfbcc('0x45')]=[{'all':!![]}];}_0x302939=_[_0xfbcc('0x41')]({},_0x302939,_0x216a06[_0xfbcc('0x43')]);return db[_0xfbcc('0x4d')][_0xfbcc('0x4e')](_0x302939)[_0xfbcc('0x28')](handleEntityNotFound(_0x47cc23,null))[_0xfbcc('0x28')](respondWithResult(_0x47cc23,null))['catch'](handleError(_0x47cc23,null));};exports[_0xfbcc('0x4f')]=function(_0x44f724,_0x319383){return db[_0xfbcc('0x4d')][_0xfbcc('0x4f')](_0x44f724[_0xfbcc('0x50')],{})[_0xfbcc('0x28')](function(_0x690224){var _0x44fed0=_0x44f724[_0xfbcc('0x51')][_0xfbcc('0x2a')]({'plain':!![]});if(!_0x44fed0)throw new Error(_0xfbcc('0x52'));if(_0x44fed0['role']===_0xfbcc('0x51')){var _0x148c46=_0x690224[_0xfbcc('0x2a')]({'plain':!![]});var _0x18e27a=_0xfbcc('0x2b');return db[_0xfbcc('0x53')][_0xfbcc('0x4e')]({'where':{'name':_0x18e27a,'userProfileId':_0x44fed0['userProfileId']},'raw':!![]})[_0xfbcc('0x28')](function(_0x594e59){if(_0x594e59&&_0x594e59[_0xfbcc('0x54')]===0x0){return db[_0xfbcc('0x2c')][_0xfbcc('0x4f')]({'name':_0x148c46['name'],'resourceId':_0x148c46['id'],'type':_0x594e59[_0xfbcc('0x2f')],'sectionId':_0x594e59['id']},{})['then'](function(){return _0x690224;});}else{return _0x690224;}})[_0xfbcc('0x48')](function(_0x44a430){logger[_0xfbcc('0x2e')](_0xfbcc('0x55'),_0x44a430);throw _0x44a430;});}return _0x690224;})[_0xfbcc('0x28')](respondWithResult(_0x319383,0xc9))[_0xfbcc('0x48')](handleError(_0x319383,null));};exports[_0xfbcc('0x27')]=function(_0x701a9,_0xfc3aab){if(_0x701a9[_0xfbcc('0x50')]['id']){delete _0x701a9[_0xfbcc('0x50')]['id'];}return db[_0xfbcc('0x4d')][_0xfbcc('0x4e')]({'where':{'id':_0x701a9['params']['id']}})[_0xfbcc('0x28')](handleEntityNotFound(_0xfc3aab,null))['then'](saveUpdates(_0x701a9[_0xfbcc('0x50')],null))['then'](respondWithResult(_0xfc3aab,null))[_0xfbcc('0x48')](handleError(_0xfc3aab,null));};exports[_0xfbcc('0x29')]=function(_0x783ce0,_0x5a25e6){return db[_0xfbcc('0x4d')][_0xfbcc('0x4e')]({'where':{'id':_0x783ce0[_0xfbcc('0x4a')]['id']}})[_0xfbcc('0x28')](handleEntityNotFound(_0x5a25e6,null))[_0xfbcc('0x28')](removeEntity(_0x5a25e6,null))['catch'](handleError(_0x5a25e6,null));};exports[_0xfbcc('0x56')]=function(_0x11fe1f,_0x52a2db){return db['MailQueue'][_0xfbcc('0x56')]()[_0xfbcc('0x28')](respondWithResult(_0x52a2db,null))[_0xfbcc('0x48')](handleError(_0x52a2db,null));};exports['getMembers']=function(_0x55b094,_0x45ec01,_0x64a6d8){var _0x479a2d={'raw':!![],'where':{}},_0x5b87f3={},_0x3197b1;return db[_0xfbcc('0x4d')]['findOne']({'where':{'id':_0x55b094[_0xfbcc('0x4a')]['id']}})[_0xfbcc('0x28')](handleEntityNotFound(_0x45ec01,null))['then'](function(_0x25245c){if(_0x25245c){_0x3197b1=_0x25245c[_0xfbcc('0x2a')]({'plain':!![]});_0x5b87f3[_0xfbcc('0x35')]=_[_0xfbcc('0x37')](db[_0xfbcc('0x57')][_0xfbcc('0x4b')]);_0x5b87f3[_0xfbcc('0x36')]=_[_0xfbcc('0x37')](_0x55b094['query']);_0x5b87f3[_0xfbcc('0x38')]=_[_0xfbcc('0x39')](_0x5b87f3[_0xfbcc('0x35')],_0x5b87f3[_0xfbcc('0x36')]);_0x479a2d[_0xfbcc('0x3b')]=_[_0xfbcc('0x39')](_0x5b87f3[_0xfbcc('0x35')],qs[_0xfbcc('0x3a')](_0x55b094['query']['fields']));_0x479a2d[_0xfbcc('0x3b')]=_0x479a2d[_0xfbcc('0x3b')][_0xfbcc('0x4c')]?_0x479a2d[_0xfbcc('0x3b')]:_0x5b87f3['model'];if(!_0x55b094['query'][_0xfbcc('0x3c')](_0xfbcc('0x58'))){_0x479a2d[_0xfbcc('0x21')]=qs[_0xfbcc('0x21')](_0x55b094[_0xfbcc('0x36')][_0xfbcc('0x21')]);_0x479a2d[_0xfbcc('0x1f')]=qs[_0xfbcc('0x1f')](_0x55b094[_0xfbcc('0x36')][_0xfbcc('0x1f')]);}_0x479a2d[_0xfbcc('0x3d')]=qs[_0xfbcc('0x3e')](_0x55b094[_0xfbcc('0x36')][_0xfbcc('0x3e')]);_0x479a2d[_0xfbcc('0x3f')]=qs['filters'](_['pick'](_0x55b094['query'],_0x5b87f3[_0xfbcc('0x38')]));_0x479a2d[_0xfbcc('0x3f')][_0xfbcc('0x59')]=_0x25245c['id'];if(_0x55b094[_0xfbcc('0x36')][_0xfbcc('0x5a')]){_0x479a2d['where']=_[_0xfbcc('0x41')](_0x479a2d[_0xfbcc('0x3f')],{'$or':_[_0xfbcc('0x32')](_0x479a2d[_0xfbcc('0x3b')],function(_0x3c5f67){var _0x2f1afb={};_0x2f1afb[_0x3c5f67]={'$like':'%'+_0x55b094[_0xfbcc('0x36')][_0xfbcc('0x5a')]+'%'};return _0x2f1afb;})});}_0x479a2d=_[_0xfbcc('0x41')]({},_0x479a2d,_0x55b094[_0xfbcc('0x43')]);return db[_0xfbcc('0x57')][_0xfbcc('0x46')](_0x479a2d);}})['then'](function(_0x325914){if(_0x325914){return db[_0xfbcc('0x5b')][_0xfbcc('0x5c')]({'where':{'id':_[_0xfbcc('0x32')](_0x325914,_0xfbcc('0x5d')),'role':'agent'},'attributes':['id','name',_0xfbcc('0x5e'),'updatedAt',_0xfbcc('0x5f')]});}})[_0xfbcc('0x28')](function(_0x4bb34b){if(_0x4bb34b){return{'count':_0x4bb34b['count'],'rows':_[_0xfbcc('0x32')](_0x4bb34b[_0xfbcc('0x47')],function(_0x30116e){return{'membername':_0x30116e['name'],'UserId':_0x30116e['id'],'queue_name':_0x3197b1['name'],'MailQueueId':_0x3197b1['id'],'interface':util[_0xfbcc('0x60')]('%s/%s',_0xfbcc('0x61'),_0x30116e[_0xfbcc('0x2f')]),'penalty':0x0,'paused':_0x30116e[_0xfbcc('0x5e')],'createdAt':_0x30116e[_0xfbcc('0x5f')],'updatedAt':_0x30116e[_0xfbcc('0x62')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x45ec01,_0x479a2d))[_0xfbcc('0x48')](handleError(_0x45ec01,null));};exports[_0xfbcc('0x63')]=function(_0x2efd37,_0xe8e81a,_0x495a0d){var _0x168e66={};var _0x5954e4={};var _0x2e6a15;var _0x371702;return db[_0xfbcc('0x4d')][_0xfbcc('0x64')]({'where':{'id':_0x2efd37['params']['id']}})[_0xfbcc('0x28')](handleEntityNotFound(_0xe8e81a,null))[_0xfbcc('0x28')](function(_0x2ba93c){if(_0x2ba93c){_0x2e6a15=_0x2ba93c;_0x5954e4[_0xfbcc('0x35')]=_[_0xfbcc('0x37')](db[_0xfbcc('0x65')]['rawAttributes']);_0x5954e4[_0xfbcc('0x36')]=_[_0xfbcc('0x37')](_0x2efd37['query']);_0x5954e4[_0xfbcc('0x38')]=_['intersection'](_0x5954e4[_0xfbcc('0x35')],_0x5954e4[_0xfbcc('0x36')]);_0x168e66[_0xfbcc('0x3b')]=_[_0xfbcc('0x39')](_0x5954e4[_0xfbcc('0x35')],qs[_0xfbcc('0x3a')](_0x2efd37[_0xfbcc('0x36')][_0xfbcc('0x3a')]));_0x168e66[_0xfbcc('0x3b')]=_0x168e66[_0xfbcc('0x3b')][_0xfbcc('0x4c')]?_0x168e66[_0xfbcc('0x3b')]:_0x5954e4[_0xfbcc('0x35')];_0x168e66['order']=qs[_0xfbcc('0x3e')](_0x2efd37['query'][_0xfbcc('0x3e')]);_0x168e66[_0xfbcc('0x3f')]=qs['filters'](_[_0xfbcc('0x40')](_0x2efd37['query'],_0x5954e4[_0xfbcc('0x38')]));if(_0x2efd37[_0xfbcc('0x36')]['filter']){_0x168e66[_0xfbcc('0x3f')]=_[_0xfbcc('0x41')](_0x168e66[_0xfbcc('0x3f')],{'$or':_[_0xfbcc('0x32')](_0x168e66[_0xfbcc('0x3b')],function(_0x11095b){var _0x49a93b={};_0x49a93b[_0x11095b]={'$like':'%'+_0x2efd37['query']['filter']+'%'};return _0x49a93b;})});}_0x168e66=_[_0xfbcc('0x41')]({},_0x168e66,_0x2efd37['options']);return _0x2e6a15['getTeams'](_0x168e66);}})[_0xfbcc('0x28')](function(_0x8daad5){if(_0x8daad5){_0x371702=_0x8daad5[_0xfbcc('0x4c')];if(!_0x2efd37[_0xfbcc('0x36')]['hasOwnProperty'](_0xfbcc('0x58'))){_0x168e66[_0xfbcc('0x21')]=qs['limit'](_0x2efd37[_0xfbcc('0x36')]['limit']);_0x168e66['offset']=qs[_0xfbcc('0x1f')](_0x2efd37[_0xfbcc('0x36')][_0xfbcc('0x1f')]);}return _0x2e6a15[_0xfbcc('0x63')](_0x168e66);}})[_0xfbcc('0x28')](function(_0xd18b5e){if(_0xd18b5e){return _0xd18b5e?{'count':_0x371702,'rows':_0xd18b5e}:null;}})[_0xfbcc('0x28')](respondWithResult(_0xe8e81a,null))[_0xfbcc('0x48')](handleError(_0xe8e81a,null));};exports[_0xfbcc('0x66')]=function(_0x54c24c,_0x52c823,_0x126085){var _0x13b221=_0x54c24c[_0xfbcc('0x50')][_0xfbcc('0x67')];return db['Team']['findAll']({'where':{'id':_0x13b221},'attributes':['id'],'include':[{'model':db[_0xfbcc('0x5b')],'as':_0xfbcc('0x68'),'attributes':['id',_0xfbcc('0x2f'),'online',_0xfbcc('0x69'),'interface'],'raw':!![]}]})['then'](function(_0x3e944c){if(_0x3e944c){var _0x52ff21=_[_0xfbcc('0x6a')](_0x3e944c,function(_0x323f6d){var _0x49f286=_0x323f6d[_0xfbcc('0x2a')]({'plain':!![]});return _0x49f286['Agents'];});return db[_0xfbcc('0x4d')][_0xfbcc('0x4e')]({'where':{'id':_0x54c24c[_0xfbcc('0x4a')]['id']}})['then'](function(_0x2f68d6){return db[_0xfbcc('0x6b')]['transaction'](function(_0x16302a){return _0x2f68d6[_0xfbcc('0x66')](_0x13b221,{'transaction':_0x16302a})['then'](function(){return BPromise['each'](_0x52ff21,function(_0x266fa2){return db['UserMailQueue']['findOrCreate']({'where':{'UserId':_0x266fa2['id'],'MailQueueId':_0x54c24c[_0xfbcc('0x4a')]['id']},'transaction':_0x16302a});});})[_0xfbcc('0x28')](function(){_0x52ff21[_0xfbcc('0x6c')](function(_0x489560){socket[_0xfbcc('0x6d')]('userMailQueue:save',{'UserId':_0x489560['id'],'MailQueueId':_0x2f68d6['id']});});});});});}})[_0xfbcc('0x28')](respondWithStatusCode(_0x52c823,null))[_0xfbcc('0x48')](handleError(_0x52c823,null));};exports[_0xfbcc('0x6e')]=function(_0x490c8c,_0x477a0b,_0x15ec98){return db[_0xfbcc('0x65')][_0xfbcc('0x46')]({'where':{'id':_0x490c8c[_0xfbcc('0x36')][_0xfbcc('0x67')]},'attributes':['id'],'include':[{'model':db[_0xfbcc('0x5b')],'as':_0xfbcc('0x68'),'attributes':['id'],'raw':!![]}]})[_0xfbcc('0x28')](handleEntityNotFound(_0x477a0b,null))[_0xfbcc('0x28')](function(_0x4ab631){var _0x59b80f=_['map'](_0x4ab631,'id');var _0x1dac6a=[];var _0x3adc2d=[];var _0x44f007=squel['select']();_0x44f007['field'](_0xfbcc('0x6f'))['from'](_0xfbcc('0x70'),'tq')[_0xfbcc('0x71')](_0xfbcc('0x72'),'ut',_0xfbcc('0x73'))[_0xfbcc('0x3f')](_0xfbcc('0x74'),_0x490c8c[_0xfbcc('0x4a')]['id']);for(var _0x27f4a0=0x0;_0x27f4a0<_0x4ab631[_0xfbcc('0x4c')];_0x27f4a0+=0x1){let _0x4f6f35=_0x4ab631[_0x27f4a0];for(var _0x4d86ad=0x0;_0x4d86ad<_0x4f6f35['Agents'][_0xfbcc('0x4c')];_0x4d86ad+=0x1){let _0x1c02dd=_0x4f6f35[_0xfbcc('0x68')][_0x4d86ad];var _0x330bde=_0x44f007[_0xfbcc('0x75')]();_0x330bde[_0xfbcc('0x3f')](_0xfbcc('0x76'),_0x1c02dd['id']);_0x3adc2d['push'](db[_0xfbcc('0x6b')][_0xfbcc('0x36')](_0x330bde[_0xfbcc('0x77')](),{'type':db['sequelize']['QueryTypes'][_0xfbcc('0x78')]})[_0xfbcc('0x28')](function(_0x176a6e){if(_0x176a6e[_0xfbcc('0x4c')]===0x1){return _0x1c02dd['id'];}else{var _0x3cb709=_['every'](_[_0xfbcc('0x32')](_0x176a6e,_0xfbcc('0x79')),function(_0x478a74){return _['includes'](_0x59b80f,_0x478a74);});if(_0x3cb709){return _0x1c02dd['id'];}}}));}}return BPromise[_0xfbcc('0x7a')](_0x3adc2d)[_0xfbcc('0x28')](function(_0x283fe6){_0x1dac6a=_(_0x1dac6a)[_0xfbcc('0x7b')](_0x283fe6)[_0xfbcc('0x7c')]()[_0xfbcc('0x7d')]();return db[_0xfbcc('0x4d')][_0xfbcc('0x4e')]({'where':{'id':_0x490c8c[_0xfbcc('0x4a')]['id']}})['then'](function(_0x297b2a){return db[_0xfbcc('0x6b')][_0xfbcc('0x7e')](function(_0x85d2a3){return _0x297b2a['removeTeams'](_0x490c8c[_0xfbcc('0x36')]['ids'],{'transaction':_0x85d2a3})['then'](function(){if(!_['isEmpty'](_0x1dac6a)){return _0x297b2a[_0xfbcc('0x7f')](_0x1dac6a,{'transaction':_0x85d2a3});}})[_0xfbcc('0x28')](function(){_0x1dac6a[_0xfbcc('0x6c')](function(_0x5c81e7){socket['emit'](_0xfbcc('0x80'),{'UserId':_0x5c81e7,'MailQueueId':_0x297b2a['id']});});});});});});})[_0xfbcc('0x28')](respondWithStatusCode(_0x477a0b,null))[_0xfbcc('0x48')](handleError(_0x477a0b,null));};exports[_0xfbcc('0x81')]=function(_0x1d82bb,_0x4c33b0,_0x4db2d5){return db['MailQueue'][_0xfbcc('0x4e')]({'where':{'id':_0x1d82bb['params']['id']}})[_0xfbcc('0x28')](handleEntityNotFound(_0x4c33b0,null))[_0xfbcc('0x28')](function(_0x22ba57){if(_0x22ba57){return _0x22ba57['addAgents'](_0x1d82bb[_0xfbcc('0x50')][_0xfbcc('0x67')],_[_0xfbcc('0x82')](_0x1d82bb[_0xfbcc('0x50')],[_0xfbcc('0x67'),'id'])||{})[_0xfbcc('0x83')](function(_0xf59f1e){for(var _0x5007e7=0x0;_0x5007e7<_0x1d82bb['body']['ids'][_0xfbcc('0x4c')];_0x5007e7+=0x1){socket[_0xfbcc('0x6d')](_0xfbcc('0x84'),{'UserId':Number(_0x1d82bb[_0xfbcc('0x50')][_0xfbcc('0x67')][_0x5007e7]),'MailQueueId':Number(_0x1d82bb[_0xfbcc('0x4a')]['id'])});}return _0xf59f1e;});}})[_0xfbcc('0x28')](respondWithResult(_0x4c33b0,null))[_0xfbcc('0x48')](handleError(_0x4c33b0,null));};exports['removeAgents']=function(_0x3be525,_0x15ca54,_0x1b61ab){return db[_0xfbcc('0x4d')][_0xfbcc('0x4e')]({'where':{'id':_0x3be525[_0xfbcc('0x4a')]['id']}})[_0xfbcc('0x28')](handleEntityNotFound(_0x15ca54,null))[_0xfbcc('0x28')](function(_0x2a4063){if(_0x2a4063){return _0x2a4063[_0xfbcc('0x7f')](_0x3be525[_0xfbcc('0x36')][_0xfbcc('0x67')])['then'](function(){if(_[_0xfbcc('0x85')](_0x3be525[_0xfbcc('0x36')][_0xfbcc('0x67')])){for(var _0x8ce0e6=0x0;_0x8ce0e6<_0x3be525[_0xfbcc('0x36')][_0xfbcc('0x67')][_0xfbcc('0x4c')];_0x8ce0e6+=0x1){socket[_0xfbcc('0x6d')](_0xfbcc('0x80'),{'UserId':Number(_0x3be525['query']['ids'][_0x8ce0e6]),'MailQueueId':Number(_0x3be525[_0xfbcc('0x4a')]['id'])});}}else{socket['emit']('userMailQueue:remove',{'UserId':Number(_0x3be525['query'][_0xfbcc('0x67')]),'MailQueueId':Number(_0x3be525[_0xfbcc('0x4a')]['id'])});}});}})[_0xfbcc('0x28')](respondWithStatusCode(_0x15ca54,null))[_0xfbcc('0x48')](handleError(_0x15ca54,null));};exports['getAgents']=function(_0x3ef7ed,_0x32846c,_0x21806b){var _0x262053={};var _0x387d19={};var _0xa96a7c;var _0x3566f2;return db[_0xfbcc('0x4d')][_0xfbcc('0x64')]({'where':{'id':_0x3ef7ed[_0xfbcc('0x4a')]['id']}})[_0xfbcc('0x28')](handleEntityNotFound(_0x32846c,null))[_0xfbcc('0x28')](function(_0x36c36e){if(_0x36c36e){_0xa96a7c=_0x36c36e;_0x387d19[_0xfbcc('0x35')]=_[_0xfbcc('0x37')](db['User']['rawAttributes']);_0x387d19['query']=_[_0xfbcc('0x37')](_0x3ef7ed[_0xfbcc('0x36')]);_0x387d19[_0xfbcc('0x38')]=_[_0xfbcc('0x39')](_0x387d19[_0xfbcc('0x35')],_0x387d19[_0xfbcc('0x36')]);_0x262053[_0xfbcc('0x3b')]=_[_0xfbcc('0x39')](_0x387d19[_0xfbcc('0x35')],qs[_0xfbcc('0x3a')](_0x3ef7ed['query'][_0xfbcc('0x3a')]));_0x262053[_0xfbcc('0x3b')]=_0x262053[_0xfbcc('0x3b')][_0xfbcc('0x4c')]?_0x262053[_0xfbcc('0x3b')]:_0x387d19[_0xfbcc('0x35')];_0x262053['order']=qs[_0xfbcc('0x3e')](_0x3ef7ed[_0xfbcc('0x36')][_0xfbcc('0x3e')]);_0x262053[_0xfbcc('0x3f')]=qs[_0xfbcc('0x38')](_[_0xfbcc('0x40')](_0x3ef7ed[_0xfbcc('0x36')],_0x387d19['filters']));if(_0x3ef7ed[_0xfbcc('0x36')][_0xfbcc('0x5a')]){_0x262053[_0xfbcc('0x3f')]=_[_0xfbcc('0x41')](_0x262053[_0xfbcc('0x3f')],{'$or':_[_0xfbcc('0x32')](_0x262053[_0xfbcc('0x3b')],function(_0x97e3e7){var _0x591e6c={};_0x591e6c[_0x97e3e7]={'$like':'%'+_0x3ef7ed[_0xfbcc('0x36')][_0xfbcc('0x5a')]+'%'};return _0x591e6c;})});}_0x262053=_[_0xfbcc('0x41')]({},_0x262053,_0x3ef7ed[_0xfbcc('0x43')]);return _0xa96a7c['getAgents'](_0x262053);}})[_0xfbcc('0x28')](function(_0x5df623){if(_0x5df623){_0x3566f2=_0x5df623['length'];if(!_0x3ef7ed[_0xfbcc('0x36')][_0xfbcc('0x3c')](_0xfbcc('0x58'))){_0x262053[_0xfbcc('0x21')]=qs[_0xfbcc('0x21')](_0x3ef7ed[_0xfbcc('0x36')]['limit']);_0x262053[_0xfbcc('0x1f')]=qs[_0xfbcc('0x1f')](_0x3ef7ed['query'][_0xfbcc('0x1f')]);}return _0xa96a7c[_0xfbcc('0x86')](_0x262053);}})[_0xfbcc('0x28')](function(_0x62da34){if(_0x62da34){return _0x62da34?{'count':_0x3566f2,'rows':_0x62da34}:null;}})[_0xfbcc('0x28')](respondWithResult(_0x32846c,null))[_0xfbcc('0x48')](handleError(_0x32846c,null));};
\ No newline at end of file
+var _0x58b7=['params','include','find','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','MailQueues','UserProfileSection','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','destroy','describe','getMembers','findOne','UserMailQueue','MailQueueId','User','UserId','agent','mailPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','ids','Agents','online','voicePause','interface','flatMap','transaction','each','forEach','userMailQueue:save','select','field','tq.TeamId','from','team_has_mail_queues','join','user_has_teams','MailQueueId\x20=\x20?','clone','push','sequelize','toString','QueryTypes','SELECT','every','TeamId','includes','compact','value','removeTeams','isEmpty','removeAgents','emit','addAgents','spread','isArray','userMailQueue:remove','getAgents','nolimit','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./mailQueue.socket','register','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','update','then','get','UserProfileResource','name','send','index','map','MailQueue','rawAttributes','fieldName','type','query','keys','intersection','model','attributes','fields','length','hasOwnProperty','order','sort','where','filters','pick','filter','merge','options','includeAll','findAll','rows','catch','show'];(function(_0x4ba691,_0x24d437){var _0x5a7d02=function(_0x12c6ab){while(--_0x12c6ab){_0x4ba691['push'](_0x4ba691['shift']());}};_0x5a7d02(++_0x24d437);}(_0x58b7,0x16e));var _0x758b=function(_0x1ffafb,_0x3841c0){_0x1ffafb=_0x1ffafb-0x0;var _0x40d55e=_0x58b7[_0x1ffafb];return _0x40d55e;};'use strict';var emlformat=require(_0x758b('0x0'));var rimraf=require(_0x758b('0x1'));var zipdir=require(_0x758b('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x758b('0x3'));var moment=require(_0x758b('0x4'));var BPromise=require(_0x758b('0x5'));var Mustache=require(_0x758b('0x6'));var util=require(_0x758b('0x7'));var path=require(_0x758b('0x8'));var sox=require(_0x758b('0x9'));var csv=require(_0x758b('0xa'));var ejs=require(_0x758b('0xb'));var fs=require('fs');var fs_extra=require(_0x758b('0xc'));var _=require(_0x758b('0xd'));var squel=require(_0x758b('0xe'));var crypto=require(_0x758b('0xf'));var jsforce=require(_0x758b('0x10'));var deskjs=require(_0x758b('0x11'));var toCsv=require(_0x758b('0xa'));var querystring=require(_0x758b('0x12'));var Papa=require(_0x758b('0x13'));var Redis=require(_0x758b('0x14'));var authService=require(_0x758b('0x15'));var qs=require('../../components/parsers/qs');var as=require(_0x758b('0x16'));var hardwareService=require(_0x758b('0x17'));var logger=require(_0x758b('0x18'))(_0x758b('0x19'));var utils=require(_0x758b('0x1a'));var config=require(_0x758b('0x1b'));var licenseUtil=require('../../config/license/util');var db=require(_0x758b('0x1c'))['db'];config[_0x758b('0x1d')]=_[_0x758b('0x1e')](config[_0x758b('0x1d')],{'host':'localhost','port':0x18eb});var socket=require(_0x758b('0x1f'))(new Redis(config[_0x758b('0x1d')]));require(_0x758b('0x20'))[_0x758b('0x21')](socket);function respondWithStatusCode(_0x1cf173,_0x404719){_0x404719=_0x404719||0xcc;return function(_0x505129){if(_0x505129){return _0x1cf173[_0x758b('0x22')](_0x404719);}return _0x1cf173['status'](_0x404719)[_0x758b('0x23')]();};}function respondWithResult(_0x8aed40,_0x51fc10){_0x51fc10=_0x51fc10||0xc8;return function(_0x3833b8){if(_0x3833b8){return _0x8aed40[_0x758b('0x24')](_0x51fc10)[_0x758b('0x25')](_0x3833b8);}};}function respondWithFilteredResult(_0x56976f,_0x273593){return function(_0xe3210e){if(_0xe3210e){var _0x50fc7f=typeof _0x273593[_0x758b('0x26')]===_0x758b('0x27')&&typeof _0x273593[_0x758b('0x28')]===_0x758b('0x27');var _0x73c40c=_0xe3210e[_0x758b('0x29')];var _0x2bfc83=_0x50fc7f?0x0:_0x273593[_0x758b('0x26')];var _0x2e9f49=_0x50fc7f?_0xe3210e[_0x758b('0x29')]:_0x273593[_0x758b('0x26')]+_0x273593[_0x758b('0x28')];var _0x548dc3;if(_0x2e9f49>=_0x73c40c){_0x2e9f49=_0x73c40c;_0x548dc3=0xc8;}else{_0x548dc3=0xce;}_0x56976f[_0x758b('0x24')](_0x548dc3);return _0x56976f[_0x758b('0x2a')](_0x758b('0x2b'),_0x2bfc83+'-'+_0x2e9f49+'/'+_0x73c40c)['json'](_0xe3210e);}return null;};}function patchUpdates(_0x40b636){return function(_0x14258e){try{jsonpatch[_0x758b('0x2c')](_0x14258e,_0x40b636,!![]);}catch(_0x3d0fac){return BPromise['reject'](_0x3d0fac);}return _0x14258e['save']();};}function saveUpdates(_0x425125,_0x3a662b){return function(_0x654ae2){if(_0x654ae2){return _0x654ae2[_0x758b('0x2d')](_0x425125)[_0x758b('0x2e')](function(_0x1fbb6f){return _0x1fbb6f;});}return null;};}function removeEntity(_0x66d1ed,_0x24851b){return function(_0x46172c){if(_0x46172c){return _0x46172c['destroy']()[_0x758b('0x2e')](function(){var _0x5a3a11=_0x46172c[_0x758b('0x2f')]({'plain':!![]});var _0x104e46='MailQueues';return db[_0x758b('0x30')]['destroy']({'where':{'type':_0x104e46,'resourceId':_0x5a3a11['id']}})['then'](function(){return _0x46172c;});})[_0x758b('0x2e')](function(){_0x66d1ed[_0x758b('0x24')](0xcc)[_0x758b('0x23')]();});}};}function handleEntityNotFound(_0x491849,_0x293db5){return function(_0x495042){if(!_0x495042){_0x491849[_0x758b('0x22')](0x194);}return _0x495042;};}function handleError(_0x356e07,_0x5106b7){_0x5106b7=_0x5106b7||0x1f4;return function(_0x2fae1d){logger['error'](_0x2fae1d['stack']);if(_0x2fae1d[_0x758b('0x31')]){delete _0x2fae1d[_0x758b('0x31')];}_0x356e07['status'](_0x5106b7)[_0x758b('0x32')](_0x2fae1d);};}exports[_0x758b('0x33')]=function(_0x59820f,_0x1dacb1){var _0x5b577a={},_0x5b81be={},_0x447776={'count':0x0,'rows':[]};var _0x23facb=_[_0x758b('0x34')](db[_0x758b('0x35')][_0x758b('0x36')],function(_0x3c1fcd){return{'name':_0x3c1fcd[_0x758b('0x37')],'type':_0x3c1fcd[_0x758b('0x38')]['key']};});_0x5b81be['model']=_[_0x758b('0x34')](_0x23facb,_0x758b('0x31'));_0x5b81be[_0x758b('0x39')]=_[_0x758b('0x3a')](_0x59820f[_0x758b('0x39')]);_0x5b81be['filters']=_[_0x758b('0x3b')](_0x5b81be[_0x758b('0x3c')],_0x5b81be[_0x758b('0x39')]);_0x5b577a[_0x758b('0x3d')]=_[_0x758b('0x3b')](_0x5b81be[_0x758b('0x3c')],qs[_0x758b('0x3e')](_0x59820f[_0x758b('0x39')][_0x758b('0x3e')]));_0x5b577a[_0x758b('0x3d')]=_0x5b577a['attributes'][_0x758b('0x3f')]?_0x5b577a[_0x758b('0x3d')]:_0x5b81be[_0x758b('0x3c')];if(!_0x59820f[_0x758b('0x39')][_0x758b('0x40')]('nolimit')){_0x5b577a[_0x758b('0x28')]=qs[_0x758b('0x28')](_0x59820f['query'][_0x758b('0x28')]);_0x5b577a[_0x758b('0x26')]=qs[_0x758b('0x26')](_0x59820f['query']['offset']);}_0x5b577a[_0x758b('0x41')]=qs[_0x758b('0x42')](_0x59820f[_0x758b('0x39')][_0x758b('0x42')]);_0x5b577a[_0x758b('0x43')]=qs[_0x758b('0x44')](_[_0x758b('0x45')](_0x59820f[_0x758b('0x39')],_0x5b81be[_0x758b('0x44')]),_0x23facb);if(_0x59820f[_0x758b('0x39')][_0x758b('0x46')]){_0x5b577a['where']=_[_0x758b('0x47')](_0x5b577a['where'],{'$or':_[_0x758b('0x34')](_0x23facb,function(_0x27b69a){if(_0x27b69a['type']!=='VIRTUAL'){var _0x536efc={};_0x536efc[_0x27b69a[_0x758b('0x31')]]={'$like':'%'+_0x59820f[_0x758b('0x39')][_0x758b('0x46')]+'%'};return _0x536efc;}})});}_0x5b577a=_[_0x758b('0x47')]({},_0x5b577a,_0x59820f[_0x758b('0x48')]);var _0x2967f7={'where':_0x5b577a[_0x758b('0x43')]};return db[_0x758b('0x35')][_0x758b('0x29')](_0x2967f7)['then'](function(_0x4d1954){_0x447776[_0x758b('0x29')]=_0x4d1954;if(_0x59820f['query'][_0x758b('0x49')]){_0x5b577a['include']=[{'all':!![]}];}return db['MailQueue'][_0x758b('0x4a')](_0x5b577a);})[_0x758b('0x2e')](function(_0x22f6c8){_0x447776[_0x758b('0x4b')]=_0x22f6c8;return _0x447776;})[_0x758b('0x2e')](respondWithFilteredResult(_0x1dacb1,_0x5b577a))[_0x758b('0x4c')](handleError(_0x1dacb1,null));};exports[_0x758b('0x4d')]=function(_0x369e46,_0x2769d4){var _0x27d064={'raw':!![],'where':{'id':_0x369e46[_0x758b('0x4e')]['id']}},_0xc92865={};_0xc92865[_0x758b('0x3c')]=_[_0x758b('0x3a')](db['MailQueue'][_0x758b('0x36')]);_0xc92865[_0x758b('0x39')]=_[_0x758b('0x3a')](_0x369e46[_0x758b('0x39')]);_0xc92865[_0x758b('0x44')]=_['intersection'](_0xc92865['model'],_0xc92865[_0x758b('0x39')]);_0x27d064['attributes']=_[_0x758b('0x3b')](_0xc92865[_0x758b('0x3c')],qs[_0x758b('0x3e')](_0x369e46[_0x758b('0x39')][_0x758b('0x3e')]));_0x27d064[_0x758b('0x3d')]=_0x27d064[_0x758b('0x3d')][_0x758b('0x3f')]?_0x27d064[_0x758b('0x3d')]:_0xc92865[_0x758b('0x3c')];if(_0x369e46[_0x758b('0x39')][_0x758b('0x49')]){_0x27d064[_0x758b('0x4f')]=[{'all':!![]}];}_0x27d064=_[_0x758b('0x47')]({},_0x27d064,_0x369e46[_0x758b('0x48')]);return db[_0x758b('0x35')][_0x758b('0x50')](_0x27d064)[_0x758b('0x2e')](handleEntityNotFound(_0x2769d4,null))[_0x758b('0x2e')](respondWithResult(_0x2769d4,null))[_0x758b('0x4c')](handleError(_0x2769d4,null));};exports[_0x758b('0x51')]=function(_0x3999ad,_0x5a2252){return db[_0x758b('0x35')][_0x758b('0x51')](_0x3999ad['body'],{})[_0x758b('0x2e')](function(_0xab90cb){var _0x4e0a4b=_0x3999ad['user'][_0x758b('0x2f')]({'plain':!![]});if(!_0x4e0a4b)throw new Error(_0x758b('0x52'));if(_0x4e0a4b[_0x758b('0x53')]===_0x758b('0x54')){var _0x32ab05=_0xab90cb['get']({'plain':!![]});var _0x367e9c=_0x758b('0x55');return db[_0x758b('0x56')][_0x758b('0x50')]({'where':{'name':_0x367e9c,'userProfileId':_0x4e0a4b['userProfileId']},'raw':!![]})[_0x758b('0x2e')](function(_0x3de93c){if(_0x3de93c&&_0x3de93c[_0x758b('0x57')]===0x0){return db[_0x758b('0x30')]['create']({'name':_0x32ab05[_0x758b('0x31')],'resourceId':_0x32ab05['id'],'type':_0x3de93c[_0x758b('0x31')],'sectionId':_0x3de93c['id']},{})['then'](function(){return _0xab90cb;});}else{return _0xab90cb;}})[_0x758b('0x4c')](function(_0x408eb2){logger[_0x758b('0x58')](_0x758b('0x59'),_0x408eb2);throw _0x408eb2;});}return _0xab90cb;})[_0x758b('0x2e')](respondWithResult(_0x5a2252,0xc9))['catch'](handleError(_0x5a2252,null));};exports[_0x758b('0x2d')]=function(_0x9e3162,_0x253269){if(_0x9e3162[_0x758b('0x5a')]['id']){delete _0x9e3162[_0x758b('0x5a')]['id'];}return db[_0x758b('0x35')][_0x758b('0x50')]({'where':{'id':_0x9e3162[_0x758b('0x4e')]['id']}})[_0x758b('0x2e')](handleEntityNotFound(_0x253269,null))[_0x758b('0x2e')](saveUpdates(_0x9e3162[_0x758b('0x5a')],null))['then'](respondWithResult(_0x253269,null))[_0x758b('0x4c')](handleError(_0x253269,null));};exports[_0x758b('0x5b')]=function(_0x5aa4e3,_0x1214b4){return db[_0x758b('0x35')]['find']({'where':{'id':_0x5aa4e3[_0x758b('0x4e')]['id']}})[_0x758b('0x2e')](handleEntityNotFound(_0x1214b4,null))[_0x758b('0x2e')](removeEntity(_0x1214b4,null))['catch'](handleError(_0x1214b4,null));};exports[_0x758b('0x5c')]=function(_0x56831c,_0x46ba75){return db[_0x758b('0x35')][_0x758b('0x5c')]()[_0x758b('0x2e')](respondWithResult(_0x46ba75,null))[_0x758b('0x4c')](handleError(_0x46ba75,null));};exports[_0x758b('0x5d')]=function(_0x3da958,_0x2afad6,_0x3742b0){var _0x29d8b6={'raw':!![],'where':{}},_0x43cc96={},_0x5469d9;return db[_0x758b('0x35')][_0x758b('0x5e')]({'where':{'id':_0x3da958[_0x758b('0x4e')]['id']}})[_0x758b('0x2e')](handleEntityNotFound(_0x2afad6,null))[_0x758b('0x2e')](function(_0x2432e3){if(_0x2432e3){_0x5469d9=_0x2432e3[_0x758b('0x2f')]({'plain':!![]});_0x43cc96['model']=_['keys'](db[_0x758b('0x5f')][_0x758b('0x36')]);_0x43cc96[_0x758b('0x39')]=_[_0x758b('0x3a')](_0x3da958[_0x758b('0x39')]);_0x43cc96[_0x758b('0x44')]=_[_0x758b('0x3b')](_0x43cc96[_0x758b('0x3c')],_0x43cc96[_0x758b('0x39')]);_0x29d8b6[_0x758b('0x3d')]=_[_0x758b('0x3b')](_0x43cc96[_0x758b('0x3c')],qs[_0x758b('0x3e')](_0x3da958[_0x758b('0x39')]['fields']));_0x29d8b6[_0x758b('0x3d')]=_0x29d8b6['attributes'][_0x758b('0x3f')]?_0x29d8b6['attributes']:_0x43cc96[_0x758b('0x3c')];if(!_0x3da958[_0x758b('0x39')][_0x758b('0x40')]('nolimit')){_0x29d8b6['limit']=qs[_0x758b('0x28')](_0x3da958[_0x758b('0x39')]['limit']);_0x29d8b6[_0x758b('0x26')]=qs[_0x758b('0x26')](_0x3da958[_0x758b('0x39')][_0x758b('0x26')]);}_0x29d8b6[_0x758b('0x41')]=qs[_0x758b('0x42')](_0x3da958[_0x758b('0x39')][_0x758b('0x42')]);_0x29d8b6['where']=qs['filters'](_[_0x758b('0x45')](_0x3da958[_0x758b('0x39')],_0x43cc96[_0x758b('0x44')]));_0x29d8b6[_0x758b('0x43')][_0x758b('0x60')]=_0x2432e3['id'];if(_0x3da958[_0x758b('0x39')][_0x758b('0x46')]){_0x29d8b6[_0x758b('0x43')]=_[_0x758b('0x47')](_0x29d8b6['where'],{'$or':_[_0x758b('0x34')](_0x29d8b6[_0x758b('0x3d')],function(_0x1ef08a){var _0xd2db43={};_0xd2db43[_0x1ef08a]={'$like':'%'+_0x3da958[_0x758b('0x39')][_0x758b('0x46')]+'%'};return _0xd2db43;})});}_0x29d8b6=_['merge']({},_0x29d8b6,_0x3da958[_0x758b('0x48')]);return db[_0x758b('0x5f')]['findAll'](_0x29d8b6);}})[_0x758b('0x2e')](function(_0x4bde9c){if(_0x4bde9c){return db[_0x758b('0x61')]['findAndCountAll']({'where':{'id':_[_0x758b('0x34')](_0x4bde9c,_0x758b('0x62')),'role':_0x758b('0x63')},'attributes':['id',_0x758b('0x31'),_0x758b('0x64'),_0x758b('0x65'),_0x758b('0x66')]});}})['then'](function(_0x3bc89b){if(_0x3bc89b){return{'count':_0x3bc89b[_0x758b('0x29')],'rows':_['map'](_0x3bc89b[_0x758b('0x4b')],function(_0x3b6944){return{'membername':_0x3b6944['name'],'UserId':_0x3b6944['id'],'queue_name':_0x5469d9[_0x758b('0x31')],'MailQueueId':_0x5469d9['id'],'interface':util[_0x758b('0x67')](_0x758b('0x68'),_0x758b('0x69'),_0x3b6944[_0x758b('0x31')]),'penalty':0x0,'paused':_0x3b6944[_0x758b('0x64')],'createdAt':_0x3b6944[_0x758b('0x66')],'updatedAt':_0x3b6944[_0x758b('0x65')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x2afad6,_0x29d8b6))[_0x758b('0x4c')](handleError(_0x2afad6,null));};exports[_0x758b('0x6a')]=function(_0x2d9836,_0x1a708f,_0x72b667){var _0x2dca9f={};var _0x45f080={};var _0xde8c54;var _0x35914c;return db[_0x758b('0x35')]['findOne']({'where':{'id':_0x2d9836[_0x758b('0x4e')]['id']}})[_0x758b('0x2e')](handleEntityNotFound(_0x1a708f,null))[_0x758b('0x2e')](function(_0x78df57){if(_0x78df57){_0xde8c54=_0x78df57;_0x45f080[_0x758b('0x3c')]=_[_0x758b('0x3a')](db[_0x758b('0x6b')][_0x758b('0x36')]);_0x45f080['query']=_[_0x758b('0x3a')](_0x2d9836[_0x758b('0x39')]);_0x45f080['filters']=_[_0x758b('0x3b')](_0x45f080[_0x758b('0x3c')],_0x45f080[_0x758b('0x39')]);_0x2dca9f['attributes']=_['intersection'](_0x45f080[_0x758b('0x3c')],qs[_0x758b('0x3e')](_0x2d9836[_0x758b('0x39')][_0x758b('0x3e')]));_0x2dca9f[_0x758b('0x3d')]=_0x2dca9f['attributes'][_0x758b('0x3f')]?_0x2dca9f['attributes']:_0x45f080['model'];_0x2dca9f[_0x758b('0x41')]=qs['sort'](_0x2d9836[_0x758b('0x39')][_0x758b('0x42')]);_0x2dca9f[_0x758b('0x43')]=qs['filters'](_[_0x758b('0x45')](_0x2d9836['query'],_0x45f080['filters']));if(_0x2d9836['query']['filter']){_0x2dca9f[_0x758b('0x43')]=_['merge'](_0x2dca9f['where'],{'$or':_['map'](_0x2dca9f[_0x758b('0x3d')],function(_0x392259){var _0x4b9c1a={};_0x4b9c1a[_0x392259]={'$like':'%'+_0x2d9836[_0x758b('0x39')]['filter']+'%'};return _0x4b9c1a;})});}_0x2dca9f=_[_0x758b('0x47')]({},_0x2dca9f,_0x2d9836['options']);return _0xde8c54[_0x758b('0x6a')](_0x2dca9f);}})[_0x758b('0x2e')](function(_0xdb70e4){if(_0xdb70e4){_0x35914c=_0xdb70e4[_0x758b('0x3f')];if(!_0x2d9836[_0x758b('0x39')][_0x758b('0x40')]('nolimit')){_0x2dca9f[_0x758b('0x28')]=qs[_0x758b('0x28')](_0x2d9836[_0x758b('0x39')]['limit']);_0x2dca9f[_0x758b('0x26')]=qs[_0x758b('0x26')](_0x2d9836[_0x758b('0x39')][_0x758b('0x26')]);}return _0xde8c54[_0x758b('0x6a')](_0x2dca9f);}})[_0x758b('0x2e')](function(_0x97ae6e){if(_0x97ae6e){return _0x97ae6e?{'count':_0x35914c,'rows':_0x97ae6e}:null;}})['then'](respondWithResult(_0x1a708f,null))[_0x758b('0x4c')](handleError(_0x1a708f,null));};exports[_0x758b('0x6c')]=function(_0x31039b,_0x588a4e,_0x48c452){var _0x54cf57=_0x31039b['body'][_0x758b('0x6d')];return db[_0x758b('0x6b')][_0x758b('0x4a')]({'where':{'id':_0x54cf57},'attributes':['id'],'include':[{'model':db[_0x758b('0x61')],'as':_0x758b('0x6e'),'attributes':['id',_0x758b('0x31'),_0x758b('0x6f'),_0x758b('0x70'),_0x758b('0x71')],'raw':!![]}]})[_0x758b('0x2e')](function(_0x4b824b){if(_0x4b824b){var _0x138eda=_[_0x758b('0x72')](_0x4b824b,function(_0x538df8){var _0x1c39dc=_0x538df8[_0x758b('0x2f')]({'plain':!![]});return _0x1c39dc[_0x758b('0x6e')];});return db[_0x758b('0x35')][_0x758b('0x50')]({'where':{'id':_0x31039b[_0x758b('0x4e')]['id']}})[_0x758b('0x2e')](function(_0x4f02dd){return db['sequelize'][_0x758b('0x73')](function(_0x53ed73){return _0x4f02dd[_0x758b('0x6c')](_0x54cf57,{'transaction':_0x53ed73})[_0x758b('0x2e')](function(){return BPromise[_0x758b('0x74')](_0x138eda,function(_0x1bdb63){return db[_0x758b('0x5f')]['findOrCreate']({'where':{'UserId':_0x1bdb63['id'],'MailQueueId':_0x31039b[_0x758b('0x4e')]['id']},'transaction':_0x53ed73});});})[_0x758b('0x2e')](function(){_0x138eda[_0x758b('0x75')](function(_0x5b0966){socket['emit'](_0x758b('0x76'),{'UserId':_0x5b0966['id'],'MailQueueId':_0x4f02dd['id']});});});});});}})['then'](respondWithStatusCode(_0x588a4e,null))[_0x758b('0x4c')](handleError(_0x588a4e,null));};exports['removeTeams']=function(_0x446936,_0x2dfd99,_0x5ea83c){return db['Team'][_0x758b('0x4a')]({'where':{'id':_0x446936[_0x758b('0x39')][_0x758b('0x6d')]},'attributes':['id'],'include':[{'model':db[_0x758b('0x61')],'as':_0x758b('0x6e'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x2dfd99,null))[_0x758b('0x2e')](function(_0x3f910f){var _0x5867d8=_['map'](_0x3f910f,'id');var _0xa068e2=[];var _0x311233=[];var _0x2e469d=squel[_0x758b('0x77')]();_0x2e469d[_0x758b('0x78')](_0x758b('0x79'))[_0x758b('0x7a')](_0x758b('0x7b'),'tq')[_0x758b('0x7c')](_0x758b('0x7d'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x758b('0x43')](_0x758b('0x7e'),_0x446936[_0x758b('0x4e')]['id']);for(var _0x7cbf50=0x0;_0x7cbf50<_0x3f910f['length'];_0x7cbf50+=0x1){let _0x2d839b=_0x3f910f[_0x7cbf50];for(var _0x190562=0x0;_0x190562<_0x2d839b[_0x758b('0x6e')]['length'];_0x190562+=0x1){let _0x3270bd=_0x2d839b[_0x758b('0x6e')][_0x190562];var _0x4854f3=_0x2e469d[_0x758b('0x7f')]();_0x4854f3[_0x758b('0x43')]('ut.UserId\x20=\x20?',_0x3270bd['id']);_0x311233[_0x758b('0x80')](db[_0x758b('0x81')][_0x758b('0x39')](_0x4854f3[_0x758b('0x82')](),{'type':db[_0x758b('0x81')][_0x758b('0x83')][_0x758b('0x84')]})[_0x758b('0x2e')](function(_0x387d05){if(_0x387d05[_0x758b('0x3f')]===0x1){return _0x3270bd['id'];}else{var _0x142549=_[_0x758b('0x85')](_[_0x758b('0x34')](_0x387d05,_0x758b('0x86')),function(_0x22bfc7){return _[_0x758b('0x87')](_0x5867d8,_0x22bfc7);});if(_0x142549){return _0x3270bd['id'];}}}));}}return BPromise['all'](_0x311233)[_0x758b('0x2e')](function(_0x27289b){_0xa068e2=_(_0xa068e2)['union'](_0x27289b)[_0x758b('0x88')]()[_0x758b('0x89')]();return db['MailQueue'][_0x758b('0x50')]({'where':{'id':_0x446936['params']['id']}})[_0x758b('0x2e')](function(_0x162c46){return db[_0x758b('0x81')]['transaction'](function(_0x15a1b9){return _0x162c46[_0x758b('0x8a')](_0x446936['query'][_0x758b('0x6d')],{'transaction':_0x15a1b9})[_0x758b('0x2e')](function(){if(!_[_0x758b('0x8b')](_0xa068e2)){return _0x162c46[_0x758b('0x8c')](_0xa068e2,{'transaction':_0x15a1b9});}})[_0x758b('0x2e')](function(){_0xa068e2[_0x758b('0x75')](function(_0x220511){socket[_0x758b('0x8d')]('userMailQueue:remove',{'UserId':_0x220511,'MailQueueId':_0x162c46['id']});});});});});});})['then'](respondWithStatusCode(_0x2dfd99,null))[_0x758b('0x4c')](handleError(_0x2dfd99,null));};exports[_0x758b('0x8e')]=function(_0x1c40e3,_0x32fa2a,_0x29ed2a){return db['MailQueue'][_0x758b('0x50')]({'where':{'id':_0x1c40e3[_0x758b('0x4e')]['id']}})['then'](handleEntityNotFound(_0x32fa2a,null))['then'](function(_0xb2e04d){if(_0xb2e04d){return _0xb2e04d['addAgents'](_0x1c40e3[_0x758b('0x5a')][_0x758b('0x6d')],_['omit'](_0x1c40e3['body'],['ids','id'])||{})[_0x758b('0x8f')](function(_0x116090){for(var _0x2cef68=0x0;_0x2cef68<_0x1c40e3[_0x758b('0x5a')][_0x758b('0x6d')][_0x758b('0x3f')];_0x2cef68+=0x1){socket[_0x758b('0x8d')]('userMailQueue:save',{'UserId':Number(_0x1c40e3[_0x758b('0x5a')][_0x758b('0x6d')][_0x2cef68]),'MailQueueId':Number(_0x1c40e3[_0x758b('0x4e')]['id'])});}return _0x116090;});}})['then'](respondWithResult(_0x32fa2a,null))[_0x758b('0x4c')](handleError(_0x32fa2a,null));};exports[_0x758b('0x8c')]=function(_0xe28b87,_0xf6723b,_0x558179){return db['MailQueue'][_0x758b('0x50')]({'where':{'id':_0xe28b87[_0x758b('0x4e')]['id']}})[_0x758b('0x2e')](handleEntityNotFound(_0xf6723b,null))[_0x758b('0x2e')](function(_0x4eecb4){if(_0x4eecb4){return _0x4eecb4[_0x758b('0x8c')](_0xe28b87[_0x758b('0x39')][_0x758b('0x6d')])[_0x758b('0x2e')](function(){if(_[_0x758b('0x90')](_0xe28b87['query'][_0x758b('0x6d')])){for(var _0x5b5e1a=0x0;_0x5b5e1a<_0xe28b87[_0x758b('0x39')]['ids'][_0x758b('0x3f')];_0x5b5e1a+=0x1){socket[_0x758b('0x8d')](_0x758b('0x91'),{'UserId':Number(_0xe28b87['query'][_0x758b('0x6d')][_0x5b5e1a]),'MailQueueId':Number(_0xe28b87[_0x758b('0x4e')]['id'])});}}else{socket[_0x758b('0x8d')](_0x758b('0x91'),{'UserId':Number(_0xe28b87[_0x758b('0x39')]['ids']),'MailQueueId':Number(_0xe28b87['params']['id'])});}});}})['then'](respondWithStatusCode(_0xf6723b,null))['catch'](handleError(_0xf6723b,null));};exports[_0x758b('0x92')]=function(_0x4adde0,_0x56f687,_0x1c58a2){var _0x102c50={};var _0x32737f={};var _0x2347aa;var _0x3c6d04;return db[_0x758b('0x35')][_0x758b('0x5e')]({'where':{'id':_0x4adde0[_0x758b('0x4e')]['id']}})[_0x758b('0x2e')](handleEntityNotFound(_0x56f687,null))[_0x758b('0x2e')](function(_0x171612){if(_0x171612){_0x2347aa=_0x171612;_0x32737f[_0x758b('0x3c')]=_[_0x758b('0x3a')](db[_0x758b('0x61')][_0x758b('0x36')]);_0x32737f['query']=_[_0x758b('0x3a')](_0x4adde0[_0x758b('0x39')]);_0x32737f[_0x758b('0x44')]=_[_0x758b('0x3b')](_0x32737f[_0x758b('0x3c')],_0x32737f[_0x758b('0x39')]);_0x102c50[_0x758b('0x3d')]=_['intersection'](_0x32737f[_0x758b('0x3c')],qs[_0x758b('0x3e')](_0x4adde0[_0x758b('0x39')]['fields']));_0x102c50[_0x758b('0x3d')]=_0x102c50[_0x758b('0x3d')][_0x758b('0x3f')]?_0x102c50[_0x758b('0x3d')]:_0x32737f[_0x758b('0x3c')];_0x102c50['order']=qs['sort'](_0x4adde0[_0x758b('0x39')][_0x758b('0x42')]);_0x102c50[_0x758b('0x43')]=qs['filters'](_[_0x758b('0x45')](_0x4adde0[_0x758b('0x39')],_0x32737f[_0x758b('0x44')]));if(_0x4adde0[_0x758b('0x39')]['filter']){_0x102c50[_0x758b('0x43')]=_['merge'](_0x102c50[_0x758b('0x43')],{'$or':_[_0x758b('0x34')](_0x102c50[_0x758b('0x3d')],function(_0x451b2c){var _0x11ab9e={};_0x11ab9e[_0x451b2c]={'$like':'%'+_0x4adde0['query'][_0x758b('0x46')]+'%'};return _0x11ab9e;})});}_0x102c50=_['merge']({},_0x102c50,_0x4adde0[_0x758b('0x48')]);return _0x2347aa[_0x758b('0x92')](_0x102c50);}})[_0x758b('0x2e')](function(_0x3626a1){if(_0x3626a1){_0x3c6d04=_0x3626a1[_0x758b('0x3f')];if(!_0x4adde0[_0x758b('0x39')][_0x758b('0x40')](_0x758b('0x93'))){_0x102c50['limit']=qs[_0x758b('0x28')](_0x4adde0['query'][_0x758b('0x28')]);_0x102c50[_0x758b('0x26')]=qs[_0x758b('0x26')](_0x4adde0[_0x758b('0x39')][_0x758b('0x26')]);}return _0x2347aa['getAgents'](_0x102c50);}})['then'](function(_0x144c3c){if(_0x144c3c){return _0x144c3c?{'count':_0x3c6d04,'rows':_0x144c3c}:null;}})['then'](respondWithResult(_0x56f687,null))[_0x758b('0x4c')](handleError(_0x56f687,null));};
\ No newline at end of file