Built motion from commit (unavailable).|2.5.24
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 496f0ac..2d9d35e 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 _0xf3f9=['sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getMembers','UserMailQueue','User','agent','mailPause','updatedAt','format','%s/%s','SIP','createdAt','getTeams','addTeams','ids','Team','interface','flatMap','Agents','transaction','findOrCreate','forEach','userMailQueue:save','removeTeams','select','tq.TeamId','from','team_has_mail_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','every','includes','all','union','compact','value','isEmpty','removeAgents','emit','userMailQueue:remove','addAgents','spread','getAgents','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','lodash','crypto','jsforce','desk.js','querystring','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./mailQueue.socket','sendStatus','status','end','json','count','offset','limit','set','apply','save','then','get','MailQueues','destroy','error','send','index','MailQueue','rawAttributes','fieldName','type','key','model','map','name','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order'];(function(_0x3b742f,_0x592e86){var _0x404303=function(_0x386d3c){while(--_0x386d3c){_0x3b742f['push'](_0x3b742f['shift']());}};_0x404303(++_0x592e86);}(_0xf3f9,0x1de));var _0x9f3f=function(_0x189599,_0xdd106a){_0x189599=_0x189599-0x0;var _0x152ed2=_0xf3f9[_0x189599];return _0x152ed2;};'use strict';var pdf=require(_0x9f3f('0x0'));var emlformat=require(_0x9f3f('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x9f3f('0x2'));var jsonpatch=require(_0x9f3f('0x3'));var rp=require(_0x9f3f('0x4'));var moment=require(_0x9f3f('0x5'));var BPromise=require(_0x9f3f('0x6'));var Mustache=require(_0x9f3f('0x7'));var util=require(_0x9f3f('0x8'));var path=require('path');var sox=require('sox');var csv=require(_0x9f3f('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x9f3f('0xa'));var squel=require('squel');var crypto=require(_0x9f3f('0xb'));var jsforce=require(_0x9f3f('0xc'));var deskjs=require(_0x9f3f('0xd'));var toCsv=require('to-csv');var querystring=require(_0x9f3f('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x9f3f('0xf'));var hardwareService=require(_0x9f3f('0x10'));var logger=require(_0x9f3f('0x11'))(_0x9f3f('0x12'));var utils=require(_0x9f3f('0x13'));var config=require(_0x9f3f('0x14'));var licenseUtil=require(_0x9f3f('0x15'));var db=require(_0x9f3f('0x16'))['db'];config[_0x9f3f('0x17')]=_[_0x9f3f('0x18')](config[_0x9f3f('0x17')],{'host':_0x9f3f('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9f3f('0x17')]));require(_0x9f3f('0x1a'))['register'](socket);function respondWithStatusCode(_0x588ab3,_0x3564b4){_0x3564b4=_0x3564b4||0xcc;return function(_0x4849da){if(_0x4849da){return _0x588ab3[_0x9f3f('0x1b')](_0x3564b4);}return _0x588ab3[_0x9f3f('0x1c')](_0x3564b4)[_0x9f3f('0x1d')]();};}function respondWithResult(_0x40a26b,_0x569dc9){_0x569dc9=_0x569dc9||0xc8;return function(_0x258ecd){if(_0x258ecd){return _0x40a26b[_0x9f3f('0x1c')](_0x569dc9)[_0x9f3f('0x1e')](_0x258ecd);}};}function respondWithFilteredResult(_0x124077,_0x1c7633){return function(_0x153b2f){if(_0x153b2f){var _0x5d3fc9=_0x153b2f[_0x9f3f('0x1f')],_0x115b23=_0x1c7633['offset'],_0x542670=_0x1c7633[_0x9f3f('0x20')]+_0x1c7633[_0x9f3f('0x21')],_0x1b8706;if(_0x542670>=_0x5d3fc9){_0x542670=_0x5d3fc9;_0x1b8706=0xc8;}else{_0x1b8706=0xce;}_0x124077[_0x9f3f('0x1c')](_0x1b8706);return _0x124077[_0x9f3f('0x22')]('Content-Range',_0x115b23+'-'+_0x542670+'/'+_0x5d3fc9)['json'](_0x153b2f);}return null;};}function patchUpdates(_0x4445fe){return function(_0x5d51ad){try{jsonpatch[_0x9f3f('0x23')](_0x5d51ad,_0x4445fe,!![]);}catch(_0x4a6199){return BPromise['reject'](_0x4a6199);}return _0x5d51ad[_0x9f3f('0x24')]();};}function saveUpdates(_0x2e9379,_0x4a4ad5){return function(_0x37f916){if(_0x37f916){return _0x37f916['update'](_0x2e9379)['then'](function(_0x1193a1){return _0x1193a1;});}return null;};}function removeEntity(_0x2940e0,_0x18905d){return function(_0x45b6c0){if(_0x45b6c0){return _0x45b6c0['destroy']()[_0x9f3f('0x25')](function(){var _0x5d67f3=_0x45b6c0[_0x9f3f('0x26')]({'plain':!![]});var _0x1ef969=_0x9f3f('0x27');return db['UserProfileResource'][_0x9f3f('0x28')]({'where':{'type':_0x1ef969,'resourceId':_0x5d67f3['id']}})[_0x9f3f('0x25')](function(){return _0x45b6c0;});})[_0x9f3f('0x25')](function(){_0x2940e0[_0x9f3f('0x1c')](0xcc)[_0x9f3f('0x1d')]();});}};}function handleEntityNotFound(_0x5c4f15,_0x4fee86){return function(_0x2d8ce3){if(!_0x2d8ce3){_0x5c4f15['sendStatus'](0x194);}return _0x2d8ce3;};}function handleError(_0x3b43c7,_0x3187cb){_0x3187cb=_0x3187cb||0x1f4;return function(_0x5e5f3e){logger[_0x9f3f('0x29')](_0x5e5f3e['stack']);if(_0x5e5f3e['name']){delete _0x5e5f3e['name'];}_0x3b43c7['status'](_0x3187cb)[_0x9f3f('0x2a')](_0x5e5f3e);};}exports[_0x9f3f('0x2b')]=function(_0x4c496e,_0x3a5be4){var _0xf848ef={},_0x2d01cd={},_0x285fc0={'count':0x0,'rows':[]};var _0x11d14b=_['map'](db[_0x9f3f('0x2c')][_0x9f3f('0x2d')],function(_0x377a0){return{'name':_0x377a0[_0x9f3f('0x2e')],'type':_0x377a0[_0x9f3f('0x2f')][_0x9f3f('0x30')]};});_0x2d01cd[_0x9f3f('0x31')]=_[_0x9f3f('0x32')](_0x11d14b,_0x9f3f('0x33'));_0x2d01cd['query']=_[_0x9f3f('0x34')](_0x4c496e[_0x9f3f('0x35')]);_0x2d01cd[_0x9f3f('0x36')]=_[_0x9f3f('0x37')](_0x2d01cd[_0x9f3f('0x31')],_0x2d01cd[_0x9f3f('0x35')]);_0xf848ef[_0x9f3f('0x38')]=_[_0x9f3f('0x37')](_0x2d01cd[_0x9f3f('0x31')],qs['fields'](_0x4c496e['query'][_0x9f3f('0x39')]));_0xf848ef[_0x9f3f('0x38')]=_0xf848ef[_0x9f3f('0x38')][_0x9f3f('0x3a')]?_0xf848ef[_0x9f3f('0x38')]:_0x2d01cd[_0x9f3f('0x31')];if(!_0x4c496e[_0x9f3f('0x35')][_0x9f3f('0x3b')](_0x9f3f('0x3c'))){_0xf848ef[_0x9f3f('0x21')]=qs['limit'](_0x4c496e[_0x9f3f('0x35')][_0x9f3f('0x21')]);_0xf848ef['offset']=qs['offset'](_0x4c496e[_0x9f3f('0x35')][_0x9f3f('0x20')]);}_0xf848ef[_0x9f3f('0x3d')]=qs[_0x9f3f('0x3e')](_0x4c496e[_0x9f3f('0x35')][_0x9f3f('0x3e')]);_0xf848ef['where']=qs[_0x9f3f('0x36')](_[_0x9f3f('0x3f')](_0x4c496e[_0x9f3f('0x35')],_0x2d01cd[_0x9f3f('0x36')]),_0x11d14b);if(_0x4c496e[_0x9f3f('0x35')][_0x9f3f('0x40')]){_0xf848ef[_0x9f3f('0x41')]=_[_0x9f3f('0x42')](_0xf848ef['where'],{'$or':_['map'](_0x11d14b,function(_0x4d2686){if(_0x4d2686[_0x9f3f('0x2f')]!==_0x9f3f('0x43')){var _0x372786={};_0x372786[_0x4d2686[_0x9f3f('0x33')]]={'$like':'%'+_0x4c496e[_0x9f3f('0x35')]['filter']+'%'};return _0x372786;}})});}_0xf848ef=_[_0x9f3f('0x42')]({},_0xf848ef,_0x4c496e[_0x9f3f('0x44')]);var _0x35bb57={'where':_0xf848ef['where']};return db['MailQueue'][_0x9f3f('0x1f')](_0x35bb57)[_0x9f3f('0x25')](function(_0x358c3b){_0x285fc0[_0x9f3f('0x1f')]=_0x358c3b;if(_0x4c496e[_0x9f3f('0x35')][_0x9f3f('0x45')]){_0xf848ef[_0x9f3f('0x46')]=[{'all':!![]}];}return db['MailQueue'][_0x9f3f('0x47')](_0xf848ef);})['then'](function(_0x3dd9e7){_0x285fc0[_0x9f3f('0x48')]=_0x3dd9e7;return _0x285fc0;})[_0x9f3f('0x25')](respondWithFilteredResult(_0x3a5be4,_0xf848ef))[_0x9f3f('0x49')](handleError(_0x3a5be4,null));};exports[_0x9f3f('0x4a')]=function(_0x282e29,_0x1812fe){var _0x2ab148={'raw':!![],'where':{'id':_0x282e29[_0x9f3f('0x4b')]['id']}},_0x328c86={};_0x328c86['model']=_[_0x9f3f('0x34')](db['MailQueue']['rawAttributes']);_0x328c86[_0x9f3f('0x35')]=_[_0x9f3f('0x34')](_0x282e29[_0x9f3f('0x35')]);_0x328c86[_0x9f3f('0x36')]=_[_0x9f3f('0x37')](_0x328c86[_0x9f3f('0x31')],_0x328c86[_0x9f3f('0x35')]);_0x2ab148[_0x9f3f('0x38')]=_[_0x9f3f('0x37')](_0x328c86['model'],qs[_0x9f3f('0x39')](_0x282e29[_0x9f3f('0x35')][_0x9f3f('0x39')]));_0x2ab148[_0x9f3f('0x38')]=_0x2ab148['attributes'][_0x9f3f('0x3a')]?_0x2ab148['attributes']:_0x328c86[_0x9f3f('0x31')];if(_0x282e29[_0x9f3f('0x35')]['includeAll']){_0x2ab148[_0x9f3f('0x46')]=[{'all':!![]}];}_0x2ab148=_['merge']({},_0x2ab148,_0x282e29['options']);return db[_0x9f3f('0x2c')][_0x9f3f('0x4c')](_0x2ab148)['then'](handleEntityNotFound(_0x1812fe,null))[_0x9f3f('0x25')](respondWithResult(_0x1812fe,null))[_0x9f3f('0x49')](handleError(_0x1812fe,null));};exports[_0x9f3f('0x4d')]=function(_0x3d8180,_0x2772a4){return db[_0x9f3f('0x2c')]['create'](_0x3d8180[_0x9f3f('0x4e')],{})[_0x9f3f('0x25')](function(_0x7b7228){var _0x1d4960=_0x3d8180[_0x9f3f('0x4f')]['get']({'plain':!![]});if(!_0x1d4960)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1d4960[_0x9f3f('0x50')]===_0x9f3f('0x4f')){var _0x2ffaca=_0x7b7228['get']({'plain':!![]});var _0xaf027f=_0x9f3f('0x27');return db[_0x9f3f('0x51')][_0x9f3f('0x4c')]({'where':{'name':_0xaf027f,'userProfileId':_0x1d4960[_0x9f3f('0x52')]},'raw':!![]})[_0x9f3f('0x25')](function(_0x10670e){if(_0x10670e&&_0x10670e[_0x9f3f('0x53')]===0x0){return db[_0x9f3f('0x54')][_0x9f3f('0x4d')]({'name':_0x2ffaca[_0x9f3f('0x33')],'resourceId':_0x2ffaca['id'],'type':_0x10670e['name'],'sectionId':_0x10670e['id']},{})['then'](function(){return _0x7b7228;});}else{return _0x7b7228;}})[_0x9f3f('0x49')](function(_0x2337b6){logger[_0x9f3f('0x29')](_0x9f3f('0x55'),_0x2337b6);throw _0x2337b6;});}return _0x7b7228;})[_0x9f3f('0x25')](respondWithResult(_0x2772a4,0xc9))[_0x9f3f('0x49')](handleError(_0x2772a4,null));};exports['update']=function(_0x40118b,_0xda100b){if(_0x40118b[_0x9f3f('0x4e')]['id']){delete _0x40118b[_0x9f3f('0x4e')]['id'];}return db[_0x9f3f('0x2c')][_0x9f3f('0x4c')]({'where':{'id':_0x40118b[_0x9f3f('0x4b')]['id']}})['then'](handleEntityNotFound(_0xda100b,null))[_0x9f3f('0x25')](saveUpdates(_0x40118b['body'],null))['then'](respondWithResult(_0xda100b,null))[_0x9f3f('0x49')](handleError(_0xda100b,null));};exports['destroy']=function(_0x417292,_0x32acd8){return db[_0x9f3f('0x2c')][_0x9f3f('0x4c')]({'where':{'id':_0x417292['params']['id']}})[_0x9f3f('0x25')](handleEntityNotFound(_0x32acd8,null))[_0x9f3f('0x25')](removeEntity(_0x32acd8,null))[_0x9f3f('0x49')](handleError(_0x32acd8,null));};exports['describe']=function(_0x16c10b,_0x9170a3){return db['MailQueue']['describe']()['then'](respondWithResult(_0x9170a3,null))[_0x9f3f('0x49')](handleError(_0x9170a3,null));};exports[_0x9f3f('0x56')]=function(_0x155e64,_0x49d09c,_0x5706ab){var _0x3c4177={'raw':!![],'where':{}},_0x5d8c94={},_0x272433;return db[_0x9f3f('0x2c')]['findOne']({'where':{'id':_0x155e64[_0x9f3f('0x4b')]['id']}})['then'](handleEntityNotFound(_0x49d09c,null))[_0x9f3f('0x25')](function(_0xab129c){if(_0xab129c){_0x272433=_0xab129c['get']({'plain':!![]});_0x5d8c94['model']=_[_0x9f3f('0x34')](db[_0x9f3f('0x57')][_0x9f3f('0x2d')]);_0x5d8c94[_0x9f3f('0x35')]=_[_0x9f3f('0x34')](_0x155e64['query']);_0x5d8c94[_0x9f3f('0x36')]=_[_0x9f3f('0x37')](_0x5d8c94[_0x9f3f('0x31')],_0x5d8c94[_0x9f3f('0x35')]);_0x3c4177[_0x9f3f('0x38')]=_['intersection'](_0x5d8c94[_0x9f3f('0x31')],qs[_0x9f3f('0x39')](_0x155e64[_0x9f3f('0x35')][_0x9f3f('0x39')]));_0x3c4177[_0x9f3f('0x38')]=_0x3c4177[_0x9f3f('0x38')][_0x9f3f('0x3a')]?_0x3c4177['attributes']:_0x5d8c94[_0x9f3f('0x31')];if(!_0x155e64[_0x9f3f('0x35')][_0x9f3f('0x3b')]('nolimit')){_0x3c4177[_0x9f3f('0x21')]=qs[_0x9f3f('0x21')](_0x155e64[_0x9f3f('0x35')][_0x9f3f('0x21')]);_0x3c4177[_0x9f3f('0x20')]=qs[_0x9f3f('0x20')](_0x155e64['query'][_0x9f3f('0x20')]);}_0x3c4177[_0x9f3f('0x3d')]=qs[_0x9f3f('0x3e')](_0x155e64[_0x9f3f('0x35')]['sort']);_0x3c4177[_0x9f3f('0x41')]=qs[_0x9f3f('0x36')](_['pick'](_0x155e64[_0x9f3f('0x35')],_0x5d8c94[_0x9f3f('0x36')]));_0x3c4177[_0x9f3f('0x41')]['MailQueueId']=_0xab129c['id'];if(_0x155e64[_0x9f3f('0x35')]['filter']){_0x3c4177['where']=_[_0x9f3f('0x42')](_0x3c4177[_0x9f3f('0x41')],{'$or':_[_0x9f3f('0x32')](_0x3c4177['attributes'],function(_0xa61060){var _0x2f7dc5={};_0x2f7dc5[_0xa61060]={'$like':'%'+_0x155e64[_0x9f3f('0x35')]['filter']+'%'};return _0x2f7dc5;})});}_0x3c4177=_[_0x9f3f('0x42')]({},_0x3c4177,_0x155e64[_0x9f3f('0x44')]);return db[_0x9f3f('0x57')][_0x9f3f('0x47')](_0x3c4177);}})['then'](function(_0x237b6c){if(_0x237b6c){return db[_0x9f3f('0x58')]['findAndCountAll']({'where':{'id':_[_0x9f3f('0x32')](_0x237b6c,'UserId'),'role':_0x9f3f('0x59')},'attributes':['id',_0x9f3f('0x33'),_0x9f3f('0x5a'),_0x9f3f('0x5b'),'createdAt']});}})[_0x9f3f('0x25')](function(_0x5b5e85){if(_0x5b5e85){return{'count':_0x5b5e85[_0x9f3f('0x1f')],'rows':_[_0x9f3f('0x32')](_0x5b5e85['rows'],function(_0x131790){return{'membername':_0x131790[_0x9f3f('0x33')],'UserId':_0x131790['id'],'queue_name':_0x272433[_0x9f3f('0x33')],'MailQueueId':_0x272433['id'],'interface':util[_0x9f3f('0x5c')](_0x9f3f('0x5d'),_0x9f3f('0x5e'),_0x131790[_0x9f3f('0x33')]),'penalty':0x0,'paused':_0x131790[_0x9f3f('0x5a')],'createdAt':_0x131790[_0x9f3f('0x5f')],'updatedAt':_0x131790[_0x9f3f('0x5b')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x9f3f('0x25')](respondWithFilteredResult(_0x49d09c,_0x3c4177))[_0x9f3f('0x49')](handleError(_0x49d09c,null));};exports[_0x9f3f('0x60')]=function(_0x38f77b,_0x50e7f2,_0x1a749f){var _0x2f430c={};var _0x5afd34={};var _0x5547ab;var _0x2028a2;return db[_0x9f3f('0x2c')]['findOne']({'where':{'id':_0x38f77b[_0x9f3f('0x4b')]['id']}})[_0x9f3f('0x25')](handleEntityNotFound(_0x50e7f2,null))['then'](function(_0x496fd8){if(_0x496fd8){_0x5547ab=_0x496fd8;_0x5afd34[_0x9f3f('0x31')]=_['keys'](db['Team']['rawAttributes']);_0x5afd34[_0x9f3f('0x35')]=_[_0x9f3f('0x34')](_0x38f77b[_0x9f3f('0x35')]);_0x5afd34[_0x9f3f('0x36')]=_[_0x9f3f('0x37')](_0x5afd34[_0x9f3f('0x31')],_0x5afd34['query']);_0x2f430c['attributes']=_[_0x9f3f('0x37')](_0x5afd34[_0x9f3f('0x31')],qs[_0x9f3f('0x39')](_0x38f77b[_0x9f3f('0x35')][_0x9f3f('0x39')]));_0x2f430c[_0x9f3f('0x38')]=_0x2f430c[_0x9f3f('0x38')][_0x9f3f('0x3a')]?_0x2f430c[_0x9f3f('0x38')]:_0x5afd34[_0x9f3f('0x31')];_0x2f430c[_0x9f3f('0x3d')]=qs[_0x9f3f('0x3e')](_0x38f77b['query']['sort']);_0x2f430c[_0x9f3f('0x41')]=qs[_0x9f3f('0x36')](_[_0x9f3f('0x3f')](_0x38f77b[_0x9f3f('0x35')],_0x5afd34[_0x9f3f('0x36')]));if(_0x38f77b[_0x9f3f('0x35')]['filter']){_0x2f430c[_0x9f3f('0x41')]=_[_0x9f3f('0x42')](_0x2f430c['where'],{'$or':_[_0x9f3f('0x32')](_0x2f430c[_0x9f3f('0x38')],function(_0x4627e8){var _0x2ba2ac={};_0x2ba2ac[_0x4627e8]={'$like':'%'+_0x38f77b[_0x9f3f('0x35')][_0x9f3f('0x40')]+'%'};return _0x2ba2ac;})});}_0x2f430c=_[_0x9f3f('0x42')]({},_0x2f430c,_0x38f77b[_0x9f3f('0x44')]);return _0x5547ab[_0x9f3f('0x60')](_0x2f430c);}})['then'](function(_0x176771){if(_0x176771){_0x2028a2=_0x176771[_0x9f3f('0x3a')];if(!_0x38f77b[_0x9f3f('0x35')][_0x9f3f('0x3b')]('nolimit')){_0x2f430c['limit']=qs[_0x9f3f('0x21')](_0x38f77b[_0x9f3f('0x35')][_0x9f3f('0x21')]);_0x2f430c[_0x9f3f('0x20')]=qs['offset'](_0x38f77b[_0x9f3f('0x35')][_0x9f3f('0x20')]);}return _0x5547ab[_0x9f3f('0x60')](_0x2f430c);}})['then'](function(_0x34ec8f){if(_0x34ec8f){return _0x34ec8f?{'count':_0x2028a2,'rows':_0x34ec8f}:null;}})['then'](respondWithResult(_0x50e7f2,null))[_0x9f3f('0x49')](handleError(_0x50e7f2,null));};exports[_0x9f3f('0x61')]=function(_0x36e326,_0x1093ab,_0x53e407){var _0x33e2d4=_0x36e326[_0x9f3f('0x4e')][_0x9f3f('0x62')];return db[_0x9f3f('0x63')][_0x9f3f('0x47')]({'where':{'id':_0x33e2d4},'attributes':['id'],'include':[{'model':db[_0x9f3f('0x58')],'as':'Agents','attributes':['id','name','online','voicePause',_0x9f3f('0x64')],'raw':!![]}]})[_0x9f3f('0x25')](function(_0x405194){if(_0x405194){var _0x422892=_[_0x9f3f('0x65')](_0x405194,function(_0x3303b1){var _0x34169d=_0x3303b1['get']({'plain':!![]});return _0x34169d[_0x9f3f('0x66')];});return db[_0x9f3f('0x2c')][_0x9f3f('0x4c')]({'where':{'id':_0x36e326[_0x9f3f('0x4b')]['id']}})[_0x9f3f('0x25')](function(_0x180f4e){return db['sequelize'][_0x9f3f('0x67')](function(_0x59e3af){return _0x180f4e[_0x9f3f('0x61')](_0x33e2d4,{'transaction':_0x59e3af})[_0x9f3f('0x25')](function(){return BPromise['each'](_0x422892,function(_0xa18606){return db[_0x9f3f('0x57')][_0x9f3f('0x68')]({'where':{'UserId':_0xa18606['id'],'MailQueueId':_0x36e326[_0x9f3f('0x4b')]['id']},'transaction':_0x59e3af});});})[_0x9f3f('0x25')](function(){_0x422892[_0x9f3f('0x69')](function(_0x45fa21){socket['emit'](_0x9f3f('0x6a'),{'UserId':_0x45fa21['id'],'MailQueueId':_0x180f4e['id']});});});});});}})[_0x9f3f('0x25')](respondWithStatusCode(_0x1093ab,null))[_0x9f3f('0x49')](handleError(_0x1093ab,null));};exports[_0x9f3f('0x6b')]=function(_0x1112af,_0x358521,_0x193cc5){return db[_0x9f3f('0x63')]['findAll']({'where':{'id':_0x1112af['query'][_0x9f3f('0x62')]},'attributes':['id'],'include':[{'model':db[_0x9f3f('0x58')],'as':_0x9f3f('0x66'),'attributes':['id'],'raw':!![]}]})[_0x9f3f('0x25')](handleEntityNotFound(_0x358521,null))[_0x9f3f('0x25')](function(_0x255d8f){var _0x3c68e6=_[_0x9f3f('0x32')](_0x255d8f,'id');var _0x182d12=[];var _0x493132=[];var _0x2ccd84=squel[_0x9f3f('0x6c')]();_0x2ccd84['field'](_0x9f3f('0x6d'))[_0x9f3f('0x6e')](_0x9f3f('0x6f'),'tq')[_0x9f3f('0x70')](_0x9f3f('0x71'),'ut',_0x9f3f('0x72'))[_0x9f3f('0x41')](_0x9f3f('0x73'),_0x1112af['params']['id']);for(var _0xa0682c=0x0;_0xa0682c<_0x255d8f[_0x9f3f('0x3a')];_0xa0682c+=0x1){let _0x441d9b=_0x255d8f[_0xa0682c];for(var _0xc58fea=0x0;_0xc58fea<_0x441d9b[_0x9f3f('0x66')][_0x9f3f('0x3a')];_0xc58fea+=0x1){let _0x3c6f39=_0x441d9b[_0x9f3f('0x66')][_0xc58fea];var _0x43fc8=_0x2ccd84[_0x9f3f('0x74')]();_0x43fc8[_0x9f3f('0x41')](_0x9f3f('0x75'),_0x3c6f39['id']);_0x493132[_0x9f3f('0x76')](db[_0x9f3f('0x77')][_0x9f3f('0x35')](_0x43fc8[_0x9f3f('0x78')](),{'type':db[_0x9f3f('0x77')][_0x9f3f('0x79')]['SELECT']})[_0x9f3f('0x25')](function(_0x339fc7){if(_0x339fc7[_0x9f3f('0x3a')]===0x1){return _0x3c6f39['id'];}else{var _0x8e2016=_[_0x9f3f('0x7a')](_['map'](_0x339fc7,'TeamId'),function(_0x3db3e3){return _[_0x9f3f('0x7b')](_0x3c68e6,_0x3db3e3);});if(_0x8e2016){return _0x3c6f39['id'];}}}));}}return BPromise[_0x9f3f('0x7c')](_0x493132)[_0x9f3f('0x25')](function(_0x468f84){_0x182d12=_(_0x182d12)[_0x9f3f('0x7d')](_0x468f84)[_0x9f3f('0x7e')]()[_0x9f3f('0x7f')]();return db['MailQueue'][_0x9f3f('0x4c')]({'where':{'id':_0x1112af[_0x9f3f('0x4b')]['id']}})[_0x9f3f('0x25')](function(_0x4aba90){return db[_0x9f3f('0x77')][_0x9f3f('0x67')](function(_0xf4252a){return _0x4aba90[_0x9f3f('0x6b')](_0x1112af['query'][_0x9f3f('0x62')],{'transaction':_0xf4252a})[_0x9f3f('0x25')](function(){if(!_[_0x9f3f('0x80')](_0x182d12)){return _0x4aba90[_0x9f3f('0x81')](_0x182d12,{'transaction':_0xf4252a});}})[_0x9f3f('0x25')](function(){_0x182d12['forEach'](function(_0x311578){socket[_0x9f3f('0x82')](_0x9f3f('0x83'),{'UserId':_0x311578,'MailQueueId':_0x4aba90['id']});});});});});});})[_0x9f3f('0x25')](respondWithStatusCode(_0x358521,null))[_0x9f3f('0x49')](handleError(_0x358521,null));};exports[_0x9f3f('0x84')]=function(_0x1e9d4a,_0x14f4a0,_0x6b4704){return db[_0x9f3f('0x2c')][_0x9f3f('0x4c')]({'where':{'id':_0x1e9d4a[_0x9f3f('0x4b')]['id']}})['then'](handleEntityNotFound(_0x14f4a0,null))[_0x9f3f('0x25')](function(_0x340779){if(_0x340779){return _0x340779[_0x9f3f('0x84')](_0x1e9d4a[_0x9f3f('0x4e')][_0x9f3f('0x62')],_['omit'](_0x1e9d4a[_0x9f3f('0x4e')],[_0x9f3f('0x62'),'id'])||{})[_0x9f3f('0x85')](function(_0x5acfb4){for(var _0x55c524=0x0;_0x55c524<_0x1e9d4a[_0x9f3f('0x4e')][_0x9f3f('0x62')][_0x9f3f('0x3a')];_0x55c524+=0x1){socket['emit']('userMailQueue:save',{'UserId':_0x1e9d4a['body'][_0x9f3f('0x62')][_0x55c524],'MailQueueId':_0x1e9d4a['params']['id']});}return _0x5acfb4;});}})['then'](respondWithResult(_0x14f4a0,null))[_0x9f3f('0x49')](handleError(_0x14f4a0,null));};exports[_0x9f3f('0x81')]=function(_0x29008d,_0x201e40,_0x22f678){return db[_0x9f3f('0x2c')][_0x9f3f('0x4c')]({'where':{'id':_0x29008d[_0x9f3f('0x4b')]['id']}})[_0x9f3f('0x25')](handleEntityNotFound(_0x201e40,null))['then'](function(_0x49c84b){if(_0x49c84b){return _0x49c84b[_0x9f3f('0x81')](_0x29008d[_0x9f3f('0x35')][_0x9f3f('0x62')])['then'](function(){if(_['isArray'](_0x29008d[_0x9f3f('0x35')][_0x9f3f('0x62')])){for(var _0x1f6d5c=0x0;_0x1f6d5c<_0x29008d['query'][_0x9f3f('0x62')][_0x9f3f('0x3a')];_0x1f6d5c+=0x1){socket[_0x9f3f('0x82')](_0x9f3f('0x83'),{'UserId':Number(_0x29008d['query'][_0x9f3f('0x62')][_0x1f6d5c]),'MailQueueId':Number(_0x29008d[_0x9f3f('0x4b')]['id'])});}}else{socket['emit'](_0x9f3f('0x83'),{'UserId':Number(_0x29008d['query'][_0x9f3f('0x62')]),'MailQueueId':Number(_0x29008d[_0x9f3f('0x4b')]['id'])});}});}})[_0x9f3f('0x25')](respondWithStatusCode(_0x201e40,null))[_0x9f3f('0x49')](handleError(_0x201e40,null));};exports['getAgents']=function(_0x4d4dd1,_0x5cdb8c,_0x439f2f){var _0x476a1a={};var _0x37c65e={};var _0x1fa77b;var _0x41b13c;return db[_0x9f3f('0x2c')]['findOne']({'where':{'id':_0x4d4dd1['params']['id']}})['then'](handleEntityNotFound(_0x5cdb8c,null))[_0x9f3f('0x25')](function(_0x3ac141){if(_0x3ac141){_0x1fa77b=_0x3ac141;_0x37c65e['model']=_['keys'](db[_0x9f3f('0x58')][_0x9f3f('0x2d')]);_0x37c65e['query']=_[_0x9f3f('0x34')](_0x4d4dd1[_0x9f3f('0x35')]);_0x37c65e[_0x9f3f('0x36')]=_['intersection'](_0x37c65e['model'],_0x37c65e[_0x9f3f('0x35')]);_0x476a1a['attributes']=_[_0x9f3f('0x37')](_0x37c65e[_0x9f3f('0x31')],qs['fields'](_0x4d4dd1[_0x9f3f('0x35')][_0x9f3f('0x39')]));_0x476a1a[_0x9f3f('0x38')]=_0x476a1a[_0x9f3f('0x38')]['length']?_0x476a1a['attributes']:_0x37c65e[_0x9f3f('0x31')];_0x476a1a[_0x9f3f('0x3d')]=qs['sort'](_0x4d4dd1[_0x9f3f('0x35')][_0x9f3f('0x3e')]);_0x476a1a[_0x9f3f('0x41')]=qs[_0x9f3f('0x36')](_[_0x9f3f('0x3f')](_0x4d4dd1[_0x9f3f('0x35')],_0x37c65e['filters']));if(_0x4d4dd1[_0x9f3f('0x35')][_0x9f3f('0x40')]){_0x476a1a['where']=_[_0x9f3f('0x42')](_0x476a1a[_0x9f3f('0x41')],{'$or':_[_0x9f3f('0x32')](_0x476a1a[_0x9f3f('0x38')],function(_0x10a902){var _0x6c9a2={};_0x6c9a2[_0x10a902]={'$like':'%'+_0x4d4dd1[_0x9f3f('0x35')][_0x9f3f('0x40')]+'%'};return _0x6c9a2;})});}_0x476a1a=_[_0x9f3f('0x42')]({},_0x476a1a,_0x4d4dd1['options']);return _0x1fa77b[_0x9f3f('0x86')](_0x476a1a);}})[_0x9f3f('0x25')](function(_0x963114){if(_0x963114){_0x41b13c=_0x963114['length'];if(!_0x4d4dd1[_0x9f3f('0x35')][_0x9f3f('0x3b')](_0x9f3f('0x3c'))){_0x476a1a['limit']=qs[_0x9f3f('0x21')](_0x4d4dd1['query']['limit']);_0x476a1a[_0x9f3f('0x20')]=qs[_0x9f3f('0x20')](_0x4d4dd1[_0x9f3f('0x35')]['offset']);}return _0x1fa77b[_0x9f3f('0x86')](_0x476a1a);}})[_0x9f3f('0x25')](function(_0x1eb96c){if(_0x1eb96c){return _0x1eb96c?{'count':_0x41b13c,'rows':_0x1eb96c}:null;}})[_0x9f3f('0x25')](respondWithResult(_0x5cdb8c,null))[_0x9f3f('0x49')](handleError(_0x5cdb8c,null));};
\ No newline at end of file