Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 2be644e..9e7e4be 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1841=['include','rows','catch','show','params','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','find','describe','getMembers','findOne','UserMailQueue','MailQueueId','filter','findAll','findAndCountAll','UserId','agent','mailPause','updatedAt','createdAt','format','%s/%s','SIP','Team','getTeams','hasOwnProperty','online','voicePause','flatMap','Agents','transaction','each','findOrCreate','forEach','emit','userMailQueue:save','removeTeams','ids','User','select','tq.TeamId','from','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','SELECT','every','TeamId','includes','all','compact','value','removeAgents','userMailQueue:remove','addAgents','omit','spread','isArray','getAgents','nolimit','rimraf','zip-dir','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./mailQueue.socket','status','end','json','offset','undefined','count','limit','set','Content-Range','save','then','destroy','get','MailQueues','sendStatus','error','stack','name','send','MailQueue','rawAttributes','fieldName','type','key','map','keys','query','filters','intersection','model','fields','attributes','length','order','sort','where','pick','merge','VIRTUAL','includeAll'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x1841,0xdf));var _0x1184=function(_0x4705f9,_0xd5ef3){_0x4705f9=_0x4705f9-0x0;var _0x295e4b=_0x1841[_0x4705f9];return _0x295e4b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x1184('0x0'));var zipdir=require(_0x1184('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x1184('0x2'));var BPromise=require(_0x1184('0x3'));var Mustache=require(_0x1184('0x4'));var util=require(_0x1184('0x5'));var path=require(_0x1184('0x6'));var sox=require('sox');var csv=require(_0x1184('0x7'));var ejs=require(_0x1184('0x8'));var fs=require('fs');var fs_extra=require(_0x1184('0x9'));var _=require(_0x1184('0xa'));var squel=require(_0x1184('0xb'));var crypto=require(_0x1184('0xc'));var jsforce=require(_0x1184('0xd'));var deskjs=require(_0x1184('0xe'));var toCsv=require(_0x1184('0x7'));var querystring=require(_0x1184('0xf'));var Papa=require(_0x1184('0x10'));var Redis=require(_0x1184('0x11'));var authService=require(_0x1184('0x12'));var qs=require(_0x1184('0x13'));var as=require(_0x1184('0x14'));var hardwareService=require(_0x1184('0x15'));var logger=require(_0x1184('0x16'))(_0x1184('0x17'));var utils=require(_0x1184('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0x1184('0x19'));var db=require(_0x1184('0x1a'))['db'];config[_0x1184('0x1b')]=_[_0x1184('0x1c')](config[_0x1184('0x1b')],{'host':'localhost','port':0x18eb});var socket=require(_0x1184('0x1d'))(new Redis(config[_0x1184('0x1b')]));require(_0x1184('0x1e'))['register'](socket);function respondWithStatusCode(_0x54283b,_0x27637d){_0x27637d=_0x27637d||0xcc;return function(_0x4a9543){if(_0x4a9543){return _0x54283b['sendStatus'](_0x27637d);}return _0x54283b[_0x1184('0x1f')](_0x27637d)[_0x1184('0x20')]();};}function respondWithResult(_0xdfe346,_0x3e1d78){_0x3e1d78=_0x3e1d78||0xc8;return function(_0x56f21c){if(_0x56f21c){return _0xdfe346[_0x1184('0x1f')](_0x3e1d78)[_0x1184('0x21')](_0x56f21c);}};}function respondWithFilteredResult(_0x14e379,_0x2e30f6){return function(_0x2ce3c0){if(_0x2ce3c0){var _0x5bf7e7=typeof _0x2e30f6[_0x1184('0x22')]===_0x1184('0x23')&&typeof _0x2e30f6['limit']===_0x1184('0x23');var _0x4a64d6=_0x2ce3c0[_0x1184('0x24')];var _0x301bfe=_0x5bf7e7?0x0:_0x2e30f6['offset'];var _0x50f80f=_0x5bf7e7?_0x2ce3c0['count']:_0x2e30f6[_0x1184('0x22')]+_0x2e30f6[_0x1184('0x25')];var _0x5af629;if(_0x50f80f>=_0x4a64d6){_0x50f80f=_0x4a64d6;_0x5af629=0xc8;}else{_0x5af629=0xce;}_0x14e379[_0x1184('0x1f')](_0x5af629);return _0x14e379[_0x1184('0x26')](_0x1184('0x27'),_0x301bfe+'-'+_0x50f80f+'/'+_0x4a64d6)['json'](_0x2ce3c0);}return null;};}function patchUpdates(_0x220ef1){return function(_0x28bc84){try{jsonpatch['apply'](_0x28bc84,_0x220ef1,!![]);}catch(_0x50d242){return BPromise['reject'](_0x50d242);}return _0x28bc84[_0x1184('0x28')]();};}function saveUpdates(_0x250d9b,_0x31b0d0){return function(_0x202616){if(_0x202616){return _0x202616['update'](_0x250d9b)[_0x1184('0x29')](function(_0x348bd8){return _0x348bd8;});}return null;};}function removeEntity(_0x1f2a6a,_0x32a97b){return function(_0x31293a){if(_0x31293a){return _0x31293a[_0x1184('0x2a')]()['then'](function(){var _0x333d6a=_0x31293a[_0x1184('0x2b')]({'plain':!![]});var _0x5910c4=_0x1184('0x2c');return db['UserProfileResource']['destroy']({'where':{'type':_0x5910c4,'resourceId':_0x333d6a['id']}})[_0x1184('0x29')](function(){return _0x31293a;});})['then'](function(){_0x1f2a6a[_0x1184('0x1f')](0xcc)[_0x1184('0x20')]();});}};}function handleEntityNotFound(_0xcffbf6,_0x11d92f){return function(_0xad0370){if(!_0xad0370){_0xcffbf6[_0x1184('0x2d')](0x194);}return _0xad0370;};}function handleError(_0x52aac3,_0x1ed2f6){_0x1ed2f6=_0x1ed2f6||0x1f4;return function(_0x5b8c72){logger[_0x1184('0x2e')](_0x5b8c72[_0x1184('0x2f')]);if(_0x5b8c72[_0x1184('0x30')]){delete _0x5b8c72['name'];}_0x52aac3[_0x1184('0x1f')](_0x1ed2f6)[_0x1184('0x31')](_0x5b8c72);};}exports['index']=function(_0xef33fa,_0x327329){var _0x436c32={},_0x2f5231={},_0x2ae33b={'count':0x0,'rows':[]};var _0xb49ffa=_['map'](db[_0x1184('0x32')][_0x1184('0x33')],function(_0x2cebad){return{'name':_0x2cebad[_0x1184('0x34')],'type':_0x2cebad[_0x1184('0x35')][_0x1184('0x36')]};});_0x2f5231['model']=_[_0x1184('0x37')](_0xb49ffa,_0x1184('0x30'));_0x2f5231['query']=_[_0x1184('0x38')](_0xef33fa[_0x1184('0x39')]);_0x2f5231[_0x1184('0x3a')]=_[_0x1184('0x3b')](_0x2f5231[_0x1184('0x3c')],_0x2f5231[_0x1184('0x39')]);_0x436c32['attributes']=_[_0x1184('0x3b')](_0x2f5231[_0x1184('0x3c')],qs[_0x1184('0x3d')](_0xef33fa[_0x1184('0x39')][_0x1184('0x3d')]));_0x436c32[_0x1184('0x3e')]=_0x436c32[_0x1184('0x3e')][_0x1184('0x3f')]?_0x436c32[_0x1184('0x3e')]:_0x2f5231[_0x1184('0x3c')];if(!_0xef33fa[_0x1184('0x39')]['hasOwnProperty']('nolimit')){_0x436c32[_0x1184('0x25')]=qs['limit'](_0xef33fa[_0x1184('0x39')][_0x1184('0x25')]);_0x436c32['offset']=qs[_0x1184('0x22')](_0xef33fa['query'][_0x1184('0x22')]);}_0x436c32[_0x1184('0x40')]=qs[_0x1184('0x41')](_0xef33fa['query'][_0x1184('0x41')]);_0x436c32[_0x1184('0x42')]=qs['filters'](_[_0x1184('0x43')](_0xef33fa[_0x1184('0x39')],_0x2f5231[_0x1184('0x3a')]),_0xb49ffa);if(_0xef33fa[_0x1184('0x39')]['filter']){_0x436c32[_0x1184('0x42')]=_[_0x1184('0x44')](_0x436c32[_0x1184('0x42')],{'$or':_['map'](_0xb49ffa,function(_0x531fea){if(_0x531fea[_0x1184('0x35')]!==_0x1184('0x45')){var _0x132f99={};_0x132f99[_0x531fea[_0x1184('0x30')]]={'$like':'%'+_0xef33fa[_0x1184('0x39')]['filter']+'%'};return _0x132f99;}})});}_0x436c32=_[_0x1184('0x44')]({},_0x436c32,_0xef33fa['options']);var _0x503692={'where':_0x436c32[_0x1184('0x42')]};return db[_0x1184('0x32')][_0x1184('0x24')](_0x503692)[_0x1184('0x29')](function(_0x252615){_0x2ae33b['count']=_0x252615;if(_0xef33fa[_0x1184('0x39')][_0x1184('0x46')]){_0x436c32[_0x1184('0x47')]=[{'all':!![]}];}return db[_0x1184('0x32')]['findAll'](_0x436c32);})[_0x1184('0x29')](function(_0x420864){_0x2ae33b[_0x1184('0x48')]=_0x420864;return _0x2ae33b;})[_0x1184('0x29')](respondWithFilteredResult(_0x327329,_0x436c32))[_0x1184('0x49')](handleError(_0x327329,null));};exports[_0x1184('0x4a')]=function(_0x18c72a,_0x3a7e9d){var _0x37b553={'raw':!![],'where':{'id':_0x18c72a[_0x1184('0x4b')]['id']}},_0x331270={};_0x331270[_0x1184('0x3c')]=_[_0x1184('0x38')](db[_0x1184('0x32')][_0x1184('0x33')]);_0x331270[_0x1184('0x39')]=_[_0x1184('0x38')](_0x18c72a[_0x1184('0x39')]);_0x331270[_0x1184('0x3a')]=_[_0x1184('0x3b')](_0x331270[_0x1184('0x3c')],_0x331270[_0x1184('0x39')]);_0x37b553[_0x1184('0x3e')]=_[_0x1184('0x3b')](_0x331270['model'],qs['fields'](_0x18c72a[_0x1184('0x39')][_0x1184('0x3d')]));_0x37b553[_0x1184('0x3e')]=_0x37b553[_0x1184('0x3e')][_0x1184('0x3f')]?_0x37b553[_0x1184('0x3e')]:_0x331270['model'];if(_0x18c72a[_0x1184('0x39')][_0x1184('0x46')]){_0x37b553[_0x1184('0x47')]=[{'all':!![]}];}_0x37b553=_['merge']({},_0x37b553,_0x18c72a[_0x1184('0x4c')]);return db[_0x1184('0x32')]['find'](_0x37b553)[_0x1184('0x29')](handleEntityNotFound(_0x3a7e9d,null))['then'](respondWithResult(_0x3a7e9d,null))[_0x1184('0x49')](handleError(_0x3a7e9d,null));};exports[_0x1184('0x4d')]=function(_0x3104d2,_0x45e9ab){return db[_0x1184('0x32')][_0x1184('0x4d')](_0x3104d2[_0x1184('0x4e')],{})[_0x1184('0x29')](function(_0x495bc1){var _0x191097=_0x3104d2[_0x1184('0x4f')]['get']({'plain':!![]});if(!_0x191097)throw new Error(_0x1184('0x50'));if(_0x191097[_0x1184('0x51')]===_0x1184('0x4f')){var _0x4c2bab=_0x495bc1[_0x1184('0x2b')]({'plain':!![]});var _0xfcb93e=_0x1184('0x2c');return db['UserProfileSection']['find']({'where':{'name':_0xfcb93e,'userProfileId':_0x191097[_0x1184('0x52')]},'raw':!![]})['then'](function(_0x53caf2){if(_0x53caf2&&_0x53caf2[_0x1184('0x53')]===0x0){return db[_0x1184('0x54')][_0x1184('0x4d')]({'name':_0x4c2bab[_0x1184('0x30')],'resourceId':_0x4c2bab['id'],'type':_0x53caf2[_0x1184('0x30')],'sectionId':_0x53caf2['id']},{})['then'](function(){return _0x495bc1;});}else{return _0x495bc1;}})[_0x1184('0x49')](function(_0x262b85){logger['error'](_0x1184('0x55'),_0x262b85);throw _0x262b85;});}return _0x495bc1;})[_0x1184('0x29')](respondWithResult(_0x45e9ab,0xc9))[_0x1184('0x49')](handleError(_0x45e9ab,null));};exports[_0x1184('0x56')]=function(_0x4a1e0c,_0x3abff0){if(_0x4a1e0c[_0x1184('0x4e')]['id']){delete _0x4a1e0c[_0x1184('0x4e')]['id'];}return db[_0x1184('0x32')][_0x1184('0x57')]({'where':{'id':_0x4a1e0c[_0x1184('0x4b')]['id']}})[_0x1184('0x29')](handleEntityNotFound(_0x3abff0,null))[_0x1184('0x29')](saveUpdates(_0x4a1e0c['body'],null))['then'](respondWithResult(_0x3abff0,null))['catch'](handleError(_0x3abff0,null));};exports[_0x1184('0x2a')]=function(_0x2b8b86,_0xc2c883){return db[_0x1184('0x32')][_0x1184('0x57')]({'where':{'id':_0x2b8b86[_0x1184('0x4b')]['id']}})[_0x1184('0x29')](handleEntityNotFound(_0xc2c883,null))[_0x1184('0x29')](removeEntity(_0xc2c883,null))['catch'](handleError(_0xc2c883,null));};exports['describe']=function(_0x2cf128,_0x3598f4){return db[_0x1184('0x32')][_0x1184('0x58')]()[_0x1184('0x29')](respondWithResult(_0x3598f4,null))[_0x1184('0x49')](handleError(_0x3598f4,null));};exports[_0x1184('0x59')]=function(_0x12cb2b,_0x4eb396,_0x424f7a){var _0x2e9380={'raw':!![],'where':{}},_0x598751={},_0x50003d;return db[_0x1184('0x32')][_0x1184('0x5a')]({'where':{'id':_0x12cb2b[_0x1184('0x4b')]['id']}})['then'](handleEntityNotFound(_0x4eb396,null))['then'](function(_0x12417a){if(_0x12417a){_0x50003d=_0x12417a[_0x1184('0x2b')]({'plain':!![]});_0x598751[_0x1184('0x3c')]=_['keys'](db[_0x1184('0x5b')][_0x1184('0x33')]);_0x598751[_0x1184('0x39')]=_[_0x1184('0x38')](_0x12cb2b[_0x1184('0x39')]);_0x598751[_0x1184('0x3a')]=_[_0x1184('0x3b')](_0x598751[_0x1184('0x3c')],_0x598751[_0x1184('0x39')]);_0x2e9380[_0x1184('0x3e')]=_[_0x1184('0x3b')](_0x598751[_0x1184('0x3c')],qs['fields'](_0x12cb2b[_0x1184('0x39')][_0x1184('0x3d')]));_0x2e9380[_0x1184('0x3e')]=_0x2e9380[_0x1184('0x3e')][_0x1184('0x3f')]?_0x2e9380['attributes']:_0x598751['model'];if(!_0x12cb2b[_0x1184('0x39')]['hasOwnProperty']('nolimit')){_0x2e9380['limit']=qs[_0x1184('0x25')](_0x12cb2b[_0x1184('0x39')]['limit']);_0x2e9380[_0x1184('0x22')]=qs[_0x1184('0x22')](_0x12cb2b[_0x1184('0x39')]['offset']);}_0x2e9380[_0x1184('0x40')]=qs[_0x1184('0x41')](_0x12cb2b[_0x1184('0x39')]['sort']);_0x2e9380[_0x1184('0x42')]=qs[_0x1184('0x3a')](_[_0x1184('0x43')](_0x12cb2b[_0x1184('0x39')],_0x598751['filters']));_0x2e9380[_0x1184('0x42')][_0x1184('0x5c')]=_0x12417a['id'];if(_0x12cb2b[_0x1184('0x39')][_0x1184('0x5d')]){_0x2e9380['where']=_[_0x1184('0x44')](_0x2e9380[_0x1184('0x42')],{'$or':_[_0x1184('0x37')](_0x2e9380[_0x1184('0x3e')],function(_0x320f4a){var _0xbb88d8={};_0xbb88d8[_0x320f4a]={'$like':'%'+_0x12cb2b[_0x1184('0x39')][_0x1184('0x5d')]+'%'};return _0xbb88d8;})});}_0x2e9380=_[_0x1184('0x44')]({},_0x2e9380,_0x12cb2b[_0x1184('0x4c')]);return db['UserMailQueue'][_0x1184('0x5e')](_0x2e9380);}})[_0x1184('0x29')](function(_0x2fb5c3){if(_0x2fb5c3){return db['User'][_0x1184('0x5f')]({'where':{'id':_[_0x1184('0x37')](_0x2fb5c3,_0x1184('0x60')),'role':_0x1184('0x61')},'attributes':['id',_0x1184('0x30'),_0x1184('0x62'),_0x1184('0x63'),_0x1184('0x64')]});}})[_0x1184('0x29')](function(_0x83383b){if(_0x83383b){return{'count':_0x83383b[_0x1184('0x24')],'rows':_[_0x1184('0x37')](_0x83383b[_0x1184('0x48')],function(_0x103513){return{'membername':_0x103513[_0x1184('0x30')],'UserId':_0x103513['id'],'queue_name':_0x50003d[_0x1184('0x30')],'MailQueueId':_0x50003d['id'],'interface':util[_0x1184('0x65')](_0x1184('0x66'),_0x1184('0x67'),_0x103513['name']),'penalty':0x0,'paused':_0x103513['mailPause'],'createdAt':_0x103513[_0x1184('0x64')],'updatedAt':_0x103513[_0x1184('0x63')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x1184('0x29')](respondWithFilteredResult(_0x4eb396,_0x2e9380))[_0x1184('0x49')](handleError(_0x4eb396,null));};exports['getTeams']=function(_0x506de4,_0x5daa39,_0x1d572a){var _0x5bd584={};var _0x202b1c={};var _0x113599;var _0x195812;return db[_0x1184('0x32')][_0x1184('0x5a')]({'where':{'id':_0x506de4['params']['id']}})[_0x1184('0x29')](handleEntityNotFound(_0x5daa39,null))['then'](function(_0x2619f0){if(_0x2619f0){_0x113599=_0x2619f0;_0x202b1c[_0x1184('0x3c')]=_['keys'](db[_0x1184('0x68')]['rawAttributes']);_0x202b1c[_0x1184('0x39')]=_[_0x1184('0x38')](_0x506de4[_0x1184('0x39')]);_0x202b1c[_0x1184('0x3a')]=_[_0x1184('0x3b')](_0x202b1c[_0x1184('0x3c')],_0x202b1c['query']);_0x5bd584[_0x1184('0x3e')]=_[_0x1184('0x3b')](_0x202b1c[_0x1184('0x3c')],qs[_0x1184('0x3d')](_0x506de4['query'][_0x1184('0x3d')]));_0x5bd584[_0x1184('0x3e')]=_0x5bd584[_0x1184('0x3e')][_0x1184('0x3f')]?_0x5bd584[_0x1184('0x3e')]:_0x202b1c[_0x1184('0x3c')];_0x5bd584['order']=qs[_0x1184('0x41')](_0x506de4[_0x1184('0x39')][_0x1184('0x41')]);_0x5bd584[_0x1184('0x42')]=qs[_0x1184('0x3a')](_[_0x1184('0x43')](_0x506de4[_0x1184('0x39')],_0x202b1c[_0x1184('0x3a')]));if(_0x506de4['query']['filter']){_0x5bd584[_0x1184('0x42')]=_[_0x1184('0x44')](_0x5bd584[_0x1184('0x42')],{'$or':_[_0x1184('0x37')](_0x5bd584['attributes'],function(_0x5c022c){var _0x5738e4={};_0x5738e4[_0x5c022c]={'$like':'%'+_0x506de4['query'][_0x1184('0x5d')]+'%'};return _0x5738e4;})});}_0x5bd584=_[_0x1184('0x44')]({},_0x5bd584,_0x506de4[_0x1184('0x4c')]);return _0x113599[_0x1184('0x69')](_0x5bd584);}})[_0x1184('0x29')](function(_0x2bbe6c){if(_0x2bbe6c){_0x195812=_0x2bbe6c[_0x1184('0x3f')];if(!_0x506de4['query'][_0x1184('0x6a')]('nolimit')){_0x5bd584['limit']=qs['limit'](_0x506de4[_0x1184('0x39')][_0x1184('0x25')]);_0x5bd584[_0x1184('0x22')]=qs['offset'](_0x506de4[_0x1184('0x39')][_0x1184('0x22')]);}return _0x113599[_0x1184('0x69')](_0x5bd584);}})[_0x1184('0x29')](function(_0x3b4cc){if(_0x3b4cc){return _0x3b4cc?{'count':_0x195812,'rows':_0x3b4cc}:null;}})[_0x1184('0x29')](respondWithResult(_0x5daa39,null))['catch'](handleError(_0x5daa39,null));};exports['addTeams']=function(_0x5eb5c9,_0x138b52,_0x4b4dec){var _0x2172f5=_0x5eb5c9['body']['ids'];return db[_0x1184('0x68')][_0x1184('0x5e')]({'where':{'id':_0x2172f5},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0x1184('0x30'),_0x1184('0x6b'),_0x1184('0x6c'),'interface'],'raw':!![]}]})[_0x1184('0x29')](function(_0x128491){if(_0x128491){var _0x507669=_[_0x1184('0x6d')](_0x128491,function(_0x3e44c4){var _0x96a05=_0x3e44c4[_0x1184('0x2b')]({'plain':!![]});return _0x96a05[_0x1184('0x6e')];});return db[_0x1184('0x32')][_0x1184('0x57')]({'where':{'id':_0x5eb5c9[_0x1184('0x4b')]['id']}})['then'](function(_0x956a0f){return db['sequelize'][_0x1184('0x6f')](function(_0x269ffc){return _0x956a0f['addTeams'](_0x2172f5,{'transaction':_0x269ffc})[_0x1184('0x29')](function(){return BPromise[_0x1184('0x70')](_0x507669,function(_0x1db0a8){return db['UserMailQueue'][_0x1184('0x71')]({'where':{'UserId':_0x1db0a8['id'],'MailQueueId':_0x5eb5c9[_0x1184('0x4b')]['id']},'transaction':_0x269ffc});});})[_0x1184('0x29')](function(){_0x507669[_0x1184('0x72')](function(_0x4720e7){socket[_0x1184('0x73')](_0x1184('0x74'),{'UserId':_0x4720e7['id'],'MailQueueId':_0x956a0f['id']});});});});});}})[_0x1184('0x29')](respondWithStatusCode(_0x138b52,null))[_0x1184('0x49')](handleError(_0x138b52,null));};exports[_0x1184('0x75')]=function(_0x3b36e3,_0xea099d,_0x1d96ff){return db[_0x1184('0x68')][_0x1184('0x5e')]({'where':{'id':_0x3b36e3[_0x1184('0x39')][_0x1184('0x76')]},'attributes':['id'],'include':[{'model':db[_0x1184('0x77')],'as':_0x1184('0x6e'),'attributes':['id'],'raw':!![]}]})[_0x1184('0x29')](handleEntityNotFound(_0xea099d,null))[_0x1184('0x29')](function(_0x228cf5){var _0x27ce60=_['map'](_0x228cf5,'id');var _0x51629e=[];var _0x51cc63=[];var _0x37f788=squel[_0x1184('0x78')]();_0x37f788['field'](_0x1184('0x79'))[_0x1184('0x7a')]('team_has_mail_queues','tq')['join'](_0x1184('0x7b'),'ut',_0x1184('0x7c'))['where'](_0x1184('0x7d'),_0x3b36e3[_0x1184('0x4b')]['id']);for(var _0x105e2e=0x0;_0x105e2e<_0x228cf5['length'];_0x105e2e+=0x1){let _0x56dae5=_0x228cf5[_0x105e2e];for(var _0x3f6aa8=0x0;_0x3f6aa8<_0x56dae5['Agents'][_0x1184('0x3f')];_0x3f6aa8+=0x1){let _0x467972=_0x56dae5[_0x1184('0x6e')][_0x3f6aa8];var _0x1ac485=_0x37f788[_0x1184('0x7e')]();_0x1ac485[_0x1184('0x42')](_0x1184('0x7f'),_0x467972['id']);_0x51cc63[_0x1184('0x80')](db[_0x1184('0x81')][_0x1184('0x39')](_0x1ac485[_0x1184('0x82')](),{'type':db[_0x1184('0x81')][_0x1184('0x83')][_0x1184('0x84')]})[_0x1184('0x29')](function(_0x240c9f){if(_0x240c9f[_0x1184('0x3f')]===0x1){return _0x467972['id'];}else{var _0x239288=_[_0x1184('0x85')](_['map'](_0x240c9f,_0x1184('0x86')),function(_0x99fdb8){return _[_0x1184('0x87')](_0x27ce60,_0x99fdb8);});if(_0x239288){return _0x467972['id'];}}}));}}return BPromise[_0x1184('0x88')](_0x51cc63)['then'](function(_0x4eaf9a){_0x51629e=_(_0x51629e)['union'](_0x4eaf9a)[_0x1184('0x89')]()[_0x1184('0x8a')]();return db['MailQueue']['find']({'where':{'id':_0x3b36e3['params']['id']}})[_0x1184('0x29')](function(_0x248bd3){return db[_0x1184('0x81')][_0x1184('0x6f')](function(_0x330713){return _0x248bd3['removeTeams'](_0x3b36e3[_0x1184('0x39')][_0x1184('0x76')],{'transaction':_0x330713})[_0x1184('0x29')](function(){if(!_['isEmpty'](_0x51629e)){return _0x248bd3[_0x1184('0x8b')](_0x51629e,{'transaction':_0x330713});}})[_0x1184('0x29')](function(){_0x51629e['forEach'](function(_0x555213){socket['emit'](_0x1184('0x8c'),{'UserId':_0x555213,'MailQueueId':_0x248bd3['id']});});});});});});})[_0x1184('0x29')](respondWithStatusCode(_0xea099d,null))[_0x1184('0x49')](handleError(_0xea099d,null));};exports[_0x1184('0x8d')]=function(_0xff6e33,_0x22b35b,_0x176c3b){return db[_0x1184('0x32')][_0x1184('0x57')]({'where':{'id':_0xff6e33[_0x1184('0x4b')]['id']}})['then'](handleEntityNotFound(_0x22b35b,null))['then'](function(_0x497b5e){if(_0x497b5e){return _0x497b5e[_0x1184('0x8d')](_0xff6e33[_0x1184('0x4e')][_0x1184('0x76')],_[_0x1184('0x8e')](_0xff6e33[_0x1184('0x4e')],[_0x1184('0x76'),'id'])||{})[_0x1184('0x8f')](function(_0x376ce7){for(var _0x23186d=0x0;_0x23186d<_0xff6e33[_0x1184('0x4e')][_0x1184('0x76')][_0x1184('0x3f')];_0x23186d+=0x1){socket[_0x1184('0x73')](_0x1184('0x74'),{'UserId':Number(_0xff6e33['body'][_0x1184('0x76')][_0x23186d]),'MailQueueId':Number(_0xff6e33[_0x1184('0x4b')]['id'])});}return _0x376ce7;});}})[_0x1184('0x29')](respondWithResult(_0x22b35b,null))[_0x1184('0x49')](handleError(_0x22b35b,null));};exports[_0x1184('0x8b')]=function(_0x279bf6,_0x510d26,_0xd95a0f){return db[_0x1184('0x32')][_0x1184('0x57')]({'where':{'id':_0x279bf6[_0x1184('0x4b')]['id']}})[_0x1184('0x29')](handleEntityNotFound(_0x510d26,null))[_0x1184('0x29')](function(_0x518c74){if(_0x518c74){return _0x518c74[_0x1184('0x8b')](_0x279bf6[_0x1184('0x39')]['ids'])[_0x1184('0x29')](function(){if(_[_0x1184('0x90')](_0x279bf6[_0x1184('0x39')][_0x1184('0x76')])){for(var _0x1501ad=0x0;_0x1501ad<_0x279bf6[_0x1184('0x39')][_0x1184('0x76')]['length'];_0x1501ad+=0x1){socket[_0x1184('0x73')](_0x1184('0x8c'),{'UserId':Number(_0x279bf6[_0x1184('0x39')]['ids'][_0x1501ad]),'MailQueueId':Number(_0x279bf6[_0x1184('0x4b')]['id'])});}}else{socket[_0x1184('0x73')](_0x1184('0x8c'),{'UserId':Number(_0x279bf6['query'][_0x1184('0x76')]),'MailQueueId':Number(_0x279bf6['params']['id'])});}});}})[_0x1184('0x29')](respondWithStatusCode(_0x510d26,null))['catch'](handleError(_0x510d26,null));};exports[_0x1184('0x91')]=function(_0x355fa8,_0x13c377,_0x55614e){var _0x5606b1={};var _0x141fd2={};var _0x3fd28a;var _0x51e1a2;return db['MailQueue'][_0x1184('0x5a')]({'where':{'id':_0x355fa8['params']['id']}})[_0x1184('0x29')](handleEntityNotFound(_0x13c377,null))[_0x1184('0x29')](function(_0x1311af){if(_0x1311af){_0x3fd28a=_0x1311af;_0x141fd2['model']=_[_0x1184('0x38')](db[_0x1184('0x77')][_0x1184('0x33')]);_0x141fd2[_0x1184('0x39')]=_[_0x1184('0x38')](_0x355fa8[_0x1184('0x39')]);_0x141fd2['filters']=_['intersection'](_0x141fd2[_0x1184('0x3c')],_0x141fd2['query']);_0x5606b1[_0x1184('0x3e')]=_['intersection'](_0x141fd2[_0x1184('0x3c')],qs['fields'](_0x355fa8[_0x1184('0x39')][_0x1184('0x3d')]));_0x5606b1[_0x1184('0x3e')]=_0x5606b1[_0x1184('0x3e')][_0x1184('0x3f')]?_0x5606b1[_0x1184('0x3e')]:_0x141fd2['model'];_0x5606b1[_0x1184('0x40')]=qs[_0x1184('0x41')](_0x355fa8[_0x1184('0x39')][_0x1184('0x41')]);_0x5606b1[_0x1184('0x42')]=qs[_0x1184('0x3a')](_[_0x1184('0x43')](_0x355fa8[_0x1184('0x39')],_0x141fd2[_0x1184('0x3a')]));if(_0x355fa8[_0x1184('0x39')][_0x1184('0x5d')]){_0x5606b1[_0x1184('0x42')]=_['merge'](_0x5606b1[_0x1184('0x42')],{'$or':_[_0x1184('0x37')](_0x5606b1[_0x1184('0x3e')],function(_0x1ca6cc){var _0x5b6931={};_0x5b6931[_0x1ca6cc]={'$like':'%'+_0x355fa8[_0x1184('0x39')][_0x1184('0x5d')]+'%'};return _0x5b6931;})});}_0x5606b1=_['merge']({},_0x5606b1,_0x355fa8[_0x1184('0x4c')]);return _0x3fd28a['getAgents'](_0x5606b1);}})[_0x1184('0x29')](function(_0x5201d7){if(_0x5201d7){_0x51e1a2=_0x5201d7['length'];if(!_0x355fa8['query'][_0x1184('0x6a')](_0x1184('0x92'))){_0x5606b1[_0x1184('0x25')]=qs['limit'](_0x355fa8[_0x1184('0x39')]['limit']);_0x5606b1[_0x1184('0x22')]=qs[_0x1184('0x22')](_0x355fa8[_0x1184('0x39')]['offset']);}return _0x3fd28a[_0x1184('0x91')](_0x5606b1);}})[_0x1184('0x29')](function(_0x3d529a){if(_0x3d529a){return _0x3d529a?{'count':_0x51e1a2,'rows':_0x3d529a}:null;}})[_0x1184('0x29')](respondWithResult(_0x13c377,null))[_0x1184('0x49')](handleError(_0x13c377,null));};
\ No newline at end of file
+var _0xf0a3=['fields','hasOwnProperty','nolimit','sort','pick','merge','VIRTUAL','options','where','count','includeAll','include','findAll','catch','show','params','find','create','body','user','MailQueues','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','findOne','UserMailQueue','order','MailQueueId','filter','User','findAndCountAll','agent','mailPause','updatedAt','createdAt','rows','format','%s/%s','getTeams','Team','length','addTeams','online','interface','Agents','sequelize','transaction','each','findOrCreate','forEach','emit','userMailQueue:save','removeTeams','ids','select','field','tq.TeamId','from','team_has_mail_queues','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','removeAgents','userMailQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./mailQueue.socket','register','sendStatus','status','json','offset','undefined','limit','Content-Range','apply','reject','save','then','destroy','get','end','error','name','send','index','MailQueue','rawAttributes','fieldName','type','model','map','query','keys','filters','intersection','attributes'];(function(_0x4efdd4,_0x1a6670){var _0x47a25b=function(_0x1a1be4){while(--_0x1a1be4){_0x4efdd4['push'](_0x4efdd4['shift']());}};_0x47a25b(++_0x1a6670);}(_0xf0a3,0xe1));var _0x3f0a=function(_0x127902,_0x169f94){_0x127902=_0x127902-0x0;var _0x45407e=_0xf0a3[_0x127902];return _0x45407e;};'use strict';var emlformat=require(_0x3f0a('0x0'));var rimraf=require(_0x3f0a('0x1'));var zipdir=require(_0x3f0a('0x2'));var jsonpatch=require(_0x3f0a('0x3'));var rp=require(_0x3f0a('0x4'));var moment=require(_0x3f0a('0x5'));var BPromise=require(_0x3f0a('0x6'));var Mustache=require(_0x3f0a('0x7'));var util=require(_0x3f0a('0x8'));var path=require(_0x3f0a('0x9'));var sox=require(_0x3f0a('0xa'));var csv=require('to-csv');var ejs=require(_0x3f0a('0xb'));var fs=require('fs');var fs_extra=require(_0x3f0a('0xc'));var _=require(_0x3f0a('0xd'));var squel=require('squel');var crypto=require(_0x3f0a('0xe'));var jsforce=require(_0x3f0a('0xf'));var deskjs=require(_0x3f0a('0x10'));var toCsv=require(_0x3f0a('0x11'));var querystring=require(_0x3f0a('0x12'));var Papa=require(_0x3f0a('0x13'));var Redis=require(_0x3f0a('0x14'));var authService=require('../../components/auth/service');var qs=require(_0x3f0a('0x15'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x3f0a('0x16'));var logger=require('../../config/logger')(_0x3f0a('0x17'));var utils=require('../../config/utils');var config=require(_0x3f0a('0x18'));var licenseUtil=require(_0x3f0a('0x19'));var db=require(_0x3f0a('0x1a'))['db'];config[_0x3f0a('0x1b')]=_[_0x3f0a('0x1c')](config[_0x3f0a('0x1b')],{'host':'localhost','port':0x18eb});var socket=require(_0x3f0a('0x1d'))(new Redis(config[_0x3f0a('0x1b')]));require(_0x3f0a('0x1e'))[_0x3f0a('0x1f')](socket);function respondWithStatusCode(_0x1ec80d,_0x2ed046){_0x2ed046=_0x2ed046||0xcc;return function(_0x3b9820){if(_0x3b9820){return _0x1ec80d[_0x3f0a('0x20')](_0x2ed046);}return _0x1ec80d[_0x3f0a('0x21')](_0x2ed046)['end']();};}function respondWithResult(_0xc33f21,_0x36ef5e){_0x36ef5e=_0x36ef5e||0xc8;return function(_0xcc706a){if(_0xcc706a){return _0xc33f21[_0x3f0a('0x21')](_0x36ef5e)[_0x3f0a('0x22')](_0xcc706a);}};}function respondWithFilteredResult(_0x1b19cd,_0x4deb89){return function(_0x449c70){if(_0x449c70){var _0x2de44c=typeof _0x4deb89[_0x3f0a('0x23')]===_0x3f0a('0x24')&&typeof _0x4deb89[_0x3f0a('0x25')]===_0x3f0a('0x24');var _0x1ea1ab=_0x449c70['count'];var _0x268b41=_0x2de44c?0x0:_0x4deb89[_0x3f0a('0x23')];var _0x8325e6=_0x2de44c?_0x449c70['count']:_0x4deb89[_0x3f0a('0x23')]+_0x4deb89['limit'];var _0x5021a7;if(_0x8325e6>=_0x1ea1ab){_0x8325e6=_0x1ea1ab;_0x5021a7=0xc8;}else{_0x5021a7=0xce;}_0x1b19cd['status'](_0x5021a7);return _0x1b19cd['set'](_0x3f0a('0x26'),_0x268b41+'-'+_0x8325e6+'/'+_0x1ea1ab)[_0x3f0a('0x22')](_0x449c70);}return null;};}function patchUpdates(_0x4e1316){return function(_0x4bb7fe){try{jsonpatch[_0x3f0a('0x27')](_0x4bb7fe,_0x4e1316,!![]);}catch(_0x4f0cad){return BPromise[_0x3f0a('0x28')](_0x4f0cad);}return _0x4bb7fe[_0x3f0a('0x29')]();};}function saveUpdates(_0x1ac99f,_0x5366ee){return function(_0x2db3ed){if(_0x2db3ed){return _0x2db3ed['update'](_0x1ac99f)[_0x3f0a('0x2a')](function(_0x11e113){return _0x11e113;});}return null;};}function removeEntity(_0x5b4227,_0x4281c5){return function(_0x5a8f6e){if(_0x5a8f6e){return _0x5a8f6e[_0x3f0a('0x2b')]()[_0x3f0a('0x2a')](function(){var _0x2c2d4e=_0x5a8f6e[_0x3f0a('0x2c')]({'plain':!![]});var _0x4a1873='MailQueues';return db['UserProfileResource'][_0x3f0a('0x2b')]({'where':{'type':_0x4a1873,'resourceId':_0x2c2d4e['id']}})[_0x3f0a('0x2a')](function(){return _0x5a8f6e;});})[_0x3f0a('0x2a')](function(){_0x5b4227[_0x3f0a('0x21')](0xcc)[_0x3f0a('0x2d')]();});}};}function handleEntityNotFound(_0x2bb426,_0x107986){return function(_0x3303fc){if(!_0x3303fc){_0x2bb426[_0x3f0a('0x20')](0x194);}return _0x3303fc;};}function handleError(_0x47e2b9,_0x515b41){_0x515b41=_0x515b41||0x1f4;return function(_0x16afda){logger[_0x3f0a('0x2e')](_0x16afda['stack']);if(_0x16afda[_0x3f0a('0x2f')]){delete _0x16afda[_0x3f0a('0x2f')];}_0x47e2b9[_0x3f0a('0x21')](_0x515b41)[_0x3f0a('0x30')](_0x16afda);};}exports[_0x3f0a('0x31')]=function(_0x21e0e0,_0x22cb95){var _0x348082={},_0x2a32d3={},_0x24fe7d={'count':0x0,'rows':[]};var _0x550485=_['map'](db[_0x3f0a('0x32')][_0x3f0a('0x33')],function(_0x47cee5){return{'name':_0x47cee5[_0x3f0a('0x34')],'type':_0x47cee5[_0x3f0a('0x35')]['key']};});_0x2a32d3[_0x3f0a('0x36')]=_[_0x3f0a('0x37')](_0x550485,_0x3f0a('0x2f'));_0x2a32d3[_0x3f0a('0x38')]=_[_0x3f0a('0x39')](_0x21e0e0[_0x3f0a('0x38')]);_0x2a32d3[_0x3f0a('0x3a')]=_[_0x3f0a('0x3b')](_0x2a32d3['model'],_0x2a32d3[_0x3f0a('0x38')]);_0x348082[_0x3f0a('0x3c')]=_['intersection'](_0x2a32d3['model'],qs[_0x3f0a('0x3d')](_0x21e0e0['query']['fields']));_0x348082['attributes']=_0x348082[_0x3f0a('0x3c')]['length']?_0x348082[_0x3f0a('0x3c')]:_0x2a32d3[_0x3f0a('0x36')];if(!_0x21e0e0['query'][_0x3f0a('0x3e')](_0x3f0a('0x3f'))){_0x348082['limit']=qs[_0x3f0a('0x25')](_0x21e0e0['query'][_0x3f0a('0x25')]);_0x348082['offset']=qs['offset'](_0x21e0e0[_0x3f0a('0x38')][_0x3f0a('0x23')]);}_0x348082['order']=qs[_0x3f0a('0x40')](_0x21e0e0[_0x3f0a('0x38')][_0x3f0a('0x40')]);_0x348082['where']=qs[_0x3f0a('0x3a')](_[_0x3f0a('0x41')](_0x21e0e0[_0x3f0a('0x38')],_0x2a32d3['filters']),_0x550485);if(_0x21e0e0['query']['filter']){_0x348082['where']=_[_0x3f0a('0x42')](_0x348082['where'],{'$or':_[_0x3f0a('0x37')](_0x550485,function(_0x5d759a){if(_0x5d759a['type']!==_0x3f0a('0x43')){var _0xf8da42={};_0xf8da42[_0x5d759a[_0x3f0a('0x2f')]]={'$like':'%'+_0x21e0e0[_0x3f0a('0x38')]['filter']+'%'};return _0xf8da42;}})});}_0x348082=_[_0x3f0a('0x42')]({},_0x348082,_0x21e0e0[_0x3f0a('0x44')]);var _0x409492={'where':_0x348082[_0x3f0a('0x45')]};return db[_0x3f0a('0x32')][_0x3f0a('0x46')](_0x409492)[_0x3f0a('0x2a')](function(_0x1a7f08){_0x24fe7d['count']=_0x1a7f08;if(_0x21e0e0[_0x3f0a('0x38')][_0x3f0a('0x47')]){_0x348082[_0x3f0a('0x48')]=[{'all':!![]}];}return db[_0x3f0a('0x32')][_0x3f0a('0x49')](_0x348082);})[_0x3f0a('0x2a')](function(_0x483a6c){_0x24fe7d['rows']=_0x483a6c;return _0x24fe7d;})[_0x3f0a('0x2a')](respondWithFilteredResult(_0x22cb95,_0x348082))[_0x3f0a('0x4a')](handleError(_0x22cb95,null));};exports[_0x3f0a('0x4b')]=function(_0x33dcf1,_0x438c61){var _0x3a4b63={'raw':!![],'where':{'id':_0x33dcf1[_0x3f0a('0x4c')]['id']}},_0x1f5f49={};_0x1f5f49['model']=_[_0x3f0a('0x39')](db['MailQueue'][_0x3f0a('0x33')]);_0x1f5f49[_0x3f0a('0x38')]=_[_0x3f0a('0x39')](_0x33dcf1[_0x3f0a('0x38')]);_0x1f5f49[_0x3f0a('0x3a')]=_[_0x3f0a('0x3b')](_0x1f5f49['model'],_0x1f5f49[_0x3f0a('0x38')]);_0x3a4b63[_0x3f0a('0x3c')]=_[_0x3f0a('0x3b')](_0x1f5f49[_0x3f0a('0x36')],qs[_0x3f0a('0x3d')](_0x33dcf1['query'][_0x3f0a('0x3d')]));_0x3a4b63[_0x3f0a('0x3c')]=_0x3a4b63['attributes']['length']?_0x3a4b63[_0x3f0a('0x3c')]:_0x1f5f49['model'];if(_0x33dcf1[_0x3f0a('0x38')][_0x3f0a('0x47')]){_0x3a4b63[_0x3f0a('0x48')]=[{'all':!![]}];}_0x3a4b63=_[_0x3f0a('0x42')]({},_0x3a4b63,_0x33dcf1['options']);return db[_0x3f0a('0x32')][_0x3f0a('0x4d')](_0x3a4b63)[_0x3f0a('0x2a')](handleEntityNotFound(_0x438c61,null))['then'](respondWithResult(_0x438c61,null))[_0x3f0a('0x4a')](handleError(_0x438c61,null));};exports[_0x3f0a('0x4e')]=function(_0x1a3279,_0x4585df){return db['MailQueue'][_0x3f0a('0x4e')](_0x1a3279[_0x3f0a('0x4f')],{})['then'](function(_0x5831f5){var _0x2d741c=_0x1a3279['user']['get']({'plain':!![]});if(!_0x2d741c)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2d741c['role']===_0x3f0a('0x50')){var _0x285d54=_0x5831f5[_0x3f0a('0x2c')]({'plain':!![]});var _0x1998a7=_0x3f0a('0x51');return db['UserProfileSection']['find']({'where':{'name':_0x1998a7,'userProfileId':_0x2d741c[_0x3f0a('0x52')]},'raw':!![]})['then'](function(_0x8fac43){if(_0x8fac43&&_0x8fac43['autoAssociation']===0x0){return db[_0x3f0a('0x53')][_0x3f0a('0x4e')]({'name':_0x285d54[_0x3f0a('0x2f')],'resourceId':_0x285d54['id'],'type':_0x8fac43[_0x3f0a('0x2f')],'sectionId':_0x8fac43['id']},{})['then'](function(){return _0x5831f5;});}else{return _0x5831f5;}})[_0x3f0a('0x4a')](function(_0x2839ee){logger[_0x3f0a('0x2e')](_0x3f0a('0x54'),_0x2839ee);throw _0x2839ee;});}return _0x5831f5;})[_0x3f0a('0x2a')](respondWithResult(_0x4585df,0xc9))[_0x3f0a('0x4a')](handleError(_0x4585df,null));};exports[_0x3f0a('0x55')]=function(_0x5e3aba,_0x22e810){if(_0x5e3aba[_0x3f0a('0x4f')]['id']){delete _0x5e3aba[_0x3f0a('0x4f')]['id'];}return db[_0x3f0a('0x32')]['find']({'where':{'id':_0x5e3aba['params']['id']}})[_0x3f0a('0x2a')](handleEntityNotFound(_0x22e810,null))[_0x3f0a('0x2a')](saveUpdates(_0x5e3aba[_0x3f0a('0x4f')],null))[_0x3f0a('0x2a')](respondWithResult(_0x22e810,null))[_0x3f0a('0x4a')](handleError(_0x22e810,null));};exports[_0x3f0a('0x2b')]=function(_0x34388,_0x4ebfe2){return db['MailQueue'][_0x3f0a('0x4d')]({'where':{'id':_0x34388[_0x3f0a('0x4c')]['id']}})[_0x3f0a('0x2a')](handleEntityNotFound(_0x4ebfe2,null))[_0x3f0a('0x2a')](removeEntity(_0x4ebfe2,null))[_0x3f0a('0x4a')](handleError(_0x4ebfe2,null));};exports[_0x3f0a('0x56')]=function(_0x2dc92e,_0x4cdc07){return db['MailQueue'][_0x3f0a('0x56')]()['then'](respondWithResult(_0x4cdc07,null))['catch'](handleError(_0x4cdc07,null));};exports['getMembers']=function(_0x322a6f,_0x5ea38e,_0x51e30e){var _0x4a6a44={'raw':!![],'where':{}},_0x4dc226={},_0x532263;return db[_0x3f0a('0x32')][_0x3f0a('0x57')]({'where':{'id':_0x322a6f[_0x3f0a('0x4c')]['id']}})[_0x3f0a('0x2a')](handleEntityNotFound(_0x5ea38e,null))[_0x3f0a('0x2a')](function(_0x1a78e5){if(_0x1a78e5){_0x532263=_0x1a78e5[_0x3f0a('0x2c')]({'plain':!![]});_0x4dc226[_0x3f0a('0x36')]=_[_0x3f0a('0x39')](db[_0x3f0a('0x58')][_0x3f0a('0x33')]);_0x4dc226[_0x3f0a('0x38')]=_['keys'](_0x322a6f[_0x3f0a('0x38')]);_0x4dc226[_0x3f0a('0x3a')]=_['intersection'](_0x4dc226['model'],_0x4dc226[_0x3f0a('0x38')]);_0x4a6a44['attributes']=_[_0x3f0a('0x3b')](_0x4dc226[_0x3f0a('0x36')],qs['fields'](_0x322a6f[_0x3f0a('0x38')][_0x3f0a('0x3d')]));_0x4a6a44[_0x3f0a('0x3c')]=_0x4a6a44[_0x3f0a('0x3c')]['length']?_0x4a6a44[_0x3f0a('0x3c')]:_0x4dc226['model'];if(!_0x322a6f[_0x3f0a('0x38')][_0x3f0a('0x3e')](_0x3f0a('0x3f'))){_0x4a6a44[_0x3f0a('0x25')]=qs[_0x3f0a('0x25')](_0x322a6f[_0x3f0a('0x38')][_0x3f0a('0x25')]);_0x4a6a44['offset']=qs[_0x3f0a('0x23')](_0x322a6f[_0x3f0a('0x38')][_0x3f0a('0x23')]);}_0x4a6a44[_0x3f0a('0x59')]=qs[_0x3f0a('0x40')](_0x322a6f['query'][_0x3f0a('0x40')]);_0x4a6a44[_0x3f0a('0x45')]=qs[_0x3f0a('0x3a')](_[_0x3f0a('0x41')](_0x322a6f['query'],_0x4dc226[_0x3f0a('0x3a')]));_0x4a6a44['where'][_0x3f0a('0x5a')]=_0x1a78e5['id'];if(_0x322a6f[_0x3f0a('0x38')][_0x3f0a('0x5b')]){_0x4a6a44['where']=_[_0x3f0a('0x42')](_0x4a6a44['where'],{'$or':_[_0x3f0a('0x37')](_0x4a6a44[_0x3f0a('0x3c')],function(_0x34784b){var _0x5e30ba={};_0x5e30ba[_0x34784b]={'$like':'%'+_0x322a6f[_0x3f0a('0x38')][_0x3f0a('0x5b')]+'%'};return _0x5e30ba;})});}_0x4a6a44=_[_0x3f0a('0x42')]({},_0x4a6a44,_0x322a6f[_0x3f0a('0x44')]);return db[_0x3f0a('0x58')][_0x3f0a('0x49')](_0x4a6a44);}})['then'](function(_0x14af66){if(_0x14af66){return db[_0x3f0a('0x5c')][_0x3f0a('0x5d')]({'where':{'id':_[_0x3f0a('0x37')](_0x14af66,'UserId'),'role':_0x3f0a('0x5e')},'attributes':['id','name',_0x3f0a('0x5f'),_0x3f0a('0x60'),_0x3f0a('0x61')]});}})['then'](function(_0x141c21){if(_0x141c21){return{'count':_0x141c21[_0x3f0a('0x46')],'rows':_[_0x3f0a('0x37')](_0x141c21[_0x3f0a('0x62')],function(_0x4551dc){return{'membername':_0x4551dc[_0x3f0a('0x2f')],'UserId':_0x4551dc['id'],'queue_name':_0x532263[_0x3f0a('0x2f')],'MailQueueId':_0x532263['id'],'interface':util[_0x3f0a('0x63')](_0x3f0a('0x64'),'SIP',_0x4551dc[_0x3f0a('0x2f')]),'penalty':0x0,'paused':_0x4551dc[_0x3f0a('0x5f')],'createdAt':_0x4551dc[_0x3f0a('0x61')],'updatedAt':_0x4551dc[_0x3f0a('0x60')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x3f0a('0x2a')](respondWithFilteredResult(_0x5ea38e,_0x4a6a44))[_0x3f0a('0x4a')](handleError(_0x5ea38e,null));};exports[_0x3f0a('0x65')]=function(_0x3136af,_0x243a7c,_0x45707e){var _0x28fe69={};var _0x2620b9={};var _0x5127e1;var _0x1130ab;return db[_0x3f0a('0x32')][_0x3f0a('0x57')]({'where':{'id':_0x3136af[_0x3f0a('0x4c')]['id']}})['then'](handleEntityNotFound(_0x243a7c,null))['then'](function(_0x57bcef){if(_0x57bcef){_0x5127e1=_0x57bcef;_0x2620b9['model']=_[_0x3f0a('0x39')](db[_0x3f0a('0x66')][_0x3f0a('0x33')]);_0x2620b9['query']=_[_0x3f0a('0x39')](_0x3136af['query']);_0x2620b9[_0x3f0a('0x3a')]=_[_0x3f0a('0x3b')](_0x2620b9[_0x3f0a('0x36')],_0x2620b9[_0x3f0a('0x38')]);_0x28fe69[_0x3f0a('0x3c')]=_[_0x3f0a('0x3b')](_0x2620b9[_0x3f0a('0x36')],qs[_0x3f0a('0x3d')](_0x3136af[_0x3f0a('0x38')][_0x3f0a('0x3d')]));_0x28fe69['attributes']=_0x28fe69[_0x3f0a('0x3c')][_0x3f0a('0x67')]?_0x28fe69[_0x3f0a('0x3c')]:_0x2620b9[_0x3f0a('0x36')];_0x28fe69[_0x3f0a('0x59')]=qs['sort'](_0x3136af[_0x3f0a('0x38')][_0x3f0a('0x40')]);_0x28fe69[_0x3f0a('0x45')]=qs['filters'](_[_0x3f0a('0x41')](_0x3136af[_0x3f0a('0x38')],_0x2620b9[_0x3f0a('0x3a')]));if(_0x3136af[_0x3f0a('0x38')][_0x3f0a('0x5b')]){_0x28fe69['where']=_[_0x3f0a('0x42')](_0x28fe69[_0x3f0a('0x45')],{'$or':_[_0x3f0a('0x37')](_0x28fe69['attributes'],function(_0xdd1ec){var _0x4bd27b={};_0x4bd27b[_0xdd1ec]={'$like':'%'+_0x3136af['query'][_0x3f0a('0x5b')]+'%'};return _0x4bd27b;})});}_0x28fe69=_[_0x3f0a('0x42')]({},_0x28fe69,_0x3136af[_0x3f0a('0x44')]);return _0x5127e1['getTeams'](_0x28fe69);}})[_0x3f0a('0x2a')](function(_0x1bb1fd){if(_0x1bb1fd){_0x1130ab=_0x1bb1fd[_0x3f0a('0x67')];if(!_0x3136af[_0x3f0a('0x38')][_0x3f0a('0x3e')](_0x3f0a('0x3f'))){_0x28fe69[_0x3f0a('0x25')]=qs[_0x3f0a('0x25')](_0x3136af[_0x3f0a('0x38')][_0x3f0a('0x25')]);_0x28fe69[_0x3f0a('0x23')]=qs[_0x3f0a('0x23')](_0x3136af[_0x3f0a('0x38')][_0x3f0a('0x23')]);}return _0x5127e1['getTeams'](_0x28fe69);}})['then'](function(_0x14565c){if(_0x14565c){return _0x14565c?{'count':_0x1130ab,'rows':_0x14565c}:null;}})[_0x3f0a('0x2a')](respondWithResult(_0x243a7c,null))[_0x3f0a('0x4a')](handleError(_0x243a7c,null));};exports[_0x3f0a('0x68')]=function(_0x45de3d,_0x1a7f55,_0x24b198){var _0x2c38e3=_0x45de3d[_0x3f0a('0x4f')]['ids'];return db[_0x3f0a('0x66')][_0x3f0a('0x49')]({'where':{'id':_0x2c38e3},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id',_0x3f0a('0x2f'),_0x3f0a('0x69'),'voicePause',_0x3f0a('0x6a')],'raw':!![]}]})[_0x3f0a('0x2a')](function(_0x37c8e5){if(_0x37c8e5){var _0x36b5c5=_['flatMap'](_0x37c8e5,function(_0x113525){var _0x5a23b3=_0x113525[_0x3f0a('0x2c')]({'plain':!![]});return _0x5a23b3[_0x3f0a('0x6b')];});return db[_0x3f0a('0x32')]['find']({'where':{'id':_0x45de3d[_0x3f0a('0x4c')]['id']}})['then'](function(_0x24f9d9){return db[_0x3f0a('0x6c')][_0x3f0a('0x6d')](function(_0x4d846e){return _0x24f9d9[_0x3f0a('0x68')](_0x2c38e3,{'transaction':_0x4d846e})['then'](function(){return BPromise[_0x3f0a('0x6e')](_0x36b5c5,function(_0x38f1fb){return db['UserMailQueue'][_0x3f0a('0x6f')]({'where':{'UserId':_0x38f1fb['id'],'MailQueueId':_0x45de3d[_0x3f0a('0x4c')]['id']},'transaction':_0x4d846e});});})[_0x3f0a('0x2a')](function(){_0x36b5c5[_0x3f0a('0x70')](function(_0x34c20c){socket[_0x3f0a('0x71')](_0x3f0a('0x72'),{'UserId':_0x34c20c['id'],'MailQueueId':_0x24f9d9['id']});});});});});}})[_0x3f0a('0x2a')](respondWithStatusCode(_0x1a7f55,null))['catch'](handleError(_0x1a7f55,null));};exports[_0x3f0a('0x73')]=function(_0x40a612,_0x4a14e7,_0x1fea16){return db[_0x3f0a('0x66')][_0x3f0a('0x49')]({'where':{'id':_0x40a612[_0x3f0a('0x38')][_0x3f0a('0x74')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x3f0a('0x6b'),'attributes':['id'],'raw':!![]}]})[_0x3f0a('0x2a')](handleEntityNotFound(_0x4a14e7,null))[_0x3f0a('0x2a')](function(_0x26d695){var _0x24f9b0=_[_0x3f0a('0x37')](_0x26d695,'id');var _0x5b88f1=[];var _0x4e12b8=[];var _0x14cb9e=squel[_0x3f0a('0x75')]();_0x14cb9e[_0x3f0a('0x76')](_0x3f0a('0x77'))[_0x3f0a('0x78')](_0x3f0a('0x79'),'tq')['join']('user_has_teams','ut',_0x3f0a('0x7a'))['where']('MailQueueId\x20=\x20?',_0x40a612[_0x3f0a('0x4c')]['id']);for(var _0xa60c8f=0x0;_0xa60c8f<_0x26d695[_0x3f0a('0x67')];_0xa60c8f+=0x1){let _0x53ed91=_0x26d695[_0xa60c8f];for(var _0x44ca66=0x0;_0x44ca66<_0x53ed91[_0x3f0a('0x6b')][_0x3f0a('0x67')];_0x44ca66+=0x1){let _0x40853e=_0x53ed91[_0x3f0a('0x6b')][_0x44ca66];var _0xa3a4f0=_0x14cb9e[_0x3f0a('0x7b')]();_0xa3a4f0[_0x3f0a('0x45')](_0x3f0a('0x7c'),_0x40853e['id']);_0x4e12b8[_0x3f0a('0x7d')](db['sequelize'][_0x3f0a('0x38')](_0xa3a4f0[_0x3f0a('0x7e')](),{'type':db['sequelize'][_0x3f0a('0x7f')][_0x3f0a('0x80')]})['then'](function(_0x2a39b7){if(_0x2a39b7[_0x3f0a('0x67')]===0x1){return _0x40853e['id'];}else{var _0x523d12=_[_0x3f0a('0x81')](_[_0x3f0a('0x37')](_0x2a39b7,_0x3f0a('0x82')),function(_0x172c0a){return _[_0x3f0a('0x83')](_0x24f9b0,_0x172c0a);});if(_0x523d12){return _0x40853e['id'];}}}));}}return BPromise[_0x3f0a('0x84')](_0x4e12b8)['then'](function(_0x480045){_0x5b88f1=_(_0x5b88f1)[_0x3f0a('0x85')](_0x480045)[_0x3f0a('0x86')]()[_0x3f0a('0x87')]();return db[_0x3f0a('0x32')][_0x3f0a('0x4d')]({'where':{'id':_0x40a612['params']['id']}})[_0x3f0a('0x2a')](function(_0x3afc66){return db[_0x3f0a('0x6c')][_0x3f0a('0x6d')](function(_0x410c4e){return _0x3afc66['removeTeams'](_0x40a612[_0x3f0a('0x38')][_0x3f0a('0x74')],{'transaction':_0x410c4e})[_0x3f0a('0x2a')](function(){if(!_['isEmpty'](_0x5b88f1)){return _0x3afc66[_0x3f0a('0x88')](_0x5b88f1,{'transaction':_0x410c4e});}})[_0x3f0a('0x2a')](function(){_0x5b88f1[_0x3f0a('0x70')](function(_0x219ee3){socket['emit'](_0x3f0a('0x89'),{'UserId':_0x219ee3,'MailQueueId':_0x3afc66['id']});});});});});});})[_0x3f0a('0x2a')](respondWithStatusCode(_0x4a14e7,null))[_0x3f0a('0x4a')](handleError(_0x4a14e7,null));};exports[_0x3f0a('0x8a')]=function(_0x2029e5,_0x58fdb8,_0x278d53){return db[_0x3f0a('0x32')][_0x3f0a('0x4d')]({'where':{'id':_0x2029e5[_0x3f0a('0x4c')]['id']}})['then'](handleEntityNotFound(_0x58fdb8,null))[_0x3f0a('0x2a')](function(_0x4e6260){if(_0x4e6260){return _0x4e6260[_0x3f0a('0x8a')](_0x2029e5[_0x3f0a('0x4f')][_0x3f0a('0x74')],_[_0x3f0a('0x8b')](_0x2029e5['body'],[_0x3f0a('0x74'),'id'])||{})[_0x3f0a('0x8c')](function(_0x3ac9e1){for(var _0x156295=0x0;_0x156295<_0x2029e5[_0x3f0a('0x4f')]['ids'][_0x3f0a('0x67')];_0x156295+=0x1){socket[_0x3f0a('0x71')](_0x3f0a('0x72'),{'UserId':Number(_0x2029e5['body']['ids'][_0x156295]),'MailQueueId':Number(_0x2029e5[_0x3f0a('0x4c')]['id'])});}return _0x3ac9e1;});}})[_0x3f0a('0x2a')](respondWithResult(_0x58fdb8,null))['catch'](handleError(_0x58fdb8,null));};exports['removeAgents']=function(_0x1c0d2a,_0x8cee91,_0x47df4e){return db[_0x3f0a('0x32')][_0x3f0a('0x4d')]({'where':{'id':_0x1c0d2a[_0x3f0a('0x4c')]['id']}})[_0x3f0a('0x2a')](handleEntityNotFound(_0x8cee91,null))[_0x3f0a('0x2a')](function(_0x304315){if(_0x304315){return _0x304315[_0x3f0a('0x88')](_0x1c0d2a[_0x3f0a('0x38')][_0x3f0a('0x74')])[_0x3f0a('0x2a')](function(){if(_[_0x3f0a('0x8d')](_0x1c0d2a[_0x3f0a('0x38')][_0x3f0a('0x74')])){for(var _0x1085d3=0x0;_0x1085d3<_0x1c0d2a['query']['ids'][_0x3f0a('0x67')];_0x1085d3+=0x1){socket[_0x3f0a('0x71')](_0x3f0a('0x89'),{'UserId':Number(_0x1c0d2a[_0x3f0a('0x38')][_0x3f0a('0x74')][_0x1085d3]),'MailQueueId':Number(_0x1c0d2a['params']['id'])});}}else{socket['emit'](_0x3f0a('0x89'),{'UserId':Number(_0x1c0d2a['query'][_0x3f0a('0x74')]),'MailQueueId':Number(_0x1c0d2a[_0x3f0a('0x4c')]['id'])});}});}})['then'](respondWithStatusCode(_0x8cee91,null))['catch'](handleError(_0x8cee91,null));};exports[_0x3f0a('0x8e')]=function(_0x1dd367,_0x3f2199,_0x575107){var _0xef1e21={};var _0x1bb06d={};var _0x2e76e0;var _0x7a1855;return db[_0x3f0a('0x32')][_0x3f0a('0x57')]({'where':{'id':_0x1dd367['params']['id']}})['then'](handleEntityNotFound(_0x3f2199,null))[_0x3f0a('0x2a')](function(_0x145c03){if(_0x145c03){_0x2e76e0=_0x145c03;_0x1bb06d[_0x3f0a('0x36')]=_[_0x3f0a('0x39')](db[_0x3f0a('0x5c')]['rawAttributes']);_0x1bb06d[_0x3f0a('0x38')]=_[_0x3f0a('0x39')](_0x1dd367[_0x3f0a('0x38')]);_0x1bb06d[_0x3f0a('0x3a')]=_['intersection'](_0x1bb06d[_0x3f0a('0x36')],_0x1bb06d[_0x3f0a('0x38')]);_0xef1e21[_0x3f0a('0x3c')]=_[_0x3f0a('0x3b')](_0x1bb06d['model'],qs['fields'](_0x1dd367['query'][_0x3f0a('0x3d')]));_0xef1e21[_0x3f0a('0x3c')]=_0xef1e21[_0x3f0a('0x3c')][_0x3f0a('0x67')]?_0xef1e21[_0x3f0a('0x3c')]:_0x1bb06d['model'];_0xef1e21[_0x3f0a('0x59')]=qs[_0x3f0a('0x40')](_0x1dd367[_0x3f0a('0x38')][_0x3f0a('0x40')]);_0xef1e21[_0x3f0a('0x45')]=qs[_0x3f0a('0x3a')](_['pick'](_0x1dd367['query'],_0x1bb06d[_0x3f0a('0x3a')]));if(_0x1dd367[_0x3f0a('0x38')][_0x3f0a('0x5b')]){_0xef1e21[_0x3f0a('0x45')]=_['merge'](_0xef1e21[_0x3f0a('0x45')],{'$or':_[_0x3f0a('0x37')](_0xef1e21[_0x3f0a('0x3c')],function(_0x2dde90){var _0x50d9e8={};_0x50d9e8[_0x2dde90]={'$like':'%'+_0x1dd367[_0x3f0a('0x38')][_0x3f0a('0x5b')]+'%'};return _0x50d9e8;})});}_0xef1e21=_[_0x3f0a('0x42')]({},_0xef1e21,_0x1dd367[_0x3f0a('0x44')]);return _0x2e76e0[_0x3f0a('0x8e')](_0xef1e21);}})[_0x3f0a('0x2a')](function(_0x48a1bf){if(_0x48a1bf){_0x7a1855=_0x48a1bf[_0x3f0a('0x67')];if(!_0x1dd367[_0x3f0a('0x38')][_0x3f0a('0x3e')]('nolimit')){_0xef1e21[_0x3f0a('0x25')]=qs[_0x3f0a('0x25')](_0x1dd367['query'][_0x3f0a('0x25')]);_0xef1e21[_0x3f0a('0x23')]=qs[_0x3f0a('0x23')](_0x1dd367['query'][_0x3f0a('0x23')]);}return _0x2e76e0[_0x3f0a('0x8e')](_0xef1e21);}})[_0x3f0a('0x2a')](function(_0x37398a){if(_0x37398a){return _0x37398a?{'count':_0x7a1855,'rows':_0x37398a}:null;}})[_0x3f0a('0x2a')](respondWithResult(_0x3f2199,null))[_0x3f0a('0x4a')](handleError(_0x3f2199,null));};
\ No newline at end of file