Built motion from commit (unavailable).|2.5.9
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 922d852..c74d8b5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x96d9=['then','destroy','get','UserProfileResource','error','stack','name','index','rawAttributes','fieldName','type','model','map','keys','query','filters','attributes','fields','length','hasOwnProperty','limit','sort','pick','filter','where','merge','MailQueue','includeAll','include','findAll','rows','catch','params','intersection','options','find','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','getMembers','findOne','nolimit','order','MailQueueId','UserMailQueue','User','findAndCountAll','UserId','agent','mailPause','createdAt','%s/%s','updatedAt','Team','getTeams','Agents','online','flatMap','sequelize','addTeams','each','findOrCreate','forEach','emit','userMailQueue:save','removeTeams','field','tq.TeamId','from','team_has_mail_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','every','TeamId','includes','all','union','transaction','ids','removeAgents','userMailQueue:remove','addAgents','omit','spread','isArray','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','redis','defaults','localhost','socket.io-emitter','./mailQueue.socket','register','status','end','json','count','offset','set','Content-Range','apply','reject','save','update'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x96d9,0xea));var _0x996d=function(_0x663b77,_0x11a4bd){_0x663b77=_0x663b77-0x0;var _0x17fc55=_0x96d9[_0x663b77];return _0x17fc55;};'use strict';var pdf=require(_0x996d('0x0'));var emlformat=require(_0x996d('0x1'));var rimraf=require(_0x996d('0x2'));var zipdir=require(_0x996d('0x3'));var jsonpatch=require(_0x996d('0x4'));var rp=require(_0x996d('0x5'));var moment=require(_0x996d('0x6'));var BPromise=require(_0x996d('0x7'));var Mustache=require('mustache');var util=require(_0x996d('0x8'));var path=require(_0x996d('0x9'));var sox=require(_0x996d('0xa'));var csv=require(_0x996d('0xb'));var ejs=require(_0x996d('0xc'));var fs=require('fs');var _=require(_0x996d('0xd'));var squel=require(_0x996d('0xe'));var crypto=require('crypto');var jsforce=require(_0x996d('0xf'));var deskjs=require(_0x996d('0x10'));var toCsv=require(_0x996d('0xb'));var querystring=require(_0x996d('0x11'));var Papa=require(_0x996d('0x12'));var Redis=require('ioredis');var authService=require(_0x996d('0x13'));var qs=require(_0x996d('0x14'));var as=require(_0x996d('0x15'));var hardwareService=require(_0x996d('0x16'));var logger=require('../../config/logger')(_0x996d('0x17'));var utils=require(_0x996d('0x18'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x996d('0x19')]=_[_0x996d('0x1a')](config['redis'],{'host':_0x996d('0x1b'),'port':0x18eb});var socket=require(_0x996d('0x1c'))(new Redis(config['redis']));require(_0x996d('0x1d'))[_0x996d('0x1e')](socket);function respondWithStatusCode(_0x18c2b8,_0x47cd95){_0x47cd95=_0x47cd95||0xcc;return function(_0x467195){if(_0x467195){return _0x18c2b8['sendStatus'](_0x47cd95);}return _0x18c2b8[_0x996d('0x1f')](_0x47cd95)[_0x996d('0x20')]();};}function respondWithResult(_0x281281,_0x15a985){_0x15a985=_0x15a985||0xc8;return function(_0xa94294){if(_0xa94294){return _0x281281[_0x996d('0x1f')](_0x15a985)[_0x996d('0x21')](_0xa94294);}};}function respondWithFilteredResult(_0x5a8b12,_0x5dacb7){return function(_0x465c94){if(_0x465c94){var _0x17ce93=_0x465c94[_0x996d('0x22')],_0x33bf07=_0x5dacb7[_0x996d('0x23')],_0x26d8c6=_0x5dacb7[_0x996d('0x23')]+_0x5dacb7['limit'],_0x2cee14;if(_0x26d8c6>=_0x17ce93){_0x26d8c6=_0x17ce93;_0x2cee14=0xc8;}else{_0x2cee14=0xce;}_0x5a8b12['status'](_0x2cee14);return _0x5a8b12[_0x996d('0x24')](_0x996d('0x25'),_0x33bf07+'-'+_0x26d8c6+'/'+_0x17ce93)[_0x996d('0x21')](_0x465c94);}return null;};}function patchUpdates(_0x109662){return function(_0x141bcb){try{jsonpatch[_0x996d('0x26')](_0x141bcb,_0x109662,!![]);}catch(_0x57a15c){return BPromise[_0x996d('0x27')](_0x57a15c);}return _0x141bcb[_0x996d('0x28')]();};}function saveUpdates(_0x379165,_0x5bbf4c){return function(_0x4bbdb6){if(_0x4bbdb6){return _0x4bbdb6[_0x996d('0x29')](_0x379165)[_0x996d('0x2a')](function(_0x53c4d9){return _0x53c4d9;});}return null;};}function removeEntity(_0x2a9da1,_0x273aad){return function(_0x33abd5){if(_0x33abd5){return _0x33abd5[_0x996d('0x2b')]()['then'](function(){var _0x534873=_0x33abd5[_0x996d('0x2c')]({'plain':!![]});var _0x22defb='MailQueues';return db[_0x996d('0x2d')]['destroy']({'where':{'type':_0x22defb,'resourceId':_0x534873['id']}})[_0x996d('0x2a')](function(){return _0x33abd5;});})[_0x996d('0x2a')](function(){_0x2a9da1[_0x996d('0x1f')](0xcc)[_0x996d('0x20')]();});}};}function handleEntityNotFound(_0x29f1df,_0x23ac01){return function(_0x3c45be){if(!_0x3c45be){_0x29f1df['sendStatus'](0x194);}return _0x3c45be;};}function handleError(_0xf93301,_0x150e7d){_0x150e7d=_0x150e7d||0x1f4;return function(_0x45a158){logger[_0x996d('0x2e')](_0x45a158[_0x996d('0x2f')]);if(_0x45a158[_0x996d('0x30')]){delete _0x45a158['name'];}_0xf93301['status'](_0x150e7d)['send'](_0x45a158);};}exports[_0x996d('0x31')]=function(_0x6b3221,_0xf84d49){var _0x2ce7b7={},_0x1cf99e={},_0x1fc340={'count':0x0,'rows':[]};var _0x4610ec=_['map'](db['MailQueue'][_0x996d('0x32')],function(_0x4c3c9a){return{'name':_0x4c3c9a[_0x996d('0x33')],'type':_0x4c3c9a[_0x996d('0x34')]['key']};});_0x1cf99e[_0x996d('0x35')]=_[_0x996d('0x36')](_0x4610ec,_0x996d('0x30'));_0x1cf99e['query']=_[_0x996d('0x37')](_0x6b3221[_0x996d('0x38')]);_0x1cf99e[_0x996d('0x39')]=_['intersection'](_0x1cf99e['model'],_0x1cf99e[_0x996d('0x38')]);_0x2ce7b7[_0x996d('0x3a')]=_['intersection'](_0x1cf99e[_0x996d('0x35')],qs[_0x996d('0x3b')](_0x6b3221[_0x996d('0x38')][_0x996d('0x3b')]));_0x2ce7b7[_0x996d('0x3a')]=_0x2ce7b7['attributes'][_0x996d('0x3c')]?_0x2ce7b7[_0x996d('0x3a')]:_0x1cf99e[_0x996d('0x35')];if(!_0x6b3221[_0x996d('0x38')][_0x996d('0x3d')]('nolimit')){_0x2ce7b7[_0x996d('0x3e')]=qs[_0x996d('0x3e')](_0x6b3221[_0x996d('0x38')][_0x996d('0x3e')]);_0x2ce7b7[_0x996d('0x23')]=qs['offset'](_0x6b3221['query']['offset']);}_0x2ce7b7['order']=qs[_0x996d('0x3f')](_0x6b3221[_0x996d('0x38')][_0x996d('0x3f')]);_0x2ce7b7['where']=qs[_0x996d('0x39')](_[_0x996d('0x40')](_0x6b3221[_0x996d('0x38')],_0x1cf99e[_0x996d('0x39')]),_0x4610ec);if(_0x6b3221[_0x996d('0x38')][_0x996d('0x41')]){_0x2ce7b7[_0x996d('0x42')]=_[_0x996d('0x43')](_0x2ce7b7[_0x996d('0x42')],{'$or':_[_0x996d('0x36')](_0x4610ec,function(_0x226039){if(_0x226039[_0x996d('0x34')]!=='VIRTUAL'){var _0x43e5bb={};_0x43e5bb[_0x226039[_0x996d('0x30')]]={'$like':'%'+_0x6b3221['query'][_0x996d('0x41')]+'%'};return _0x43e5bb;}})});}_0x2ce7b7=_['merge']({},_0x2ce7b7,_0x6b3221['options']);var _0x496eb8={'where':_0x2ce7b7['where']};return db[_0x996d('0x44')][_0x996d('0x22')](_0x496eb8)['then'](function(_0x115ab0){_0x1fc340[_0x996d('0x22')]=_0x115ab0;if(_0x6b3221[_0x996d('0x38')][_0x996d('0x45')]){_0x2ce7b7[_0x996d('0x46')]=[{'all':!![]}];}return db['MailQueue'][_0x996d('0x47')](_0x2ce7b7);})[_0x996d('0x2a')](function(_0x21d46f){_0x1fc340[_0x996d('0x48')]=_0x21d46f;return _0x1fc340;})[_0x996d('0x2a')](respondWithFilteredResult(_0xf84d49,_0x2ce7b7))[_0x996d('0x49')](handleError(_0xf84d49,null));};exports['show']=function(_0x3e4555,_0x906237){var _0x2b5e5b={'raw':!![],'where':{'id':_0x3e4555[_0x996d('0x4a')]['id']}},_0x4b57c0={};_0x4b57c0[_0x996d('0x35')]=_['keys'](db['MailQueue'][_0x996d('0x32')]);_0x4b57c0['query']=_[_0x996d('0x37')](_0x3e4555[_0x996d('0x38')]);_0x4b57c0['filters']=_[_0x996d('0x4b')](_0x4b57c0[_0x996d('0x35')],_0x4b57c0[_0x996d('0x38')]);_0x2b5e5b[_0x996d('0x3a')]=_[_0x996d('0x4b')](_0x4b57c0['model'],qs[_0x996d('0x3b')](_0x3e4555['query']['fields']));_0x2b5e5b['attributes']=_0x2b5e5b['attributes'][_0x996d('0x3c')]?_0x2b5e5b[_0x996d('0x3a')]:_0x4b57c0[_0x996d('0x35')];if(_0x3e4555['query']['includeAll']){_0x2b5e5b[_0x996d('0x46')]=[{'all':!![]}];}_0x2b5e5b=_[_0x996d('0x43')]({},_0x2b5e5b,_0x3e4555[_0x996d('0x4c')]);return db[_0x996d('0x44')][_0x996d('0x4d')](_0x2b5e5b)['then'](handleEntityNotFound(_0x906237,null))[_0x996d('0x2a')](respondWithResult(_0x906237,null))[_0x996d('0x49')](handleError(_0x906237,null));};exports[_0x996d('0x4e')]=function(_0x42c2f0,_0x201c6a){return db[_0x996d('0x44')][_0x996d('0x4e')](_0x42c2f0['body'],{})['then'](function(_0x14c074){var _0x18de33=_0x42c2f0['user']['get']({'plain':!![]});if(!_0x18de33)throw new Error(_0x996d('0x4f'));if(_0x18de33['role']===_0x996d('0x50')){var _0xcd988b=_0x14c074[_0x996d('0x2c')]({'plain':!![]});var _0x4f1dc7='MailQueues';return db[_0x996d('0x51')]['find']({'where':{'name':_0x4f1dc7,'userProfileId':_0x18de33[_0x996d('0x52')]},'raw':!![]})[_0x996d('0x2a')](function(_0x37dcac){if(_0x37dcac&&_0x37dcac[_0x996d('0x53')]===0x0){return db['UserProfileResource'][_0x996d('0x4e')]({'name':_0xcd988b[_0x996d('0x30')],'resourceId':_0xcd988b['id'],'type':_0x37dcac[_0x996d('0x30')],'sectionId':_0x37dcac['id']},{})[_0x996d('0x2a')](function(){return _0x14c074;});}else{return _0x14c074;}})[_0x996d('0x49')](function(_0x14d19c){logger[_0x996d('0x2e')](_0x996d('0x54'),_0x14d19c);throw _0x14d19c;});}return _0x14c074;})['then'](respondWithResult(_0x201c6a,0xc9))['catch'](handleError(_0x201c6a,null));};exports['update']=function(_0x34466f,_0x259690){if(_0x34466f[_0x996d('0x55')]['id']){delete _0x34466f[_0x996d('0x55')]['id'];}return db[_0x996d('0x44')]['find']({'where':{'id':_0x34466f[_0x996d('0x4a')]['id']}})[_0x996d('0x2a')](handleEntityNotFound(_0x259690,null))[_0x996d('0x2a')](saveUpdates(_0x34466f[_0x996d('0x55')],null))[_0x996d('0x2a')](respondWithResult(_0x259690,null))[_0x996d('0x49')](handleError(_0x259690,null));};exports[_0x996d('0x2b')]=function(_0x27d699,_0x22e058){return db[_0x996d('0x44')]['find']({'where':{'id':_0x27d699[_0x996d('0x4a')]['id']}})[_0x996d('0x2a')](handleEntityNotFound(_0x22e058,null))[_0x996d('0x2a')](removeEntity(_0x22e058,null))['catch'](handleError(_0x22e058,null));};exports['describe']=function(_0x75864d,_0x29ecd0){return db[_0x996d('0x44')]['describe']()['then'](respondWithResult(_0x29ecd0,null))[_0x996d('0x49')](handleError(_0x29ecd0,null));};exports[_0x996d('0x56')]=function(_0x39f800,_0x54ec62,_0x3e487c){var _0x4ca59e={'raw':!![],'where':{}},_0x9e903d={},_0x14d3d6;return db[_0x996d('0x44')][_0x996d('0x57')]({'where':{'id':_0x39f800[_0x996d('0x4a')]['id']}})[_0x996d('0x2a')](handleEntityNotFound(_0x54ec62,null))[_0x996d('0x2a')](function(_0x1d8917){if(_0x1d8917){_0x14d3d6=_0x1d8917[_0x996d('0x2c')]({'plain':!![]});_0x9e903d['model']=_['keys'](db['UserMailQueue'][_0x996d('0x32')]);_0x9e903d[_0x996d('0x38')]=_[_0x996d('0x37')](_0x39f800[_0x996d('0x38')]);_0x9e903d[_0x996d('0x39')]=_[_0x996d('0x4b')](_0x9e903d[_0x996d('0x35')],_0x9e903d[_0x996d('0x38')]);_0x4ca59e['attributes']=_[_0x996d('0x4b')](_0x9e903d[_0x996d('0x35')],qs[_0x996d('0x3b')](_0x39f800[_0x996d('0x38')][_0x996d('0x3b')]));_0x4ca59e['attributes']=_0x4ca59e[_0x996d('0x3a')]['length']?_0x4ca59e[_0x996d('0x3a')]:_0x9e903d[_0x996d('0x35')];if(!_0x39f800[_0x996d('0x38')]['hasOwnProperty'](_0x996d('0x58'))){_0x4ca59e[_0x996d('0x3e')]=qs[_0x996d('0x3e')](_0x39f800[_0x996d('0x38')][_0x996d('0x3e')]);_0x4ca59e[_0x996d('0x23')]=qs[_0x996d('0x23')](_0x39f800[_0x996d('0x38')][_0x996d('0x23')]);}_0x4ca59e[_0x996d('0x59')]=qs[_0x996d('0x3f')](_0x39f800[_0x996d('0x38')]['sort']);_0x4ca59e[_0x996d('0x42')]=qs[_0x996d('0x39')](_['pick'](_0x39f800[_0x996d('0x38')],_0x9e903d[_0x996d('0x39')]));_0x4ca59e[_0x996d('0x42')][_0x996d('0x5a')]=_0x1d8917['id'];if(_0x39f800['query']['filter']){_0x4ca59e['where']=_['merge'](_0x4ca59e['where'],{'$or':_['map'](_0x4ca59e[_0x996d('0x3a')],function(_0x4debca){var _0x2169fd={};_0x2169fd[_0x4debca]={'$like':'%'+_0x39f800[_0x996d('0x38')]['filter']+'%'};return _0x2169fd;})});}_0x4ca59e=_[_0x996d('0x43')]({},_0x4ca59e,_0x39f800['options']);return db[_0x996d('0x5b')][_0x996d('0x47')](_0x4ca59e);}})['then'](function(_0x38dd68){if(_0x38dd68){return db[_0x996d('0x5c')][_0x996d('0x5d')]({'where':{'id':_[_0x996d('0x36')](_0x38dd68,_0x996d('0x5e')),'role':_0x996d('0x5f')},'attributes':['id',_0x996d('0x30'),_0x996d('0x60'),'updatedAt',_0x996d('0x61')]});}})[_0x996d('0x2a')](function(_0x86a834){if(_0x86a834){return{'count':_0x86a834[_0x996d('0x22')],'rows':_[_0x996d('0x36')](_0x86a834[_0x996d('0x48')],function(_0x313316){return{'membername':_0x313316[_0x996d('0x30')],'UserId':_0x313316['id'],'queue_name':_0x14d3d6['name'],'MailQueueId':_0x14d3d6['id'],'interface':util['format'](_0x996d('0x62'),'SIP',_0x313316[_0x996d('0x30')]),'penalty':0x0,'paused':_0x313316[_0x996d('0x60')],'createdAt':_0x313316[_0x996d('0x61')],'updatedAt':_0x313316[_0x996d('0x63')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x996d('0x2a')](respondWithFilteredResult(_0x54ec62,_0x4ca59e))['catch'](handleError(_0x54ec62,null));};exports['getTeams']=function(_0x3868bc,_0x288690,_0x231d0f){var _0x16d851={};var _0x3f0585={};var _0x3bb886;var _0x575099;return db['MailQueue']['findOne']({'where':{'id':_0x3868bc['params']['id']}})[_0x996d('0x2a')](handleEntityNotFound(_0x288690,null))[_0x996d('0x2a')](function(_0x4bf792){if(_0x4bf792){_0x3bb886=_0x4bf792;_0x3f0585['model']=_[_0x996d('0x37')](db[_0x996d('0x64')][_0x996d('0x32')]);_0x3f0585['query']=_[_0x996d('0x37')](_0x3868bc['query']);_0x3f0585[_0x996d('0x39')]=_[_0x996d('0x4b')](_0x3f0585[_0x996d('0x35')],_0x3f0585[_0x996d('0x38')]);_0x16d851[_0x996d('0x3a')]=_[_0x996d('0x4b')](_0x3f0585[_0x996d('0x35')],qs[_0x996d('0x3b')](_0x3868bc[_0x996d('0x38')]['fields']));_0x16d851['attributes']=_0x16d851[_0x996d('0x3a')][_0x996d('0x3c')]?_0x16d851['attributes']:_0x3f0585[_0x996d('0x35')];_0x16d851[_0x996d('0x59')]=qs['sort'](_0x3868bc[_0x996d('0x38')][_0x996d('0x3f')]);_0x16d851[_0x996d('0x42')]=qs['filters'](_['pick'](_0x3868bc[_0x996d('0x38')],_0x3f0585[_0x996d('0x39')]));if(_0x3868bc['query'][_0x996d('0x41')]){_0x16d851[_0x996d('0x42')]=_['merge'](_0x16d851[_0x996d('0x42')],{'$or':_[_0x996d('0x36')](_0x16d851[_0x996d('0x3a')],function(_0x448bac){var _0x226a4e={};_0x226a4e[_0x448bac]={'$like':'%'+_0x3868bc['query'][_0x996d('0x41')]+'%'};return _0x226a4e;})});}_0x16d851=_[_0x996d('0x43')]({},_0x16d851,_0x3868bc[_0x996d('0x4c')]);return _0x3bb886[_0x996d('0x65')](_0x16d851);}})[_0x996d('0x2a')](function(_0x10b38d){if(_0x10b38d){_0x575099=_0x10b38d[_0x996d('0x3c')];if(!_0x3868bc[_0x996d('0x38')][_0x996d('0x3d')]('nolimit')){_0x16d851['limit']=qs[_0x996d('0x3e')](_0x3868bc[_0x996d('0x38')][_0x996d('0x3e')]);_0x16d851[_0x996d('0x23')]=qs[_0x996d('0x23')](_0x3868bc[_0x996d('0x38')][_0x996d('0x23')]);}return _0x3bb886[_0x996d('0x65')](_0x16d851);}})[_0x996d('0x2a')](function(_0x2209d0){if(_0x2209d0){return _0x2209d0?{'count':_0x575099,'rows':_0x2209d0}:null;}})['then'](respondWithResult(_0x288690,null))[_0x996d('0x49')](handleError(_0x288690,null));};exports['addTeams']=function(_0x1496e9,_0x38f488,_0x27b416){var _0x52a320=_0x1496e9[_0x996d('0x55')]['ids'];return db['Team'][_0x996d('0x47')]({'where':{'id':_0x52a320},'attributes':['id'],'include':[{'model':db[_0x996d('0x5c')],'as':_0x996d('0x66'),'attributes':['id','name',_0x996d('0x67'),'voicePause','interface'],'raw':!![]}]})[_0x996d('0x2a')](function(_0x216687){if(_0x216687){var _0x5bdb90=_[_0x996d('0x68')](_0x216687,function(_0x1d1ef2){var _0x197fca=_0x1d1ef2[_0x996d('0x2c')]({'plain':!![]});return _0x197fca[_0x996d('0x66')];});return db['MailQueue']['find']({'where':{'id':_0x1496e9[_0x996d('0x4a')]['id']}})[_0x996d('0x2a')](function(_0x2904f6){return db[_0x996d('0x69')]['transaction'](function(_0xa4e00c){return _0x2904f6[_0x996d('0x6a')](_0x52a320,{'transaction':_0xa4e00c})[_0x996d('0x2a')](function(){return BPromise[_0x996d('0x6b')](_0x5bdb90,function(_0x5ca299){return db[_0x996d('0x5b')][_0x996d('0x6c')]({'where':{'UserId':_0x5ca299['id'],'MailQueueId':_0x1496e9['params']['id']},'transaction':_0xa4e00c});});})[_0x996d('0x2a')](function(){_0x5bdb90[_0x996d('0x6d')](function(_0x5497c0){socket[_0x996d('0x6e')](_0x996d('0x6f'),{'UserId':_0x5497c0['id'],'MailQueueId':_0x2904f6['id']});});});});});}})[_0x996d('0x2a')](respondWithStatusCode(_0x38f488,null))[_0x996d('0x49')](handleError(_0x38f488,null));};exports[_0x996d('0x70')]=function(_0x5a37e1,_0x2fd642,_0x47f38f){return db['Team'][_0x996d('0x47')]({'where':{'id':_0x5a37e1[_0x996d('0x38')]['ids']},'attributes':['id'],'include':[{'model':db[_0x996d('0x5c')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x996d('0x2a')](handleEntityNotFound(_0x2fd642,null))[_0x996d('0x2a')](function(_0xa4bda4){var _0x78e0e7=_[_0x996d('0x36')](_0xa4bda4,'id');var _0x2f9870=[];var _0x4b9b84=[];var _0x5062e6=squel['select']();_0x5062e6[_0x996d('0x71')](_0x996d('0x72'))[_0x996d('0x73')](_0x996d('0x74'),'tq')[_0x996d('0x75')](_0x996d('0x76'),'ut',_0x996d('0x77'))['where'](_0x996d('0x78'),_0x5a37e1[_0x996d('0x4a')]['id']);for(var _0x507296=0x0;_0x507296<_0xa4bda4[_0x996d('0x3c')];_0x507296+=0x1){let _0x4821ec=_0xa4bda4[_0x507296];for(var _0x145baa=0x0;_0x145baa<_0x4821ec[_0x996d('0x66')][_0x996d('0x3c')];_0x145baa+=0x1){let _0x10c5b7=_0x4821ec[_0x996d('0x66')][_0x145baa];var _0x34cff9=_0x5062e6[_0x996d('0x79')]();_0x34cff9[_0x996d('0x42')](_0x996d('0x7a'),_0x10c5b7['id']);_0x4b9b84[_0x996d('0x7b')](db[_0x996d('0x69')][_0x996d('0x38')](_0x34cff9['toString'](),{'type':db[_0x996d('0x69')]['QueryTypes']['SELECT']})[_0x996d('0x2a')](function(_0x5a2f6b){if(_0x5a2f6b['length']===0x1){return _0x10c5b7['id'];}else{var _0x56804d=_[_0x996d('0x7c')](_[_0x996d('0x36')](_0x5a2f6b,_0x996d('0x7d')),function(_0x59306c){return _[_0x996d('0x7e')](_0x78e0e7,_0x59306c);});if(_0x56804d){return _0x10c5b7['id'];}}}));}}return BPromise[_0x996d('0x7f')](_0x4b9b84)[_0x996d('0x2a')](function(_0x49af19){_0x2f9870=_(_0x2f9870)[_0x996d('0x80')](_0x49af19)['compact']()['value']();return db[_0x996d('0x44')][_0x996d('0x4d')]({'where':{'id':_0x5a37e1[_0x996d('0x4a')]['id']}})[_0x996d('0x2a')](function(_0x49a4af){return db['sequelize'][_0x996d('0x81')](function(_0xebbff2){return _0x49a4af[_0x996d('0x70')](_0x5a37e1[_0x996d('0x38')][_0x996d('0x82')],{'transaction':_0xebbff2})[_0x996d('0x2a')](function(){if(!_['isEmpty'](_0x2f9870)){return _0x49a4af[_0x996d('0x83')](_0x2f9870,{'transaction':_0xebbff2});}})[_0x996d('0x2a')](function(){_0x2f9870['forEach'](function(_0xeea435){socket[_0x996d('0x6e')](_0x996d('0x84'),{'UserId':_0xeea435,'MailQueueId':_0x49a4af['id']});});});});});});})[_0x996d('0x2a')](respondWithStatusCode(_0x2fd642,null))['catch'](handleError(_0x2fd642,null));};exports[_0x996d('0x85')]=function(_0x318eb1,_0x3e7d74,_0x8d6f71){return db[_0x996d('0x44')]['find']({'where':{'id':_0x318eb1[_0x996d('0x4a')]['id']}})[_0x996d('0x2a')](handleEntityNotFound(_0x3e7d74,null))[_0x996d('0x2a')](function(_0x490159){if(_0x490159){return _0x490159[_0x996d('0x85')](_0x318eb1[_0x996d('0x55')][_0x996d('0x82')],_[_0x996d('0x86')](_0x318eb1[_0x996d('0x55')],[_0x996d('0x82'),'id'])||{})[_0x996d('0x87')](function(_0x3686f1){for(var _0x5318f3=0x0;_0x5318f3<_0x318eb1[_0x996d('0x55')][_0x996d('0x82')][_0x996d('0x3c')];_0x5318f3+=0x1){socket[_0x996d('0x6e')](_0x996d('0x6f'),{'UserId':_0x318eb1[_0x996d('0x55')]['ids'][_0x5318f3],'MailQueueId':_0x318eb1[_0x996d('0x4a')]['id']});}return _0x3686f1;});}})[_0x996d('0x2a')](respondWithResult(_0x3e7d74,null))['catch'](handleError(_0x3e7d74,null));};exports['removeAgents']=function(_0x818908,_0x5c17e,_0x2154bc){return db[_0x996d('0x44')][_0x996d('0x4d')]({'where':{'id':_0x818908[_0x996d('0x4a')]['id']}})[_0x996d('0x2a')](handleEntityNotFound(_0x5c17e,null))[_0x996d('0x2a')](function(_0x420819){if(_0x420819){return _0x420819[_0x996d('0x83')](_0x818908[_0x996d('0x38')][_0x996d('0x82')])[_0x996d('0x2a')](function(){if(_[_0x996d('0x88')](_0x818908[_0x996d('0x38')][_0x996d('0x82')])){for(var _0x1daf43=0x0;_0x1daf43<_0x818908[_0x996d('0x38')]['ids'][_0x996d('0x3c')];_0x1daf43+=0x1){socket[_0x996d('0x6e')](_0x996d('0x84'),{'UserId':Number(_0x818908[_0x996d('0x38')][_0x996d('0x82')][_0x1daf43]),'MailQueueId':Number(_0x818908[_0x996d('0x4a')]['id'])});}}else{socket['emit'](_0x996d('0x84'),{'UserId':Number(_0x818908[_0x996d('0x38')]['ids']),'MailQueueId':Number(_0x818908[_0x996d('0x4a')]['id'])});}});}})[_0x996d('0x2a')](respondWithStatusCode(_0x5c17e,null))['catch'](handleError(_0x5c17e,null));};exports[_0x996d('0x89')]=function(_0x4a2190,_0x100f35,_0x35abde){var _0x4f0fc3={};var _0x3f41a8={};var _0xfa7ce3;var _0x268cb3;return db['MailQueue'][_0x996d('0x57')]({'where':{'id':_0x4a2190[_0x996d('0x4a')]['id']}})['then'](handleEntityNotFound(_0x100f35,null))[_0x996d('0x2a')](function(_0x3d7884){if(_0x3d7884){_0xfa7ce3=_0x3d7884;_0x3f41a8['model']=_['keys'](db[_0x996d('0x5c')][_0x996d('0x32')]);_0x3f41a8['query']=_['keys'](_0x4a2190[_0x996d('0x38')]);_0x3f41a8[_0x996d('0x39')]=_[_0x996d('0x4b')](_0x3f41a8[_0x996d('0x35')],_0x3f41a8[_0x996d('0x38')]);_0x4f0fc3['attributes']=_[_0x996d('0x4b')](_0x3f41a8[_0x996d('0x35')],qs[_0x996d('0x3b')](_0x4a2190[_0x996d('0x38')][_0x996d('0x3b')]));_0x4f0fc3[_0x996d('0x3a')]=_0x4f0fc3[_0x996d('0x3a')][_0x996d('0x3c')]?_0x4f0fc3[_0x996d('0x3a')]:_0x3f41a8['model'];_0x4f0fc3['order']=qs[_0x996d('0x3f')](_0x4a2190[_0x996d('0x38')][_0x996d('0x3f')]);_0x4f0fc3[_0x996d('0x42')]=qs[_0x996d('0x39')](_['pick'](_0x4a2190[_0x996d('0x38')],_0x3f41a8[_0x996d('0x39')]));if(_0x4a2190[_0x996d('0x38')][_0x996d('0x41')]){_0x4f0fc3[_0x996d('0x42')]=_[_0x996d('0x43')](_0x4f0fc3[_0x996d('0x42')],{'$or':_['map'](_0x4f0fc3[_0x996d('0x3a')],function(_0x356d3a){var _0x16fde3={};_0x16fde3[_0x356d3a]={'$like':'%'+_0x4a2190[_0x996d('0x38')]['filter']+'%'};return _0x16fde3;})});}_0x4f0fc3=_['merge']({},_0x4f0fc3,_0x4a2190['options']);return _0xfa7ce3['getAgents'](_0x4f0fc3);}})['then'](function(_0x3816b9){if(_0x3816b9){_0x268cb3=_0x3816b9['length'];if(!_0x4a2190[_0x996d('0x38')][_0x996d('0x3d')]('nolimit')){_0x4f0fc3[_0x996d('0x3e')]=qs[_0x996d('0x3e')](_0x4a2190['query'][_0x996d('0x3e')]);_0x4f0fc3[_0x996d('0x23')]=qs[_0x996d('0x23')](_0x4a2190[_0x996d('0x38')]['offset']);}return _0xfa7ce3[_0x996d('0x89')](_0x4f0fc3);}})[_0x996d('0x2a')](function(_0x3b7655){if(_0x3b7655){return _0x3b7655?{'count':_0x268cb3,'rows':_0x3b7655}:null;}})[_0x996d('0x2a')](respondWithResult(_0x100f35,null))[_0x996d('0x49')](handleError(_0x100f35,null));};
\ No newline at end of file
+var _0xd945=['crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./mailQueue.socket','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','MailQueues','UserProfileResource','error','stack','name','send','index','map','MailQueue','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','includeAll','include','findAll','rows','show','params','rawAttributes','options','find','create','body','user','get','UserProfileSection','userProfileId','autoAssociation','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','MailQueueId','UserMailQueue','User','findAndCountAll','UserId','agent','mailPause','createdAt','format','%s/%s','SIP','updatedAt','findOne','Team','getTeams','addTeams','ids','Agents','online','flatMap','findOrCreate','forEach','emit','userMailQueue:save','removeTeams','select','from','team_has_mail_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','push','sequelize','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','transaction','isEmpty','removeAgents','userMailQueue:remove','addAgents','omit','spread','isArray','getAgents','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash'];(function(_0x263db0,_0x740092){var _0x31d644=function(_0x42d301){while(--_0x42d301){_0x263db0['push'](_0x263db0['shift']());}};_0x31d644(++_0x740092);}(_0xd945,0x84));var _0x5d94=function(_0x72f600,_0x24b0ea){_0x72f600=_0x72f600-0x0;var _0x10ce6b=_0xd945[_0x72f600];return _0x10ce6b;};'use strict';var pdf=require(_0x5d94('0x0'));var emlformat=require(_0x5d94('0x1'));var rimraf=require(_0x5d94('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x5d94('0x3'));var rp=require(_0x5d94('0x4'));var moment=require(_0x5d94('0x5'));var BPromise=require(_0x5d94('0x6'));var Mustache=require(_0x5d94('0x7'));var util=require('util');var path=require(_0x5d94('0x8'));var sox=require(_0x5d94('0x9'));var csv=require(_0x5d94('0xa'));var ejs=require(_0x5d94('0xb'));var fs=require('fs');var _=require(_0x5d94('0xc'));var squel=require('squel');var crypto=require(_0x5d94('0xd'));var jsforce=require(_0x5d94('0xe'));var deskjs=require(_0x5d94('0xf'));var toCsv=require('to-csv');var querystring=require(_0x5d94('0x10'));var Papa=require(_0x5d94('0x11'));var Redis=require(_0x5d94('0x12'));var authService=require(_0x5d94('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0x5d94('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x5d94('0x15'))(_0x5d94('0x16'));var utils=require(_0x5d94('0x17'));var config=require(_0x5d94('0x18'));var licenseUtil=require(_0x5d94('0x19'));var db=require(_0x5d94('0x1a'))['db'];config[_0x5d94('0x1b')]=_[_0x5d94('0x1c')](config[_0x5d94('0x1b')],{'host':_0x5d94('0x1d'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x5d94('0x1b')]));require(_0x5d94('0x1e'))['register'](socket);function respondWithStatusCode(_0x1d8291,_0x427eb2){_0x427eb2=_0x427eb2||0xcc;return function(_0xd78460){if(_0xd78460){return _0x1d8291[_0x5d94('0x1f')](_0x427eb2);}return _0x1d8291[_0x5d94('0x20')](_0x427eb2)[_0x5d94('0x21')]();};}function respondWithResult(_0x5c4d65,_0x555419){_0x555419=_0x555419||0xc8;return function(_0x541ef1){if(_0x541ef1){return _0x5c4d65[_0x5d94('0x20')](_0x555419)[_0x5d94('0x22')](_0x541ef1);}};}function respondWithFilteredResult(_0x1ef529,_0x133ee5){return function(_0x12c238){if(_0x12c238){var _0x47ea45=_0x12c238[_0x5d94('0x23')],_0x322380=_0x133ee5[_0x5d94('0x24')],_0xe34c3a=_0x133ee5[_0x5d94('0x24')]+_0x133ee5[_0x5d94('0x25')],_0x338568;if(_0xe34c3a>=_0x47ea45){_0xe34c3a=_0x47ea45;_0x338568=0xc8;}else{_0x338568=0xce;}_0x1ef529[_0x5d94('0x20')](_0x338568);return _0x1ef529[_0x5d94('0x26')](_0x5d94('0x27'),_0x322380+'-'+_0xe34c3a+'/'+_0x47ea45)[_0x5d94('0x22')](_0x12c238);}return null;};}function patchUpdates(_0x1a0bd5){return function(_0xe21853){try{jsonpatch['apply'](_0xe21853,_0x1a0bd5,!![]);}catch(_0x2da8ba){return BPromise[_0x5d94('0x28')](_0x2da8ba);}return _0xe21853[_0x5d94('0x29')]();};}function saveUpdates(_0x2a643f,_0x2b867b){return function(_0x15fe07){if(_0x15fe07){return _0x15fe07[_0x5d94('0x2a')](_0x2a643f)[_0x5d94('0x2b')](function(_0x2f12d9){return _0x2f12d9;});}return null;};}function removeEntity(_0x40c0a6,_0x100aa2){return function(_0x330d46){if(_0x330d46){return _0x330d46[_0x5d94('0x2c')]()[_0x5d94('0x2b')](function(){var _0x1c1344=_0x330d46['get']({'plain':!![]});var _0x374c3f=_0x5d94('0x2d');return db[_0x5d94('0x2e')][_0x5d94('0x2c')]({'where':{'type':_0x374c3f,'resourceId':_0x1c1344['id']}})[_0x5d94('0x2b')](function(){return _0x330d46;});})[_0x5d94('0x2b')](function(){_0x40c0a6[_0x5d94('0x20')](0xcc)[_0x5d94('0x21')]();});}};}function handleEntityNotFound(_0x2f3b3e,_0x456c59){return function(_0x235d18){if(!_0x235d18){_0x2f3b3e['sendStatus'](0x194);}return _0x235d18;};}function handleError(_0x5a117f,_0xbf0bc6){_0xbf0bc6=_0xbf0bc6||0x1f4;return function(_0x54d4df){logger[_0x5d94('0x2f')](_0x54d4df[_0x5d94('0x30')]);if(_0x54d4df[_0x5d94('0x31')]){delete _0x54d4df[_0x5d94('0x31')];}_0x5a117f[_0x5d94('0x20')](_0xbf0bc6)[_0x5d94('0x32')](_0x54d4df);};}exports[_0x5d94('0x33')]=function(_0x12a145,_0x20f6ba){var _0x150f56={},_0x530fe5={},_0x4eb1fc={'count':0x0,'rows':[]};var _0x60def0=_[_0x5d94('0x34')](db[_0x5d94('0x35')]['rawAttributes'],function(_0x5c4d90){return{'name':_0x5c4d90['fieldName'],'type':_0x5c4d90[_0x5d94('0x36')]['key']};});_0x530fe5[_0x5d94('0x37')]=_[_0x5d94('0x34')](_0x60def0,_0x5d94('0x31'));_0x530fe5[_0x5d94('0x38')]=_[_0x5d94('0x39')](_0x12a145[_0x5d94('0x38')]);_0x530fe5[_0x5d94('0x3a')]=_[_0x5d94('0x3b')](_0x530fe5['model'],_0x530fe5[_0x5d94('0x38')]);_0x150f56[_0x5d94('0x3c')]=_[_0x5d94('0x3b')](_0x530fe5[_0x5d94('0x37')],qs['fields'](_0x12a145['query'][_0x5d94('0x3d')]));_0x150f56['attributes']=_0x150f56['attributes'][_0x5d94('0x3e')]?_0x150f56[_0x5d94('0x3c')]:_0x530fe5['model'];if(!_0x12a145['query'][_0x5d94('0x3f')](_0x5d94('0x40'))){_0x150f56['limit']=qs[_0x5d94('0x25')](_0x12a145[_0x5d94('0x38')][_0x5d94('0x25')]);_0x150f56[_0x5d94('0x24')]=qs[_0x5d94('0x24')](_0x12a145[_0x5d94('0x38')][_0x5d94('0x24')]);}_0x150f56[_0x5d94('0x41')]=qs[_0x5d94('0x42')](_0x12a145[_0x5d94('0x38')]['sort']);_0x150f56[_0x5d94('0x43')]=qs[_0x5d94('0x3a')](_[_0x5d94('0x44')](_0x12a145[_0x5d94('0x38')],_0x530fe5['filters']),_0x60def0);if(_0x12a145[_0x5d94('0x38')][_0x5d94('0x45')]){_0x150f56['where']=_['merge'](_0x150f56[_0x5d94('0x43')],{'$or':_[_0x5d94('0x34')](_0x60def0,function(_0xdb10a5){if(_0xdb10a5[_0x5d94('0x36')]!==_0x5d94('0x46')){var _0x5e8dfd={};_0x5e8dfd[_0xdb10a5[_0x5d94('0x31')]]={'$like':'%'+_0x12a145[_0x5d94('0x38')][_0x5d94('0x45')]+'%'};return _0x5e8dfd;}})});}_0x150f56=_[_0x5d94('0x47')]({},_0x150f56,_0x12a145['options']);var _0x1cf907={'where':_0x150f56[_0x5d94('0x43')]};return db[_0x5d94('0x35')]['count'](_0x1cf907)[_0x5d94('0x2b')](function(_0x4b7617){_0x4eb1fc['count']=_0x4b7617;if(_0x12a145['query'][_0x5d94('0x48')]){_0x150f56[_0x5d94('0x49')]=[{'all':!![]}];}return db[_0x5d94('0x35')][_0x5d94('0x4a')](_0x150f56);})['then'](function(_0xa901c){_0x4eb1fc[_0x5d94('0x4b')]=_0xa901c;return _0x4eb1fc;})['then'](respondWithFilteredResult(_0x20f6ba,_0x150f56))['catch'](handleError(_0x20f6ba,null));};exports[_0x5d94('0x4c')]=function(_0x257836,_0x5b0a31){var _0x78b2b9={'raw':!![],'where':{'id':_0x257836[_0x5d94('0x4d')]['id']}},_0x57dd01={};_0x57dd01['model']=_[_0x5d94('0x39')](db[_0x5d94('0x35')][_0x5d94('0x4e')]);_0x57dd01[_0x5d94('0x38')]=_[_0x5d94('0x39')](_0x257836[_0x5d94('0x38')]);_0x57dd01['filters']=_[_0x5d94('0x3b')](_0x57dd01[_0x5d94('0x37')],_0x57dd01[_0x5d94('0x38')]);_0x78b2b9[_0x5d94('0x3c')]=_['intersection'](_0x57dd01[_0x5d94('0x37')],qs['fields'](_0x257836['query'][_0x5d94('0x3d')]));_0x78b2b9[_0x5d94('0x3c')]=_0x78b2b9[_0x5d94('0x3c')][_0x5d94('0x3e')]?_0x78b2b9[_0x5d94('0x3c')]:_0x57dd01[_0x5d94('0x37')];if(_0x257836['query']['includeAll']){_0x78b2b9[_0x5d94('0x49')]=[{'all':!![]}];}_0x78b2b9=_[_0x5d94('0x47')]({},_0x78b2b9,_0x257836[_0x5d94('0x4f')]);return db[_0x5d94('0x35')][_0x5d94('0x50')](_0x78b2b9)[_0x5d94('0x2b')](handleEntityNotFound(_0x5b0a31,null))[_0x5d94('0x2b')](respondWithResult(_0x5b0a31,null))['catch'](handleError(_0x5b0a31,null));};exports[_0x5d94('0x51')]=function(_0x1c2b06,_0x5c6521){return db[_0x5d94('0x35')][_0x5d94('0x51')](_0x1c2b06[_0x5d94('0x52')],{})[_0x5d94('0x2b')](function(_0x40e595){var _0x12e049=_0x1c2b06[_0x5d94('0x53')][_0x5d94('0x54')]({'plain':!![]});if(!_0x12e049)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x12e049['role']===_0x5d94('0x53')){var _0x38d21a=_0x40e595[_0x5d94('0x54')]({'plain':!![]});var _0x134689='MailQueues';return db[_0x5d94('0x55')][_0x5d94('0x50')]({'where':{'name':_0x134689,'userProfileId':_0x12e049[_0x5d94('0x56')]},'raw':!![]})['then'](function(_0x3178e0){if(_0x3178e0&&_0x3178e0[_0x5d94('0x57')]===0x0){return db[_0x5d94('0x2e')][_0x5d94('0x51')]({'name':_0x38d21a['name'],'resourceId':_0x38d21a['id'],'type':_0x3178e0[_0x5d94('0x31')],'sectionId':_0x3178e0['id']},{})[_0x5d94('0x2b')](function(){return _0x40e595;});}else{return _0x40e595;}})[_0x5d94('0x58')](function(_0x4987cd){logger[_0x5d94('0x2f')](_0x5d94('0x59'),_0x4987cd);throw _0x4987cd;});}return _0x40e595;})[_0x5d94('0x2b')](respondWithResult(_0x5c6521,0xc9))['catch'](handleError(_0x5c6521,null));};exports[_0x5d94('0x2a')]=function(_0x15ed7e,_0x447338){if(_0x15ed7e[_0x5d94('0x52')]['id']){delete _0x15ed7e[_0x5d94('0x52')]['id'];}return db[_0x5d94('0x35')][_0x5d94('0x50')]({'where':{'id':_0x15ed7e[_0x5d94('0x4d')]['id']}})[_0x5d94('0x2b')](handleEntityNotFound(_0x447338,null))[_0x5d94('0x2b')](saveUpdates(_0x15ed7e['body'],null))[_0x5d94('0x2b')](respondWithResult(_0x447338,null))[_0x5d94('0x58')](handleError(_0x447338,null));};exports[_0x5d94('0x2c')]=function(_0xc27d01,_0x32944c){return db[_0x5d94('0x35')]['find']({'where':{'id':_0xc27d01[_0x5d94('0x4d')]['id']}})[_0x5d94('0x2b')](handleEntityNotFound(_0x32944c,null))[_0x5d94('0x2b')](removeEntity(_0x32944c,null))[_0x5d94('0x58')](handleError(_0x32944c,null));};exports[_0x5d94('0x5a')]=function(_0x330698,_0x5ddd2e){return db[_0x5d94('0x35')][_0x5d94('0x5a')]()['then'](respondWithResult(_0x5ddd2e,null))['catch'](handleError(_0x5ddd2e,null));};exports[_0x5d94('0x5b')]=function(_0x51de26,_0x6a9625,_0x13ab17){var _0x1288dc={'raw':!![],'where':{}},_0x2b448e={},_0xe44937;return db['MailQueue']['findOne']({'where':{'id':_0x51de26[_0x5d94('0x4d')]['id']}})['then'](handleEntityNotFound(_0x6a9625,null))[_0x5d94('0x2b')](function(_0x12aec2){if(_0x12aec2){_0xe44937=_0x12aec2[_0x5d94('0x54')]({'plain':!![]});_0x2b448e[_0x5d94('0x37')]=_[_0x5d94('0x39')](db['UserMailQueue'][_0x5d94('0x4e')]);_0x2b448e['query']=_[_0x5d94('0x39')](_0x51de26[_0x5d94('0x38')]);_0x2b448e[_0x5d94('0x3a')]=_[_0x5d94('0x3b')](_0x2b448e[_0x5d94('0x37')],_0x2b448e[_0x5d94('0x38')]);_0x1288dc[_0x5d94('0x3c')]=_[_0x5d94('0x3b')](_0x2b448e[_0x5d94('0x37')],qs[_0x5d94('0x3d')](_0x51de26[_0x5d94('0x38')][_0x5d94('0x3d')]));_0x1288dc[_0x5d94('0x3c')]=_0x1288dc[_0x5d94('0x3c')][_0x5d94('0x3e')]?_0x1288dc[_0x5d94('0x3c')]:_0x2b448e[_0x5d94('0x37')];if(!_0x51de26[_0x5d94('0x38')][_0x5d94('0x3f')](_0x5d94('0x40'))){_0x1288dc[_0x5d94('0x25')]=qs[_0x5d94('0x25')](_0x51de26['query'][_0x5d94('0x25')]);_0x1288dc['offset']=qs['offset'](_0x51de26[_0x5d94('0x38')][_0x5d94('0x24')]);}_0x1288dc['order']=qs[_0x5d94('0x42')](_0x51de26[_0x5d94('0x38')][_0x5d94('0x42')]);_0x1288dc[_0x5d94('0x43')]=qs[_0x5d94('0x3a')](_[_0x5d94('0x44')](_0x51de26[_0x5d94('0x38')],_0x2b448e[_0x5d94('0x3a')]));_0x1288dc[_0x5d94('0x43')][_0x5d94('0x5c')]=_0x12aec2['id'];if(_0x51de26[_0x5d94('0x38')]['filter']){_0x1288dc[_0x5d94('0x43')]=_[_0x5d94('0x47')](_0x1288dc[_0x5d94('0x43')],{'$or':_[_0x5d94('0x34')](_0x1288dc[_0x5d94('0x3c')],function(_0x51dedb){var _0x6a4ccd={};_0x6a4ccd[_0x51dedb]={'$like':'%'+_0x51de26[_0x5d94('0x38')][_0x5d94('0x45')]+'%'};return _0x6a4ccd;})});}_0x1288dc=_['merge']({},_0x1288dc,_0x51de26['options']);return db[_0x5d94('0x5d')]['findAll'](_0x1288dc);}})[_0x5d94('0x2b')](function(_0x18a1e6){if(_0x18a1e6){return db[_0x5d94('0x5e')][_0x5d94('0x5f')]({'where':{'id':_[_0x5d94('0x34')](_0x18a1e6,_0x5d94('0x60')),'role':_0x5d94('0x61')},'attributes':['id',_0x5d94('0x31'),_0x5d94('0x62'),'updatedAt',_0x5d94('0x63')]});}})['then'](function(_0xa8576d){if(_0xa8576d){return{'count':_0xa8576d[_0x5d94('0x23')],'rows':_[_0x5d94('0x34')](_0xa8576d[_0x5d94('0x4b')],function(_0xe59c79){return{'membername':_0xe59c79['name'],'UserId':_0xe59c79['id'],'queue_name':_0xe44937['name'],'MailQueueId':_0xe44937['id'],'interface':util[_0x5d94('0x64')](_0x5d94('0x65'),_0x5d94('0x66'),_0xe59c79[_0x5d94('0x31')]),'penalty':0x0,'paused':_0xe59c79[_0x5d94('0x62')],'createdAt':_0xe59c79[_0x5d94('0x63')],'updatedAt':_0xe59c79[_0x5d94('0x67')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x5d94('0x2b')](respondWithFilteredResult(_0x6a9625,_0x1288dc))[_0x5d94('0x58')](handleError(_0x6a9625,null));};exports['getTeams']=function(_0x28e61e,_0x3ace9c,_0x4cc339){var _0x27911d={};var _0x4ddb87={};var _0x5f45a9;var _0x13c988;return db['MailQueue'][_0x5d94('0x68')]({'where':{'id':_0x28e61e[_0x5d94('0x4d')]['id']}})[_0x5d94('0x2b')](handleEntityNotFound(_0x3ace9c,null))[_0x5d94('0x2b')](function(_0x8a97a9){if(_0x8a97a9){_0x5f45a9=_0x8a97a9;_0x4ddb87['model']=_[_0x5d94('0x39')](db[_0x5d94('0x69')][_0x5d94('0x4e')]);_0x4ddb87['query']=_[_0x5d94('0x39')](_0x28e61e[_0x5d94('0x38')]);_0x4ddb87['filters']=_[_0x5d94('0x3b')](_0x4ddb87[_0x5d94('0x37')],_0x4ddb87[_0x5d94('0x38')]);_0x27911d['attributes']=_[_0x5d94('0x3b')](_0x4ddb87[_0x5d94('0x37')],qs['fields'](_0x28e61e[_0x5d94('0x38')][_0x5d94('0x3d')]));_0x27911d[_0x5d94('0x3c')]=_0x27911d['attributes'][_0x5d94('0x3e')]?_0x27911d[_0x5d94('0x3c')]:_0x4ddb87[_0x5d94('0x37')];_0x27911d['order']=qs[_0x5d94('0x42')](_0x28e61e[_0x5d94('0x38')][_0x5d94('0x42')]);_0x27911d[_0x5d94('0x43')]=qs[_0x5d94('0x3a')](_[_0x5d94('0x44')](_0x28e61e[_0x5d94('0x38')],_0x4ddb87[_0x5d94('0x3a')]));if(_0x28e61e[_0x5d94('0x38')][_0x5d94('0x45')]){_0x27911d['where']=_[_0x5d94('0x47')](_0x27911d['where'],{'$or':_['map'](_0x27911d[_0x5d94('0x3c')],function(_0x4e13aa){var _0x2f8ab1={};_0x2f8ab1[_0x4e13aa]={'$like':'%'+_0x28e61e[_0x5d94('0x38')][_0x5d94('0x45')]+'%'};return _0x2f8ab1;})});}_0x27911d=_[_0x5d94('0x47')]({},_0x27911d,_0x28e61e['options']);return _0x5f45a9['getTeams'](_0x27911d);}})[_0x5d94('0x2b')](function(_0x156da9){if(_0x156da9){_0x13c988=_0x156da9[_0x5d94('0x3e')];if(!_0x28e61e[_0x5d94('0x38')][_0x5d94('0x3f')](_0x5d94('0x40'))){_0x27911d[_0x5d94('0x25')]=qs['limit'](_0x28e61e[_0x5d94('0x38')][_0x5d94('0x25')]);_0x27911d[_0x5d94('0x24')]=qs[_0x5d94('0x24')](_0x28e61e[_0x5d94('0x38')]['offset']);}return _0x5f45a9[_0x5d94('0x6a')](_0x27911d);}})[_0x5d94('0x2b')](function(_0x474b50){if(_0x474b50){return _0x474b50?{'count':_0x13c988,'rows':_0x474b50}:null;}})[_0x5d94('0x2b')](respondWithResult(_0x3ace9c,null))['catch'](handleError(_0x3ace9c,null));};exports[_0x5d94('0x6b')]=function(_0x390543,_0x50382c,_0xcc8815){var _0x347be0=_0x390543[_0x5d94('0x52')][_0x5d94('0x6c')];return db[_0x5d94('0x69')][_0x5d94('0x4a')]({'where':{'id':_0x347be0},'attributes':['id'],'include':[{'model':db[_0x5d94('0x5e')],'as':_0x5d94('0x6d'),'attributes':['id',_0x5d94('0x31'),_0x5d94('0x6e'),'voicePause','interface'],'raw':!![]}]})[_0x5d94('0x2b')](function(_0x3f9595){if(_0x3f9595){var _0x31a1ed=_[_0x5d94('0x6f')](_0x3f9595,function(_0x352c05){var _0x7fe8cf=_0x352c05[_0x5d94('0x54')]({'plain':!![]});return _0x7fe8cf[_0x5d94('0x6d')];});return db[_0x5d94('0x35')][_0x5d94('0x50')]({'where':{'id':_0x390543['params']['id']}})['then'](function(_0x26586f){return db['sequelize']['transaction'](function(_0x59d9ab){return _0x26586f['addTeams'](_0x347be0,{'transaction':_0x59d9ab})[_0x5d94('0x2b')](function(){return BPromise['each'](_0x31a1ed,function(_0x3a9a7c){return db['UserMailQueue'][_0x5d94('0x70')]({'where':{'UserId':_0x3a9a7c['id'],'MailQueueId':_0x390543[_0x5d94('0x4d')]['id']},'transaction':_0x59d9ab});});})[_0x5d94('0x2b')](function(){_0x31a1ed[_0x5d94('0x71')](function(_0x4a8e9a){socket[_0x5d94('0x72')](_0x5d94('0x73'),{'UserId':_0x4a8e9a['id'],'MailQueueId':_0x26586f['id']});});});});});}})[_0x5d94('0x2b')](respondWithStatusCode(_0x50382c,null))[_0x5d94('0x58')](handleError(_0x50382c,null));};exports[_0x5d94('0x74')]=function(_0x2864d7,_0x51fd62,_0x12e683){return db[_0x5d94('0x69')][_0x5d94('0x4a')]({'where':{'id':_0x2864d7[_0x5d94('0x38')][_0x5d94('0x6c')]},'attributes':['id'],'include':[{'model':db[_0x5d94('0x5e')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x5d94('0x2b')](handleEntityNotFound(_0x51fd62,null))[_0x5d94('0x2b')](function(_0x33d33b){var _0x4c46be=_[_0x5d94('0x34')](_0x33d33b,'id');var _0x104ae9=[];var _0x31b51c=[];var _0x35efe7=squel[_0x5d94('0x75')]();_0x35efe7['field']('tq.TeamId')[_0x5d94('0x76')](_0x5d94('0x77'),'tq')['join'](_0x5d94('0x78'),'ut',_0x5d94('0x79'))[_0x5d94('0x43')](_0x5d94('0x7a'),_0x2864d7['params']['id']);for(var _0x528c14=0x0;_0x528c14<_0x33d33b[_0x5d94('0x3e')];_0x528c14+=0x1){let _0x59462f=_0x33d33b[_0x528c14];for(var _0x5a0827=0x0;_0x5a0827<_0x59462f[_0x5d94('0x6d')][_0x5d94('0x3e')];_0x5a0827+=0x1){let _0x2bb97b=_0x59462f[_0x5d94('0x6d')][_0x5a0827];var _0x138922=_0x35efe7[_0x5d94('0x7b')]();_0x138922['where']('ut.UserId\x20=\x20?',_0x2bb97b['id']);_0x31b51c[_0x5d94('0x7c')](db[_0x5d94('0x7d')][_0x5d94('0x38')](_0x138922[_0x5d94('0x7e')](),{'type':db[_0x5d94('0x7d')][_0x5d94('0x7f')][_0x5d94('0x80')]})[_0x5d94('0x2b')](function(_0x352bc1){if(_0x352bc1[_0x5d94('0x3e')]===0x1){return _0x2bb97b['id'];}else{var _0x2a11aa=_[_0x5d94('0x81')](_['map'](_0x352bc1,_0x5d94('0x82')),function(_0x539309){return _[_0x5d94('0x83')](_0x4c46be,_0x539309);});if(_0x2a11aa){return _0x2bb97b['id'];}}}));}}return BPromise[_0x5d94('0x84')](_0x31b51c)[_0x5d94('0x2b')](function(_0x217dfd){_0x104ae9=_(_0x104ae9)[_0x5d94('0x85')](_0x217dfd)[_0x5d94('0x86')]()[_0x5d94('0x87')]();return db[_0x5d94('0x35')][_0x5d94('0x50')]({'where':{'id':_0x2864d7[_0x5d94('0x4d')]['id']}})['then'](function(_0x711220){return db[_0x5d94('0x7d')][_0x5d94('0x88')](function(_0x27698c){return _0x711220[_0x5d94('0x74')](_0x2864d7[_0x5d94('0x38')][_0x5d94('0x6c')],{'transaction':_0x27698c})[_0x5d94('0x2b')](function(){if(!_[_0x5d94('0x89')](_0x104ae9)){return _0x711220[_0x5d94('0x8a')](_0x104ae9,{'transaction':_0x27698c});}})[_0x5d94('0x2b')](function(){_0x104ae9[_0x5d94('0x71')](function(_0x337821){socket['emit'](_0x5d94('0x8b'),{'UserId':_0x337821,'MailQueueId':_0x711220['id']});});});});});});})[_0x5d94('0x2b')](respondWithStatusCode(_0x51fd62,null))['catch'](handleError(_0x51fd62,null));};exports[_0x5d94('0x8c')]=function(_0x522922,_0x226f68,_0x4f16fb){return db[_0x5d94('0x35')][_0x5d94('0x50')]({'where':{'id':_0x522922[_0x5d94('0x4d')]['id']}})[_0x5d94('0x2b')](handleEntityNotFound(_0x226f68,null))[_0x5d94('0x2b')](function(_0x432bcf){if(_0x432bcf){return _0x432bcf[_0x5d94('0x8c')](_0x522922[_0x5d94('0x52')][_0x5d94('0x6c')],_[_0x5d94('0x8d')](_0x522922[_0x5d94('0x52')],[_0x5d94('0x6c'),'id'])||{})[_0x5d94('0x8e')](function(_0x559f59){for(var _0x5ae97e=0x0;_0x5ae97e<_0x522922['body'][_0x5d94('0x6c')][_0x5d94('0x3e')];_0x5ae97e+=0x1){socket['emit'](_0x5d94('0x73'),{'UserId':_0x522922['body'][_0x5d94('0x6c')][_0x5ae97e],'MailQueueId':_0x522922[_0x5d94('0x4d')]['id']});}return _0x559f59;});}})['then'](respondWithResult(_0x226f68,null))[_0x5d94('0x58')](handleError(_0x226f68,null));};exports[_0x5d94('0x8a')]=function(_0x5db7e0,_0xff69a6,_0x2381d2){return db[_0x5d94('0x35')]['find']({'where':{'id':_0x5db7e0[_0x5d94('0x4d')]['id']}})[_0x5d94('0x2b')](handleEntityNotFound(_0xff69a6,null))[_0x5d94('0x2b')](function(_0x4a5c24){if(_0x4a5c24){return _0x4a5c24[_0x5d94('0x8a')](_0x5db7e0[_0x5d94('0x38')]['ids'])[_0x5d94('0x2b')](function(){if(_[_0x5d94('0x8f')](_0x5db7e0[_0x5d94('0x38')]['ids'])){for(var _0x940191=0x0;_0x940191<_0x5db7e0[_0x5d94('0x38')][_0x5d94('0x6c')][_0x5d94('0x3e')];_0x940191+=0x1){socket[_0x5d94('0x72')](_0x5d94('0x8b'),{'UserId':Number(_0x5db7e0[_0x5d94('0x38')][_0x5d94('0x6c')][_0x940191]),'MailQueueId':Number(_0x5db7e0[_0x5d94('0x4d')]['id'])});}}else{socket['emit'](_0x5d94('0x8b'),{'UserId':Number(_0x5db7e0['query'][_0x5d94('0x6c')]),'MailQueueId':Number(_0x5db7e0[_0x5d94('0x4d')]['id'])});}});}})[_0x5d94('0x2b')](respondWithStatusCode(_0xff69a6,null))['catch'](handleError(_0xff69a6,null));};exports[_0x5d94('0x90')]=function(_0x4551d1,_0x6f921f,_0x580b77){var _0x7a8fc8={};var _0x480654={};var _0x20dde8;var _0xd2be2;return db['MailQueue'][_0x5d94('0x68')]({'where':{'id':_0x4551d1[_0x5d94('0x4d')]['id']}})['then'](handleEntityNotFound(_0x6f921f,null))[_0x5d94('0x2b')](function(_0x728d52){if(_0x728d52){_0x20dde8=_0x728d52;_0x480654[_0x5d94('0x37')]=_['keys'](db[_0x5d94('0x5e')][_0x5d94('0x4e')]);_0x480654['query']=_[_0x5d94('0x39')](_0x4551d1[_0x5d94('0x38')]);_0x480654[_0x5d94('0x3a')]=_[_0x5d94('0x3b')](_0x480654[_0x5d94('0x37')],_0x480654[_0x5d94('0x38')]);_0x7a8fc8[_0x5d94('0x3c')]=_['intersection'](_0x480654[_0x5d94('0x37')],qs['fields'](_0x4551d1['query'][_0x5d94('0x3d')]));_0x7a8fc8[_0x5d94('0x3c')]=_0x7a8fc8[_0x5d94('0x3c')][_0x5d94('0x3e')]?_0x7a8fc8['attributes']:_0x480654[_0x5d94('0x37')];_0x7a8fc8[_0x5d94('0x41')]=qs['sort'](_0x4551d1['query'][_0x5d94('0x42')]);_0x7a8fc8['where']=qs[_0x5d94('0x3a')](_['pick'](_0x4551d1[_0x5d94('0x38')],_0x480654[_0x5d94('0x3a')]));if(_0x4551d1[_0x5d94('0x38')][_0x5d94('0x45')]){_0x7a8fc8[_0x5d94('0x43')]=_[_0x5d94('0x47')](_0x7a8fc8[_0x5d94('0x43')],{'$or':_[_0x5d94('0x34')](_0x7a8fc8['attributes'],function(_0x53ee28){var _0x23d570={};_0x23d570[_0x53ee28]={'$like':'%'+_0x4551d1[_0x5d94('0x38')]['filter']+'%'};return _0x23d570;})});}_0x7a8fc8=_[_0x5d94('0x47')]({},_0x7a8fc8,_0x4551d1[_0x5d94('0x4f')]);return _0x20dde8[_0x5d94('0x90')](_0x7a8fc8);}})['then'](function(_0x1f1ac4){if(_0x1f1ac4){_0xd2be2=_0x1f1ac4[_0x5d94('0x3e')];if(!_0x4551d1[_0x5d94('0x38')][_0x5d94('0x3f')](_0x5d94('0x40'))){_0x7a8fc8['limit']=qs['limit'](_0x4551d1[_0x5d94('0x38')][_0x5d94('0x25')]);_0x7a8fc8['offset']=qs[_0x5d94('0x24')](_0x4551d1[_0x5d94('0x38')][_0x5d94('0x24')]);}return _0x20dde8[_0x5d94('0x90')](_0x7a8fc8);}})['then'](function(_0x4323c5){if(_0x4323c5){return _0x4323c5?{'count':_0xd2be2,'rows':_0x4323c5}:null;}})[_0x5d94('0x2b')](respondWithResult(_0x6f921f,null))[_0x5d94('0x58')](handleError(_0x6f921f,null));};
\ No newline at end of file