Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 6a84707..ae8b151 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 _0x3a67=['../../components/parsers/qs','api','../../mysqldb','redis','localhost','socket.io-emitter','register','sendStatus','status','json','offset','limit','undefined','count','set','Content-Range','update','then','get','MailQueues','UserProfileResource','destroy','end','error','stack','name','map','MailQueue','rawAttributes','type','key','getOptions','include','query','findAll','rows','catch','show','params','model','intersection','attributes','fields','length','includeAll','merge','options','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','getMembers','findOne','keys','UserMailQueue','filters','nolimit','sort','where','pick','MailQueueId','filter','User','findAndCountAll','agent','mailPause','updatedAt','format','SIP','createdAt','Team','order','getTeams','addTeams','Agents','online','voicePause','interface','flatMap','sequelize','transaction','findOrCreate','forEach','emit','userMailQueue:save','removeTeams','ids','select','field','tq.TeamId','from','team_has_mail_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','push','toString','QueryTypes','every','TeamId','includes','all','union','compact','value','isEmpty','userMailQueue:remove','addAgents','omit','removeAgents','isArray','getAgents','hasOwnProperty','bluebird','util','lodash','squel','ioredis'];(function(_0x181ccd,_0x16c825){var _0x2df44c=function(_0xa6a905){while(--_0xa6a905){_0x181ccd['push'](_0x181ccd['shift']());}};_0x2df44c(++_0x16c825);}(_0x3a67,0x78));var _0x73a6=function(_0x29ed3e,_0x37521f){_0x29ed3e=_0x29ed3e-0x0;var _0x3b9b69=_0x3a67[_0x29ed3e];return _0x3b9b69;};'use strict';var BPromise=require(_0x73a6('0x0'));var util=require(_0x73a6('0x1'));var _=require(_0x73a6('0x2'));var squel=require(_0x73a6('0x3'));var Redis=require(_0x73a6('0x4'));var qs=require(_0x73a6('0x5'));var logger=require('../../config/logger')(_0x73a6('0x6'));var config=require('../../config/environment');var db=require(_0x73a6('0x7'))['db'];config['redis']=_['defaults'](config[_0x73a6('0x8')],{'host':_0x73a6('0x9'),'port':0x18eb});var socket=require(_0x73a6('0xa'))(new Redis(config[_0x73a6('0x8')]));require('./mailQueue.socket')[_0x73a6('0xb')](socket);function respondWithStatusCode(_0x2fcdc8,_0x22c71e){_0x22c71e=_0x22c71e||0xcc;return function(_0x545ac1){if(_0x545ac1){return _0x2fcdc8[_0x73a6('0xc')](_0x22c71e);}return _0x2fcdc8['status'](_0x22c71e)['end']();};}function respondWithResult(_0x1e6b4c,_0x51f70a){_0x51f70a=_0x51f70a||0xc8;return function(_0x22d62e){if(_0x22d62e){return _0x1e6b4c[_0x73a6('0xd')](_0x51f70a)[_0x73a6('0xe')](_0x22d62e);}};}function respondWithFilteredResult(_0x48b291,_0x2a3d8a){return function(_0xb01f5d){if(_0xb01f5d){var _0x1fdea1=typeof _0x2a3d8a[_0x73a6('0xf')]==='undefined'&&typeof _0x2a3d8a[_0x73a6('0x10')]===_0x73a6('0x11');var _0x7c3704=_0xb01f5d[_0x73a6('0x12')];var _0x2f58a3=_0x1fdea1?0x0:_0x2a3d8a['offset'];var _0x35a9fc=_0x1fdea1?_0xb01f5d['count']:_0x2a3d8a['offset']+_0x2a3d8a[_0x73a6('0x10')];var _0x46b6e0;if(_0x35a9fc>=_0x7c3704){_0x35a9fc=_0x7c3704;_0x46b6e0=0xc8;}else{_0x46b6e0=0xce;}_0x48b291['status'](_0x46b6e0);return _0x48b291[_0x73a6('0x13')](_0x73a6('0x14'),_0x2f58a3+'-'+_0x35a9fc+'/'+_0x7c3704)[_0x73a6('0xe')](_0xb01f5d);}return null;};}function saveUpdates(_0x4b1afd){return function(_0x4c73ab){if(_0x4c73ab){return _0x4c73ab[_0x73a6('0x15')](_0x4b1afd)[_0x73a6('0x16')](function(_0xc2fbb1){return _0xc2fbb1;});}return null;};}function removeEntity(_0x34f4b6){return function(_0xfd2c6a){if(_0xfd2c6a){return _0xfd2c6a['destroy']()[_0x73a6('0x16')](function(){var _0x31e3fc=_0xfd2c6a[_0x73a6('0x17')]({'plain':!![]});var _0x42b18c=_0x73a6('0x18');return db[_0x73a6('0x19')][_0x73a6('0x1a')]({'where':{'type':_0x42b18c,'resourceId':_0x31e3fc['id']}})[_0x73a6('0x16')](function(){return _0xfd2c6a;});})[_0x73a6('0x16')](function(){_0x34f4b6['status'](0xcc)[_0x73a6('0x1b')]();});}};}function handleEntityNotFound(_0x31d94d){return function(_0x118e0e){if(!_0x118e0e){_0x31d94d['sendStatus'](0x194);}return _0x118e0e;};}function handleError(_0x21d663,_0x331fc4){_0x331fc4=_0x331fc4||0x1f4;return function(_0x574111){logger[_0x73a6('0x1c')](_0x574111[_0x73a6('0x1d')]);if(_0x574111[_0x73a6('0x1e')]){delete _0x574111[_0x73a6('0x1e')];}_0x21d663[_0x73a6('0xd')](_0x331fc4)['send'](_0x574111);};}exports['index']=function(_0x5c6528,_0x37564d){var _0x50bf0d={};var _0x1268a4={'count':0x0,'rows':[]};var _0x2e9b6d=_[_0x73a6('0x1f')](db[_0x73a6('0x20')][_0x73a6('0x21')],function(_0x315616){return{'name':_0x315616['fieldName'],'type':_0x315616[_0x73a6('0x22')][_0x73a6('0x23')]};});_0x50bf0d=qs[_0x73a6('0x24')](_0x2e9b6d,_0x5c6528);var _0x25867f={'where':_0x50bf0d['where']};return db['MailQueue'][_0x73a6('0x12')](_0x25867f)[_0x73a6('0x16')](function(_0x32b727){_0x1268a4['count']=_0x32b727;_0x50bf0d['include']=qs[_0x73a6('0x25')](_0x5c6528[_0x73a6('0x26')]);return db[_0x73a6('0x20')][_0x73a6('0x27')](_0x50bf0d);})[_0x73a6('0x16')](function(_0x466c8b){_0x1268a4[_0x73a6('0x28')]=_0x466c8b;return _0x1268a4;})[_0x73a6('0x16')](respondWithFilteredResult(_0x37564d,_0x50bf0d))[_0x73a6('0x29')](handleError(_0x37564d,null));};exports[_0x73a6('0x2a')]=function(_0x4a9a78,_0x41ee32){var _0x2eb035={'raw':!![],'where':{'id':_0x4a9a78[_0x73a6('0x2b')]['id']}},_0x32d08f={};_0x32d08f[_0x73a6('0x2c')]=_['keys'](db[_0x73a6('0x20')][_0x73a6('0x21')]);_0x32d08f[_0x73a6('0x26')]=_['keys'](_0x4a9a78[_0x73a6('0x26')]);_0x32d08f['filters']=_[_0x73a6('0x2d')](_0x32d08f[_0x73a6('0x2c')],_0x32d08f[_0x73a6('0x26')]);_0x2eb035[_0x73a6('0x2e')]=_[_0x73a6('0x2d')](_0x32d08f[_0x73a6('0x2c')],qs[_0x73a6('0x2f')](_0x4a9a78[_0x73a6('0x26')][_0x73a6('0x2f')]));_0x2eb035['attributes']=_0x2eb035[_0x73a6('0x2e')][_0x73a6('0x30')]?_0x2eb035[_0x73a6('0x2e')]:_0x32d08f['model'];if(_0x4a9a78[_0x73a6('0x26')][_0x73a6('0x31')]){_0x2eb035[_0x73a6('0x25')]=[{'all':!![]}];}_0x2eb035=_[_0x73a6('0x32')]({},_0x2eb035,_0x4a9a78[_0x73a6('0x33')]);return db[_0x73a6('0x20')][_0x73a6('0x34')](_0x2eb035)[_0x73a6('0x16')](handleEntityNotFound(_0x41ee32,null))[_0x73a6('0x16')](respondWithResult(_0x41ee32,null))[_0x73a6('0x29')](handleError(_0x41ee32,null));};exports['create']=function(_0x58a42d,_0x1d5af4){return db['MailQueue'][_0x73a6('0x35')](_0x58a42d['body'],{})[_0x73a6('0x16')](function(_0x4893b6){var _0x518254=_0x58a42d[_0x73a6('0x36')][_0x73a6('0x17')]({'plain':!![]});if(!_0x518254)throw new Error(_0x73a6('0x37'));if(_0x518254['role']===_0x73a6('0x36')){var _0x17c1b9=_0x4893b6[_0x73a6('0x17')]({'plain':!![]});var _0x3376c2=_0x73a6('0x18');return db[_0x73a6('0x38')][_0x73a6('0x34')]({'where':{'name':_0x3376c2,'userProfileId':_0x518254[_0x73a6('0x39')]},'raw':!![]})[_0x73a6('0x16')](function(_0x2bb6b4){if(_0x2bb6b4&&_0x2bb6b4[_0x73a6('0x3a')]===0x0){return db['UserProfileResource'][_0x73a6('0x35')]({'name':_0x17c1b9[_0x73a6('0x1e')],'resourceId':_0x17c1b9['id'],'type':_0x2bb6b4[_0x73a6('0x1e')],'sectionId':_0x2bb6b4['id']},{})[_0x73a6('0x16')](function(){return _0x4893b6;});}else{return _0x4893b6;}})[_0x73a6('0x29')](function(_0x3ac82e){logger['error'](_0x73a6('0x3b'),_0x3ac82e);throw _0x3ac82e;});}return _0x4893b6;})[_0x73a6('0x16')](respondWithResult(_0x1d5af4,0xc9))[_0x73a6('0x29')](handleError(_0x1d5af4,null));};exports[_0x73a6('0x15')]=function(_0x178212,_0x5dd4d7){if(_0x178212['body']['id']){delete _0x178212[_0x73a6('0x3c')]['id'];}return db[_0x73a6('0x20')][_0x73a6('0x34')]({'where':{'id':_0x178212[_0x73a6('0x2b')]['id']}})[_0x73a6('0x16')](handleEntityNotFound(_0x5dd4d7,null))[_0x73a6('0x16')](saveUpdates(_0x178212[_0x73a6('0x3c')],null))[_0x73a6('0x16')](respondWithResult(_0x5dd4d7,null))[_0x73a6('0x29')](handleError(_0x5dd4d7,null));};exports[_0x73a6('0x1a')]=function(_0x391fec,_0x1f5e94){return db[_0x73a6('0x20')][_0x73a6('0x34')]({'where':{'id':_0x391fec[_0x73a6('0x2b')]['id']}})[_0x73a6('0x16')](handleEntityNotFound(_0x1f5e94,null))['then'](removeEntity(_0x1f5e94,null))[_0x73a6('0x29')](handleError(_0x1f5e94,null));};exports[_0x73a6('0x3d')]=function(_0x382166,_0x56685f){return db[_0x73a6('0x20')]['describe']()[_0x73a6('0x16')](respondWithResult(_0x56685f,null))[_0x73a6('0x29')](handleError(_0x56685f,null));};exports[_0x73a6('0x3e')]=function(_0x348284,_0x28a3fe){var _0x2f5fe5={'raw':!![],'where':{}},_0xb1a205={},_0x173eaa;return db[_0x73a6('0x20')][_0x73a6('0x3f')]({'where':{'id':_0x348284[_0x73a6('0x2b')]['id']}})[_0x73a6('0x16')](handleEntityNotFound(_0x28a3fe,null))[_0x73a6('0x16')](function(_0x1f9e0b){if(_0x1f9e0b){_0x173eaa=_0x1f9e0b[_0x73a6('0x17')]({'plain':!![]});_0xb1a205['model']=_[_0x73a6('0x40')](db[_0x73a6('0x41')][_0x73a6('0x21')]);_0xb1a205[_0x73a6('0x26')]=_[_0x73a6('0x40')](_0x348284[_0x73a6('0x26')]);_0xb1a205[_0x73a6('0x42')]=_[_0x73a6('0x2d')](_0xb1a205[_0x73a6('0x2c')],_0xb1a205['query']);_0x2f5fe5[_0x73a6('0x2e')]=_[_0x73a6('0x2d')](_0xb1a205[_0x73a6('0x2c')],qs[_0x73a6('0x2f')](_0x348284[_0x73a6('0x26')][_0x73a6('0x2f')]));_0x2f5fe5[_0x73a6('0x2e')]=_0x2f5fe5[_0x73a6('0x2e')][_0x73a6('0x30')]?_0x2f5fe5[_0x73a6('0x2e')]:_0xb1a205[_0x73a6('0x2c')];if(!_0x348284[_0x73a6('0x26')]['hasOwnProperty'](_0x73a6('0x43'))){_0x2f5fe5[_0x73a6('0x10')]=qs['limit'](_0x348284[_0x73a6('0x26')][_0x73a6('0x10')]);_0x2f5fe5['offset']=qs['offset'](_0x348284['query'][_0x73a6('0xf')]);}_0x2f5fe5['order']=qs['sort'](_0x348284['query'][_0x73a6('0x44')]);_0x2f5fe5[_0x73a6('0x45')]=qs['filters'](_[_0x73a6('0x46')](_0x348284['query'],_0xb1a205['filters']));_0x2f5fe5[_0x73a6('0x45')][_0x73a6('0x47')]=_0x1f9e0b['id'];if(_0x348284[_0x73a6('0x26')][_0x73a6('0x48')]){_0x2f5fe5['where']=_[_0x73a6('0x32')](_0x2f5fe5[_0x73a6('0x45')],{'$or':_['map'](_0x2f5fe5['attributes'],function(_0x5c0016){var _0x2cc525={};_0x2cc525[_0x5c0016]={'$like':'%'+_0x348284[_0x73a6('0x26')][_0x73a6('0x48')]+'%'};return _0x2cc525;})});}_0x2f5fe5=_[_0x73a6('0x32')]({},_0x2f5fe5,_0x348284[_0x73a6('0x33')]);return db[_0x73a6('0x41')][_0x73a6('0x27')](_0x2f5fe5);}})[_0x73a6('0x16')](function(_0x11d0bc){if(_0x11d0bc){return db[_0x73a6('0x49')][_0x73a6('0x4a')]({'where':{'id':_[_0x73a6('0x1f')](_0x11d0bc,'UserId'),'role':_0x73a6('0x4b')},'attributes':['id',_0x73a6('0x1e'),_0x73a6('0x4c'),_0x73a6('0x4d'),'createdAt']});}})[_0x73a6('0x16')](function(_0xceb2fa){if(_0xceb2fa){return{'count':_0xceb2fa[_0x73a6('0x12')],'rows':_[_0x73a6('0x1f')](_0xceb2fa[_0x73a6('0x28')],function(_0x1205f2){return{'membername':_0x1205f2[_0x73a6('0x1e')],'UserId':_0x1205f2['id'],'queue_name':_0x173eaa[_0x73a6('0x1e')],'MailQueueId':_0x173eaa['id'],'interface':util[_0x73a6('0x4e')]('%s/%s',_0x73a6('0x4f'),_0x1205f2[_0x73a6('0x1e')]),'penalty':0x0,'paused':_0x1205f2['mailPause'],'createdAt':_0x1205f2[_0x73a6('0x50')],'updatedAt':_0x1205f2[_0x73a6('0x4d')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x73a6('0x16')](respondWithFilteredResult(_0x28a3fe,_0x2f5fe5))[_0x73a6('0x29')](handleError(_0x28a3fe,null));};exports['getTeams']=function(_0x1672e5,_0x1c41c7){var _0x49c41a={};var _0x15e505={};var _0x5d9038;var _0x2b3236;return db[_0x73a6('0x20')][_0x73a6('0x3f')]({'where':{'id':_0x1672e5[_0x73a6('0x2b')]['id']}})[_0x73a6('0x16')](handleEntityNotFound(_0x1c41c7,null))[_0x73a6('0x16')](function(_0x5549b4){if(_0x5549b4){_0x5d9038=_0x5549b4;_0x15e505[_0x73a6('0x2c')]=_[_0x73a6('0x40')](db[_0x73a6('0x51')][_0x73a6('0x21')]);_0x15e505[_0x73a6('0x26')]=_['keys'](_0x1672e5['query']);_0x15e505[_0x73a6('0x42')]=_[_0x73a6('0x2d')](_0x15e505[_0x73a6('0x2c')],_0x15e505[_0x73a6('0x26')]);_0x49c41a[_0x73a6('0x2e')]=_[_0x73a6('0x2d')](_0x15e505[_0x73a6('0x2c')],qs['fields'](_0x1672e5[_0x73a6('0x26')][_0x73a6('0x2f')]));_0x49c41a[_0x73a6('0x2e')]=_0x49c41a[_0x73a6('0x2e')][_0x73a6('0x30')]?_0x49c41a[_0x73a6('0x2e')]:_0x15e505['model'];_0x49c41a[_0x73a6('0x52')]=qs[_0x73a6('0x44')](_0x1672e5[_0x73a6('0x26')][_0x73a6('0x44')]);_0x49c41a[_0x73a6('0x45')]=qs['filters'](_[_0x73a6('0x46')](_0x1672e5[_0x73a6('0x26')],_0x15e505['filters']));if(_0x1672e5[_0x73a6('0x26')][_0x73a6('0x48')]){_0x49c41a[_0x73a6('0x45')]=_[_0x73a6('0x32')](_0x49c41a[_0x73a6('0x45')],{'$or':_[_0x73a6('0x1f')](_0x49c41a[_0x73a6('0x2e')],function(_0x23ead8){var _0x49f714={};_0x49f714[_0x23ead8]={'$like':'%'+_0x1672e5['query'][_0x73a6('0x48')]+'%'};return _0x49f714;})});}_0x49c41a=_[_0x73a6('0x32')]({},_0x49c41a,_0x1672e5[_0x73a6('0x33')]);return _0x5d9038['getTeams'](_0x49c41a);}})['then'](function(_0x4d5f8f){if(_0x4d5f8f){_0x2b3236=_0x4d5f8f[_0x73a6('0x30')];if(!_0x1672e5[_0x73a6('0x26')]['hasOwnProperty'](_0x73a6('0x43'))){_0x49c41a[_0x73a6('0x10')]=qs['limit'](_0x1672e5['query'][_0x73a6('0x10')]);_0x49c41a[_0x73a6('0xf')]=qs[_0x73a6('0xf')](_0x1672e5[_0x73a6('0x26')][_0x73a6('0xf')]);}return _0x5d9038[_0x73a6('0x53')](_0x49c41a);}})[_0x73a6('0x16')](function(_0x5e7403){if(_0x5e7403){return _0x5e7403?{'count':_0x2b3236,'rows':_0x5e7403}:null;}})['then'](respondWithResult(_0x1c41c7,null))['catch'](handleError(_0x1c41c7,null));};exports[_0x73a6('0x54')]=function(_0x25e7c7,_0x2379cd){var _0x5d6a9=_0x25e7c7[_0x73a6('0x3c')]['ids'];return db['Team'][_0x73a6('0x27')]({'where':{'id':_0x5d6a9},'attributes':['id'],'include':[{'model':db['User'],'as':_0x73a6('0x55'),'attributes':['id','name',_0x73a6('0x56'),_0x73a6('0x57'),_0x73a6('0x58')],'raw':!![]}]})['then'](function(_0x36d1d0){if(_0x36d1d0){var _0x5d2967=_[_0x73a6('0x59')](_0x36d1d0,function(_0x1d8c52){var _0x2e51ac=_0x1d8c52[_0x73a6('0x17')]({'plain':!![]});return _0x2e51ac['Agents'];});return db['MailQueue']['find']({'where':{'id':_0x25e7c7[_0x73a6('0x2b')]['id']}})[_0x73a6('0x16')](function(_0x1ff3b2){return db[_0x73a6('0x5a')][_0x73a6('0x5b')](function(_0x59ba20){return _0x1ff3b2[_0x73a6('0x54')](_0x5d6a9,{'transaction':_0x59ba20})['then'](function(){return BPromise['each'](_0x5d2967,function(_0x3e4cfd){return db[_0x73a6('0x41')][_0x73a6('0x5c')]({'where':{'UserId':_0x3e4cfd['id'],'MailQueueId':_0x25e7c7[_0x73a6('0x2b')]['id']},'transaction':_0x59ba20});});})['then'](function(){_0x5d2967[_0x73a6('0x5d')](function(_0x4b4652){socket[_0x73a6('0x5e')](_0x73a6('0x5f'),{'UserId':_0x4b4652['id'],'MailQueueId':_0x1ff3b2['id']});});});});});}})['then'](respondWithStatusCode(_0x2379cd,null))[_0x73a6('0x29')](handleError(_0x2379cd,null));};exports[_0x73a6('0x60')]=function(_0x139084,_0x34dbce){return db[_0x73a6('0x51')]['findAll']({'where':{'id':_0x139084['query'][_0x73a6('0x61')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x73a6('0x55'),'attributes':['id'],'raw':!![]}]})[_0x73a6('0x16')](handleEntityNotFound(_0x34dbce,null))[_0x73a6('0x16')](function(_0x6faf3){var _0x21e7b6=_[_0x73a6('0x1f')](_0x6faf3,'id');var _0x2196c9=[];var _0x2490ab=[];var _0x9b89ee=squel[_0x73a6('0x62')]();_0x9b89ee[_0x73a6('0x63')](_0x73a6('0x64'))[_0x73a6('0x65')](_0x73a6('0x66'),'tq')['join'](_0x73a6('0x67'),'ut',_0x73a6('0x68'))[_0x73a6('0x45')](_0x73a6('0x69'),_0x139084[_0x73a6('0x2b')]['id']);for(var _0x37411f=0x0;_0x37411f<_0x6faf3[_0x73a6('0x30')];_0x37411f+=0x1){let _0x18ddbe=_0x6faf3[_0x37411f];for(var _0x2aca36=0x0;_0x2aca36<_0x18ddbe[_0x73a6('0x55')][_0x73a6('0x30')];_0x2aca36+=0x1){let _0x1dfeb9=_0x18ddbe['Agents'][_0x2aca36];var _0x154180=_0x9b89ee[_0x73a6('0x6a')]();_0x154180[_0x73a6('0x45')]('ut.UserId\x20=\x20?',_0x1dfeb9['id']);_0x2490ab[_0x73a6('0x6b')](db[_0x73a6('0x5a')][_0x73a6('0x26')](_0x154180[_0x73a6('0x6c')](),{'type':db['sequelize'][_0x73a6('0x6d')]['SELECT']})[_0x73a6('0x16')](function(_0x279fd7){if(_0x279fd7[_0x73a6('0x30')]===0x1){return _0x1dfeb9['id'];}else{var _0x4967aa=_[_0x73a6('0x6e')](_[_0x73a6('0x1f')](_0x279fd7,_0x73a6('0x6f')),function(_0x210a4d){return _[_0x73a6('0x70')](_0x21e7b6,_0x210a4d);});if(_0x4967aa){return _0x1dfeb9['id'];}}}));}}return BPromise[_0x73a6('0x71')](_0x2490ab)['then'](function(_0x2b89ef){_0x2196c9=_(_0x2196c9)[_0x73a6('0x72')](_0x2b89ef)[_0x73a6('0x73')]()[_0x73a6('0x74')]();return db[_0x73a6('0x20')][_0x73a6('0x34')]({'where':{'id':_0x139084[_0x73a6('0x2b')]['id']}})[_0x73a6('0x16')](function(_0x31cf10){return db[_0x73a6('0x5a')][_0x73a6('0x5b')](function(_0x11b218){return _0x31cf10[_0x73a6('0x60')](_0x139084['query'][_0x73a6('0x61')],{'transaction':_0x11b218})[_0x73a6('0x16')](function(){if(!_[_0x73a6('0x75')](_0x2196c9)){return _0x31cf10['removeAgents'](_0x2196c9,{'transaction':_0x11b218});}})[_0x73a6('0x16')](function(){_0x2196c9[_0x73a6('0x5d')](function(_0x477f29){socket[_0x73a6('0x5e')](_0x73a6('0x76'),{'UserId':_0x477f29,'MailQueueId':_0x31cf10['id']});});});});});});})[_0x73a6('0x16')](respondWithStatusCode(_0x34dbce,null))[_0x73a6('0x29')](handleError(_0x34dbce,null));};exports['addAgents']=function(_0x495c6a,_0x2a827a){return db[_0x73a6('0x20')][_0x73a6('0x34')]({'where':{'id':_0x495c6a[_0x73a6('0x2b')]['id']}})[_0x73a6('0x16')](handleEntityNotFound(_0x2a827a,null))['then'](function(_0x3e851a){if(_0x3e851a){return _0x3e851a[_0x73a6('0x77')](_0x495c6a[_0x73a6('0x3c')]['ids'],_[_0x73a6('0x78')](_0x495c6a['body'],[_0x73a6('0x61'),'id'])||{})['spread'](function(_0x493ff0){for(var _0x4e6add=0x0;_0x4e6add<_0x495c6a[_0x73a6('0x3c')][_0x73a6('0x61')][_0x73a6('0x30')];_0x4e6add+=0x1){socket[_0x73a6('0x5e')](_0x73a6('0x5f'),{'UserId':Number(_0x495c6a[_0x73a6('0x3c')][_0x73a6('0x61')][_0x4e6add]),'MailQueueId':Number(_0x495c6a[_0x73a6('0x2b')]['id'])});}return _0x493ff0;});}})[_0x73a6('0x16')](respondWithResult(_0x2a827a,null))[_0x73a6('0x29')](handleError(_0x2a827a,null));};exports[_0x73a6('0x79')]=function(_0x23c4e9,_0x530451){return db[_0x73a6('0x20')][_0x73a6('0x34')]({'where':{'id':_0x23c4e9[_0x73a6('0x2b')]['id']}})['then'](handleEntityNotFound(_0x530451,null))[_0x73a6('0x16')](function(_0x1dd175){if(_0x1dd175){return _0x1dd175[_0x73a6('0x79')](_0x23c4e9[_0x73a6('0x26')]['ids'])['then'](function(){if(_[_0x73a6('0x7a')](_0x23c4e9[_0x73a6('0x26')][_0x73a6('0x61')])){for(var _0x32c35b=0x0;_0x32c35b<_0x23c4e9['query'][_0x73a6('0x61')][_0x73a6('0x30')];_0x32c35b+=0x1){socket[_0x73a6('0x5e')]('userMailQueue:remove',{'UserId':Number(_0x23c4e9['query']['ids'][_0x32c35b]),'MailQueueId':Number(_0x23c4e9[_0x73a6('0x2b')]['id'])});}}else{socket['emit']('userMailQueue:remove',{'UserId':Number(_0x23c4e9['query'][_0x73a6('0x61')]),'MailQueueId':Number(_0x23c4e9[_0x73a6('0x2b')]['id'])});}});}})[_0x73a6('0x16')](respondWithStatusCode(_0x530451,null))[_0x73a6('0x29')](handleError(_0x530451,null));};exports[_0x73a6('0x7b')]=function(_0x571f14,_0x11ab3f){var _0x18b4ae={};var _0x117266={};var _0x2408ca;var _0x472b6b;return db['MailQueue'][_0x73a6('0x3f')]({'where':{'id':_0x571f14[_0x73a6('0x2b')]['id']}})['then'](handleEntityNotFound(_0x11ab3f,null))['then'](function(_0x558863){if(_0x558863){_0x2408ca=_0x558863;_0x117266['model']=_[_0x73a6('0x40')](db['User'][_0x73a6('0x21')]);_0x117266[_0x73a6('0x26')]=_[_0x73a6('0x40')](_0x571f14['query']);_0x117266[_0x73a6('0x42')]=_[_0x73a6('0x2d')](_0x117266[_0x73a6('0x2c')],_0x117266[_0x73a6('0x26')]);_0x18b4ae[_0x73a6('0x2e')]=_[_0x73a6('0x2d')](_0x117266[_0x73a6('0x2c')],qs[_0x73a6('0x2f')](_0x571f14[_0x73a6('0x26')][_0x73a6('0x2f')]));_0x18b4ae[_0x73a6('0x2e')]=_0x18b4ae[_0x73a6('0x2e')]['length']?_0x18b4ae[_0x73a6('0x2e')]:_0x117266[_0x73a6('0x2c')];_0x18b4ae[_0x73a6('0x52')]=qs[_0x73a6('0x44')](_0x571f14['query'][_0x73a6('0x44')]);_0x18b4ae[_0x73a6('0x45')]=qs['filters'](_[_0x73a6('0x46')](_0x571f14['query'],_0x117266[_0x73a6('0x42')]));if(_0x571f14[_0x73a6('0x26')][_0x73a6('0x48')]){_0x18b4ae[_0x73a6('0x45')]=_[_0x73a6('0x32')](_0x18b4ae[_0x73a6('0x45')],{'$or':_[_0x73a6('0x1f')](_0x18b4ae[_0x73a6('0x2e')],function(_0x5a9ca7){var _0x407f1c={};_0x407f1c[_0x5a9ca7]={'$like':'%'+_0x571f14[_0x73a6('0x26')]['filter']+'%'};return _0x407f1c;})});}_0x18b4ae=_[_0x73a6('0x32')]({},_0x18b4ae,_0x571f14[_0x73a6('0x33')]);return _0x2408ca[_0x73a6('0x7b')](_0x18b4ae);}})[_0x73a6('0x16')](function(_0x2aa3a9){if(_0x2aa3a9){_0x472b6b=_0x2aa3a9[_0x73a6('0x30')];if(!_0x571f14[_0x73a6('0x26')][_0x73a6('0x7c')](_0x73a6('0x43'))){_0x18b4ae[_0x73a6('0x10')]=qs['limit'](_0x571f14[_0x73a6('0x26')][_0x73a6('0x10')]);_0x18b4ae[_0x73a6('0xf')]=qs[_0x73a6('0xf')](_0x571f14[_0x73a6('0x26')][_0x73a6('0xf')]);}return _0x2408ca[_0x73a6('0x7b')](_0x18b4ae);}})[_0x73a6('0x16')](function(_0x188687){if(_0x188687){return _0x188687?{'count':_0x472b6b,'rows':_0x188687}:null;}})[_0x73a6('0x16')](respondWithResult(_0x11ab3f,null))[_0x73a6('0x29')](handleError(_0x11ab3f,null));};
\ No newline at end of file