Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 6a84707..9e7e4be 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf165=['TeamId','union','compact','value','isEmpty','removeAgents','addAgents','omit','userMailQueue:remove','getAgents','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./mailQueue.socket','sendStatus','status','end','offset','limit','undefined','count','Content-Range','json','apply','reject','save','update','then','destroy','get','error','stack','name','index','MailQueue','fieldName','type','key','model','map','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','rows','catch','rawAttributes','include','create','body','user','role','MailQueues','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','params','describe','getMembers','findOne','UserMailQueue','findAll','findAndCountAll','UserId','agent','updatedAt','createdAt','%s/%s','SIP','mailPause','getTeams','order','addTeams','ids','Team','Agents','voicePause','interface','flatMap','sequelize','transaction','each','forEach','emit','userMailQueue:save','removeTeams','User','tq.TeamId','from','team_has_mail_queues','join','ut.TeamId\x20=\x20tq.TeamId','clone','push','toString','QueryTypes','SELECT','every'];(function(_0x3ccc6c,_0x5d1fc8){var _0x1d851d=function(_0x435940){while(--_0x435940){_0x3ccc6c['push'](_0x3ccc6c['shift']());}};_0x1d851d(++_0x5d1fc8);}(_0xf165,0x11e));var _0x5f16=function(_0x352b52,_0x321417){_0x352b52=_0x352b52-0x0;var _0x1e3b5b=_0xf165[_0x352b52];return _0x1e3b5b;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x5f16('0x0'));var jsonpatch=require(_0x5f16('0x1'));var rp=require(_0x5f16('0x2'));var moment=require(_0x5f16('0x3'));var BPromise=require(_0x5f16('0x4'));var Mustache=require('mustache');var util=require(_0x5f16('0x5'));var path=require('path');var sox=require(_0x5f16('0x6'));var csv=require(_0x5f16('0x7'));var ejs=require(_0x5f16('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x5f16('0x9'));var squel=require(_0x5f16('0xa'));var crypto=require(_0x5f16('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x5f16('0xc'));var toCsv=require('to-csv');var querystring=require(_0x5f16('0xd'));var Papa=require(_0x5f16('0xe'));var Redis=require(_0x5f16('0xf'));var authService=require(_0x5f16('0x10'));var qs=require(_0x5f16('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5f16('0x12'));var logger=require(_0x5f16('0x13'))(_0x5f16('0x14'));var utils=require(_0x5f16('0x15'));var config=require(_0x5f16('0x16'));var licenseUtil=require(_0x5f16('0x17'));var db=require(_0x5f16('0x18'))['db'];config[_0x5f16('0x19')]=_[_0x5f16('0x1a')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x5f16('0x1b'))(new Redis(config[_0x5f16('0x19')]));require(_0x5f16('0x1c'))['register'](socket);function respondWithStatusCode(_0xfce46e,_0x495230){_0x495230=_0x495230||0xcc;return function(_0x609e52){if(_0x609e52){return _0xfce46e[_0x5f16('0x1d')](_0x495230);}return _0xfce46e[_0x5f16('0x1e')](_0x495230)[_0x5f16('0x1f')]();};}function respondWithResult(_0x3939f8,_0x527a0f){_0x527a0f=_0x527a0f||0xc8;return function(_0x159d9c){if(_0x159d9c){return _0x3939f8[_0x5f16('0x1e')](_0x527a0f)['json'](_0x159d9c);}};}function respondWithFilteredResult(_0x3c466f,_0x2c26f6){return function(_0x46d029){if(_0x46d029){var _0x30299b=typeof _0x2c26f6[_0x5f16('0x20')]==='undefined'&&typeof _0x2c26f6[_0x5f16('0x21')]===_0x5f16('0x22');var _0x2935f9=_0x46d029[_0x5f16('0x23')];var _0x2e4d78=_0x30299b?0x0:_0x2c26f6['offset'];var _0x36e4ad=_0x30299b?_0x46d029[_0x5f16('0x23')]:_0x2c26f6[_0x5f16('0x20')]+_0x2c26f6['limit'];var _0x9b8053;if(_0x36e4ad>=_0x2935f9){_0x36e4ad=_0x2935f9;_0x9b8053=0xc8;}else{_0x9b8053=0xce;}_0x3c466f[_0x5f16('0x1e')](_0x9b8053);return _0x3c466f['set'](_0x5f16('0x24'),_0x2e4d78+'-'+_0x36e4ad+'/'+_0x2935f9)[_0x5f16('0x25')](_0x46d029);}return null;};}function patchUpdates(_0x49f91a){return function(_0x344d02){try{jsonpatch[_0x5f16('0x26')](_0x344d02,_0x49f91a,!![]);}catch(_0xe5a540){return BPromise[_0x5f16('0x27')](_0xe5a540);}return _0x344d02[_0x5f16('0x28')]();};}function saveUpdates(_0x240220,_0x218c1f){return function(_0x4850c0){if(_0x4850c0){return _0x4850c0[_0x5f16('0x29')](_0x240220)[_0x5f16('0x2a')](function(_0x2dbc26){return _0x2dbc26;});}return null;};}function removeEntity(_0x50f517,_0x2c866b){return function(_0x5aed0d){if(_0x5aed0d){return _0x5aed0d[_0x5f16('0x2b')]()['then'](function(){var _0x565f7b=_0x5aed0d[_0x5f16('0x2c')]({'plain':!![]});var _0x4f4d80='MailQueues';return db['UserProfileResource'][_0x5f16('0x2b')]({'where':{'type':_0x4f4d80,'resourceId':_0x565f7b['id']}})[_0x5f16('0x2a')](function(){return _0x5aed0d;});})['then'](function(){_0x50f517['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x5082a4,_0x2e47cb){return function(_0x431597){if(!_0x431597){_0x5082a4['sendStatus'](0x194);}return _0x431597;};}function handleError(_0x23b911,_0x2e9905){_0x2e9905=_0x2e9905||0x1f4;return function(_0x2f7037){logger[_0x5f16('0x2d')](_0x2f7037[_0x5f16('0x2e')]);if(_0x2f7037[_0x5f16('0x2f')]){delete _0x2f7037[_0x5f16('0x2f')];}_0x23b911['status'](_0x2e9905)['send'](_0x2f7037);};}exports[_0x5f16('0x30')]=function(_0x5e3c6c,_0x2ef9e3){var _0x504e99={},_0x1fdebd={},_0x3952b4={'count':0x0,'rows':[]};var _0x5fd9f3=_['map'](db[_0x5f16('0x31')]['rawAttributes'],function(_0x7aaff5){return{'name':_0x7aaff5[_0x5f16('0x32')],'type':_0x7aaff5[_0x5f16('0x33')][_0x5f16('0x34')]};});_0x1fdebd[_0x5f16('0x35')]=_[_0x5f16('0x36')](_0x5fd9f3,_0x5f16('0x2f'));_0x1fdebd[_0x5f16('0x37')]=_[_0x5f16('0x38')](_0x5e3c6c[_0x5f16('0x37')]);_0x1fdebd['filters']=_['intersection'](_0x1fdebd[_0x5f16('0x35')],_0x1fdebd[_0x5f16('0x37')]);_0x504e99[_0x5f16('0x39')]=_[_0x5f16('0x3a')](_0x1fdebd[_0x5f16('0x35')],qs[_0x5f16('0x3b')](_0x5e3c6c[_0x5f16('0x37')][_0x5f16('0x3b')]));_0x504e99['attributes']=_0x504e99[_0x5f16('0x39')][_0x5f16('0x3c')]?_0x504e99[_0x5f16('0x39')]:_0x1fdebd[_0x5f16('0x35')];if(!_0x5e3c6c[_0x5f16('0x37')][_0x5f16('0x3d')](_0x5f16('0x3e'))){_0x504e99[_0x5f16('0x21')]=qs[_0x5f16('0x21')](_0x5e3c6c[_0x5f16('0x37')]['limit']);_0x504e99[_0x5f16('0x20')]=qs[_0x5f16('0x20')](_0x5e3c6c[_0x5f16('0x37')][_0x5f16('0x20')]);}_0x504e99['order']=qs[_0x5f16('0x3f')](_0x5e3c6c[_0x5f16('0x37')]['sort']);_0x504e99[_0x5f16('0x40')]=qs[_0x5f16('0x41')](_[_0x5f16('0x42')](_0x5e3c6c[_0x5f16('0x37')],_0x1fdebd['filters']),_0x5fd9f3);if(_0x5e3c6c['query'][_0x5f16('0x43')]){_0x504e99[_0x5f16('0x40')]=_[_0x5f16('0x44')](_0x504e99[_0x5f16('0x40')],{'$or':_[_0x5f16('0x36')](_0x5fd9f3,function(_0x12c071){if(_0x12c071[_0x5f16('0x33')]!==_0x5f16('0x45')){var _0xd63c70={};_0xd63c70[_0x12c071[_0x5f16('0x2f')]]={'$like':'%'+_0x5e3c6c['query']['filter']+'%'};return _0xd63c70;}})});}_0x504e99=_[_0x5f16('0x44')]({},_0x504e99,_0x5e3c6c[_0x5f16('0x46')]);var _0xc167f7={'where':_0x504e99[_0x5f16('0x40')]};return db[_0x5f16('0x31')][_0x5f16('0x23')](_0xc167f7)[_0x5f16('0x2a')](function(_0x22be5a){_0x3952b4[_0x5f16('0x23')]=_0x22be5a;if(_0x5e3c6c[_0x5f16('0x37')][_0x5f16('0x47')]){_0x504e99['include']=[{'all':!![]}];}return db['MailQueue']['findAll'](_0x504e99);})[_0x5f16('0x2a')](function(_0x1dc568){_0x3952b4[_0x5f16('0x48')]=_0x1dc568;return _0x3952b4;})[_0x5f16('0x2a')](respondWithFilteredResult(_0x2ef9e3,_0x504e99))[_0x5f16('0x49')](handleError(_0x2ef9e3,null));};exports['show']=function(_0x45e09a,_0x5e5dc7){var _0x114ad4={'raw':!![],'where':{'id':_0x45e09a['params']['id']}},_0xcb1438={};_0xcb1438[_0x5f16('0x35')]=_[_0x5f16('0x38')](db[_0x5f16('0x31')][_0x5f16('0x4a')]);_0xcb1438['query']=_[_0x5f16('0x38')](_0x45e09a[_0x5f16('0x37')]);_0xcb1438[_0x5f16('0x41')]=_[_0x5f16('0x3a')](_0xcb1438[_0x5f16('0x35')],_0xcb1438[_0x5f16('0x37')]);_0x114ad4[_0x5f16('0x39')]=_[_0x5f16('0x3a')](_0xcb1438[_0x5f16('0x35')],qs[_0x5f16('0x3b')](_0x45e09a[_0x5f16('0x37')]['fields']));_0x114ad4['attributes']=_0x114ad4[_0x5f16('0x39')][_0x5f16('0x3c')]?_0x114ad4[_0x5f16('0x39')]:_0xcb1438[_0x5f16('0x35')];if(_0x45e09a[_0x5f16('0x37')][_0x5f16('0x47')]){_0x114ad4[_0x5f16('0x4b')]=[{'all':!![]}];}_0x114ad4=_[_0x5f16('0x44')]({},_0x114ad4,_0x45e09a[_0x5f16('0x46')]);return db[_0x5f16('0x31')]['find'](_0x114ad4)['then'](handleEntityNotFound(_0x5e5dc7,null))[_0x5f16('0x2a')](respondWithResult(_0x5e5dc7,null))[_0x5f16('0x49')](handleError(_0x5e5dc7,null));};exports['create']=function(_0x59d4fc,_0x58ba59){return db['MailQueue'][_0x5f16('0x4c')](_0x59d4fc[_0x5f16('0x4d')],{})[_0x5f16('0x2a')](function(_0x1b9b25){var _0x142e75=_0x59d4fc[_0x5f16('0x4e')][_0x5f16('0x2c')]({'plain':!![]});if(!_0x142e75)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x142e75[_0x5f16('0x4f')]===_0x5f16('0x4e')){var _0xc2ea59=_0x1b9b25['get']({'plain':!![]});var _0x140326=_0x5f16('0x50');return db[_0x5f16('0x51')]['find']({'where':{'name':_0x140326,'userProfileId':_0x142e75['userProfileId']},'raw':!![]})[_0x5f16('0x2a')](function(_0x1f3f3b){if(_0x1f3f3b&&_0x1f3f3b[_0x5f16('0x52')]===0x0){return db[_0x5f16('0x53')][_0x5f16('0x4c')]({'name':_0xc2ea59[_0x5f16('0x2f')],'resourceId':_0xc2ea59['id'],'type':_0x1f3f3b['name'],'sectionId':_0x1f3f3b['id']},{})[_0x5f16('0x2a')](function(){return _0x1b9b25;});}else{return _0x1b9b25;}})[_0x5f16('0x49')](function(_0x13f1c7){logger[_0x5f16('0x2d')](_0x5f16('0x54'),_0x13f1c7);throw _0x13f1c7;});}return _0x1b9b25;})[_0x5f16('0x2a')](respondWithResult(_0x58ba59,0xc9))[_0x5f16('0x49')](handleError(_0x58ba59,null));};exports['update']=function(_0x54b24a,_0x1c8764){if(_0x54b24a[_0x5f16('0x4d')]['id']){delete _0x54b24a[_0x5f16('0x4d')]['id'];}return db[_0x5f16('0x31')][_0x5f16('0x55')]({'where':{'id':_0x54b24a[_0x5f16('0x56')]['id']}})[_0x5f16('0x2a')](handleEntityNotFound(_0x1c8764,null))[_0x5f16('0x2a')](saveUpdates(_0x54b24a[_0x5f16('0x4d')],null))[_0x5f16('0x2a')](respondWithResult(_0x1c8764,null))[_0x5f16('0x49')](handleError(_0x1c8764,null));};exports[_0x5f16('0x2b')]=function(_0x4d1975,_0x534b5f){return db[_0x5f16('0x31')][_0x5f16('0x55')]({'where':{'id':_0x4d1975[_0x5f16('0x56')]['id']}})[_0x5f16('0x2a')](handleEntityNotFound(_0x534b5f,null))[_0x5f16('0x2a')](removeEntity(_0x534b5f,null))[_0x5f16('0x49')](handleError(_0x534b5f,null));};exports[_0x5f16('0x57')]=function(_0x3c89f3,_0x2c3492){return db[_0x5f16('0x31')]['describe']()['then'](respondWithResult(_0x2c3492,null))['catch'](handleError(_0x2c3492,null));};exports[_0x5f16('0x58')]=function(_0x45bf6c,_0x51a365,_0x56550d){var _0x1eb42f={'raw':!![],'where':{}},_0x1351c9={},_0x3918b6;return db[_0x5f16('0x31')][_0x5f16('0x59')]({'where':{'id':_0x45bf6c[_0x5f16('0x56')]['id']}})[_0x5f16('0x2a')](handleEntityNotFound(_0x51a365,null))[_0x5f16('0x2a')](function(_0x9d234b){if(_0x9d234b){_0x3918b6=_0x9d234b[_0x5f16('0x2c')]({'plain':!![]});_0x1351c9[_0x5f16('0x35')]=_[_0x5f16('0x38')](db[_0x5f16('0x5a')][_0x5f16('0x4a')]);_0x1351c9[_0x5f16('0x37')]=_[_0x5f16('0x38')](_0x45bf6c[_0x5f16('0x37')]);_0x1351c9[_0x5f16('0x41')]=_['intersection'](_0x1351c9[_0x5f16('0x35')],_0x1351c9[_0x5f16('0x37')]);_0x1eb42f[_0x5f16('0x39')]=_['intersection'](_0x1351c9[_0x5f16('0x35')],qs['fields'](_0x45bf6c[_0x5f16('0x37')][_0x5f16('0x3b')]));_0x1eb42f[_0x5f16('0x39')]=_0x1eb42f['attributes']['length']?_0x1eb42f[_0x5f16('0x39')]:_0x1351c9[_0x5f16('0x35')];if(!_0x45bf6c[_0x5f16('0x37')][_0x5f16('0x3d')](_0x5f16('0x3e'))){_0x1eb42f[_0x5f16('0x21')]=qs['limit'](_0x45bf6c['query'][_0x5f16('0x21')]);_0x1eb42f[_0x5f16('0x20')]=qs[_0x5f16('0x20')](_0x45bf6c[_0x5f16('0x37')][_0x5f16('0x20')]);}_0x1eb42f['order']=qs['sort'](_0x45bf6c[_0x5f16('0x37')]['sort']);_0x1eb42f[_0x5f16('0x40')]=qs[_0x5f16('0x41')](_['pick'](_0x45bf6c[_0x5f16('0x37')],_0x1351c9[_0x5f16('0x41')]));_0x1eb42f['where']['MailQueueId']=_0x9d234b['id'];if(_0x45bf6c[_0x5f16('0x37')]['filter']){_0x1eb42f['where']=_[_0x5f16('0x44')](_0x1eb42f['where'],{'$or':_[_0x5f16('0x36')](_0x1eb42f[_0x5f16('0x39')],function(_0x304a4b){var _0x5d5ddb={};_0x5d5ddb[_0x304a4b]={'$like':'%'+_0x45bf6c[_0x5f16('0x37')][_0x5f16('0x43')]+'%'};return _0x5d5ddb;})});}_0x1eb42f=_[_0x5f16('0x44')]({},_0x1eb42f,_0x45bf6c['options']);return db[_0x5f16('0x5a')][_0x5f16('0x5b')](_0x1eb42f);}})[_0x5f16('0x2a')](function(_0x4aa23f){if(_0x4aa23f){return db['User'][_0x5f16('0x5c')]({'where':{'id':_[_0x5f16('0x36')](_0x4aa23f,_0x5f16('0x5d')),'role':_0x5f16('0x5e')},'attributes':['id',_0x5f16('0x2f'),'mailPause',_0x5f16('0x5f'),_0x5f16('0x60')]});}})[_0x5f16('0x2a')](function(_0x43a933){if(_0x43a933){return{'count':_0x43a933[_0x5f16('0x23')],'rows':_['map'](_0x43a933[_0x5f16('0x48')],function(_0x16f107){return{'membername':_0x16f107[_0x5f16('0x2f')],'UserId':_0x16f107['id'],'queue_name':_0x3918b6[_0x5f16('0x2f')],'MailQueueId':_0x3918b6['id'],'interface':util['format'](_0x5f16('0x61'),_0x5f16('0x62'),_0x16f107[_0x5f16('0x2f')]),'penalty':0x0,'paused':_0x16f107[_0x5f16('0x63')],'createdAt':_0x16f107['createdAt'],'updatedAt':_0x16f107[_0x5f16('0x5f')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x5f16('0x2a')](respondWithFilteredResult(_0x51a365,_0x1eb42f))[_0x5f16('0x49')](handleError(_0x51a365,null));};exports[_0x5f16('0x64')]=function(_0x26a4e7,_0x383297,_0x59504f){var _0x29666a={};var _0x23f9ca={};var _0x216181;var _0x345104;return db[_0x5f16('0x31')][_0x5f16('0x59')]({'where':{'id':_0x26a4e7[_0x5f16('0x56')]['id']}})[_0x5f16('0x2a')](handleEntityNotFound(_0x383297,null))[_0x5f16('0x2a')](function(_0x361880){if(_0x361880){_0x216181=_0x361880;_0x23f9ca[_0x5f16('0x35')]=_['keys'](db['Team'][_0x5f16('0x4a')]);_0x23f9ca['query']=_[_0x5f16('0x38')](_0x26a4e7[_0x5f16('0x37')]);_0x23f9ca[_0x5f16('0x41')]=_[_0x5f16('0x3a')](_0x23f9ca[_0x5f16('0x35')],_0x23f9ca[_0x5f16('0x37')]);_0x29666a['attributes']=_[_0x5f16('0x3a')](_0x23f9ca[_0x5f16('0x35')],qs[_0x5f16('0x3b')](_0x26a4e7[_0x5f16('0x37')][_0x5f16('0x3b')]));_0x29666a['attributes']=_0x29666a['attributes'][_0x5f16('0x3c')]?_0x29666a[_0x5f16('0x39')]:_0x23f9ca[_0x5f16('0x35')];_0x29666a[_0x5f16('0x65')]=qs[_0x5f16('0x3f')](_0x26a4e7['query']['sort']);_0x29666a[_0x5f16('0x40')]=qs['filters'](_[_0x5f16('0x42')](_0x26a4e7['query'],_0x23f9ca[_0x5f16('0x41')]));if(_0x26a4e7['query']['filter']){_0x29666a[_0x5f16('0x40')]=_[_0x5f16('0x44')](_0x29666a[_0x5f16('0x40')],{'$or':_[_0x5f16('0x36')](_0x29666a[_0x5f16('0x39')],function(_0x18b942){var _0x151462={};_0x151462[_0x18b942]={'$like':'%'+_0x26a4e7['query']['filter']+'%'};return _0x151462;})});}_0x29666a=_[_0x5f16('0x44')]({},_0x29666a,_0x26a4e7[_0x5f16('0x46')]);return _0x216181['getTeams'](_0x29666a);}})['then'](function(_0x4b2572){if(_0x4b2572){_0x345104=_0x4b2572[_0x5f16('0x3c')];if(!_0x26a4e7[_0x5f16('0x37')]['hasOwnProperty'](_0x5f16('0x3e'))){_0x29666a['limit']=qs[_0x5f16('0x21')](_0x26a4e7[_0x5f16('0x37')][_0x5f16('0x21')]);_0x29666a[_0x5f16('0x20')]=qs[_0x5f16('0x20')](_0x26a4e7[_0x5f16('0x37')][_0x5f16('0x20')]);}return _0x216181[_0x5f16('0x64')](_0x29666a);}})[_0x5f16('0x2a')](function(_0x16d3ab){if(_0x16d3ab){return _0x16d3ab?{'count':_0x345104,'rows':_0x16d3ab}:null;}})[_0x5f16('0x2a')](respondWithResult(_0x383297,null))[_0x5f16('0x49')](handleError(_0x383297,null));};exports[_0x5f16('0x66')]=function(_0xc97096,_0x5a9cfc,_0x49f446){var _0x33d8c8=_0xc97096[_0x5f16('0x4d')][_0x5f16('0x67')];return db[_0x5f16('0x68')][_0x5f16('0x5b')]({'where':{'id':_0x33d8c8},'attributes':['id'],'include':[{'model':db['User'],'as':_0x5f16('0x69'),'attributes':['id',_0x5f16('0x2f'),'online',_0x5f16('0x6a'),_0x5f16('0x6b')],'raw':!![]}]})['then'](function(_0x4df23a){if(_0x4df23a){var _0x113aeb=_[_0x5f16('0x6c')](_0x4df23a,function(_0x5c4566){var _0x1d8e5e=_0x5c4566['get']({'plain':!![]});return _0x1d8e5e[_0x5f16('0x69')];});return db[_0x5f16('0x31')][_0x5f16('0x55')]({'where':{'id':_0xc97096['params']['id']}})['then'](function(_0x3a2d90){return db[_0x5f16('0x6d')][_0x5f16('0x6e')](function(_0x334aee){return _0x3a2d90[_0x5f16('0x66')](_0x33d8c8,{'transaction':_0x334aee})[_0x5f16('0x2a')](function(){return BPromise[_0x5f16('0x6f')](_0x113aeb,function(_0x3f23c1){return db['UserMailQueue']['findOrCreate']({'where':{'UserId':_0x3f23c1['id'],'MailQueueId':_0xc97096['params']['id']},'transaction':_0x334aee});});})[_0x5f16('0x2a')](function(){_0x113aeb[_0x5f16('0x70')](function(_0x4f776d){socket[_0x5f16('0x71')](_0x5f16('0x72'),{'UserId':_0x4f776d['id'],'MailQueueId':_0x3a2d90['id']});});});});});}})[_0x5f16('0x2a')](respondWithStatusCode(_0x5a9cfc,null))[_0x5f16('0x49')](handleError(_0x5a9cfc,null));};exports[_0x5f16('0x73')]=function(_0x54bc52,_0x59919c,_0x4e19cf){return db[_0x5f16('0x68')][_0x5f16('0x5b')]({'where':{'id':_0x54bc52[_0x5f16('0x37')][_0x5f16('0x67')]},'attributes':['id'],'include':[{'model':db[_0x5f16('0x74')],'as':_0x5f16('0x69'),'attributes':['id'],'raw':!![]}]})[_0x5f16('0x2a')](handleEntityNotFound(_0x59919c,null))[_0x5f16('0x2a')](function(_0x4b24ca){var _0x5b94ba=_[_0x5f16('0x36')](_0x4b24ca,'id');var _0x1c8584=[];var _0x521a3b=[];var _0x17cf15=squel['select']();_0x17cf15['field'](_0x5f16('0x75'))[_0x5f16('0x76')](_0x5f16('0x77'),'tq')[_0x5f16('0x78')]('user_has_teams','ut',_0x5f16('0x79'))[_0x5f16('0x40')]('MailQueueId\x20=\x20?',_0x54bc52[_0x5f16('0x56')]['id']);for(var _0x324fcb=0x0;_0x324fcb<_0x4b24ca['length'];_0x324fcb+=0x1){let _0x28d38d=_0x4b24ca[_0x324fcb];for(var _0x55ac0d=0x0;_0x55ac0d<_0x28d38d[_0x5f16('0x69')][_0x5f16('0x3c')];_0x55ac0d+=0x1){let _0x2d5f86=_0x28d38d[_0x5f16('0x69')][_0x55ac0d];var _0x37347d=_0x17cf15[_0x5f16('0x7a')]();_0x37347d[_0x5f16('0x40')]('ut.UserId\x20=\x20?',_0x2d5f86['id']);_0x521a3b[_0x5f16('0x7b')](db[_0x5f16('0x6d')]['query'](_0x37347d[_0x5f16('0x7c')](),{'type':db[_0x5f16('0x6d')][_0x5f16('0x7d')][_0x5f16('0x7e')]})[_0x5f16('0x2a')](function(_0x4c384c){if(_0x4c384c['length']===0x1){return _0x2d5f86['id'];}else{var _0x2644d3=_[_0x5f16('0x7f')](_[_0x5f16('0x36')](_0x4c384c,_0x5f16('0x80')),function(_0x48824a){return _['includes'](_0x5b94ba,_0x48824a);});if(_0x2644d3){return _0x2d5f86['id'];}}}));}}return BPromise['all'](_0x521a3b)[_0x5f16('0x2a')](function(_0x2ad4b2){_0x1c8584=_(_0x1c8584)[_0x5f16('0x81')](_0x2ad4b2)[_0x5f16('0x82')]()[_0x5f16('0x83')]();return db[_0x5f16('0x31')]['find']({'where':{'id':_0x54bc52[_0x5f16('0x56')]['id']}})[_0x5f16('0x2a')](function(_0x297c3d){return db[_0x5f16('0x6d')][_0x5f16('0x6e')](function(_0x419b2e){return _0x297c3d[_0x5f16('0x73')](_0x54bc52[_0x5f16('0x37')][_0x5f16('0x67')],{'transaction':_0x419b2e})[_0x5f16('0x2a')](function(){if(!_[_0x5f16('0x84')](_0x1c8584)){return _0x297c3d[_0x5f16('0x85')](_0x1c8584,{'transaction':_0x419b2e});}})[_0x5f16('0x2a')](function(){_0x1c8584['forEach'](function(_0x503ee9){socket[_0x5f16('0x71')]('userMailQueue:remove',{'UserId':_0x503ee9,'MailQueueId':_0x297c3d['id']});});});});});});})[_0x5f16('0x2a')](respondWithStatusCode(_0x59919c,null))[_0x5f16('0x49')](handleError(_0x59919c,null));};exports['addAgents']=function(_0x3e91a3,_0x305bbe,_0x5399e6){return db[_0x5f16('0x31')][_0x5f16('0x55')]({'where':{'id':_0x3e91a3[_0x5f16('0x56')]['id']}})[_0x5f16('0x2a')](handleEntityNotFound(_0x305bbe,null))[_0x5f16('0x2a')](function(_0x1e8a0d){if(_0x1e8a0d){return _0x1e8a0d[_0x5f16('0x86')](_0x3e91a3['body'][_0x5f16('0x67')],_[_0x5f16('0x87')](_0x3e91a3[_0x5f16('0x4d')],[_0x5f16('0x67'),'id'])||{})['spread'](function(_0xbffd00){for(var _0x2ff47a=0x0;_0x2ff47a<_0x3e91a3[_0x5f16('0x4d')]['ids'][_0x5f16('0x3c')];_0x2ff47a+=0x1){socket[_0x5f16('0x71')](_0x5f16('0x72'),{'UserId':Number(_0x3e91a3[_0x5f16('0x4d')][_0x5f16('0x67')][_0x2ff47a]),'MailQueueId':Number(_0x3e91a3[_0x5f16('0x56')]['id'])});}return _0xbffd00;});}})[_0x5f16('0x2a')](respondWithResult(_0x305bbe,null))[_0x5f16('0x49')](handleError(_0x305bbe,null));};exports[_0x5f16('0x85')]=function(_0x47f148,_0x169fab,_0x3cf4aa){return db[_0x5f16('0x31')]['find']({'where':{'id':_0x47f148[_0x5f16('0x56')]['id']}})[_0x5f16('0x2a')](handleEntityNotFound(_0x169fab,null))[_0x5f16('0x2a')](function(_0x2917ae){if(_0x2917ae){return _0x2917ae[_0x5f16('0x85')](_0x47f148['query'][_0x5f16('0x67')])[_0x5f16('0x2a')](function(){if(_['isArray'](_0x47f148[_0x5f16('0x37')]['ids'])){for(var _0x2105a8=0x0;_0x2105a8<_0x47f148[_0x5f16('0x37')][_0x5f16('0x67')]['length'];_0x2105a8+=0x1){socket[_0x5f16('0x71')]('userMailQueue:remove',{'UserId':Number(_0x47f148[_0x5f16('0x37')][_0x5f16('0x67')][_0x2105a8]),'MailQueueId':Number(_0x47f148[_0x5f16('0x56')]['id'])});}}else{socket[_0x5f16('0x71')](_0x5f16('0x88'),{'UserId':Number(_0x47f148[_0x5f16('0x37')][_0x5f16('0x67')]),'MailQueueId':Number(_0x47f148['params']['id'])});}});}})[_0x5f16('0x2a')](respondWithStatusCode(_0x169fab,null))[_0x5f16('0x49')](handleError(_0x169fab,null));};exports[_0x5f16('0x89')]=function(_0x33cf24,_0x5b2a00,_0x34ec01){var _0x343c02={};var _0x71a9fe={};var _0x57a656;var _0x412c0d;return db[_0x5f16('0x31')]['findOne']({'where':{'id':_0x33cf24[_0x5f16('0x56')]['id']}})['then'](handleEntityNotFound(_0x5b2a00,null))[_0x5f16('0x2a')](function(_0x3b8cac){if(_0x3b8cac){_0x57a656=_0x3b8cac;_0x71a9fe[_0x5f16('0x35')]=_[_0x5f16('0x38')](db['User'][_0x5f16('0x4a')]);_0x71a9fe[_0x5f16('0x37')]=_[_0x5f16('0x38')](_0x33cf24[_0x5f16('0x37')]);_0x71a9fe[_0x5f16('0x41')]=_[_0x5f16('0x3a')](_0x71a9fe[_0x5f16('0x35')],_0x71a9fe[_0x5f16('0x37')]);_0x343c02[_0x5f16('0x39')]=_[_0x5f16('0x3a')](_0x71a9fe[_0x5f16('0x35')],qs[_0x5f16('0x3b')](_0x33cf24[_0x5f16('0x37')][_0x5f16('0x3b')]));_0x343c02[_0x5f16('0x39')]=_0x343c02[_0x5f16('0x39')][_0x5f16('0x3c')]?_0x343c02['attributes']:_0x71a9fe['model'];_0x343c02[_0x5f16('0x65')]=qs[_0x5f16('0x3f')](_0x33cf24[_0x5f16('0x37')][_0x5f16('0x3f')]);_0x343c02[_0x5f16('0x40')]=qs[_0x5f16('0x41')](_['pick'](_0x33cf24['query'],_0x71a9fe[_0x5f16('0x41')]));if(_0x33cf24[_0x5f16('0x37')][_0x5f16('0x43')]){_0x343c02[_0x5f16('0x40')]=_[_0x5f16('0x44')](_0x343c02[_0x5f16('0x40')],{'$or':_[_0x5f16('0x36')](_0x343c02[_0x5f16('0x39')],function(_0x3c7ddb){var _0x325072={};_0x325072[_0x3c7ddb]={'$like':'%'+_0x33cf24[_0x5f16('0x37')][_0x5f16('0x43')]+'%'};return _0x325072;})});}_0x343c02=_[_0x5f16('0x44')]({},_0x343c02,_0x33cf24['options']);return _0x57a656[_0x5f16('0x89')](_0x343c02);}})[_0x5f16('0x2a')](function(_0x46c4d1){if(_0x46c4d1){_0x412c0d=_0x46c4d1[_0x5f16('0x3c')];if(!_0x33cf24[_0x5f16('0x37')]['hasOwnProperty'](_0x5f16('0x3e'))){_0x343c02[_0x5f16('0x21')]=qs[_0x5f16('0x21')](_0x33cf24[_0x5f16('0x37')][_0x5f16('0x21')]);_0x343c02[_0x5f16('0x20')]=qs[_0x5f16('0x20')](_0x33cf24[_0x5f16('0x37')][_0x5f16('0x20')]);}return _0x57a656[_0x5f16('0x89')](_0x343c02);}})[_0x5f16('0x2a')](function(_0x298bd3){if(_0x298bd3){return _0x298bd3?{'count':_0x412c0d,'rows':_0x298bd3}:null;}})['then'](respondWithResult(_0x5b2a00,null))['catch'](handleError(_0x5b2a00,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