Built motion from commit (unavailable).|2.5.27
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 496f0ac..f13a27d 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 _0xa9d7=['interface','flatMap','Agents','transaction','forEach','emit','userMailQueue:save','removeTeams','field','tq.TeamId','team_has_mail_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','sequelize','QueryTypes','SELECT','every','includes','all','union','compact','value','isEmpty','removeAgents','addAgents','spread','isArray','userMailQueue:remove','getAgents','eml-format','rimraf','zip-dir','request-promise','moment','util','path','sox','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','redis','localhost','socket.io-emitter','./mailQueue.socket','register','sendStatus','end','status','count','offset','limit','Content-Range','json','apply','reject','update','then','destroy','MailQueues','UserProfileResource','error','stack','name','map','MailQueue','fieldName','type','key','model','query','filters','attributes','intersection','fields','length','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','keys','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','find','autoAssociation','body','describe','getMembers','UserMailQueue','hasOwnProperty','nolimit','order','User','agent','mailPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','ids','online','voicePause'];(function(_0x3806b1,_0x425a11){var _0x2a0da2=function(_0x4833f3){while(--_0x4833f3){_0x3806b1['push'](_0x3806b1['shift']());}};_0x2a0da2(++_0x425a11);}(_0xa9d7,0x134));var _0x7a9d=function(_0x1e23f5,_0x5d4743){_0x1e23f5=_0x1e23f5-0x0;var _0xb815c5=_0xa9d7[_0x1e23f5];return _0xb815c5;};'use strict';var emlformat=require(_0x7a9d('0x0'));var rimraf=require(_0x7a9d('0x1'));var zipdir=require(_0x7a9d('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7a9d('0x3'));var moment=require(_0x7a9d('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x7a9d('0x5'));var path=require(_0x7a9d('0x6'));var sox=require(_0x7a9d('0x7'));var csv=require(_0x7a9d('0x8'));var ejs=require(_0x7a9d('0x9'));var fs=require('fs');var fs_extra=require(_0x7a9d('0xa'));var _=require(_0x7a9d('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x7a9d('0xc'));var deskjs=require(_0x7a9d('0xd'));var toCsv=require(_0x7a9d('0x8'));var querystring=require(_0x7a9d('0xe'));var Papa=require(_0x7a9d('0xf'));var Redis=require(_0x7a9d('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x7a9d('0x11'));var as=require(_0x7a9d('0x12'));var hardwareService=require(_0x7a9d('0x13'));var logger=require(_0x7a9d('0x14'))(_0x7a9d('0x15'));var utils=require(_0x7a9d('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x7a9d('0x17'))['db'];config[_0x7a9d('0x18')]=_['defaults'](config['redis'],{'host':_0x7a9d('0x19'),'port':0x18eb});var socket=require(_0x7a9d('0x1a'))(new Redis(config[_0x7a9d('0x18')]));require(_0x7a9d('0x1b'))[_0x7a9d('0x1c')](socket);function respondWithStatusCode(_0x2d7101,_0x5d7b92){_0x5d7b92=_0x5d7b92||0xcc;return function(_0x2a69fc){if(_0x2a69fc){return _0x2d7101[_0x7a9d('0x1d')](_0x5d7b92);}return _0x2d7101['status'](_0x5d7b92)[_0x7a9d('0x1e')]();};}function respondWithResult(_0x51a578,_0x3b0172){_0x3b0172=_0x3b0172||0xc8;return function(_0x36e4a4){if(_0x36e4a4){return _0x51a578[_0x7a9d('0x1f')](_0x3b0172)['json'](_0x36e4a4);}};}function respondWithFilteredResult(_0x260123,_0x46b60a){return function(_0x4e4992){if(_0x4e4992){var _0x3dde5e=_0x4e4992[_0x7a9d('0x20')],_0x1897b8=_0x46b60a[_0x7a9d('0x21')],_0x51a0c1=_0x46b60a[_0x7a9d('0x21')]+_0x46b60a[_0x7a9d('0x22')],_0x42ff12;if(_0x51a0c1>=_0x3dde5e){_0x51a0c1=_0x3dde5e;_0x42ff12=0xc8;}else{_0x42ff12=0xce;}_0x260123[_0x7a9d('0x1f')](_0x42ff12);return _0x260123['set'](_0x7a9d('0x23'),_0x1897b8+'-'+_0x51a0c1+'/'+_0x3dde5e)[_0x7a9d('0x24')](_0x4e4992);}return null;};}function patchUpdates(_0x392cbd){return function(_0x242279){try{jsonpatch[_0x7a9d('0x25')](_0x242279,_0x392cbd,!![]);}catch(_0x80fb64){return BPromise[_0x7a9d('0x26')](_0x80fb64);}return _0x242279['save']();};}function saveUpdates(_0x524998,_0x3ffbb6){return function(_0x1eb1df){if(_0x1eb1df){return _0x1eb1df[_0x7a9d('0x27')](_0x524998)[_0x7a9d('0x28')](function(_0x479fdf){return _0x479fdf;});}return null;};}function removeEntity(_0x5234fa,_0xe859c0){return function(_0x1a1aa7){if(_0x1a1aa7){return _0x1a1aa7[_0x7a9d('0x29')]()[_0x7a9d('0x28')](function(){var _0x5254f9=_0x1a1aa7['get']({'plain':!![]});var _0x3f7b20=_0x7a9d('0x2a');return db[_0x7a9d('0x2b')][_0x7a9d('0x29')]({'where':{'type':_0x3f7b20,'resourceId':_0x5254f9['id']}})[_0x7a9d('0x28')](function(){return _0x1a1aa7;});})[_0x7a9d('0x28')](function(){_0x5234fa['status'](0xcc)[_0x7a9d('0x1e')]();});}};}function handleEntityNotFound(_0x891e0c,_0xcf8b08){return function(_0x25f2df){if(!_0x25f2df){_0x891e0c[_0x7a9d('0x1d')](0x194);}return _0x25f2df;};}function handleError(_0x4d5995,_0x377de1){_0x377de1=_0x377de1||0x1f4;return function(_0x11f473){logger[_0x7a9d('0x2c')](_0x11f473[_0x7a9d('0x2d')]);if(_0x11f473['name']){delete _0x11f473[_0x7a9d('0x2e')];}_0x4d5995[_0x7a9d('0x1f')](_0x377de1)['send'](_0x11f473);};}exports['index']=function(_0x51843e,_0x2591a3){var _0x2a084f={},_0x4d05e3={},_0x1839a8={'count':0x0,'rows':[]};var _0x512c06=_[_0x7a9d('0x2f')](db[_0x7a9d('0x30')]['rawAttributes'],function(_0x41e536){return{'name':_0x41e536[_0x7a9d('0x31')],'type':_0x41e536[_0x7a9d('0x32')][_0x7a9d('0x33')]};});_0x4d05e3[_0x7a9d('0x34')]=_['map'](_0x512c06,_0x7a9d('0x2e'));_0x4d05e3[_0x7a9d('0x35')]=_['keys'](_0x51843e[_0x7a9d('0x35')]);_0x4d05e3[_0x7a9d('0x36')]=_['intersection'](_0x4d05e3[_0x7a9d('0x34')],_0x4d05e3[_0x7a9d('0x35')]);_0x2a084f[_0x7a9d('0x37')]=_[_0x7a9d('0x38')](_0x4d05e3[_0x7a9d('0x34')],qs[_0x7a9d('0x39')](_0x51843e[_0x7a9d('0x35')][_0x7a9d('0x39')]));_0x2a084f[_0x7a9d('0x37')]=_0x2a084f[_0x7a9d('0x37')][_0x7a9d('0x3a')]?_0x2a084f['attributes']:_0x4d05e3[_0x7a9d('0x34')];if(!_0x51843e['query']['hasOwnProperty']('nolimit')){_0x2a084f[_0x7a9d('0x22')]=qs[_0x7a9d('0x22')](_0x51843e[_0x7a9d('0x35')][_0x7a9d('0x22')]);_0x2a084f[_0x7a9d('0x21')]=qs[_0x7a9d('0x21')](_0x51843e[_0x7a9d('0x35')][_0x7a9d('0x21')]);}_0x2a084f['order']=qs[_0x7a9d('0x3b')](_0x51843e[_0x7a9d('0x35')][_0x7a9d('0x3b')]);_0x2a084f['where']=qs[_0x7a9d('0x36')](_[_0x7a9d('0x3c')](_0x51843e[_0x7a9d('0x35')],_0x4d05e3[_0x7a9d('0x36')]),_0x512c06);if(_0x51843e[_0x7a9d('0x35')][_0x7a9d('0x3d')]){_0x2a084f[_0x7a9d('0x3e')]=_[_0x7a9d('0x3f')](_0x2a084f[_0x7a9d('0x3e')],{'$or':_['map'](_0x512c06,function(_0x3c559c){if(_0x3c559c['type']!==_0x7a9d('0x40')){var _0x560da6={};_0x560da6[_0x3c559c['name']]={'$like':'%'+_0x51843e[_0x7a9d('0x35')][_0x7a9d('0x3d')]+'%'};return _0x560da6;}})});}_0x2a084f=_[_0x7a9d('0x3f')]({},_0x2a084f,_0x51843e[_0x7a9d('0x41')]);var _0x54f0fb={'where':_0x2a084f[_0x7a9d('0x3e')]};return db[_0x7a9d('0x30')][_0x7a9d('0x20')](_0x54f0fb)['then'](function(_0xd0d934){_0x1839a8[_0x7a9d('0x20')]=_0xd0d934;if(_0x51843e[_0x7a9d('0x35')][_0x7a9d('0x42')]){_0x2a084f[_0x7a9d('0x43')]=[{'all':!![]}];}return db[_0x7a9d('0x30')][_0x7a9d('0x44')](_0x2a084f);})[_0x7a9d('0x28')](function(_0x3c84ee){_0x1839a8[_0x7a9d('0x45')]=_0x3c84ee;return _0x1839a8;})[_0x7a9d('0x28')](respondWithFilteredResult(_0x2591a3,_0x2a084f))[_0x7a9d('0x46')](handleError(_0x2591a3,null));};exports[_0x7a9d('0x47')]=function(_0x1cdaf0,_0x53c593){var _0x278889={'raw':!![],'where':{'id':_0x1cdaf0[_0x7a9d('0x48')]['id']}},_0xf65e0e={};_0xf65e0e[_0x7a9d('0x34')]=_['keys'](db['MailQueue'][_0x7a9d('0x49')]);_0xf65e0e[_0x7a9d('0x35')]=_[_0x7a9d('0x4a')](_0x1cdaf0['query']);_0xf65e0e[_0x7a9d('0x36')]=_[_0x7a9d('0x38')](_0xf65e0e[_0x7a9d('0x34')],_0xf65e0e[_0x7a9d('0x35')]);_0x278889[_0x7a9d('0x37')]=_[_0x7a9d('0x38')](_0xf65e0e[_0x7a9d('0x34')],qs[_0x7a9d('0x39')](_0x1cdaf0['query'][_0x7a9d('0x39')]));_0x278889['attributes']=_0x278889[_0x7a9d('0x37')]['length']?_0x278889[_0x7a9d('0x37')]:_0xf65e0e['model'];if(_0x1cdaf0[_0x7a9d('0x35')][_0x7a9d('0x42')]){_0x278889[_0x7a9d('0x43')]=[{'all':!![]}];}_0x278889=_[_0x7a9d('0x3f')]({},_0x278889,_0x1cdaf0[_0x7a9d('0x41')]);return db['MailQueue']['find'](_0x278889)[_0x7a9d('0x28')](handleEntityNotFound(_0x53c593,null))[_0x7a9d('0x28')](respondWithResult(_0x53c593,null))[_0x7a9d('0x46')](handleError(_0x53c593,null));};exports[_0x7a9d('0x4b')]=function(_0x50c6e0,_0x3f1745){return db[_0x7a9d('0x30')]['create'](_0x50c6e0['body'],{})[_0x7a9d('0x28')](function(_0x4d62a0){var _0x1a91a1=_0x50c6e0[_0x7a9d('0x4c')][_0x7a9d('0x4d')]({'plain':!![]});if(!_0x1a91a1)throw new Error(_0x7a9d('0x4e'));if(_0x1a91a1[_0x7a9d('0x4f')]==='user'){var _0x251297=_0x4d62a0['get']({'plain':!![]});var _0x344049='MailQueues';return db['UserProfileSection'][_0x7a9d('0x50')]({'where':{'name':_0x344049,'userProfileId':_0x1a91a1['userProfileId']},'raw':!![]})[_0x7a9d('0x28')](function(_0x15d26f){if(_0x15d26f&&_0x15d26f[_0x7a9d('0x51')]===0x0){return db[_0x7a9d('0x2b')][_0x7a9d('0x4b')]({'name':_0x251297['name'],'resourceId':_0x251297['id'],'type':_0x15d26f['name'],'sectionId':_0x15d26f['id']},{})['then'](function(){return _0x4d62a0;});}else{return _0x4d62a0;}})[_0x7a9d('0x46')](function(_0x213354){logger[_0x7a9d('0x2c')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x213354);throw _0x213354;});}return _0x4d62a0;})[_0x7a9d('0x28')](respondWithResult(_0x3f1745,0xc9))['catch'](handleError(_0x3f1745,null));};exports[_0x7a9d('0x27')]=function(_0x2e1ab1,_0x1d5000){if(_0x2e1ab1['body']['id']){delete _0x2e1ab1[_0x7a9d('0x52')]['id'];}return db[_0x7a9d('0x30')][_0x7a9d('0x50')]({'where':{'id':_0x2e1ab1['params']['id']}})[_0x7a9d('0x28')](handleEntityNotFound(_0x1d5000,null))[_0x7a9d('0x28')](saveUpdates(_0x2e1ab1[_0x7a9d('0x52')],null))[_0x7a9d('0x28')](respondWithResult(_0x1d5000,null))[_0x7a9d('0x46')](handleError(_0x1d5000,null));};exports[_0x7a9d('0x29')]=function(_0x544c77,_0x379205){return db[_0x7a9d('0x30')]['find']({'where':{'id':_0x544c77[_0x7a9d('0x48')]['id']}})[_0x7a9d('0x28')](handleEntityNotFound(_0x379205,null))[_0x7a9d('0x28')](removeEntity(_0x379205,null))[_0x7a9d('0x46')](handleError(_0x379205,null));};exports['describe']=function(_0x59b3e2,_0x13a534){return db[_0x7a9d('0x30')][_0x7a9d('0x53')]()[_0x7a9d('0x28')](respondWithResult(_0x13a534,null))[_0x7a9d('0x46')](handleError(_0x13a534,null));};exports[_0x7a9d('0x54')]=function(_0x2aa8d2,_0x9e4717,_0x35bde6){var _0x41f07e={'raw':!![],'where':{}},_0x26f48f={},_0x53b92a;return db[_0x7a9d('0x30')]['findOne']({'where':{'id':_0x2aa8d2[_0x7a9d('0x48')]['id']}})[_0x7a9d('0x28')](handleEntityNotFound(_0x9e4717,null))[_0x7a9d('0x28')](function(_0x34fb23){if(_0x34fb23){_0x53b92a=_0x34fb23['get']({'plain':!![]});_0x26f48f[_0x7a9d('0x34')]=_[_0x7a9d('0x4a')](db[_0x7a9d('0x55')][_0x7a9d('0x49')]);_0x26f48f['query']=_['keys'](_0x2aa8d2['query']);_0x26f48f[_0x7a9d('0x36')]=_[_0x7a9d('0x38')](_0x26f48f['model'],_0x26f48f['query']);_0x41f07e[_0x7a9d('0x37')]=_[_0x7a9d('0x38')](_0x26f48f['model'],qs['fields'](_0x2aa8d2[_0x7a9d('0x35')][_0x7a9d('0x39')]));_0x41f07e[_0x7a9d('0x37')]=_0x41f07e[_0x7a9d('0x37')]['length']?_0x41f07e[_0x7a9d('0x37')]:_0x26f48f[_0x7a9d('0x34')];if(!_0x2aa8d2[_0x7a9d('0x35')][_0x7a9d('0x56')](_0x7a9d('0x57'))){_0x41f07e[_0x7a9d('0x22')]=qs[_0x7a9d('0x22')](_0x2aa8d2[_0x7a9d('0x35')][_0x7a9d('0x22')]);_0x41f07e[_0x7a9d('0x21')]=qs[_0x7a9d('0x21')](_0x2aa8d2[_0x7a9d('0x35')][_0x7a9d('0x21')]);}_0x41f07e[_0x7a9d('0x58')]=qs[_0x7a9d('0x3b')](_0x2aa8d2[_0x7a9d('0x35')][_0x7a9d('0x3b')]);_0x41f07e[_0x7a9d('0x3e')]=qs[_0x7a9d('0x36')](_[_0x7a9d('0x3c')](_0x2aa8d2[_0x7a9d('0x35')],_0x26f48f[_0x7a9d('0x36')]));_0x41f07e[_0x7a9d('0x3e')]['MailQueueId']=_0x34fb23['id'];if(_0x2aa8d2[_0x7a9d('0x35')][_0x7a9d('0x3d')]){_0x41f07e[_0x7a9d('0x3e')]=_[_0x7a9d('0x3f')](_0x41f07e[_0x7a9d('0x3e')],{'$or':_[_0x7a9d('0x2f')](_0x41f07e[_0x7a9d('0x37')],function(_0x50b096){var _0x23ec8b={};_0x23ec8b[_0x50b096]={'$like':'%'+_0x2aa8d2['query']['filter']+'%'};return _0x23ec8b;})});}_0x41f07e=_['merge']({},_0x41f07e,_0x2aa8d2[_0x7a9d('0x41')]);return db[_0x7a9d('0x55')][_0x7a9d('0x44')](_0x41f07e);}})[_0x7a9d('0x28')](function(_0x563dc9){if(_0x563dc9){return db[_0x7a9d('0x59')]['findAndCountAll']({'where':{'id':_[_0x7a9d('0x2f')](_0x563dc9,'UserId'),'role':_0x7a9d('0x5a')},'attributes':['id',_0x7a9d('0x2e'),_0x7a9d('0x5b'),_0x7a9d('0x5c'),_0x7a9d('0x5d')]});}})[_0x7a9d('0x28')](function(_0x231413){if(_0x231413){return{'count':_0x231413['count'],'rows':_[_0x7a9d('0x2f')](_0x231413[_0x7a9d('0x45')],function(_0x4b180b){return{'membername':_0x4b180b[_0x7a9d('0x2e')],'UserId':_0x4b180b['id'],'queue_name':_0x53b92a[_0x7a9d('0x2e')],'MailQueueId':_0x53b92a['id'],'interface':util[_0x7a9d('0x5e')](_0x7a9d('0x5f'),_0x7a9d('0x60'),_0x4b180b[_0x7a9d('0x2e')]),'penalty':0x0,'paused':_0x4b180b[_0x7a9d('0x5b')],'createdAt':_0x4b180b[_0x7a9d('0x5d')],'updatedAt':_0x4b180b[_0x7a9d('0x5c')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x7a9d('0x28')](respondWithFilteredResult(_0x9e4717,_0x41f07e))[_0x7a9d('0x46')](handleError(_0x9e4717,null));};exports[_0x7a9d('0x61')]=function(_0x2ab0a4,_0x6b02b5,_0x4c5c26){var _0x20ce34={};var _0x2c9627={};var _0x316b12;var _0x20d238;return db[_0x7a9d('0x30')]['findOne']({'where':{'id':_0x2ab0a4[_0x7a9d('0x48')]['id']}})[_0x7a9d('0x28')](handleEntityNotFound(_0x6b02b5,null))[_0x7a9d('0x28')](function(_0x276b45){if(_0x276b45){_0x316b12=_0x276b45;_0x2c9627[_0x7a9d('0x34')]=_[_0x7a9d('0x4a')](db[_0x7a9d('0x62')][_0x7a9d('0x49')]);_0x2c9627[_0x7a9d('0x35')]=_[_0x7a9d('0x4a')](_0x2ab0a4[_0x7a9d('0x35')]);_0x2c9627[_0x7a9d('0x36')]=_[_0x7a9d('0x38')](_0x2c9627[_0x7a9d('0x34')],_0x2c9627[_0x7a9d('0x35')]);_0x20ce34['attributes']=_[_0x7a9d('0x38')](_0x2c9627[_0x7a9d('0x34')],qs[_0x7a9d('0x39')](_0x2ab0a4['query'][_0x7a9d('0x39')]));_0x20ce34[_0x7a9d('0x37')]=_0x20ce34[_0x7a9d('0x37')]['length']?_0x20ce34[_0x7a9d('0x37')]:_0x2c9627[_0x7a9d('0x34')];_0x20ce34['order']=qs[_0x7a9d('0x3b')](_0x2ab0a4['query'][_0x7a9d('0x3b')]);_0x20ce34[_0x7a9d('0x3e')]=qs[_0x7a9d('0x36')](_[_0x7a9d('0x3c')](_0x2ab0a4[_0x7a9d('0x35')],_0x2c9627[_0x7a9d('0x36')]));if(_0x2ab0a4[_0x7a9d('0x35')]['filter']){_0x20ce34[_0x7a9d('0x3e')]=_[_0x7a9d('0x3f')](_0x20ce34[_0x7a9d('0x3e')],{'$or':_[_0x7a9d('0x2f')](_0x20ce34[_0x7a9d('0x37')],function(_0x48d087){var _0x473fa7={};_0x473fa7[_0x48d087]={'$like':'%'+_0x2ab0a4[_0x7a9d('0x35')][_0x7a9d('0x3d')]+'%'};return _0x473fa7;})});}_0x20ce34=_['merge']({},_0x20ce34,_0x2ab0a4['options']);return _0x316b12[_0x7a9d('0x61')](_0x20ce34);}})['then'](function(_0x46538c){if(_0x46538c){_0x20d238=_0x46538c[_0x7a9d('0x3a')];if(!_0x2ab0a4[_0x7a9d('0x35')][_0x7a9d('0x56')](_0x7a9d('0x57'))){_0x20ce34[_0x7a9d('0x22')]=qs[_0x7a9d('0x22')](_0x2ab0a4[_0x7a9d('0x35')][_0x7a9d('0x22')]);_0x20ce34[_0x7a9d('0x21')]=qs[_0x7a9d('0x21')](_0x2ab0a4['query'][_0x7a9d('0x21')]);}return _0x316b12[_0x7a9d('0x61')](_0x20ce34);}})['then'](function(_0x3d35b7){if(_0x3d35b7){return _0x3d35b7?{'count':_0x20d238,'rows':_0x3d35b7}:null;}})[_0x7a9d('0x28')](respondWithResult(_0x6b02b5,null))[_0x7a9d('0x46')](handleError(_0x6b02b5,null));};exports[_0x7a9d('0x63')]=function(_0x3f59d1,_0x2abea6,_0x1d27d1){var _0x5494ff=_0x3f59d1[_0x7a9d('0x52')][_0x7a9d('0x64')];return db[_0x7a9d('0x62')][_0x7a9d('0x44')]({'where':{'id':_0x5494ff},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0x7a9d('0x2e'),_0x7a9d('0x65'),_0x7a9d('0x66'),_0x7a9d('0x67')],'raw':!![]}]})[_0x7a9d('0x28')](function(_0x219631){if(_0x219631){var _0x359a40=_[_0x7a9d('0x68')](_0x219631,function(_0x3632a6){var _0x4c59be=_0x3632a6[_0x7a9d('0x4d')]({'plain':!![]});return _0x4c59be[_0x7a9d('0x69')];});return db[_0x7a9d('0x30')][_0x7a9d('0x50')]({'where':{'id':_0x3f59d1[_0x7a9d('0x48')]['id']}})[_0x7a9d('0x28')](function(_0x4daa6e){return db['sequelize'][_0x7a9d('0x6a')](function(_0x30a9ec){return _0x4daa6e[_0x7a9d('0x63')](_0x5494ff,{'transaction':_0x30a9ec})['then'](function(){return BPromise['each'](_0x359a40,function(_0x5509cf){return db['UserMailQueue']['findOrCreate']({'where':{'UserId':_0x5509cf['id'],'MailQueueId':_0x3f59d1[_0x7a9d('0x48')]['id']},'transaction':_0x30a9ec});});})[_0x7a9d('0x28')](function(){_0x359a40[_0x7a9d('0x6b')](function(_0x1ec99c){socket[_0x7a9d('0x6c')](_0x7a9d('0x6d'),{'UserId':_0x1ec99c['id'],'MailQueueId':_0x4daa6e['id']});});});});});}})[_0x7a9d('0x28')](respondWithStatusCode(_0x2abea6,null))['catch'](handleError(_0x2abea6,null));};exports[_0x7a9d('0x6e')]=function(_0xf8663e,_0x561d22,_0x208c3a){return db['Team'][_0x7a9d('0x44')]({'where':{'id':_0xf8663e[_0x7a9d('0x35')]['ids']},'attributes':['id'],'include':[{'model':db[_0x7a9d('0x59')],'as':_0x7a9d('0x69'),'attributes':['id'],'raw':!![]}]})[_0x7a9d('0x28')](handleEntityNotFound(_0x561d22,null))[_0x7a9d('0x28')](function(_0x49082c){var _0x478b9f=_[_0x7a9d('0x2f')](_0x49082c,'id');var _0x7cbb6f=[];var _0x1b95c2=[];var _0x3be6e2=squel['select']();_0x3be6e2[_0x7a9d('0x6f')](_0x7a9d('0x70'))['from'](_0x7a9d('0x71'),'tq')['join'](_0x7a9d('0x72'),'ut',_0x7a9d('0x73'))[_0x7a9d('0x3e')](_0x7a9d('0x74'),_0xf8663e[_0x7a9d('0x48')]['id']);for(var _0x33005f=0x0;_0x33005f<_0x49082c[_0x7a9d('0x3a')];_0x33005f+=0x1){let _0x110537=_0x49082c[_0x33005f];for(var _0x1c3986=0x0;_0x1c3986<_0x110537['Agents'][_0x7a9d('0x3a')];_0x1c3986+=0x1){let _0x2c7861=_0x110537['Agents'][_0x1c3986];var _0x2f96dc=_0x3be6e2[_0x7a9d('0x75')]();_0x2f96dc[_0x7a9d('0x3e')](_0x7a9d('0x76'),_0x2c7861['id']);_0x1b95c2[_0x7a9d('0x77')](db['sequelize']['query'](_0x2f96dc[_0x7a9d('0x78')](),{'type':db[_0x7a9d('0x79')][_0x7a9d('0x7a')][_0x7a9d('0x7b')]})[_0x7a9d('0x28')](function(_0x47e0b5){if(_0x47e0b5[_0x7a9d('0x3a')]===0x1){return _0x2c7861['id'];}else{var _0x5e4801=_[_0x7a9d('0x7c')](_[_0x7a9d('0x2f')](_0x47e0b5,'TeamId'),function(_0x32665f){return _[_0x7a9d('0x7d')](_0x478b9f,_0x32665f);});if(_0x5e4801){return _0x2c7861['id'];}}}));}}return BPromise[_0x7a9d('0x7e')](_0x1b95c2)[_0x7a9d('0x28')](function(_0x4abfd9){_0x7cbb6f=_(_0x7cbb6f)[_0x7a9d('0x7f')](_0x4abfd9)[_0x7a9d('0x80')]()[_0x7a9d('0x81')]();return db[_0x7a9d('0x30')][_0x7a9d('0x50')]({'where':{'id':_0xf8663e['params']['id']}})[_0x7a9d('0x28')](function(_0x454ede){return db[_0x7a9d('0x79')]['transaction'](function(_0x5be8d0){return _0x454ede[_0x7a9d('0x6e')](_0xf8663e[_0x7a9d('0x35')][_0x7a9d('0x64')],{'transaction':_0x5be8d0})['then'](function(){if(!_[_0x7a9d('0x82')](_0x7cbb6f)){return _0x454ede[_0x7a9d('0x83')](_0x7cbb6f,{'transaction':_0x5be8d0});}})[_0x7a9d('0x28')](function(){_0x7cbb6f[_0x7a9d('0x6b')](function(_0x4c6a9d){socket[_0x7a9d('0x6c')]('userMailQueue:remove',{'UserId':_0x4c6a9d,'MailQueueId':_0x454ede['id']});});});});});});})['then'](respondWithStatusCode(_0x561d22,null))['catch'](handleError(_0x561d22,null));};exports[_0x7a9d('0x84')]=function(_0x2bf3cb,_0x38e9e8,_0x30bced){return db[_0x7a9d('0x30')][_0x7a9d('0x50')]({'where':{'id':_0x2bf3cb[_0x7a9d('0x48')]['id']}})[_0x7a9d('0x28')](handleEntityNotFound(_0x38e9e8,null))[_0x7a9d('0x28')](function(_0x5dd86a){if(_0x5dd86a){return _0x5dd86a[_0x7a9d('0x84')](_0x2bf3cb['body'][_0x7a9d('0x64')],_['omit'](_0x2bf3cb[_0x7a9d('0x52')],[_0x7a9d('0x64'),'id'])||{})[_0x7a9d('0x85')](function(_0x2415d3){for(var _0x557df9=0x0;_0x557df9<_0x2bf3cb[_0x7a9d('0x52')]['ids'][_0x7a9d('0x3a')];_0x557df9+=0x1){socket[_0x7a9d('0x6c')]('userMailQueue:save',{'UserId':_0x2bf3cb['body']['ids'][_0x557df9],'MailQueueId':_0x2bf3cb[_0x7a9d('0x48')]['id']});}return _0x2415d3;});}})[_0x7a9d('0x28')](respondWithResult(_0x38e9e8,null))[_0x7a9d('0x46')](handleError(_0x38e9e8,null));};exports['removeAgents']=function(_0x560aa5,_0x44e2f8,_0x34a435){return db['MailQueue'][_0x7a9d('0x50')]({'where':{'id':_0x560aa5[_0x7a9d('0x48')]['id']}})['then'](handleEntityNotFound(_0x44e2f8,null))[_0x7a9d('0x28')](function(_0x5ef43a){if(_0x5ef43a){return _0x5ef43a[_0x7a9d('0x83')](_0x560aa5[_0x7a9d('0x35')][_0x7a9d('0x64')])[_0x7a9d('0x28')](function(){if(_[_0x7a9d('0x86')](_0x560aa5[_0x7a9d('0x35')]['ids'])){for(var _0x4467ca=0x0;_0x4467ca<_0x560aa5[_0x7a9d('0x35')][_0x7a9d('0x64')][_0x7a9d('0x3a')];_0x4467ca+=0x1){socket[_0x7a9d('0x6c')](_0x7a9d('0x87'),{'UserId':Number(_0x560aa5[_0x7a9d('0x35')][_0x7a9d('0x64')][_0x4467ca]),'MailQueueId':Number(_0x560aa5['params']['id'])});}}else{socket['emit'](_0x7a9d('0x87'),{'UserId':Number(_0x560aa5[_0x7a9d('0x35')][_0x7a9d('0x64')]),'MailQueueId':Number(_0x560aa5[_0x7a9d('0x48')]['id'])});}});}})[_0x7a9d('0x28')](respondWithStatusCode(_0x44e2f8,null))['catch'](handleError(_0x44e2f8,null));};exports['getAgents']=function(_0x28cefa,_0x274437,_0x273395){var _0x1dcdc6={};var _0x3430fc={};var _0x1a6646;var _0x5c9fe2;return db[_0x7a9d('0x30')]['findOne']({'where':{'id':_0x28cefa[_0x7a9d('0x48')]['id']}})['then'](handleEntityNotFound(_0x274437,null))[_0x7a9d('0x28')](function(_0x59f430){if(_0x59f430){_0x1a6646=_0x59f430;_0x3430fc[_0x7a9d('0x34')]=_[_0x7a9d('0x4a')](db['User'][_0x7a9d('0x49')]);_0x3430fc[_0x7a9d('0x35')]=_['keys'](_0x28cefa[_0x7a9d('0x35')]);_0x3430fc[_0x7a9d('0x36')]=_['intersection'](_0x3430fc[_0x7a9d('0x34')],_0x3430fc[_0x7a9d('0x35')]);_0x1dcdc6[_0x7a9d('0x37')]=_['intersection'](_0x3430fc['model'],qs[_0x7a9d('0x39')](_0x28cefa[_0x7a9d('0x35')][_0x7a9d('0x39')]));_0x1dcdc6[_0x7a9d('0x37')]=_0x1dcdc6[_0x7a9d('0x37')][_0x7a9d('0x3a')]?_0x1dcdc6[_0x7a9d('0x37')]:_0x3430fc['model'];_0x1dcdc6['order']=qs[_0x7a9d('0x3b')](_0x28cefa[_0x7a9d('0x35')]['sort']);_0x1dcdc6[_0x7a9d('0x3e')]=qs[_0x7a9d('0x36')](_['pick'](_0x28cefa['query'],_0x3430fc[_0x7a9d('0x36')]));if(_0x28cefa['query'][_0x7a9d('0x3d')]){_0x1dcdc6[_0x7a9d('0x3e')]=_['merge'](_0x1dcdc6['where'],{'$or':_[_0x7a9d('0x2f')](_0x1dcdc6[_0x7a9d('0x37')],function(_0x226793){var _0x2457cf={};_0x2457cf[_0x226793]={'$like':'%'+_0x28cefa[_0x7a9d('0x35')]['filter']+'%'};return _0x2457cf;})});}_0x1dcdc6=_['merge']({},_0x1dcdc6,_0x28cefa[_0x7a9d('0x41')]);return _0x1a6646[_0x7a9d('0x88')](_0x1dcdc6);}})[_0x7a9d('0x28')](function(_0x26b2ca){if(_0x26b2ca){_0x5c9fe2=_0x26b2ca[_0x7a9d('0x3a')];if(!_0x28cefa[_0x7a9d('0x35')][_0x7a9d('0x56')](_0x7a9d('0x57'))){_0x1dcdc6[_0x7a9d('0x22')]=qs[_0x7a9d('0x22')](_0x28cefa[_0x7a9d('0x35')]['limit']);_0x1dcdc6['offset']=qs['offset'](_0x28cefa['query'][_0x7a9d('0x21')]);}return _0x1a6646['getAgents'](_0x1dcdc6);}})[_0x7a9d('0x28')](function(_0x46fd61){if(_0x46fd61){return _0x46fd61?{'count':_0x5c9fe2,'rows':_0x46fd61}:null;}})[_0x7a9d('0x28')](respondWithResult(_0x274437,null))[_0x7a9d('0x46')](handleError(_0x274437,null));};
\ No newline at end of file