Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 496f0ac..169b87e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+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