Built motion from commit (unavailable).|2.5.1
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index c182b85..c296642 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8ab2=['spread','getAgents','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','util','path','to-csv','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','./mailQueue.socket','status','json','count','offset','limit','Content-Range','apply','reject','save','update','then','destroy','get','MailQueues','UserProfileResource','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','MailQueue','includeAll','include','findAll','rows','catch','show','params','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','UserMailQueue','findAndCountAll','UserId','agent','mailPause','updatedAt','format','%s/%s','SIP','createdAt','getTeams','findOne','Team','addTeams','ids','User','Agents','online','voicePause','interface','flatMap','sequelize','transaction','forEach','emit','removeTeams','select','field','tq.TeamId','team_has_mail_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','push','QueryTypes','SELECT','every','TeamId','union','compact','isEmpty','removeAgents','userMailQueue:remove','addAgents','omit'];(function(_0x1b7368,_0x3286ed){var _0x25d54c=function(_0x2366da){while(--_0x2366da){_0x1b7368['push'](_0x1b7368['shift']());}};_0x25d54c(++_0x3286ed);}(_0x8ab2,0x89));var _0x28ab=function(_0x55c92a,_0x42c5de){_0x55c92a=_0x55c92a-0x0;var _0x50541f=_0x8ab2[_0x55c92a];return _0x50541f;};'use strict';var pdf=require(_0x28ab('0x0'));var emlformat=require(_0x28ab('0x1'));var rimraf=require(_0x28ab('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x28ab('0x3'));var rp=require(_0x28ab('0x4'));var moment=require(_0x28ab('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x28ab('0x6'));var path=require(_0x28ab('0x7'));var sox=require('sox');var csv=require(_0x28ab('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x28ab('0x9'));var squel=require('squel');var crypto=require(_0x28ab('0xa'));var jsforce=require(_0x28ab('0xb'));var deskjs=require(_0x28ab('0xc'));var toCsv=require(_0x28ab('0x8'));var querystring=require('querystring');var Papa=require(_0x28ab('0xd'));var Redis=require(_0x28ab('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x28ab('0xf'));var as=require(_0x28ab('0x10'));var hardwareService=require(_0x28ab('0x11'));var logger=require(_0x28ab('0x12'))(_0x28ab('0x13'));var utils=require(_0x28ab('0x14'));var config=require(_0x28ab('0x15'));var db=require(_0x28ab('0x16'))['db'];config['redis']=_['defaults'](config[_0x28ab('0x17')],{'host':_0x28ab('0x18'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x28ab('0x17')]));require(_0x28ab('0x19'))['register'](socket);function respondWithStatusCode(_0x1ec47a,_0x5872e2){_0x5872e2=_0x5872e2||0xcc;return function(_0x2cba10){if(_0x2cba10){return _0x1ec47a['sendStatus'](_0x5872e2);}return _0x1ec47a[_0x28ab('0x1a')](_0x5872e2)['end']();};}function respondWithResult(_0x4fbaf3,_0x26a784){_0x26a784=_0x26a784||0xc8;return function(_0x466942){if(_0x466942){return _0x4fbaf3[_0x28ab('0x1a')](_0x26a784)[_0x28ab('0x1b')](_0x466942);}};}function respondWithFilteredResult(_0x53179f,_0x147d58){return function(_0x2e5593){if(_0x2e5593){var _0x4f1bbd=_0x2e5593[_0x28ab('0x1c')],_0x39f1a4=_0x147d58[_0x28ab('0x1d')],_0x129d10=_0x147d58[_0x28ab('0x1d')]+_0x147d58[_0x28ab('0x1e')],_0x5e21ca;if(_0x129d10>=_0x4f1bbd){_0x129d10=_0x4f1bbd;_0x5e21ca=0xc8;}else{_0x5e21ca=0xce;}_0x53179f[_0x28ab('0x1a')](_0x5e21ca);return _0x53179f['set'](_0x28ab('0x1f'),_0x39f1a4+'-'+_0x129d10+'/'+_0x4f1bbd)[_0x28ab('0x1b')](_0x2e5593);}return null;};}function patchUpdates(_0x529bd7){return function(_0x416a49){try{jsonpatch[_0x28ab('0x20')](_0x416a49,_0x529bd7,!![]);}catch(_0xbe7356){return BPromise[_0x28ab('0x21')](_0xbe7356);}return _0x416a49[_0x28ab('0x22')]();};}function saveUpdates(_0x3763d7,_0x3ae38a){return function(_0x3659a0){if(_0x3659a0){return _0x3659a0[_0x28ab('0x23')](_0x3763d7)[_0x28ab('0x24')](function(_0x5d5ecc){return _0x5d5ecc;});}return null;};}function removeEntity(_0x12cd15,_0x4c8b17){return function(_0x56623b){if(_0x56623b){return _0x56623b[_0x28ab('0x25')]()[_0x28ab('0x24')](function(){var _0xb3e40e=_0x56623b[_0x28ab('0x26')]({'plain':!![]});var _0x5600a4=_0x28ab('0x27');return db[_0x28ab('0x28')][_0x28ab('0x25')]({'where':{'type':_0x5600a4,'resourceId':_0xb3e40e['id']}})[_0x28ab('0x24')](function(){return _0x56623b;});})[_0x28ab('0x24')](function(){_0x12cd15[_0x28ab('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4e9638,_0x337b9a){return function(_0x282338){if(!_0x282338){_0x4e9638['sendStatus'](0x194);}return _0x282338;};}function handleError(_0x376f16,_0x3b4d0b){_0x3b4d0b=_0x3b4d0b||0x1f4;return function(_0x574c53){logger[_0x28ab('0x29')](_0x574c53[_0x28ab('0x2a')]);if(_0x574c53[_0x28ab('0x2b')]){delete _0x574c53['name'];}_0x376f16['status'](_0x3b4d0b)[_0x28ab('0x2c')](_0x574c53);};}exports['index']=function(_0x43aa9d,_0x59b95c){var _0x4065c6={},_0x122f6b={},_0x2090ea={'count':0x0,'rows':[]};var _0x3285ba=_[_0x28ab('0x2d')](db['MailQueue'][_0x28ab('0x2e')],function(_0x4a0fbf){return{'name':_0x4a0fbf[_0x28ab('0x2f')],'type':_0x4a0fbf[_0x28ab('0x30')][_0x28ab('0x31')]};});_0x122f6b[_0x28ab('0x32')]=_[_0x28ab('0x2d')](_0x3285ba,_0x28ab('0x2b'));_0x122f6b[_0x28ab('0x33')]=_[_0x28ab('0x34')](_0x43aa9d[_0x28ab('0x33')]);_0x122f6b[_0x28ab('0x35')]=_[_0x28ab('0x36')](_0x122f6b['model'],_0x122f6b[_0x28ab('0x33')]);_0x4065c6['attributes']=_[_0x28ab('0x36')](_0x122f6b['model'],qs[_0x28ab('0x37')](_0x43aa9d[_0x28ab('0x33')]['fields']));_0x4065c6[_0x28ab('0x38')]=_0x4065c6[_0x28ab('0x38')][_0x28ab('0x39')]?_0x4065c6[_0x28ab('0x38')]:_0x122f6b[_0x28ab('0x32')];if(!_0x43aa9d[_0x28ab('0x33')][_0x28ab('0x3a')](_0x28ab('0x3b'))){_0x4065c6['limit']=qs['limit'](_0x43aa9d[_0x28ab('0x33')][_0x28ab('0x1e')]);_0x4065c6[_0x28ab('0x1d')]=qs['offset'](_0x43aa9d[_0x28ab('0x33')][_0x28ab('0x1d')]);}_0x4065c6[_0x28ab('0x3c')]=qs['sort'](_0x43aa9d[_0x28ab('0x33')][_0x28ab('0x3d')]);_0x4065c6[_0x28ab('0x3e')]=qs[_0x28ab('0x35')](_[_0x28ab('0x3f')](_0x43aa9d['query'],_0x122f6b['filters']));if(_0x43aa9d[_0x28ab('0x33')][_0x28ab('0x40')]){_0x4065c6[_0x28ab('0x3e')]=_[_0x28ab('0x41')](_0x4065c6[_0x28ab('0x3e')],{'$or':_[_0x28ab('0x2d')](_0x3285ba,function(_0xbde569){if(_0xbde569['type']!==_0x28ab('0x42')){var _0x21813e={};_0x21813e[_0xbde569['name']]={'$like':'%'+_0x43aa9d[_0x28ab('0x33')][_0x28ab('0x40')]+'%'};return _0x21813e;}})});}_0x4065c6=_[_0x28ab('0x41')]({},_0x4065c6,_0x43aa9d[_0x28ab('0x43')]);var _0x4d98fd={'where':_0x4065c6[_0x28ab('0x3e')]};return db[_0x28ab('0x44')][_0x28ab('0x1c')](_0x4d98fd)['then'](function(_0x4b94e0){_0x2090ea[_0x28ab('0x1c')]=_0x4b94e0;if(_0x43aa9d[_0x28ab('0x33')][_0x28ab('0x45')]){_0x4065c6[_0x28ab('0x46')]=[{'all':!![]}];}return db['MailQueue'][_0x28ab('0x47')](_0x4065c6);})[_0x28ab('0x24')](function(_0x392402){_0x2090ea[_0x28ab('0x48')]=_0x392402;return _0x2090ea;})['then'](respondWithFilteredResult(_0x59b95c,_0x4065c6))[_0x28ab('0x49')](handleError(_0x59b95c,null));};exports[_0x28ab('0x4a')]=function(_0x14c283,_0x371e25){var _0x599788={'raw':!![],'where':{'id':_0x14c283[_0x28ab('0x4b')]['id']}},_0x2d19aa={};_0x2d19aa[_0x28ab('0x32')]=_['keys'](db[_0x28ab('0x44')][_0x28ab('0x2e')]);_0x2d19aa[_0x28ab('0x33')]=_['keys'](_0x14c283[_0x28ab('0x33')]);_0x2d19aa[_0x28ab('0x35')]=_[_0x28ab('0x36')](_0x2d19aa[_0x28ab('0x32')],_0x2d19aa[_0x28ab('0x33')]);_0x599788['attributes']=_[_0x28ab('0x36')](_0x2d19aa['model'],qs[_0x28ab('0x37')](_0x14c283[_0x28ab('0x33')][_0x28ab('0x37')]));_0x599788[_0x28ab('0x38')]=_0x599788['attributes']['length']?_0x599788[_0x28ab('0x38')]:_0x2d19aa[_0x28ab('0x32')];if(_0x14c283[_0x28ab('0x33')][_0x28ab('0x45')]){_0x599788[_0x28ab('0x46')]=[{'all':!![]}];}_0x599788=_[_0x28ab('0x41')]({},_0x599788,_0x14c283[_0x28ab('0x43')]);return db[_0x28ab('0x44')][_0x28ab('0x4c')](_0x599788)[_0x28ab('0x24')](handleEntityNotFound(_0x371e25,null))[_0x28ab('0x24')](respondWithResult(_0x371e25,null))['catch'](handleError(_0x371e25,null));};exports[_0x28ab('0x4d')]=function(_0x21ecfc,_0x59e989){return db[_0x28ab('0x44')][_0x28ab('0x4d')](_0x21ecfc[_0x28ab('0x4e')],{})[_0x28ab('0x24')](function(_0x4564b1){var _0x1ed268=_0x21ecfc['user'][_0x28ab('0x26')]({'plain':!![]});if(!_0x1ed268)throw new Error(_0x28ab('0x4f'));if(_0x1ed268[_0x28ab('0x50')]===_0x28ab('0x51')){var _0xb99068=_0x4564b1[_0x28ab('0x26')]({'plain':!![]});var _0x3874b8='MailQueues';return db[_0x28ab('0x52')]['find']({'where':{'name':_0x3874b8,'userProfileId':_0x1ed268['userProfileId']},'raw':!![]})[_0x28ab('0x24')](function(_0x4171a1){if(_0x4171a1&&_0x4171a1['autoAssociation']===0x0){return db[_0x28ab('0x28')]['create']({'name':_0xb99068[_0x28ab('0x2b')],'resourceId':_0xb99068['id'],'type':_0x4171a1[_0x28ab('0x2b')],'sectionId':_0x4171a1['id']},{})[_0x28ab('0x24')](function(){return _0x4564b1;});}else{return _0x4564b1;}})[_0x28ab('0x49')](function(_0x4518eb){logger[_0x28ab('0x29')](_0x28ab('0x53'),_0x4518eb);throw _0x4518eb;});}return _0x4564b1;})[_0x28ab('0x24')](respondWithResult(_0x59e989,0xc9))['catch'](handleError(_0x59e989,null));};exports[_0x28ab('0x23')]=function(_0x385df7,_0x4e8995){if(_0x385df7['body']['id']){delete _0x385df7[_0x28ab('0x4e')]['id'];}return db['MailQueue'][_0x28ab('0x4c')]({'where':{'id':_0x385df7[_0x28ab('0x4b')]['id']}})['then'](handleEntityNotFound(_0x4e8995,null))[_0x28ab('0x24')](saveUpdates(_0x385df7['body'],null))['then'](respondWithResult(_0x4e8995,null))[_0x28ab('0x49')](handleError(_0x4e8995,null));};exports[_0x28ab('0x25')]=function(_0x403c1b,_0x5f0bc7){return db['MailQueue'][_0x28ab('0x4c')]({'where':{'id':_0x403c1b['params']['id']}})[_0x28ab('0x24')](handleEntityNotFound(_0x5f0bc7,null))['then'](removeEntity(_0x5f0bc7,null))[_0x28ab('0x49')](handleError(_0x5f0bc7,null));};exports['describe']=function(_0x1b5264,_0xc616dd){return db['MailQueue'][_0x28ab('0x54')]()['then'](respondWithResult(_0xc616dd,null))['catch'](handleError(_0xc616dd,null));};exports[_0x28ab('0x55')]=function(_0x4b280d,_0x2a796a,_0xee742e){var _0x50952d={'raw':!![],'where':{}},_0x199c39={},_0x26c6ad;return db[_0x28ab('0x44')]['findOne']({'where':{'id':_0x4b280d[_0x28ab('0x4b')]['id']}})[_0x28ab('0x24')](handleEntityNotFound(_0x2a796a,null))[_0x28ab('0x24')](function(_0x1dbd4d){if(_0x1dbd4d){_0x26c6ad=_0x1dbd4d[_0x28ab('0x26')]({'plain':!![]});_0x199c39[_0x28ab('0x32')]=_[_0x28ab('0x34')](db[_0x28ab('0x56')]['rawAttributes']);_0x199c39[_0x28ab('0x33')]=_[_0x28ab('0x34')](_0x4b280d['query']);_0x199c39[_0x28ab('0x35')]=_[_0x28ab('0x36')](_0x199c39[_0x28ab('0x32')],_0x199c39[_0x28ab('0x33')]);_0x50952d[_0x28ab('0x38')]=_['intersection'](_0x199c39['model'],qs[_0x28ab('0x37')](_0x4b280d[_0x28ab('0x33')][_0x28ab('0x37')]));_0x50952d[_0x28ab('0x38')]=_0x50952d[_0x28ab('0x38')][_0x28ab('0x39')]?_0x50952d[_0x28ab('0x38')]:_0x199c39[_0x28ab('0x32')];if(!_0x4b280d[_0x28ab('0x33')][_0x28ab('0x3a')](_0x28ab('0x3b'))){_0x50952d[_0x28ab('0x1e')]=qs['limit'](_0x4b280d[_0x28ab('0x33')]['limit']);_0x50952d[_0x28ab('0x1d')]=qs[_0x28ab('0x1d')](_0x4b280d[_0x28ab('0x33')]['offset']);}_0x50952d[_0x28ab('0x3c')]=qs['sort'](_0x4b280d[_0x28ab('0x33')][_0x28ab('0x3d')]);_0x50952d['where']=qs[_0x28ab('0x35')](_[_0x28ab('0x3f')](_0x4b280d[_0x28ab('0x33')],_0x199c39[_0x28ab('0x35')]));_0x50952d[_0x28ab('0x3e')]['MailQueueId']=_0x1dbd4d['id'];if(_0x4b280d['query'][_0x28ab('0x40')]){_0x50952d[_0x28ab('0x3e')]=_[_0x28ab('0x41')](_0x50952d['where'],{'$or':_[_0x28ab('0x2d')](_0x50952d[_0x28ab('0x38')],function(_0x69734c){var _0x1e1823={};_0x1e1823[_0x69734c]={'$like':'%'+_0x4b280d[_0x28ab('0x33')]['filter']+'%'};return _0x1e1823;})});}_0x50952d=_[_0x28ab('0x41')]({},_0x50952d,_0x4b280d[_0x28ab('0x43')]);return db[_0x28ab('0x56')][_0x28ab('0x47')](_0x50952d);}})[_0x28ab('0x24')](function(_0x4d7481){if(_0x4d7481){return db['User'][_0x28ab('0x57')]({'where':{'id':_['map'](_0x4d7481,_0x28ab('0x58')),'role':_0x28ab('0x59')},'attributes':['id',_0x28ab('0x2b'),_0x28ab('0x5a'),_0x28ab('0x5b'),'createdAt']});}})[_0x28ab('0x24')](function(_0x360885){if(_0x360885){return{'count':_0x360885['count'],'rows':_[_0x28ab('0x2d')](_0x360885[_0x28ab('0x48')],function(_0x5ec828){return{'membername':_0x5ec828[_0x28ab('0x2b')],'UserId':_0x5ec828['id'],'queue_name':_0x26c6ad['name'],'MailQueueId':_0x26c6ad['id'],'interface':util[_0x28ab('0x5c')](_0x28ab('0x5d'),_0x28ab('0x5e'),_0x5ec828[_0x28ab('0x2b')]),'penalty':0x0,'paused':_0x5ec828[_0x28ab('0x5a')],'createdAt':_0x5ec828[_0x28ab('0x5f')],'updatedAt':_0x5ec828['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x28ab('0x24')](respondWithFilteredResult(_0x2a796a,_0x50952d))[_0x28ab('0x49')](handleError(_0x2a796a,null));};exports[_0x28ab('0x60')]=function(_0xf64a5e,_0x39c64b,_0x48009a){var _0x5f2222={};var _0x1379b1={};var _0x593fe7;var _0x1b3e2d;return db['MailQueue'][_0x28ab('0x61')]({'where':{'id':_0xf64a5e[_0x28ab('0x4b')]['id']}})['then'](handleEntityNotFound(_0x39c64b,null))['then'](function(_0x4174d2){if(_0x4174d2){_0x593fe7=_0x4174d2;_0x1379b1[_0x28ab('0x32')]=_['keys'](db[_0x28ab('0x62')][_0x28ab('0x2e')]);_0x1379b1['query']=_['keys'](_0xf64a5e[_0x28ab('0x33')]);_0x1379b1[_0x28ab('0x35')]=_['intersection'](_0x1379b1[_0x28ab('0x32')],_0x1379b1['query']);_0x5f2222[_0x28ab('0x38')]=_[_0x28ab('0x36')](_0x1379b1[_0x28ab('0x32')],qs[_0x28ab('0x37')](_0xf64a5e[_0x28ab('0x33')]['fields']));_0x5f2222[_0x28ab('0x38')]=_0x5f2222[_0x28ab('0x38')][_0x28ab('0x39')]?_0x5f2222[_0x28ab('0x38')]:_0x1379b1[_0x28ab('0x32')];_0x5f2222['order']=qs[_0x28ab('0x3d')](_0xf64a5e[_0x28ab('0x33')][_0x28ab('0x3d')]);_0x5f2222[_0x28ab('0x3e')]=qs[_0x28ab('0x35')](_[_0x28ab('0x3f')](_0xf64a5e[_0x28ab('0x33')],_0x1379b1[_0x28ab('0x35')]));if(_0xf64a5e[_0x28ab('0x33')][_0x28ab('0x40')]){_0x5f2222[_0x28ab('0x3e')]=_[_0x28ab('0x41')](_0x5f2222['where'],{'$or':_[_0x28ab('0x2d')](_0x5f2222[_0x28ab('0x38')],function(_0x2d3986){var _0x55cf78={};_0x55cf78[_0x2d3986]={'$like':'%'+_0xf64a5e[_0x28ab('0x33')][_0x28ab('0x40')]+'%'};return _0x55cf78;})});}_0x5f2222=_[_0x28ab('0x41')]({},_0x5f2222,_0xf64a5e[_0x28ab('0x43')]);return _0x593fe7[_0x28ab('0x60')](_0x5f2222);}})[_0x28ab('0x24')](function(_0x4c614c){if(_0x4c614c){_0x1b3e2d=_0x4c614c['length'];if(!_0xf64a5e[_0x28ab('0x33')]['hasOwnProperty'](_0x28ab('0x3b'))){_0x5f2222[_0x28ab('0x1e')]=qs[_0x28ab('0x1e')](_0xf64a5e[_0x28ab('0x33')][_0x28ab('0x1e')]);_0x5f2222[_0x28ab('0x1d')]=qs[_0x28ab('0x1d')](_0xf64a5e[_0x28ab('0x33')][_0x28ab('0x1d')]);}return _0x593fe7[_0x28ab('0x60')](_0x5f2222);}})[_0x28ab('0x24')](function(_0x152ad1){if(_0x152ad1){return _0x152ad1?{'count':_0x1b3e2d,'rows':_0x152ad1}:null;}})[_0x28ab('0x24')](respondWithResult(_0x39c64b,null))[_0x28ab('0x49')](handleError(_0x39c64b,null));};exports[_0x28ab('0x63')]=function(_0x32c6a9,_0x5c15e1,_0x5930f1){var _0x1ffca9=_0x32c6a9[_0x28ab('0x4e')][_0x28ab('0x64')];return db[_0x28ab('0x62')][_0x28ab('0x47')]({'where':{'id':_0x1ffca9},'attributes':['id'],'include':[{'model':db[_0x28ab('0x65')],'as':_0x28ab('0x66'),'attributes':['id','name',_0x28ab('0x67'),_0x28ab('0x68'),_0x28ab('0x69')],'raw':!![]}]})[_0x28ab('0x24')](function(_0x159a97){if(_0x159a97){var _0x2e52fe=_[_0x28ab('0x6a')](_0x159a97,function(_0x1996a0){var _0x3c068a=_0x1996a0[_0x28ab('0x26')]({'plain':!![]});return _0x3c068a['Agents'];});return db[_0x28ab('0x44')][_0x28ab('0x4c')]({'where':{'id':_0x32c6a9[_0x28ab('0x4b')]['id']}})[_0x28ab('0x24')](function(_0x151207){return db[_0x28ab('0x6b')][_0x28ab('0x6c')](function(_0x4395f7){return _0x151207[_0x28ab('0x63')](_0x1ffca9,{'transaction':_0x4395f7})[_0x28ab('0x24')](function(){return BPromise['each'](_0x2e52fe,function(_0x41c82f){return db[_0x28ab('0x56')]['findOrCreate']({'where':{'UserId':_0x41c82f['id'],'MailQueueId':_0x32c6a9[_0x28ab('0x4b')]['id']},'transaction':_0x4395f7});});})[_0x28ab('0x24')](function(){_0x2e52fe[_0x28ab('0x6d')](function(_0x553306){socket[_0x28ab('0x6e')]('userMailQueue:save',{'UserId':_0x553306['id'],'MailQueueId':_0x151207['id']});});});});});}})['then'](respondWithStatusCode(_0x5c15e1,null))['catch'](handleError(_0x5c15e1,null));};exports[_0x28ab('0x6f')]=function(_0x57b471,_0x19fdc4,_0x50813b){return db['Team'][_0x28ab('0x47')]({'where':{'id':_0x57b471[_0x28ab('0x33')][_0x28ab('0x64')]},'attributes':['id'],'include':[{'model':db[_0x28ab('0x65')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x19fdc4,null))['then'](function(_0x4abc2f){var _0xaf7539=_[_0x28ab('0x2d')](_0x4abc2f,'id');var _0x4acd91=[];var _0x19f333=[];var _0x21efe6=squel[_0x28ab('0x70')]();_0x21efe6[_0x28ab('0x71')](_0x28ab('0x72'))['from'](_0x28ab('0x73'),'tq')[_0x28ab('0x74')](_0x28ab('0x75'),'ut',_0x28ab('0x76'))[_0x28ab('0x3e')](_0x28ab('0x77'),_0x57b471[_0x28ab('0x4b')]['id']);for(var _0x11d73e=0x0;_0x11d73e<_0x4abc2f[_0x28ab('0x39')];_0x11d73e+=0x1){let _0x43524a=_0x4abc2f[_0x11d73e];for(var _0x4ba221=0x0;_0x4ba221<_0x43524a[_0x28ab('0x66')][_0x28ab('0x39')];_0x4ba221+=0x1){let _0x2fc729=_0x43524a[_0x28ab('0x66')][_0x4ba221];var _0x1c07a0=_0x21efe6[_0x28ab('0x78')]();_0x1c07a0[_0x28ab('0x3e')]('ut.UserId\x20=\x20?',_0x2fc729['id']);_0x19f333[_0x28ab('0x79')](db[_0x28ab('0x6b')][_0x28ab('0x33')](_0x1c07a0['toString'](),{'type':db[_0x28ab('0x6b')][_0x28ab('0x7a')][_0x28ab('0x7b')]})[_0x28ab('0x24')](function(_0x3007ce){if(_0x3007ce['length']===0x1){return _0x2fc729['id'];}else{var _0x3903fd=_[_0x28ab('0x7c')](_[_0x28ab('0x2d')](_0x3007ce,_0x28ab('0x7d')),function(_0x8b2b24){return _['includes'](_0xaf7539,_0x8b2b24);});if(_0x3903fd){return _0x2fc729['id'];}}}));}}return BPromise['all'](_0x19f333)[_0x28ab('0x24')](function(_0x11d603){_0x4acd91=_(_0x4acd91)[_0x28ab('0x7e')](_0x11d603)[_0x28ab('0x7f')]()['value']();return db[_0x28ab('0x44')][_0x28ab('0x4c')]({'where':{'id':_0x57b471[_0x28ab('0x4b')]['id']}})[_0x28ab('0x24')](function(_0x52a6d9){return db[_0x28ab('0x6b')][_0x28ab('0x6c')](function(_0x375812){return _0x52a6d9[_0x28ab('0x6f')](_0x57b471[_0x28ab('0x33')]['ids'],{'transaction':_0x375812})[_0x28ab('0x24')](function(){if(!_[_0x28ab('0x80')](_0x4acd91)){return _0x52a6d9[_0x28ab('0x81')](_0x4acd91,{'transaction':_0x375812});}})['then'](function(){_0x4acd91[_0x28ab('0x6d')](function(_0x2038f4){socket[_0x28ab('0x6e')](_0x28ab('0x82'),{'UserId':_0x2038f4,'MailQueueId':_0x52a6d9['id']});});});});});});})[_0x28ab('0x24')](respondWithStatusCode(_0x19fdc4,null))[_0x28ab('0x49')](handleError(_0x19fdc4,null));};exports[_0x28ab('0x83')]=function(_0x3cbb62,_0x3ad5f0,_0x36259c){return db[_0x28ab('0x44')][_0x28ab('0x4c')]({'where':{'id':_0x3cbb62[_0x28ab('0x4b')]['id']}})[_0x28ab('0x24')](handleEntityNotFound(_0x3ad5f0,null))['then'](function(_0x2feec5){if(_0x2feec5){return _0x2feec5[_0x28ab('0x83')](_0x3cbb62['body'][_0x28ab('0x64')],_[_0x28ab('0x84')](_0x3cbb62[_0x28ab('0x4e')],[_0x28ab('0x64'),'id'])||{})[_0x28ab('0x85')](function(_0x2fe523){for(var _0x201fd6=0x0;_0x201fd6<_0x3cbb62['body'][_0x28ab('0x64')]['length'];_0x201fd6+=0x1){socket[_0x28ab('0x6e')]('userMailQueue:save',{'UserId':_0x3cbb62[_0x28ab('0x4e')][_0x28ab('0x64')][_0x201fd6],'MailQueueId':_0x3cbb62[_0x28ab('0x4b')]['id']});}return _0x2fe523;});}})[_0x28ab('0x24')](respondWithResult(_0x3ad5f0,null))[_0x28ab('0x49')](handleError(_0x3ad5f0,null));};exports['removeAgents']=function(_0x4ef3ad,_0x18d71a,_0x385e51){return db[_0x28ab('0x44')]['find']({'where':{'id':_0x4ef3ad[_0x28ab('0x4b')]['id']}})[_0x28ab('0x24')](handleEntityNotFound(_0x18d71a,null))[_0x28ab('0x24')](function(_0x1a120d){if(_0x1a120d){return _0x1a120d[_0x28ab('0x81')](_0x4ef3ad[_0x28ab('0x33')][_0x28ab('0x64')])[_0x28ab('0x24')](function(){if(_['isArray'](_0x4ef3ad[_0x28ab('0x33')][_0x28ab('0x64')])){for(var _0x330cc9=0x0;_0x330cc9<_0x4ef3ad[_0x28ab('0x33')][_0x28ab('0x64')][_0x28ab('0x39')];_0x330cc9+=0x1){socket[_0x28ab('0x6e')]('userMailQueue:remove',{'UserId':Number(_0x4ef3ad[_0x28ab('0x33')]['ids'][_0x330cc9]),'MailQueueId':Number(_0x4ef3ad[_0x28ab('0x4b')]['id'])});}}else{socket['emit'](_0x28ab('0x82'),{'UserId':Number(_0x4ef3ad[_0x28ab('0x33')][_0x28ab('0x64')]),'MailQueueId':Number(_0x4ef3ad[_0x28ab('0x4b')]['id'])});}});}})[_0x28ab('0x24')](respondWithStatusCode(_0x18d71a,null))[_0x28ab('0x49')](handleError(_0x18d71a,null));};exports['getAgents']=function(_0x2f7440,_0x1d2ac3,_0x27621b){var _0x410a9c={};var _0x392583={};var _0x404e3a;var _0x5deb18;return db['MailQueue'][_0x28ab('0x61')]({'where':{'id':_0x2f7440['params']['id']}})[_0x28ab('0x24')](handleEntityNotFound(_0x1d2ac3,null))[_0x28ab('0x24')](function(_0x4def3a){if(_0x4def3a){_0x404e3a=_0x4def3a;_0x392583[_0x28ab('0x32')]=_[_0x28ab('0x34')](db[_0x28ab('0x65')][_0x28ab('0x2e')]);_0x392583[_0x28ab('0x33')]=_[_0x28ab('0x34')](_0x2f7440[_0x28ab('0x33')]);_0x392583[_0x28ab('0x35')]=_[_0x28ab('0x36')](_0x392583[_0x28ab('0x32')],_0x392583[_0x28ab('0x33')]);_0x410a9c['attributes']=_[_0x28ab('0x36')](_0x392583[_0x28ab('0x32')],qs[_0x28ab('0x37')](_0x2f7440[_0x28ab('0x33')]['fields']));_0x410a9c[_0x28ab('0x38')]=_0x410a9c[_0x28ab('0x38')][_0x28ab('0x39')]?_0x410a9c[_0x28ab('0x38')]:_0x392583['model'];_0x410a9c[_0x28ab('0x3c')]=qs[_0x28ab('0x3d')](_0x2f7440[_0x28ab('0x33')][_0x28ab('0x3d')]);_0x410a9c['where']=qs[_0x28ab('0x35')](_[_0x28ab('0x3f')](_0x2f7440[_0x28ab('0x33')],_0x392583['filters']));if(_0x2f7440[_0x28ab('0x33')][_0x28ab('0x40')]){_0x410a9c[_0x28ab('0x3e')]=_[_0x28ab('0x41')](_0x410a9c[_0x28ab('0x3e')],{'$or':_[_0x28ab('0x2d')](_0x410a9c[_0x28ab('0x38')],function(_0x54b598){var _0x223063={};_0x223063[_0x54b598]={'$like':'%'+_0x2f7440[_0x28ab('0x33')][_0x28ab('0x40')]+'%'};return _0x223063;})});}_0x410a9c=_[_0x28ab('0x41')]({},_0x410a9c,_0x2f7440['options']);return _0x404e3a[_0x28ab('0x86')](_0x410a9c);}})[_0x28ab('0x24')](function(_0x4eccbc){if(_0x4eccbc){_0x5deb18=_0x4eccbc[_0x28ab('0x39')];if(!_0x2f7440['query'][_0x28ab('0x3a')](_0x28ab('0x3b'))){_0x410a9c[_0x28ab('0x1e')]=qs[_0x28ab('0x1e')](_0x2f7440[_0x28ab('0x33')][_0x28ab('0x1e')]);_0x410a9c['offset']=qs[_0x28ab('0x1d')](_0x2f7440[_0x28ab('0x33')][_0x28ab('0x1d')]);}return _0x404e3a[_0x28ab('0x86')](_0x410a9c);}})['then'](function(_0x37b940){if(_0x37b940){return _0x37b940?{'count':_0x5deb18,'rows':_0x37b940}:null;}})['then'](respondWithResult(_0x1d2ac3,null))[_0x28ab('0x49')](handleError(_0x1d2ac3,null));};
\ No newline at end of file
+var _0xba13=['save','update','then','destroy','get','UserProfileResource','error','stack','name','index','map','type','model','query','keys','intersection','attributes','fields','length','order','where','pick','filters','filter','merge','VIRTUAL','options','MailQueue','count','includeAll','include','findAll','rows','show','params','rawAttributes','find','catch','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','MailQueues','UserProfileSection','userProfileId','autoAssociation','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','UserMailQueue','nolimit','sort','MailQueueId','User','findAndCountAll','agent','updatedAt','createdAt','format','%s/%s','SIP','mailPause','Team','getTeams','ids','Agents','voicePause','interface','sequelize','transaction','addTeams','each','findOrCreate','forEach','emit','userMailQueue:save','removeTeams','select','tq.TeamId','team_has_mail_queues','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','push','toString','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','addAgents','omit','removeAgents','isArray','userMailQueue:remove','findOne','getAgents','hasOwnProperty','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','util','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','./mailQueue.socket','sendStatus','status','end','offset','limit','set','Content-Range','json','reject'];(function(_0x34bfd8,_0x24eaa3){var _0x122c91=function(_0x17081a){while(--_0x17081a){_0x34bfd8['push'](_0x34bfd8['shift']());}};_0x122c91(++_0x24eaa3);}(_0xba13,0x17e));var _0x3ba1=function(_0x3d42d8,_0x4cffaa){_0x3d42d8=_0x3d42d8-0x0;var _0x27fc41=_0xba13[_0x3d42d8];return _0x27fc41;};'use strict';var pdf=require(_0x3ba1('0x0'));var emlformat=require(_0x3ba1('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x3ba1('0x2'));var jsonpatch=require(_0x3ba1('0x3'));var rp=require(_0x3ba1('0x4'));var moment=require('moment');var BPromise=require(_0x3ba1('0x5'));var Mustache=require('mustache');var util=require(_0x3ba1('0x6'));var path=require('path');var sox=require(_0x3ba1('0x7'));var csv=require(_0x3ba1('0x8'));var ejs=require(_0x3ba1('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x3ba1('0xa'));var crypto=require(_0x3ba1('0xb'));var jsforce=require(_0x3ba1('0xc'));var deskjs=require(_0x3ba1('0xd'));var toCsv=require('to-csv');var querystring=require(_0x3ba1('0xe'));var Papa=require(_0x3ba1('0xf'));var Redis=require(_0x3ba1('0x10'));var authService=require(_0x3ba1('0x11'));var qs=require(_0x3ba1('0x12'));var as=require(_0x3ba1('0x13'));var hardwareService=require(_0x3ba1('0x14'));var logger=require(_0x3ba1('0x15'))(_0x3ba1('0x16'));var utils=require('../../config/utils');var config=require(_0x3ba1('0x17'));var db=require(_0x3ba1('0x18'))['db'];config[_0x3ba1('0x19')]=_[_0x3ba1('0x1a')](config[_0x3ba1('0x19')],{'host':_0x3ba1('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x3ba1('0x1c'))['register'](socket);function respondWithStatusCode(_0x4293e0,_0x4ac06f){_0x4ac06f=_0x4ac06f||0xcc;return function(_0x21b498){if(_0x21b498){return _0x4293e0[_0x3ba1('0x1d')](_0x4ac06f);}return _0x4293e0[_0x3ba1('0x1e')](_0x4ac06f)[_0x3ba1('0x1f')]();};}function respondWithResult(_0x439943,_0x37dcff){_0x37dcff=_0x37dcff||0xc8;return function(_0x55f02f){if(_0x55f02f){return _0x439943[_0x3ba1('0x1e')](_0x37dcff)['json'](_0x55f02f);}};}function respondWithFilteredResult(_0x29aed7,_0x1b18ab){return function(_0x2fbd12){if(_0x2fbd12){var _0x2b4b1d=_0x2fbd12['count'],_0x4ef6fa=_0x1b18ab[_0x3ba1('0x20')],_0x434e14=_0x1b18ab[_0x3ba1('0x20')]+_0x1b18ab[_0x3ba1('0x21')],_0x39c9dd;if(_0x434e14>=_0x2b4b1d){_0x434e14=_0x2b4b1d;_0x39c9dd=0xc8;}else{_0x39c9dd=0xce;}_0x29aed7[_0x3ba1('0x1e')](_0x39c9dd);return _0x29aed7[_0x3ba1('0x22')](_0x3ba1('0x23'),_0x4ef6fa+'-'+_0x434e14+'/'+_0x2b4b1d)[_0x3ba1('0x24')](_0x2fbd12);}return null;};}function patchUpdates(_0x2eadb5){return function(_0x3c37fc){try{jsonpatch['apply'](_0x3c37fc,_0x2eadb5,!![]);}catch(_0x3c9852){return BPromise[_0x3ba1('0x25')](_0x3c9852);}return _0x3c37fc[_0x3ba1('0x26')]();};}function saveUpdates(_0x1e44b8,_0x349ec3){return function(_0x171aa5){if(_0x171aa5){return _0x171aa5[_0x3ba1('0x27')](_0x1e44b8)[_0x3ba1('0x28')](function(_0x2c505e){return _0x2c505e;});}return null;};}function removeEntity(_0x29977f,_0x2f5044){return function(_0x5975e6){if(_0x5975e6){return _0x5975e6[_0x3ba1('0x29')]()[_0x3ba1('0x28')](function(){var _0x4a4767=_0x5975e6[_0x3ba1('0x2a')]({'plain':!![]});var _0x5bf9e3='MailQueues';return db[_0x3ba1('0x2b')][_0x3ba1('0x29')]({'where':{'type':_0x5bf9e3,'resourceId':_0x4a4767['id']}})[_0x3ba1('0x28')](function(){return _0x5975e6;});})[_0x3ba1('0x28')](function(){_0x29977f[_0x3ba1('0x1e')](0xcc)[_0x3ba1('0x1f')]();});}};}function handleEntityNotFound(_0x2a7b9d,_0x5bdd86){return function(_0x14c302){if(!_0x14c302){_0x2a7b9d[_0x3ba1('0x1d')](0x194);}return _0x14c302;};}function handleError(_0x45b74b,_0x24000d){_0x24000d=_0x24000d||0x1f4;return function(_0x4adc55){logger[_0x3ba1('0x2c')](_0x4adc55[_0x3ba1('0x2d')]);if(_0x4adc55[_0x3ba1('0x2e')]){delete _0x4adc55[_0x3ba1('0x2e')];}_0x45b74b[_0x3ba1('0x1e')](_0x24000d)['send'](_0x4adc55);};}exports[_0x3ba1('0x2f')]=function(_0x3b1c02,_0x475efe){var _0x12a3ee={},_0x3855e2={},_0x4c9442={'count':0x0,'rows':[]};var _0x45621f=_[_0x3ba1('0x30')](db['MailQueue']['rawAttributes'],function(_0x130596){return{'name':_0x130596['fieldName'],'type':_0x130596[_0x3ba1('0x31')]['key']};});_0x3855e2[_0x3ba1('0x32')]=_[_0x3ba1('0x30')](_0x45621f,_0x3ba1('0x2e'));_0x3855e2[_0x3ba1('0x33')]=_[_0x3ba1('0x34')](_0x3b1c02['query']);_0x3855e2['filters']=_[_0x3ba1('0x35')](_0x3855e2[_0x3ba1('0x32')],_0x3855e2[_0x3ba1('0x33')]);_0x12a3ee[_0x3ba1('0x36')]=_[_0x3ba1('0x35')](_0x3855e2[_0x3ba1('0x32')],qs[_0x3ba1('0x37')](_0x3b1c02[_0x3ba1('0x33')]['fields']));_0x12a3ee[_0x3ba1('0x36')]=_0x12a3ee[_0x3ba1('0x36')][_0x3ba1('0x38')]?_0x12a3ee[_0x3ba1('0x36')]:_0x3855e2[_0x3ba1('0x32')];if(!_0x3b1c02[_0x3ba1('0x33')]['hasOwnProperty']('nolimit')){_0x12a3ee['limit']=qs[_0x3ba1('0x21')](_0x3b1c02[_0x3ba1('0x33')][_0x3ba1('0x21')]);_0x12a3ee[_0x3ba1('0x20')]=qs[_0x3ba1('0x20')](_0x3b1c02['query'][_0x3ba1('0x20')]);}_0x12a3ee[_0x3ba1('0x39')]=qs['sort'](_0x3b1c02[_0x3ba1('0x33')]['sort']);_0x12a3ee[_0x3ba1('0x3a')]=qs['filters'](_[_0x3ba1('0x3b')](_0x3b1c02[_0x3ba1('0x33')],_0x3855e2[_0x3ba1('0x3c')]),_0x45621f);if(_0x3b1c02[_0x3ba1('0x33')][_0x3ba1('0x3d')]){_0x12a3ee['where']=_[_0x3ba1('0x3e')](_0x12a3ee[_0x3ba1('0x3a')],{'$or':_[_0x3ba1('0x30')](_0x45621f,function(_0x487443){if(_0x487443[_0x3ba1('0x31')]!==_0x3ba1('0x3f')){var _0x15911e={};_0x15911e[_0x487443[_0x3ba1('0x2e')]]={'$like':'%'+_0x3b1c02['query']['filter']+'%'};return _0x15911e;}})});}_0x12a3ee=_[_0x3ba1('0x3e')]({},_0x12a3ee,_0x3b1c02[_0x3ba1('0x40')]);var _0x409819={'where':_0x12a3ee[_0x3ba1('0x3a')]};return db[_0x3ba1('0x41')][_0x3ba1('0x42')](_0x409819)[_0x3ba1('0x28')](function(_0x1085e8){_0x4c9442[_0x3ba1('0x42')]=_0x1085e8;if(_0x3b1c02[_0x3ba1('0x33')][_0x3ba1('0x43')]){_0x12a3ee[_0x3ba1('0x44')]=[{'all':!![]}];}return db[_0x3ba1('0x41')][_0x3ba1('0x45')](_0x12a3ee);})[_0x3ba1('0x28')](function(_0x417058){_0x4c9442[_0x3ba1('0x46')]=_0x417058;return _0x4c9442;})[_0x3ba1('0x28')](respondWithFilteredResult(_0x475efe,_0x12a3ee))['catch'](handleError(_0x475efe,null));};exports[_0x3ba1('0x47')]=function(_0x357169,_0x26d397){var _0x28269a={'raw':!![],'where':{'id':_0x357169[_0x3ba1('0x48')]['id']}},_0x3024dc={};_0x3024dc[_0x3ba1('0x32')]=_['keys'](db[_0x3ba1('0x41')][_0x3ba1('0x49')]);_0x3024dc[_0x3ba1('0x33')]=_['keys'](_0x357169['query']);_0x3024dc[_0x3ba1('0x3c')]=_['intersection'](_0x3024dc[_0x3ba1('0x32')],_0x3024dc['query']);_0x28269a['attributes']=_[_0x3ba1('0x35')](_0x3024dc[_0x3ba1('0x32')],qs[_0x3ba1('0x37')](_0x357169[_0x3ba1('0x33')][_0x3ba1('0x37')]));_0x28269a[_0x3ba1('0x36')]=_0x28269a[_0x3ba1('0x36')][_0x3ba1('0x38')]?_0x28269a[_0x3ba1('0x36')]:_0x3024dc[_0x3ba1('0x32')];if(_0x357169['query'][_0x3ba1('0x43')]){_0x28269a[_0x3ba1('0x44')]=[{'all':!![]}];}_0x28269a=_[_0x3ba1('0x3e')]({},_0x28269a,_0x357169[_0x3ba1('0x40')]);return db[_0x3ba1('0x41')][_0x3ba1('0x4a')](_0x28269a)[_0x3ba1('0x28')](handleEntityNotFound(_0x26d397,null))['then'](respondWithResult(_0x26d397,null))[_0x3ba1('0x4b')](handleError(_0x26d397,null));};exports['create']=function(_0xa73062,_0x3960d5){return db[_0x3ba1('0x41')]['create'](_0xa73062[_0x3ba1('0x4c')],{})[_0x3ba1('0x28')](function(_0x951ffb){var _0x5d8855=_0xa73062[_0x3ba1('0x4d')]['get']({'plain':!![]});if(!_0x5d8855)throw new Error(_0x3ba1('0x4e'));if(_0x5d8855[_0x3ba1('0x4f')]===_0x3ba1('0x4d')){var _0x557ad6=_0x951ffb[_0x3ba1('0x2a')]({'plain':!![]});var _0x3e594a=_0x3ba1('0x50');return db[_0x3ba1('0x51')][_0x3ba1('0x4a')]({'where':{'name':_0x3e594a,'userProfileId':_0x5d8855[_0x3ba1('0x52')]},'raw':!![]})[_0x3ba1('0x28')](function(_0x324852){if(_0x324852&&_0x324852[_0x3ba1('0x53')]===0x0){return db[_0x3ba1('0x2b')][_0x3ba1('0x54')]({'name':_0x557ad6[_0x3ba1('0x2e')],'resourceId':_0x557ad6['id'],'type':_0x324852[_0x3ba1('0x2e')],'sectionId':_0x324852['id']},{})[_0x3ba1('0x28')](function(){return _0x951ffb;});}else{return _0x951ffb;}})[_0x3ba1('0x4b')](function(_0x2f09ad){logger[_0x3ba1('0x2c')](_0x3ba1('0x55'),_0x2f09ad);throw _0x2f09ad;});}return _0x951ffb;})[_0x3ba1('0x28')](respondWithResult(_0x3960d5,0xc9))[_0x3ba1('0x4b')](handleError(_0x3960d5,null));};exports['update']=function(_0x384d4f,_0xc039fe){if(_0x384d4f['body']['id']){delete _0x384d4f[_0x3ba1('0x4c')]['id'];}return db[_0x3ba1('0x41')][_0x3ba1('0x4a')]({'where':{'id':_0x384d4f[_0x3ba1('0x48')]['id']}})[_0x3ba1('0x28')](handleEntityNotFound(_0xc039fe,null))['then'](saveUpdates(_0x384d4f[_0x3ba1('0x4c')],null))['then'](respondWithResult(_0xc039fe,null))['catch'](handleError(_0xc039fe,null));};exports['destroy']=function(_0x34f226,_0x4859e0){return db['MailQueue']['find']({'where':{'id':_0x34f226[_0x3ba1('0x48')]['id']}})['then'](handleEntityNotFound(_0x4859e0,null))[_0x3ba1('0x28')](removeEntity(_0x4859e0,null))['catch'](handleError(_0x4859e0,null));};exports[_0x3ba1('0x56')]=function(_0x3d5b1f,_0x4ace7e){return db[_0x3ba1('0x41')][_0x3ba1('0x56')]()[_0x3ba1('0x28')](respondWithResult(_0x4ace7e,null))[_0x3ba1('0x4b')](handleError(_0x4ace7e,null));};exports[_0x3ba1('0x57')]=function(_0x3d1c3a,_0x190af1,_0x2dc744){var _0x2ba261={'raw':!![],'where':{}},_0x25913f={},_0x5c0249;return db[_0x3ba1('0x41')]['findOne']({'where':{'id':_0x3d1c3a[_0x3ba1('0x48')]['id']}})[_0x3ba1('0x28')](handleEntityNotFound(_0x190af1,null))[_0x3ba1('0x28')](function(_0x46dd04){if(_0x46dd04){_0x5c0249=_0x46dd04[_0x3ba1('0x2a')]({'plain':!![]});_0x25913f['model']=_[_0x3ba1('0x34')](db[_0x3ba1('0x58')]['rawAttributes']);_0x25913f['query']=_[_0x3ba1('0x34')](_0x3d1c3a[_0x3ba1('0x33')]);_0x25913f['filters']=_[_0x3ba1('0x35')](_0x25913f[_0x3ba1('0x32')],_0x25913f[_0x3ba1('0x33')]);_0x2ba261['attributes']=_[_0x3ba1('0x35')](_0x25913f[_0x3ba1('0x32')],qs['fields'](_0x3d1c3a[_0x3ba1('0x33')][_0x3ba1('0x37')]));_0x2ba261[_0x3ba1('0x36')]=_0x2ba261[_0x3ba1('0x36')][_0x3ba1('0x38')]?_0x2ba261['attributes']:_0x25913f[_0x3ba1('0x32')];if(!_0x3d1c3a[_0x3ba1('0x33')]['hasOwnProperty'](_0x3ba1('0x59'))){_0x2ba261[_0x3ba1('0x21')]=qs[_0x3ba1('0x21')](_0x3d1c3a[_0x3ba1('0x33')][_0x3ba1('0x21')]);_0x2ba261[_0x3ba1('0x20')]=qs[_0x3ba1('0x20')](_0x3d1c3a[_0x3ba1('0x33')]['offset']);}_0x2ba261['order']=qs['sort'](_0x3d1c3a['query'][_0x3ba1('0x5a')]);_0x2ba261[_0x3ba1('0x3a')]=qs['filters'](_[_0x3ba1('0x3b')](_0x3d1c3a[_0x3ba1('0x33')],_0x25913f[_0x3ba1('0x3c')]));_0x2ba261['where'][_0x3ba1('0x5b')]=_0x46dd04['id'];if(_0x3d1c3a[_0x3ba1('0x33')][_0x3ba1('0x3d')]){_0x2ba261[_0x3ba1('0x3a')]=_[_0x3ba1('0x3e')](_0x2ba261[_0x3ba1('0x3a')],{'$or':_[_0x3ba1('0x30')](_0x2ba261[_0x3ba1('0x36')],function(_0x4cbb2f){var _0x1a50ae={};_0x1a50ae[_0x4cbb2f]={'$like':'%'+_0x3d1c3a[_0x3ba1('0x33')]['filter']+'%'};return _0x1a50ae;})});}_0x2ba261=_[_0x3ba1('0x3e')]({},_0x2ba261,_0x3d1c3a[_0x3ba1('0x40')]);return db[_0x3ba1('0x58')][_0x3ba1('0x45')](_0x2ba261);}})[_0x3ba1('0x28')](function(_0x4fa47b){if(_0x4fa47b){return db[_0x3ba1('0x5c')][_0x3ba1('0x5d')]({'where':{'id':_['map'](_0x4fa47b,'UserId'),'role':_0x3ba1('0x5e')},'attributes':['id',_0x3ba1('0x2e'),'mailPause',_0x3ba1('0x5f'),_0x3ba1('0x60')]});}})[_0x3ba1('0x28')](function(_0x29f583){if(_0x29f583){return{'count':_0x29f583['count'],'rows':_[_0x3ba1('0x30')](_0x29f583['rows'],function(_0x16a817){return{'membername':_0x16a817[_0x3ba1('0x2e')],'UserId':_0x16a817['id'],'queue_name':_0x5c0249[_0x3ba1('0x2e')],'MailQueueId':_0x5c0249['id'],'interface':util[_0x3ba1('0x61')](_0x3ba1('0x62'),_0x3ba1('0x63'),_0x16a817[_0x3ba1('0x2e')]),'penalty':0x0,'paused':_0x16a817[_0x3ba1('0x64')],'createdAt':_0x16a817[_0x3ba1('0x60')],'updatedAt':_0x16a817[_0x3ba1('0x5f')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x3ba1('0x28')](respondWithFilteredResult(_0x190af1,_0x2ba261))[_0x3ba1('0x4b')](handleError(_0x190af1,null));};exports['getTeams']=function(_0x49c3dc,_0x2aac59,_0x1367a6){var _0x2ebb07={};var _0x317066={};var _0x458475;var _0x4d56d3;return db['MailQueue']['findOne']({'where':{'id':_0x49c3dc[_0x3ba1('0x48')]['id']}})[_0x3ba1('0x28')](handleEntityNotFound(_0x2aac59,null))[_0x3ba1('0x28')](function(_0x33e9c8){if(_0x33e9c8){_0x458475=_0x33e9c8;_0x317066['model']=_[_0x3ba1('0x34')](db[_0x3ba1('0x65')][_0x3ba1('0x49')]);_0x317066['query']=_[_0x3ba1('0x34')](_0x49c3dc['query']);_0x317066[_0x3ba1('0x3c')]=_[_0x3ba1('0x35')](_0x317066[_0x3ba1('0x32')],_0x317066[_0x3ba1('0x33')]);_0x2ebb07[_0x3ba1('0x36')]=_[_0x3ba1('0x35')](_0x317066[_0x3ba1('0x32')],qs['fields'](_0x49c3dc['query'][_0x3ba1('0x37')]));_0x2ebb07[_0x3ba1('0x36')]=_0x2ebb07['attributes'][_0x3ba1('0x38')]?_0x2ebb07['attributes']:_0x317066[_0x3ba1('0x32')];_0x2ebb07['order']=qs[_0x3ba1('0x5a')](_0x49c3dc[_0x3ba1('0x33')][_0x3ba1('0x5a')]);_0x2ebb07[_0x3ba1('0x3a')]=qs['filters'](_[_0x3ba1('0x3b')](_0x49c3dc[_0x3ba1('0x33')],_0x317066[_0x3ba1('0x3c')]));if(_0x49c3dc[_0x3ba1('0x33')][_0x3ba1('0x3d')]){_0x2ebb07[_0x3ba1('0x3a')]=_[_0x3ba1('0x3e')](_0x2ebb07['where'],{'$or':_[_0x3ba1('0x30')](_0x2ebb07['attributes'],function(_0xbd3f10){var _0x4a49b5={};_0x4a49b5[_0xbd3f10]={'$like':'%'+_0x49c3dc['query'][_0x3ba1('0x3d')]+'%'};return _0x4a49b5;})});}_0x2ebb07=_[_0x3ba1('0x3e')]({},_0x2ebb07,_0x49c3dc[_0x3ba1('0x40')]);return _0x458475[_0x3ba1('0x66')](_0x2ebb07);}})['then'](function(_0x9b2bc3){if(_0x9b2bc3){_0x4d56d3=_0x9b2bc3['length'];if(!_0x49c3dc['query']['hasOwnProperty'](_0x3ba1('0x59'))){_0x2ebb07[_0x3ba1('0x21')]=qs[_0x3ba1('0x21')](_0x49c3dc[_0x3ba1('0x33')]['limit']);_0x2ebb07['offset']=qs['offset'](_0x49c3dc[_0x3ba1('0x33')]['offset']);}return _0x458475[_0x3ba1('0x66')](_0x2ebb07);}})[_0x3ba1('0x28')](function(_0x1bfd01){if(_0x1bfd01){return _0x1bfd01?{'count':_0x4d56d3,'rows':_0x1bfd01}:null;}})['then'](respondWithResult(_0x2aac59,null))[_0x3ba1('0x4b')](handleError(_0x2aac59,null));};exports['addTeams']=function(_0x575a55,_0x2cd77e,_0x362252){var _0x58f6a0=_0x575a55[_0x3ba1('0x4c')][_0x3ba1('0x67')];return db[_0x3ba1('0x65')][_0x3ba1('0x45')]({'where':{'id':_0x58f6a0},'attributes':['id'],'include':[{'model':db[_0x3ba1('0x5c')],'as':_0x3ba1('0x68'),'attributes':['id',_0x3ba1('0x2e'),'online',_0x3ba1('0x69'),_0x3ba1('0x6a')],'raw':!![]}]})[_0x3ba1('0x28')](function(_0x308cc5){if(_0x308cc5){var _0x478875=_['flatMap'](_0x308cc5,function(_0x178070){var _0x5e9eff=_0x178070[_0x3ba1('0x2a')]({'plain':!![]});return _0x5e9eff[_0x3ba1('0x68')];});return db[_0x3ba1('0x41')][_0x3ba1('0x4a')]({'where':{'id':_0x575a55[_0x3ba1('0x48')]['id']}})['then'](function(_0x1a519c){return db[_0x3ba1('0x6b')][_0x3ba1('0x6c')](function(_0x55d1b9){return _0x1a519c[_0x3ba1('0x6d')](_0x58f6a0,{'transaction':_0x55d1b9})['then'](function(){return BPromise[_0x3ba1('0x6e')](_0x478875,function(_0x106abb){return db[_0x3ba1('0x58')][_0x3ba1('0x6f')]({'where':{'UserId':_0x106abb['id'],'MailQueueId':_0x575a55[_0x3ba1('0x48')]['id']},'transaction':_0x55d1b9});});})[_0x3ba1('0x28')](function(){_0x478875[_0x3ba1('0x70')](function(_0x4c47e4){socket[_0x3ba1('0x71')](_0x3ba1('0x72'),{'UserId':_0x4c47e4['id'],'MailQueueId':_0x1a519c['id']});});});});});}})['then'](respondWithStatusCode(_0x2cd77e,null))[_0x3ba1('0x4b')](handleError(_0x2cd77e,null));};exports[_0x3ba1('0x73')]=function(_0x3b67c8,_0x385860,_0x5d0a61){return db[_0x3ba1('0x65')][_0x3ba1('0x45')]({'where':{'id':_0x3b67c8[_0x3ba1('0x33')]['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':_0x3ba1('0x68'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x385860,null))[_0x3ba1('0x28')](function(_0x5378c1){var _0xeb65ef=_[_0x3ba1('0x30')](_0x5378c1,'id');var _0x1d19e4=[];var _0x51b2b8=[];var _0x40d0ac=squel[_0x3ba1('0x74')]();_0x40d0ac['field'](_0x3ba1('0x75'))['from'](_0x3ba1('0x76'),'tq')['join']('user_has_teams','ut',_0x3ba1('0x77'))[_0x3ba1('0x3a')]('MailQueueId\x20=\x20?',_0x3b67c8['params']['id']);for(var _0xec64bd=0x0;_0xec64bd<_0x5378c1[_0x3ba1('0x38')];_0xec64bd+=0x1){let _0x231619=_0x5378c1[_0xec64bd];for(var _0x1ba480=0x0;_0x1ba480<_0x231619['Agents']['length'];_0x1ba480+=0x1){let _0xac70ba=_0x231619['Agents'][_0x1ba480];var _0x1c3d58=_0x40d0ac['clone']();_0x1c3d58[_0x3ba1('0x3a')](_0x3ba1('0x78'),_0xac70ba['id']);_0x51b2b8[_0x3ba1('0x79')](db[_0x3ba1('0x6b')][_0x3ba1('0x33')](_0x1c3d58[_0x3ba1('0x7a')](),{'type':db[_0x3ba1('0x6b')]['QueryTypes'][_0x3ba1('0x7b')]})[_0x3ba1('0x28')](function(_0x35ec07){if(_0x35ec07[_0x3ba1('0x38')]===0x1){return _0xac70ba['id'];}else{var _0x5539e9=_[_0x3ba1('0x7c')](_['map'](_0x35ec07,_0x3ba1('0x7d')),function(_0xaf064){return _[_0x3ba1('0x7e')](_0xeb65ef,_0xaf064);});if(_0x5539e9){return _0xac70ba['id'];}}}));}}return BPromise[_0x3ba1('0x7f')](_0x51b2b8)[_0x3ba1('0x28')](function(_0x401534){_0x1d19e4=_(_0x1d19e4)[_0x3ba1('0x80')](_0x401534)[_0x3ba1('0x81')]()[_0x3ba1('0x82')]();return db[_0x3ba1('0x41')][_0x3ba1('0x4a')]({'where':{'id':_0x3b67c8['params']['id']}})[_0x3ba1('0x28')](function(_0x138ac0){return db[_0x3ba1('0x6b')][_0x3ba1('0x6c')](function(_0x513953){return _0x138ac0[_0x3ba1('0x73')](_0x3b67c8[_0x3ba1('0x33')][_0x3ba1('0x67')],{'transaction':_0x513953})[_0x3ba1('0x28')](function(){if(!_[_0x3ba1('0x83')](_0x1d19e4)){return _0x138ac0['removeAgents'](_0x1d19e4,{'transaction':_0x513953});}})['then'](function(){_0x1d19e4[_0x3ba1('0x70')](function(_0x2468c5){socket[_0x3ba1('0x71')]('userMailQueue:remove',{'UserId':_0x2468c5,'MailQueueId':_0x138ac0['id']});});});});});});})[_0x3ba1('0x28')](respondWithStatusCode(_0x385860,null))[_0x3ba1('0x4b')](handleError(_0x385860,null));};exports[_0x3ba1('0x84')]=function(_0x49e404,_0x12ded4,_0x257b07){return db[_0x3ba1('0x41')][_0x3ba1('0x4a')]({'where':{'id':_0x49e404[_0x3ba1('0x48')]['id']}})[_0x3ba1('0x28')](handleEntityNotFound(_0x12ded4,null))[_0x3ba1('0x28')](function(_0x2acfdc){if(_0x2acfdc){return _0x2acfdc[_0x3ba1('0x84')](_0x49e404['body'][_0x3ba1('0x67')],_[_0x3ba1('0x85')](_0x49e404[_0x3ba1('0x4c')],[_0x3ba1('0x67'),'id'])||{})['spread'](function(_0x424e6a){for(var _0x5a28c0=0x0;_0x5a28c0<_0x49e404['body'][_0x3ba1('0x67')][_0x3ba1('0x38')];_0x5a28c0+=0x1){socket['emit']('userMailQueue:save',{'UserId':_0x49e404[_0x3ba1('0x4c')][_0x3ba1('0x67')][_0x5a28c0],'MailQueueId':_0x49e404[_0x3ba1('0x48')]['id']});}return _0x424e6a;});}})[_0x3ba1('0x28')](respondWithResult(_0x12ded4,null))[_0x3ba1('0x4b')](handleError(_0x12ded4,null));};exports['removeAgents']=function(_0x2f28b9,_0xa7ab77,_0x1b0945){return db[_0x3ba1('0x41')][_0x3ba1('0x4a')]({'where':{'id':_0x2f28b9[_0x3ba1('0x48')]['id']}})['then'](handleEntityNotFound(_0xa7ab77,null))[_0x3ba1('0x28')](function(_0x2a34a5){if(_0x2a34a5){return _0x2a34a5[_0x3ba1('0x86')](_0x2f28b9[_0x3ba1('0x33')][_0x3ba1('0x67')])['then'](function(){if(_[_0x3ba1('0x87')](_0x2f28b9[_0x3ba1('0x33')][_0x3ba1('0x67')])){for(var _0xff2162=0x0;_0xff2162<_0x2f28b9[_0x3ba1('0x33')][_0x3ba1('0x67')][_0x3ba1('0x38')];_0xff2162+=0x1){socket[_0x3ba1('0x71')](_0x3ba1('0x88'),{'UserId':Number(_0x2f28b9[_0x3ba1('0x33')]['ids'][_0xff2162]),'MailQueueId':Number(_0x2f28b9[_0x3ba1('0x48')]['id'])});}}else{socket[_0x3ba1('0x71')](_0x3ba1('0x88'),{'UserId':Number(_0x2f28b9[_0x3ba1('0x33')]['ids']),'MailQueueId':Number(_0x2f28b9[_0x3ba1('0x48')]['id'])});}});}})[_0x3ba1('0x28')](respondWithStatusCode(_0xa7ab77,null))[_0x3ba1('0x4b')](handleError(_0xa7ab77,null));};exports['getAgents']=function(_0xba38f7,_0x11c945,_0xfaec75){var _0x4ba32c={};var _0x39c418={};var _0x2cf774;var _0x3b2e72;return db[_0x3ba1('0x41')][_0x3ba1('0x89')]({'where':{'id':_0xba38f7[_0x3ba1('0x48')]['id']}})[_0x3ba1('0x28')](handleEntityNotFound(_0x11c945,null))['then'](function(_0x48155d){if(_0x48155d){_0x2cf774=_0x48155d;_0x39c418[_0x3ba1('0x32')]=_[_0x3ba1('0x34')](db[_0x3ba1('0x5c')]['rawAttributes']);_0x39c418[_0x3ba1('0x33')]=_['keys'](_0xba38f7['query']);_0x39c418[_0x3ba1('0x3c')]=_['intersection'](_0x39c418[_0x3ba1('0x32')],_0x39c418['query']);_0x4ba32c[_0x3ba1('0x36')]=_[_0x3ba1('0x35')](_0x39c418[_0x3ba1('0x32')],qs[_0x3ba1('0x37')](_0xba38f7['query'][_0x3ba1('0x37')]));_0x4ba32c[_0x3ba1('0x36')]=_0x4ba32c[_0x3ba1('0x36')][_0x3ba1('0x38')]?_0x4ba32c[_0x3ba1('0x36')]:_0x39c418[_0x3ba1('0x32')];_0x4ba32c[_0x3ba1('0x39')]=qs[_0x3ba1('0x5a')](_0xba38f7[_0x3ba1('0x33')][_0x3ba1('0x5a')]);_0x4ba32c['where']=qs[_0x3ba1('0x3c')](_[_0x3ba1('0x3b')](_0xba38f7[_0x3ba1('0x33')],_0x39c418['filters']));if(_0xba38f7[_0x3ba1('0x33')][_0x3ba1('0x3d')]){_0x4ba32c[_0x3ba1('0x3a')]=_[_0x3ba1('0x3e')](_0x4ba32c[_0x3ba1('0x3a')],{'$or':_[_0x3ba1('0x30')](_0x4ba32c[_0x3ba1('0x36')],function(_0x14984c){var _0x38fcc6={};_0x38fcc6[_0x14984c]={'$like':'%'+_0xba38f7[_0x3ba1('0x33')][_0x3ba1('0x3d')]+'%'};return _0x38fcc6;})});}_0x4ba32c=_[_0x3ba1('0x3e')]({},_0x4ba32c,_0xba38f7[_0x3ba1('0x40')]);return _0x2cf774[_0x3ba1('0x8a')](_0x4ba32c);}})[_0x3ba1('0x28')](function(_0x1a9e73){if(_0x1a9e73){_0x3b2e72=_0x1a9e73[_0x3ba1('0x38')];if(!_0xba38f7['query'][_0x3ba1('0x8b')](_0x3ba1('0x59'))){_0x4ba32c[_0x3ba1('0x21')]=qs[_0x3ba1('0x21')](_0xba38f7['query'][_0x3ba1('0x21')]);_0x4ba32c[_0x3ba1('0x20')]=qs[_0x3ba1('0x20')](_0xba38f7[_0x3ba1('0x33')]['offset']);}return _0x2cf774[_0x3ba1('0x8a')](_0x4ba32c);}})[_0x3ba1('0x28')](function(_0x490785){if(_0x490785){return _0x490785?{'count':_0x3b2e72,'rows':_0x490785}:null;}})[_0x3ba1('0x28')](respondWithResult(_0x11c945,null))[_0x3ba1('0x4b')](handleError(_0x11c945,null));};
\ No newline at end of file