Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index 43bfb69..02b7310 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x30d3=['QueryTypes','SELECT','every','TeamId','includes','all','compact','value','isEmpty','removeAgents','userMailQueue:remove','addAgents','omit','isArray','emit','getAgents','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./mailQueue.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject','save','destroy','get','MailQueues','UserProfileResource','stack','send','index','map','MailQueue','rawAttributes','fieldName','type','key','model','name','query','keys','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','then','rows','show','params','length','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','getMembers','findOne','MailQueueId','UserMailQueue','User','findAndCountAll','UserId','agent','mailPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','Agents','online','voicePause','interface','flatMap','sequelize','findOrCreate','forEach','userMailQueue:save','removeTeams','ids','select','from','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','push'];(function(_0x4c4724,_0x246f70){var _0x8345cd=function(_0x3f1dad){while(--_0x3f1dad){_0x4c4724['push'](_0x4c4724['shift']());}};_0x8345cd(++_0x246f70);}(_0x30d3,0x9f));var _0x330d=function(_0xc68242,_0x5db3a7){_0xc68242=_0xc68242-0x0;var _0x5e43cc=_0x30d3[_0xc68242];return _0x5e43cc;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x330d('0x0'));var zipdir=require(_0x330d('0x1'));var jsonpatch=require(_0x330d('0x2'));var rp=require(_0x330d('0x3'));var moment=require(_0x330d('0x4'));var BPromise=require(_0x330d('0x5'));var Mustache=require(_0x330d('0x6'));var util=require('util');var path=require(_0x330d('0x7'));var sox=require(_0x330d('0x8'));var csv=require(_0x330d('0x9'));var ejs=require(_0x330d('0xa'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x330d('0xb'));var jsforce=require(_0x330d('0xc'));var deskjs=require(_0x330d('0xd'));var toCsv=require(_0x330d('0x9'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x330d('0xe'));var authService=require(_0x330d('0xf'));var qs=require(_0x330d('0x10'));var as=require(_0x330d('0x11'));var hardwareService=require(_0x330d('0x12'));var logger=require(_0x330d('0x13'))(_0x330d('0x14'));var utils=require('../../config/utils');var config=require(_0x330d('0x15'));var licenseUtil=require(_0x330d('0x16'));var db=require(_0x330d('0x17'))['db'];config['redis']=_[_0x330d('0x18')](config[_0x330d('0x19')],{'host':_0x330d('0x1a'),'port':0x18eb});var socket=require(_0x330d('0x1b'))(new Redis(config['redis']));require(_0x330d('0x1c'))[_0x330d('0x1d')](socket);function respondWithStatusCode(_0x528b86,_0x324358){_0x324358=_0x324358||0xcc;return function(_0x491259){if(_0x491259){return _0x528b86[_0x330d('0x1e')](_0x324358);}return _0x528b86[_0x330d('0x1f')](_0x324358)[_0x330d('0x20')]();};}function respondWithResult(_0x5e5baf,_0x56ed13){_0x56ed13=_0x56ed13||0xc8;return function(_0x32d2c2){if(_0x32d2c2){return _0x5e5baf[_0x330d('0x1f')](_0x56ed13)[_0x330d('0x21')](_0x32d2c2);}};}function respondWithFilteredResult(_0x571c7f,_0x582539){return function(_0x487b48){if(_0x487b48){var _0x1d7cdd=_0x487b48[_0x330d('0x22')],_0x4e07a4=_0x582539['offset'],_0x5921c0=_0x582539[_0x330d('0x23')]+_0x582539[_0x330d('0x24')],_0x435083;if(_0x5921c0>=_0x1d7cdd){_0x5921c0=_0x1d7cdd;_0x435083=0xc8;}else{_0x435083=0xce;}_0x571c7f[_0x330d('0x1f')](_0x435083);return _0x571c7f[_0x330d('0x25')](_0x330d('0x26'),_0x4e07a4+'-'+_0x5921c0+'/'+_0x1d7cdd)['json'](_0x487b48);}return null;};}function patchUpdates(_0x5819bb){return function(_0x139204){try{jsonpatch['apply'](_0x139204,_0x5819bb,!![]);}catch(_0x3dc6bd){return BPromise[_0x330d('0x27')](_0x3dc6bd);}return _0x139204[_0x330d('0x28')]();};}function saveUpdates(_0x4d9e04,_0x28cafc){return function(_0x79ec15){if(_0x79ec15){return _0x79ec15['update'](_0x4d9e04)['then'](function(_0x3a20af){return _0x3a20af;});}return null;};}function removeEntity(_0x142c23,_0x49fe06){return function(_0x440bbd){if(_0x440bbd){return _0x440bbd[_0x330d('0x29')]()['then'](function(){var _0x538317=_0x440bbd[_0x330d('0x2a')]({'plain':!![]});var _0x3fb6b3=_0x330d('0x2b');return db[_0x330d('0x2c')][_0x330d('0x29')]({'where':{'type':_0x3fb6b3,'resourceId':_0x538317['id']}})['then'](function(){return _0x440bbd;});})['then'](function(){_0x142c23[_0x330d('0x1f')](0xcc)[_0x330d('0x20')]();});}};}function handleEntityNotFound(_0x486f14,_0x3d012d){return function(_0x3af393){if(!_0x3af393){_0x486f14[_0x330d('0x1e')](0x194);}return _0x3af393;};}function handleError(_0x2e7baf,_0x463332){_0x463332=_0x463332||0x1f4;return function(_0x20fa6c){logger['error'](_0x20fa6c[_0x330d('0x2d')]);if(_0x20fa6c['name']){delete _0x20fa6c['name'];}_0x2e7baf[_0x330d('0x1f')](_0x463332)[_0x330d('0x2e')](_0x20fa6c);};}exports[_0x330d('0x2f')]=function(_0x1121cb,_0x46c609){var _0x270ab6={},_0x451d8f={},_0x5c41bb={'count':0x0,'rows':[]};var _0x156749=_[_0x330d('0x30')](db[_0x330d('0x31')][_0x330d('0x32')],function(_0x133ac5){return{'name':_0x133ac5[_0x330d('0x33')],'type':_0x133ac5[_0x330d('0x34')][_0x330d('0x35')]};});_0x451d8f[_0x330d('0x36')]=_[_0x330d('0x30')](_0x156749,_0x330d('0x37'));_0x451d8f[_0x330d('0x38')]=_[_0x330d('0x39')](_0x1121cb['query']);_0x451d8f['filters']=_[_0x330d('0x3a')](_0x451d8f[_0x330d('0x36')],_0x451d8f[_0x330d('0x38')]);_0x270ab6[_0x330d('0x3b')]=_[_0x330d('0x3a')](_0x451d8f[_0x330d('0x36')],qs['fields'](_0x1121cb['query'][_0x330d('0x3c')]));_0x270ab6[_0x330d('0x3b')]=_0x270ab6[_0x330d('0x3b')]['length']?_0x270ab6[_0x330d('0x3b')]:_0x451d8f['model'];if(!_0x1121cb[_0x330d('0x38')][_0x330d('0x3d')](_0x330d('0x3e'))){_0x270ab6[_0x330d('0x24')]=qs[_0x330d('0x24')](_0x1121cb[_0x330d('0x38')][_0x330d('0x24')]);_0x270ab6[_0x330d('0x23')]=qs[_0x330d('0x23')](_0x1121cb[_0x330d('0x38')][_0x330d('0x23')]);}_0x270ab6[_0x330d('0x3f')]=qs['sort'](_0x1121cb['query'][_0x330d('0x40')]);_0x270ab6[_0x330d('0x41')]=qs[_0x330d('0x42')](_[_0x330d('0x43')](_0x1121cb[_0x330d('0x38')],_0x451d8f[_0x330d('0x42')]),_0x156749);if(_0x1121cb[_0x330d('0x38')][_0x330d('0x44')]){_0x270ab6['where']=_['merge'](_0x270ab6['where'],{'$or':_['map'](_0x156749,function(_0x3c2983){if(_0x3c2983[_0x330d('0x34')]!==_0x330d('0x45')){var _0xa9b859={};_0xa9b859[_0x3c2983[_0x330d('0x37')]]={'$like':'%'+_0x1121cb[_0x330d('0x38')][_0x330d('0x44')]+'%'};return _0xa9b859;}})});}_0x270ab6=_[_0x330d('0x46')]({},_0x270ab6,_0x1121cb[_0x330d('0x47')]);var _0x3eab59={'where':_0x270ab6[_0x330d('0x41')]};return db[_0x330d('0x31')][_0x330d('0x22')](_0x3eab59)['then'](function(_0x56fd52){_0x5c41bb[_0x330d('0x22')]=_0x56fd52;if(_0x1121cb[_0x330d('0x38')][_0x330d('0x48')]){_0x270ab6[_0x330d('0x49')]=[{'all':!![]}];}return db[_0x330d('0x31')][_0x330d('0x4a')](_0x270ab6);})[_0x330d('0x4b')](function(_0x341528){_0x5c41bb[_0x330d('0x4c')]=_0x341528;return _0x5c41bb;})['then'](respondWithFilteredResult(_0x46c609,_0x270ab6))['catch'](handleError(_0x46c609,null));};exports[_0x330d('0x4d')]=function(_0x1c0098,_0x3ddb3b){var _0x2f20df={'raw':!![],'where':{'id':_0x1c0098[_0x330d('0x4e')]['id']}},_0xc1d2d3={};_0xc1d2d3[_0x330d('0x36')]=_['keys'](db['MailQueue'][_0x330d('0x32')]);_0xc1d2d3[_0x330d('0x38')]=_['keys'](_0x1c0098[_0x330d('0x38')]);_0xc1d2d3[_0x330d('0x42')]=_[_0x330d('0x3a')](_0xc1d2d3[_0x330d('0x36')],_0xc1d2d3[_0x330d('0x38')]);_0x2f20df['attributes']=_[_0x330d('0x3a')](_0xc1d2d3[_0x330d('0x36')],qs[_0x330d('0x3c')](_0x1c0098[_0x330d('0x38')][_0x330d('0x3c')]));_0x2f20df['attributes']=_0x2f20df[_0x330d('0x3b')][_0x330d('0x4f')]?_0x2f20df['attributes']:_0xc1d2d3[_0x330d('0x36')];if(_0x1c0098['query'][_0x330d('0x48')]){_0x2f20df[_0x330d('0x49')]=[{'all':!![]}];}_0x2f20df=_[_0x330d('0x46')]({},_0x2f20df,_0x1c0098[_0x330d('0x47')]);return db[_0x330d('0x31')][_0x330d('0x50')](_0x2f20df)[_0x330d('0x4b')](handleEntityNotFound(_0x3ddb3b,null))[_0x330d('0x4b')](respondWithResult(_0x3ddb3b,null))[_0x330d('0x51')](handleError(_0x3ddb3b,null));};exports[_0x330d('0x52')]=function(_0x27768e,_0x357af5){return db[_0x330d('0x31')][_0x330d('0x52')](_0x27768e[_0x330d('0x53')],{})[_0x330d('0x4b')](function(_0x1e34c7){var _0x3ecb8b=_0x27768e[_0x330d('0x54')][_0x330d('0x2a')]({'plain':!![]});if(!_0x3ecb8b)throw new Error(_0x330d('0x55'));if(_0x3ecb8b[_0x330d('0x56')]===_0x330d('0x54')){var _0x5712a8=_0x1e34c7['get']({'plain':!![]});var _0x224ed9='MailQueues';return db[_0x330d('0x57')][_0x330d('0x50')]({'where':{'name':_0x224ed9,'userProfileId':_0x3ecb8b['userProfileId']},'raw':!![]})[_0x330d('0x4b')](function(_0x44833f){if(_0x44833f&&_0x44833f[_0x330d('0x58')]===0x0){return db['UserProfileResource'][_0x330d('0x52')]({'name':_0x5712a8[_0x330d('0x37')],'resourceId':_0x5712a8['id'],'type':_0x44833f[_0x330d('0x37')],'sectionId':_0x44833f['id']},{})['then'](function(){return _0x1e34c7;});}else{return _0x1e34c7;}})[_0x330d('0x51')](function(_0x1099a6){logger[_0x330d('0x59')](_0x330d('0x5a'),_0x1099a6);throw _0x1099a6;});}return _0x1e34c7;})[_0x330d('0x4b')](respondWithResult(_0x357af5,0xc9))[_0x330d('0x51')](handleError(_0x357af5,null));};exports[_0x330d('0x5b')]=function(_0x1635f6,_0xc00ee8){if(_0x1635f6[_0x330d('0x53')]['id']){delete _0x1635f6[_0x330d('0x53')]['id'];}return db[_0x330d('0x31')][_0x330d('0x50')]({'where':{'id':_0x1635f6[_0x330d('0x4e')]['id']}})['then'](handleEntityNotFound(_0xc00ee8,null))['then'](saveUpdates(_0x1635f6['body'],null))[_0x330d('0x4b')](respondWithResult(_0xc00ee8,null))[_0x330d('0x51')](handleError(_0xc00ee8,null));};exports[_0x330d('0x29')]=function(_0x27dbb3,_0x454448){return db[_0x330d('0x31')]['find']({'where':{'id':_0x27dbb3['params']['id']}})[_0x330d('0x4b')](handleEntityNotFound(_0x454448,null))[_0x330d('0x4b')](removeEntity(_0x454448,null))['catch'](handleError(_0x454448,null));};exports[_0x330d('0x5c')]=function(_0x5c01bc,_0x2e2256){return db[_0x330d('0x31')]['describe']()[_0x330d('0x4b')](respondWithResult(_0x2e2256,null))[_0x330d('0x51')](handleError(_0x2e2256,null));};exports[_0x330d('0x5d')]=function(_0x5d211c,_0x2988b9,_0x1d0f55){var _0x2e6b27={'raw':!![],'where':{}},_0x3b094b={},_0x50157e;return db['MailQueue'][_0x330d('0x5e')]({'where':{'id':_0x5d211c['params']['id']}})['then'](handleEntityNotFound(_0x2988b9,null))[_0x330d('0x4b')](function(_0x5195dc){if(_0x5195dc){_0x50157e=_0x5195dc[_0x330d('0x2a')]({'plain':!![]});_0x3b094b[_0x330d('0x36')]=_['keys'](db['UserMailQueue'][_0x330d('0x32')]);_0x3b094b['query']=_['keys'](_0x5d211c[_0x330d('0x38')]);_0x3b094b[_0x330d('0x42')]=_[_0x330d('0x3a')](_0x3b094b['model'],_0x3b094b['query']);_0x2e6b27[_0x330d('0x3b')]=_['intersection'](_0x3b094b[_0x330d('0x36')],qs[_0x330d('0x3c')](_0x5d211c[_0x330d('0x38')][_0x330d('0x3c')]));_0x2e6b27[_0x330d('0x3b')]=_0x2e6b27[_0x330d('0x3b')][_0x330d('0x4f')]?_0x2e6b27[_0x330d('0x3b')]:_0x3b094b['model'];if(!_0x5d211c[_0x330d('0x38')]['hasOwnProperty'](_0x330d('0x3e'))){_0x2e6b27[_0x330d('0x24')]=qs[_0x330d('0x24')](_0x5d211c['query'][_0x330d('0x24')]);_0x2e6b27[_0x330d('0x23')]=qs[_0x330d('0x23')](_0x5d211c['query'][_0x330d('0x23')]);}_0x2e6b27['order']=qs[_0x330d('0x40')](_0x5d211c[_0x330d('0x38')]['sort']);_0x2e6b27[_0x330d('0x41')]=qs[_0x330d('0x42')](_[_0x330d('0x43')](_0x5d211c['query'],_0x3b094b[_0x330d('0x42')]));_0x2e6b27[_0x330d('0x41')][_0x330d('0x5f')]=_0x5195dc['id'];if(_0x5d211c[_0x330d('0x38')]['filter']){_0x2e6b27[_0x330d('0x41')]=_[_0x330d('0x46')](_0x2e6b27[_0x330d('0x41')],{'$or':_['map'](_0x2e6b27[_0x330d('0x3b')],function(_0x4b8909){var _0x4e5006={};_0x4e5006[_0x4b8909]={'$like':'%'+_0x5d211c[_0x330d('0x38')][_0x330d('0x44')]+'%'};return _0x4e5006;})});}_0x2e6b27=_[_0x330d('0x46')]({},_0x2e6b27,_0x5d211c['options']);return db[_0x330d('0x60')][_0x330d('0x4a')](_0x2e6b27);}})[_0x330d('0x4b')](function(_0x420434){if(_0x420434){return db[_0x330d('0x61')][_0x330d('0x62')]({'where':{'id':_['map'](_0x420434,_0x330d('0x63')),'role':_0x330d('0x64')},'attributes':['id',_0x330d('0x37'),_0x330d('0x65'),_0x330d('0x66'),_0x330d('0x67')]});}})[_0x330d('0x4b')](function(_0x1ddf8f){if(_0x1ddf8f){return{'count':_0x1ddf8f[_0x330d('0x22')],'rows':_[_0x330d('0x30')](_0x1ddf8f['rows'],function(_0x797d83){return{'membername':_0x797d83[_0x330d('0x37')],'UserId':_0x797d83['id'],'queue_name':_0x50157e['name'],'MailQueueId':_0x50157e['id'],'interface':util[_0x330d('0x68')](_0x330d('0x69'),_0x330d('0x6a'),_0x797d83[_0x330d('0x37')]),'penalty':0x0,'paused':_0x797d83[_0x330d('0x65')],'createdAt':_0x797d83[_0x330d('0x67')],'updatedAt':_0x797d83[_0x330d('0x66')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x330d('0x4b')](respondWithFilteredResult(_0x2988b9,_0x2e6b27))[_0x330d('0x51')](handleError(_0x2988b9,null));};exports[_0x330d('0x6b')]=function(_0x268870,_0x21b796,_0x364408){var _0x5daf4f={};var _0x98007e={};var _0x51af09;var _0x1c0069;return db[_0x330d('0x31')]['findOne']({'where':{'id':_0x268870['params']['id']}})[_0x330d('0x4b')](handleEntityNotFound(_0x21b796,null))[_0x330d('0x4b')](function(_0x339bc2){if(_0x339bc2){_0x51af09=_0x339bc2;_0x98007e[_0x330d('0x36')]=_['keys'](db[_0x330d('0x6c')][_0x330d('0x32')]);_0x98007e[_0x330d('0x38')]=_[_0x330d('0x39')](_0x268870[_0x330d('0x38')]);_0x98007e[_0x330d('0x42')]=_[_0x330d('0x3a')](_0x98007e[_0x330d('0x36')],_0x98007e['query']);_0x5daf4f['attributes']=_[_0x330d('0x3a')](_0x98007e[_0x330d('0x36')],qs[_0x330d('0x3c')](_0x268870[_0x330d('0x38')][_0x330d('0x3c')]));_0x5daf4f[_0x330d('0x3b')]=_0x5daf4f[_0x330d('0x3b')]['length']?_0x5daf4f[_0x330d('0x3b')]:_0x98007e[_0x330d('0x36')];_0x5daf4f[_0x330d('0x3f')]=qs['sort'](_0x268870[_0x330d('0x38')][_0x330d('0x40')]);_0x5daf4f['where']=qs[_0x330d('0x42')](_['pick'](_0x268870[_0x330d('0x38')],_0x98007e['filters']));if(_0x268870[_0x330d('0x38')][_0x330d('0x44')]){_0x5daf4f['where']=_[_0x330d('0x46')](_0x5daf4f[_0x330d('0x41')],{'$or':_['map'](_0x5daf4f[_0x330d('0x3b')],function(_0xe8d74c){var _0x1808c8={};_0x1808c8[_0xe8d74c]={'$like':'%'+_0x268870[_0x330d('0x38')][_0x330d('0x44')]+'%'};return _0x1808c8;})});}_0x5daf4f=_[_0x330d('0x46')]({},_0x5daf4f,_0x268870['options']);return _0x51af09['getTeams'](_0x5daf4f);}})['then'](function(_0x1d574a){if(_0x1d574a){_0x1c0069=_0x1d574a[_0x330d('0x4f')];if(!_0x268870[_0x330d('0x38')][_0x330d('0x3d')](_0x330d('0x3e'))){_0x5daf4f[_0x330d('0x24')]=qs['limit'](_0x268870['query'][_0x330d('0x24')]);_0x5daf4f[_0x330d('0x23')]=qs[_0x330d('0x23')](_0x268870[_0x330d('0x38')][_0x330d('0x23')]);}return _0x51af09['getTeams'](_0x5daf4f);}})[_0x330d('0x4b')](function(_0x4084eb){if(_0x4084eb){return _0x4084eb?{'count':_0x1c0069,'rows':_0x4084eb}:null;}})['then'](respondWithResult(_0x21b796,null))[_0x330d('0x51')](handleError(_0x21b796,null));};exports[_0x330d('0x6d')]=function(_0x11d715,_0x25e761,_0x514629){var _0x3a5032=_0x11d715[_0x330d('0x53')]['ids'];return db[_0x330d('0x6c')][_0x330d('0x4a')]({'where':{'id':_0x3a5032},'attributes':['id'],'include':[{'model':db['User'],'as':_0x330d('0x6e'),'attributes':['id',_0x330d('0x37'),_0x330d('0x6f'),_0x330d('0x70'),_0x330d('0x71')],'raw':!![]}]})[_0x330d('0x4b')](function(_0x4c4f5a){if(_0x4c4f5a){var _0x57327b=_[_0x330d('0x72')](_0x4c4f5a,function(_0x142fe3){var _0x11b57e=_0x142fe3[_0x330d('0x2a')]({'plain':!![]});return _0x11b57e[_0x330d('0x6e')];});return db['MailQueue'][_0x330d('0x50')]({'where':{'id':_0x11d715[_0x330d('0x4e')]['id']}})[_0x330d('0x4b')](function(_0x4b2552){return db[_0x330d('0x73')]['transaction'](function(_0x44aadc){return _0x4b2552['addTeams'](_0x3a5032,{'transaction':_0x44aadc})[_0x330d('0x4b')](function(){return BPromise['each'](_0x57327b,function(_0x7fa45){return db[_0x330d('0x60')][_0x330d('0x74')]({'where':{'UserId':_0x7fa45['id'],'MailQueueId':_0x11d715[_0x330d('0x4e')]['id']},'transaction':_0x44aadc});});})[_0x330d('0x4b')](function(){_0x57327b[_0x330d('0x75')](function(_0x2d6ed3){socket['emit'](_0x330d('0x76'),{'UserId':_0x2d6ed3['id'],'MailQueueId':_0x4b2552['id']});});});});});}})[_0x330d('0x4b')](respondWithStatusCode(_0x25e761,null))['catch'](handleError(_0x25e761,null));};exports[_0x330d('0x77')]=function(_0x13ab1d,_0x5d3b71,_0x5cdcb9){return db[_0x330d('0x6c')][_0x330d('0x4a')]({'where':{'id':_0x13ab1d[_0x330d('0x38')][_0x330d('0x78')]},'attributes':['id'],'include':[{'model':db[_0x330d('0x61')],'as':_0x330d('0x6e'),'attributes':['id'],'raw':!![]}]})[_0x330d('0x4b')](handleEntityNotFound(_0x5d3b71,null))['then'](function(_0x4735d9){var _0x5629b8=_[_0x330d('0x30')](_0x4735d9,'id');var _0x107f6d=[];var _0x2f8077=[];var _0xdee1d3=squel[_0x330d('0x79')]();_0xdee1d3['field']('tq.TeamId')[_0x330d('0x7a')]('team_has_mail_queues','tq')['join'](_0x330d('0x7b'),'ut',_0x330d('0x7c'))['where']('MailQueueId\x20=\x20?',_0x13ab1d['params']['id']);for(var _0x303d97=0x0;_0x303d97<_0x4735d9['length'];_0x303d97+=0x1){let _0x3521d5=_0x4735d9[_0x303d97];for(var _0x54af7e=0x0;_0x54af7e<_0x3521d5['Agents'][_0x330d('0x4f')];_0x54af7e+=0x1){let _0x130010=_0x3521d5['Agents'][_0x54af7e];var _0x6fd9d7=_0xdee1d3[_0x330d('0x7d')]();_0x6fd9d7[_0x330d('0x41')]('ut.UserId\x20=\x20?',_0x130010['id']);_0x2f8077[_0x330d('0x7e')](db['sequelize']['query'](_0x6fd9d7['toString'](),{'type':db[_0x330d('0x73')][_0x330d('0x7f')][_0x330d('0x80')]})[_0x330d('0x4b')](function(_0x5f14e5){if(_0x5f14e5[_0x330d('0x4f')]===0x1){return _0x130010['id'];}else{var _0x1a3ed9=_[_0x330d('0x81')](_[_0x330d('0x30')](_0x5f14e5,_0x330d('0x82')),function(_0x2404b7){return _[_0x330d('0x83')](_0x5629b8,_0x2404b7);});if(_0x1a3ed9){return _0x130010['id'];}}}));}}return BPromise[_0x330d('0x84')](_0x2f8077)[_0x330d('0x4b')](function(_0x6d1b8d){_0x107f6d=_(_0x107f6d)['union'](_0x6d1b8d)[_0x330d('0x85')]()[_0x330d('0x86')]();return db[_0x330d('0x31')][_0x330d('0x50')]({'where':{'id':_0x13ab1d['params']['id']}})[_0x330d('0x4b')](function(_0x4f6a23){return db['sequelize']['transaction'](function(_0x32aee3){return _0x4f6a23[_0x330d('0x77')](_0x13ab1d[_0x330d('0x38')][_0x330d('0x78')],{'transaction':_0x32aee3})[_0x330d('0x4b')](function(){if(!_[_0x330d('0x87')](_0x107f6d)){return _0x4f6a23[_0x330d('0x88')](_0x107f6d,{'transaction':_0x32aee3});}})[_0x330d('0x4b')](function(){_0x107f6d[_0x330d('0x75')](function(_0x2f8da1){socket['emit'](_0x330d('0x89'),{'UserId':_0x2f8da1,'MailQueueId':_0x4f6a23['id']});});});});});});})['then'](respondWithStatusCode(_0x5d3b71,null))['catch'](handleError(_0x5d3b71,null));};exports[_0x330d('0x8a')]=function(_0x2b2a1c,_0x5b221c,_0x10c15e){return db[_0x330d('0x31')][_0x330d('0x50')]({'where':{'id':_0x2b2a1c[_0x330d('0x4e')]['id']}})[_0x330d('0x4b')](handleEntityNotFound(_0x5b221c,null))[_0x330d('0x4b')](function(_0x5ad997){if(_0x5ad997){return _0x5ad997[_0x330d('0x8a')](_0x2b2a1c[_0x330d('0x53')][_0x330d('0x78')],_[_0x330d('0x8b')](_0x2b2a1c[_0x330d('0x53')],['ids','id'])||{})['spread'](function(_0x36985c){for(var _0x4fa412=0x0;_0x4fa412<_0x2b2a1c['body'][_0x330d('0x78')][_0x330d('0x4f')];_0x4fa412+=0x1){socket['emit'](_0x330d('0x76'),{'UserId':_0x2b2a1c[_0x330d('0x53')]['ids'][_0x4fa412],'MailQueueId':_0x2b2a1c['params']['id']});}return _0x36985c;});}})[_0x330d('0x4b')](respondWithResult(_0x5b221c,null))[_0x330d('0x51')](handleError(_0x5b221c,null));};exports[_0x330d('0x88')]=function(_0x1a75b1,_0x9502dc,_0x2870e1){return db[_0x330d('0x31')][_0x330d('0x50')]({'where':{'id':_0x1a75b1[_0x330d('0x4e')]['id']}})[_0x330d('0x4b')](handleEntityNotFound(_0x9502dc,null))['then'](function(_0x632cd5){if(_0x632cd5){return _0x632cd5[_0x330d('0x88')](_0x1a75b1[_0x330d('0x38')][_0x330d('0x78')])[_0x330d('0x4b')](function(){if(_[_0x330d('0x8c')](_0x1a75b1['query'][_0x330d('0x78')])){for(var _0x4aab9e=0x0;_0x4aab9e<_0x1a75b1[_0x330d('0x38')]['ids'][_0x330d('0x4f')];_0x4aab9e+=0x1){socket[_0x330d('0x8d')](_0x330d('0x89'),{'UserId':Number(_0x1a75b1[_0x330d('0x38')][_0x330d('0x78')][_0x4aab9e]),'MailQueueId':Number(_0x1a75b1[_0x330d('0x4e')]['id'])});}}else{socket['emit'](_0x330d('0x89'),{'UserId':Number(_0x1a75b1[_0x330d('0x38')][_0x330d('0x78')]),'MailQueueId':Number(_0x1a75b1['params']['id'])});}});}})[_0x330d('0x4b')](respondWithStatusCode(_0x9502dc,null))['catch'](handleError(_0x9502dc,null));};exports['getAgents']=function(_0x368495,_0x3121cc,_0x17b0e8){var _0x194093={};var _0x566035={};var _0x27dcf1;var _0x2cee62;return db['MailQueue'][_0x330d('0x5e')]({'where':{'id':_0x368495['params']['id']}})['then'](handleEntityNotFound(_0x3121cc,null))[_0x330d('0x4b')](function(_0x6ed88c){if(_0x6ed88c){_0x27dcf1=_0x6ed88c;_0x566035[_0x330d('0x36')]=_['keys'](db[_0x330d('0x61')][_0x330d('0x32')]);_0x566035['query']=_[_0x330d('0x39')](_0x368495[_0x330d('0x38')]);_0x566035[_0x330d('0x42')]=_['intersection'](_0x566035[_0x330d('0x36')],_0x566035[_0x330d('0x38')]);_0x194093['attributes']=_[_0x330d('0x3a')](_0x566035[_0x330d('0x36')],qs['fields'](_0x368495[_0x330d('0x38')][_0x330d('0x3c')]));_0x194093[_0x330d('0x3b')]=_0x194093['attributes'][_0x330d('0x4f')]?_0x194093[_0x330d('0x3b')]:_0x566035[_0x330d('0x36')];_0x194093[_0x330d('0x3f')]=qs[_0x330d('0x40')](_0x368495[_0x330d('0x38')][_0x330d('0x40')]);_0x194093['where']=qs[_0x330d('0x42')](_['pick'](_0x368495[_0x330d('0x38')],_0x566035[_0x330d('0x42')]));if(_0x368495[_0x330d('0x38')][_0x330d('0x44')]){_0x194093[_0x330d('0x41')]=_[_0x330d('0x46')](_0x194093[_0x330d('0x41')],{'$or':_[_0x330d('0x30')](_0x194093['attributes'],function(_0x2f56ac){var _0x1757c4={};_0x1757c4[_0x2f56ac]={'$like':'%'+_0x368495[_0x330d('0x38')][_0x330d('0x44')]+'%'};return _0x1757c4;})});}_0x194093=_['merge']({},_0x194093,_0x368495[_0x330d('0x47')]);return _0x27dcf1[_0x330d('0x8e')](_0x194093);}})[_0x330d('0x4b')](function(_0x1ec9ba){if(_0x1ec9ba){_0x2cee62=_0x1ec9ba[_0x330d('0x4f')];if(!_0x368495[_0x330d('0x38')][_0x330d('0x3d')](_0x330d('0x3e'))){_0x194093['limit']=qs[_0x330d('0x24')](_0x368495[_0x330d('0x38')][_0x330d('0x24')]);_0x194093[_0x330d('0x23')]=qs['offset'](_0x368495[_0x330d('0x38')]['offset']);}return _0x27dcf1[_0x330d('0x8e')](_0x194093);}})[_0x330d('0x4b')](function(_0x5dca24){if(_0x5dca24){return _0x5dca24?{'count':_0x2cee62,'rows':_0x5dca24}:null;}})[_0x330d('0x4b')](respondWithResult(_0x3121cc,null))[_0x330d('0x51')](handleError(_0x3121cc,null));};
\ No newline at end of file
+var _0x180d=['json','count','offset','limit','Content-Range','apply','reject','save','update','then','destroy','MailQueues','UserProfileResource','end','sendStatus','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','fields','attributes','length','nolimit','sort','filter','VIRTUAL','merge','options','MailQueue','includeAll','include','rows','show','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','findOne','get','UserMailQueue','hasOwnProperty','order','where','pick','findAll','UserId','agent','mailPause','updatedAt','%s/%s','SIP','getTeams','Team','addTeams','ids','Agents','online','voicePause','sequelize','transaction','each','findOrCreate','forEach','emit','userMailQueue:save','removeTeams','User','select','from','team_has_mail_queues','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','QueryTypes','every','TeamId','all','union','value','isEmpty','removeAgents','userMailQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','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','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./mailQueue.socket','register','status'];(function(_0x77d76e,_0x106ed2){var _0x5620c8=function(_0x481b37){while(--_0x481b37){_0x77d76e['push'](_0x77d76e['shift']());}};_0x5620c8(++_0x106ed2);}(_0x180d,0xf9));var _0xd180=function(_0x4b2436,_0x452299){_0x4b2436=_0x4b2436-0x0;var _0x4f5ab2=_0x180d[_0x4b2436];return _0x4f5ab2;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xd180('0x0'));var rimraf=require(_0xd180('0x1'));var zipdir=require(_0xd180('0x2'));var jsonpatch=require(_0xd180('0x3'));var rp=require(_0xd180('0x4'));var moment=require('moment');var BPromise=require(_0xd180('0x5'));var Mustache=require(_0xd180('0x6'));var util=require(_0xd180('0x7'));var path=require(_0xd180('0x8'));var sox=require(_0xd180('0x9'));var csv=require(_0xd180('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xd180('0xb'));var crypto=require(_0xd180('0xc'));var jsforce=require(_0xd180('0xd'));var deskjs=require(_0xd180('0xe'));var toCsv=require(_0xd180('0xa'));var querystring=require(_0xd180('0xf'));var Papa=require(_0xd180('0x10'));var Redis=require(_0xd180('0x11'));var authService=require(_0xd180('0x12'));var qs=require(_0xd180('0x13'));var as=require(_0xd180('0x14'));var hardwareService=require(_0xd180('0x15'));var logger=require(_0xd180('0x16'))(_0xd180('0x17'));var utils=require('../../config/utils');var config=require(_0xd180('0x18'));var licenseUtil=require(_0xd180('0x19'));var db=require(_0xd180('0x1a'))['db'];config[_0xd180('0x1b')]=_[_0xd180('0x1c')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xd180('0x1d'))(new Redis(config[_0xd180('0x1b')]));require(_0xd180('0x1e'))[_0xd180('0x1f')](socket);function respondWithStatusCode(_0x349f5c,_0x3118da){_0x3118da=_0x3118da||0xcc;return function(_0x4f80a4){if(_0x4f80a4){return _0x349f5c['sendStatus'](_0x3118da);}return _0x349f5c[_0xd180('0x20')](_0x3118da)['end']();};}function respondWithResult(_0x544a38,_0x21653d){_0x21653d=_0x21653d||0xc8;return function(_0x488435){if(_0x488435){return _0x544a38[_0xd180('0x20')](_0x21653d)[_0xd180('0x21')](_0x488435);}};}function respondWithFilteredResult(_0x3ae54c,_0x254126){return function(_0x543e14){if(_0x543e14){var _0x45596d=_0x543e14[_0xd180('0x22')],_0x4fbfaa=_0x254126[_0xd180('0x23')],_0x3ed54d=_0x254126[_0xd180('0x23')]+_0x254126[_0xd180('0x24')],_0x24e5a4;if(_0x3ed54d>=_0x45596d){_0x3ed54d=_0x45596d;_0x24e5a4=0xc8;}else{_0x24e5a4=0xce;}_0x3ae54c[_0xd180('0x20')](_0x24e5a4);return _0x3ae54c['set'](_0xd180('0x25'),_0x4fbfaa+'-'+_0x3ed54d+'/'+_0x45596d)['json'](_0x543e14);}return null;};}function patchUpdates(_0x1bdeda){return function(_0x3e6f03){try{jsonpatch[_0xd180('0x26')](_0x3e6f03,_0x1bdeda,!![]);}catch(_0x26f4ff){return BPromise[_0xd180('0x27')](_0x26f4ff);}return _0x3e6f03[_0xd180('0x28')]();};}function saveUpdates(_0x33060f,_0xe6f3f2){return function(_0x651ff6){if(_0x651ff6){return _0x651ff6[_0xd180('0x29')](_0x33060f)[_0xd180('0x2a')](function(_0x4e7356){return _0x4e7356;});}return null;};}function removeEntity(_0x1ddd4e,_0x258932){return function(_0x514274){if(_0x514274){return _0x514274[_0xd180('0x2b')]()[_0xd180('0x2a')](function(){var _0x25b8dd=_0x514274['get']({'plain':!![]});var _0x23c690=_0xd180('0x2c');return db[_0xd180('0x2d')]['destroy']({'where':{'type':_0x23c690,'resourceId':_0x25b8dd['id']}})[_0xd180('0x2a')](function(){return _0x514274;});})[_0xd180('0x2a')](function(){_0x1ddd4e['status'](0xcc)[_0xd180('0x2e')]();});}};}function handleEntityNotFound(_0x38d44e,_0xa20dd){return function(_0x1a068e){if(!_0x1a068e){_0x38d44e[_0xd180('0x2f')](0x194);}return _0x1a068e;};}function handleError(_0x615dd0,_0x23bb24){_0x23bb24=_0x23bb24||0x1f4;return function(_0x4bd223){logger[_0xd180('0x30')](_0x4bd223[_0xd180('0x31')]);if(_0x4bd223[_0xd180('0x32')]){delete _0x4bd223[_0xd180('0x32')];}_0x615dd0[_0xd180('0x20')](_0x23bb24)[_0xd180('0x33')](_0x4bd223);};}exports[_0xd180('0x34')]=function(_0x5c6171,_0x3d54b0){var _0x301b48={},_0x4b412f={},_0x5b99eb={'count':0x0,'rows':[]};var _0x214924=_[_0xd180('0x35')](db['MailQueue'][_0xd180('0x36')],function(_0x2a7424){return{'name':_0x2a7424[_0xd180('0x37')],'type':_0x2a7424[_0xd180('0x38')][_0xd180('0x39')]};});_0x4b412f[_0xd180('0x3a')]=_[_0xd180('0x35')](_0x214924,'name');_0x4b412f['query']=_[_0xd180('0x3b')](_0x5c6171[_0xd180('0x3c')]);_0x4b412f[_0xd180('0x3d')]=_[_0xd180('0x3e')](_0x4b412f[_0xd180('0x3a')],_0x4b412f[_0xd180('0x3c')]);_0x301b48['attributes']=_['intersection'](_0x4b412f[_0xd180('0x3a')],qs[_0xd180('0x3f')](_0x5c6171['query'][_0xd180('0x3f')]));_0x301b48[_0xd180('0x40')]=_0x301b48[_0xd180('0x40')][_0xd180('0x41')]?_0x301b48[_0xd180('0x40')]:_0x4b412f[_0xd180('0x3a')];if(!_0x5c6171[_0xd180('0x3c')]['hasOwnProperty'](_0xd180('0x42'))){_0x301b48['limit']=qs['limit'](_0x5c6171[_0xd180('0x3c')][_0xd180('0x24')]);_0x301b48['offset']=qs[_0xd180('0x23')](_0x5c6171['query'][_0xd180('0x23')]);}_0x301b48['order']=qs[_0xd180('0x43')](_0x5c6171[_0xd180('0x3c')]['sort']);_0x301b48['where']=qs[_0xd180('0x3d')](_['pick'](_0x5c6171[_0xd180('0x3c')],_0x4b412f['filters']),_0x214924);if(_0x5c6171[_0xd180('0x3c')][_0xd180('0x44')]){_0x301b48['where']=_['merge'](_0x301b48['where'],{'$or':_[_0xd180('0x35')](_0x214924,function(_0x56d24e){if(_0x56d24e[_0xd180('0x38')]!==_0xd180('0x45')){var _0x2cb76b={};_0x2cb76b[_0x56d24e[_0xd180('0x32')]]={'$like':'%'+_0x5c6171[_0xd180('0x3c')][_0xd180('0x44')]+'%'};return _0x2cb76b;}})});}_0x301b48=_[_0xd180('0x46')]({},_0x301b48,_0x5c6171[_0xd180('0x47')]);var _0x26ef14={'where':_0x301b48['where']};return db[_0xd180('0x48')]['count'](_0x26ef14)[_0xd180('0x2a')](function(_0x58b7e9){_0x5b99eb[_0xd180('0x22')]=_0x58b7e9;if(_0x5c6171['query'][_0xd180('0x49')]){_0x301b48[_0xd180('0x4a')]=[{'all':!![]}];}return db[_0xd180('0x48')]['findAll'](_0x301b48);})[_0xd180('0x2a')](function(_0x518f94){_0x5b99eb[_0xd180('0x4b')]=_0x518f94;return _0x5b99eb;})[_0xd180('0x2a')](respondWithFilteredResult(_0x3d54b0,_0x301b48))['catch'](handleError(_0x3d54b0,null));};exports[_0xd180('0x4c')]=function(_0x3367f8,_0x29b95a){var _0xd772f2={'raw':!![],'where':{'id':_0x3367f8['params']['id']}},_0x11584b={};_0x11584b[_0xd180('0x3a')]=_[_0xd180('0x3b')](db[_0xd180('0x48')][_0xd180('0x36')]);_0x11584b['query']=_[_0xd180('0x3b')](_0x3367f8[_0xd180('0x3c')]);_0x11584b[_0xd180('0x3d')]=_[_0xd180('0x3e')](_0x11584b['model'],_0x11584b['query']);_0xd772f2['attributes']=_[_0xd180('0x3e')](_0x11584b[_0xd180('0x3a')],qs['fields'](_0x3367f8[_0xd180('0x3c')][_0xd180('0x3f')]));_0xd772f2[_0xd180('0x40')]=_0xd772f2[_0xd180('0x40')]['length']?_0xd772f2[_0xd180('0x40')]:_0x11584b[_0xd180('0x3a')];if(_0x3367f8[_0xd180('0x3c')][_0xd180('0x49')]){_0xd772f2['include']=[{'all':!![]}];}_0xd772f2=_['merge']({},_0xd772f2,_0x3367f8[_0xd180('0x47')]);return db[_0xd180('0x48')][_0xd180('0x4d')](_0xd772f2)[_0xd180('0x2a')](handleEntityNotFound(_0x29b95a,null))['then'](respondWithResult(_0x29b95a,null))[_0xd180('0x4e')](handleError(_0x29b95a,null));};exports['create']=function(_0x37973b,_0x2f85cc){return db[_0xd180('0x48')][_0xd180('0x4f')](_0x37973b[_0xd180('0x50')],{})[_0xd180('0x2a')](function(_0x5c0c01){var _0x56a646=_0x37973b[_0xd180('0x51')]['get']({'plain':!![]});if(!_0x56a646)throw new Error(_0xd180('0x52'));if(_0x56a646[_0xd180('0x53')]==='user'){var _0x38b2ef=_0x5c0c01['get']({'plain':!![]});var _0x1d906f=_0xd180('0x2c');return db['UserProfileSection'][_0xd180('0x4d')]({'where':{'name':_0x1d906f,'userProfileId':_0x56a646['userProfileId']},'raw':!![]})['then'](function(_0x1ee9aa){if(_0x1ee9aa&&_0x1ee9aa[_0xd180('0x54')]===0x0){return db['UserProfileResource'][_0xd180('0x4f')]({'name':_0x38b2ef[_0xd180('0x32')],'resourceId':_0x38b2ef['id'],'type':_0x1ee9aa[_0xd180('0x32')],'sectionId':_0x1ee9aa['id']},{})[_0xd180('0x2a')](function(){return _0x5c0c01;});}else{return _0x5c0c01;}})[_0xd180('0x4e')](function(_0x13aa89){logger['error'](_0xd180('0x55'),_0x13aa89);throw _0x13aa89;});}return _0x5c0c01;})[_0xd180('0x2a')](respondWithResult(_0x2f85cc,0xc9))[_0xd180('0x4e')](handleError(_0x2f85cc,null));};exports[_0xd180('0x29')]=function(_0x5e37b9,_0x1bc3b6){if(_0x5e37b9[_0xd180('0x50')]['id']){delete _0x5e37b9['body']['id'];}return db['MailQueue']['find']({'where':{'id':_0x5e37b9[_0xd180('0x56')]['id']}})[_0xd180('0x2a')](handleEntityNotFound(_0x1bc3b6,null))[_0xd180('0x2a')](saveUpdates(_0x5e37b9['body'],null))[_0xd180('0x2a')](respondWithResult(_0x1bc3b6,null))[_0xd180('0x4e')](handleError(_0x1bc3b6,null));};exports[_0xd180('0x2b')]=function(_0x169d9d,_0x59a757){return db[_0xd180('0x48')]['find']({'where':{'id':_0x169d9d[_0xd180('0x56')]['id']}})[_0xd180('0x2a')](handleEntityNotFound(_0x59a757,null))[_0xd180('0x2a')](removeEntity(_0x59a757,null))['catch'](handleError(_0x59a757,null));};exports[_0xd180('0x57')]=function(_0xa38223,_0x2a000a){return db[_0xd180('0x48')][_0xd180('0x57')]()[_0xd180('0x2a')](respondWithResult(_0x2a000a,null))[_0xd180('0x4e')](handleError(_0x2a000a,null));};exports[_0xd180('0x58')]=function(_0x16e64e,_0x1acb16,_0x4681d9){var _0x293677={'raw':!![],'where':{}},_0x5d4d20={},_0x1b84d3;return db['MailQueue'][_0xd180('0x59')]({'where':{'id':_0x16e64e[_0xd180('0x56')]['id']}})[_0xd180('0x2a')](handleEntityNotFound(_0x1acb16,null))[_0xd180('0x2a')](function(_0x10df19){if(_0x10df19){_0x1b84d3=_0x10df19[_0xd180('0x5a')]({'plain':!![]});_0x5d4d20['model']=_[_0xd180('0x3b')](db[_0xd180('0x5b')][_0xd180('0x36')]);_0x5d4d20[_0xd180('0x3c')]=_[_0xd180('0x3b')](_0x16e64e[_0xd180('0x3c')]);_0x5d4d20[_0xd180('0x3d')]=_[_0xd180('0x3e')](_0x5d4d20['model'],_0x5d4d20['query']);_0x293677[_0xd180('0x40')]=_[_0xd180('0x3e')](_0x5d4d20['model'],qs[_0xd180('0x3f')](_0x16e64e[_0xd180('0x3c')][_0xd180('0x3f')]));_0x293677[_0xd180('0x40')]=_0x293677[_0xd180('0x40')][_0xd180('0x41')]?_0x293677[_0xd180('0x40')]:_0x5d4d20['model'];if(!_0x16e64e[_0xd180('0x3c')][_0xd180('0x5c')]('nolimit')){_0x293677[_0xd180('0x24')]=qs[_0xd180('0x24')](_0x16e64e[_0xd180('0x3c')][_0xd180('0x24')]);_0x293677[_0xd180('0x23')]=qs[_0xd180('0x23')](_0x16e64e[_0xd180('0x3c')][_0xd180('0x23')]);}_0x293677[_0xd180('0x5d')]=qs[_0xd180('0x43')](_0x16e64e[_0xd180('0x3c')][_0xd180('0x43')]);_0x293677[_0xd180('0x5e')]=qs['filters'](_[_0xd180('0x5f')](_0x16e64e[_0xd180('0x3c')],_0x5d4d20[_0xd180('0x3d')]));_0x293677[_0xd180('0x5e')]['MailQueueId']=_0x10df19['id'];if(_0x16e64e['query'][_0xd180('0x44')]){_0x293677[_0xd180('0x5e')]=_[_0xd180('0x46')](_0x293677[_0xd180('0x5e')],{'$or':_[_0xd180('0x35')](_0x293677[_0xd180('0x40')],function(_0x328c6c){var _0x127143={};_0x127143[_0x328c6c]={'$like':'%'+_0x16e64e[_0xd180('0x3c')][_0xd180('0x44')]+'%'};return _0x127143;})});}_0x293677=_[_0xd180('0x46')]({},_0x293677,_0x16e64e['options']);return db[_0xd180('0x5b')][_0xd180('0x60')](_0x293677);}})[_0xd180('0x2a')](function(_0x4f3a55){if(_0x4f3a55){return db['User']['findAndCountAll']({'where':{'id':_[_0xd180('0x35')](_0x4f3a55,_0xd180('0x61')),'role':_0xd180('0x62')},'attributes':['id',_0xd180('0x32'),_0xd180('0x63'),_0xd180('0x64'),'createdAt']});}})['then'](function(_0x31aa07){if(_0x31aa07){return{'count':_0x31aa07[_0xd180('0x22')],'rows':_[_0xd180('0x35')](_0x31aa07[_0xd180('0x4b')],function(_0x1fb96d){return{'membername':_0x1fb96d[_0xd180('0x32')],'UserId':_0x1fb96d['id'],'queue_name':_0x1b84d3[_0xd180('0x32')],'MailQueueId':_0x1b84d3['id'],'interface':util['format'](_0xd180('0x65'),_0xd180('0x66'),_0x1fb96d[_0xd180('0x32')]),'penalty':0x0,'paused':_0x1fb96d['mailPause'],'createdAt':_0x1fb96d['createdAt'],'updatedAt':_0x1fb96d['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x1acb16,_0x293677))[_0xd180('0x4e')](handleError(_0x1acb16,null));};exports[_0xd180('0x67')]=function(_0x276d9b,_0x108161,_0x56c075){var _0x3d7c9f={};var _0x49ff78={};var _0x5f4406;var _0x76fffd;return db[_0xd180('0x48')][_0xd180('0x59')]({'where':{'id':_0x276d9b[_0xd180('0x56')]['id']}})['then'](handleEntityNotFound(_0x108161,null))[_0xd180('0x2a')](function(_0x30588a){if(_0x30588a){_0x5f4406=_0x30588a;_0x49ff78[_0xd180('0x3a')]=_[_0xd180('0x3b')](db[_0xd180('0x68')][_0xd180('0x36')]);_0x49ff78[_0xd180('0x3c')]=_[_0xd180('0x3b')](_0x276d9b[_0xd180('0x3c')]);_0x49ff78[_0xd180('0x3d')]=_[_0xd180('0x3e')](_0x49ff78[_0xd180('0x3a')],_0x49ff78['query']);_0x3d7c9f[_0xd180('0x40')]=_['intersection'](_0x49ff78[_0xd180('0x3a')],qs['fields'](_0x276d9b[_0xd180('0x3c')][_0xd180('0x3f')]));_0x3d7c9f[_0xd180('0x40')]=_0x3d7c9f['attributes'][_0xd180('0x41')]?_0x3d7c9f[_0xd180('0x40')]:_0x49ff78[_0xd180('0x3a')];_0x3d7c9f[_0xd180('0x5d')]=qs[_0xd180('0x43')](_0x276d9b[_0xd180('0x3c')]['sort']);_0x3d7c9f[_0xd180('0x5e')]=qs['filters'](_[_0xd180('0x5f')](_0x276d9b[_0xd180('0x3c')],_0x49ff78[_0xd180('0x3d')]));if(_0x276d9b[_0xd180('0x3c')]['filter']){_0x3d7c9f['where']=_[_0xd180('0x46')](_0x3d7c9f['where'],{'$or':_[_0xd180('0x35')](_0x3d7c9f['attributes'],function(_0x4d227d){var _0x53aa3d={};_0x53aa3d[_0x4d227d]={'$like':'%'+_0x276d9b[_0xd180('0x3c')]['filter']+'%'};return _0x53aa3d;})});}_0x3d7c9f=_[_0xd180('0x46')]({},_0x3d7c9f,_0x276d9b[_0xd180('0x47')]);return _0x5f4406[_0xd180('0x67')](_0x3d7c9f);}})[_0xd180('0x2a')](function(_0x279df1){if(_0x279df1){_0x76fffd=_0x279df1[_0xd180('0x41')];if(!_0x276d9b['query']['hasOwnProperty'](_0xd180('0x42'))){_0x3d7c9f[_0xd180('0x24')]=qs[_0xd180('0x24')](_0x276d9b[_0xd180('0x3c')][_0xd180('0x24')]);_0x3d7c9f[_0xd180('0x23')]=qs[_0xd180('0x23')](_0x276d9b[_0xd180('0x3c')][_0xd180('0x23')]);}return _0x5f4406[_0xd180('0x67')](_0x3d7c9f);}})[_0xd180('0x2a')](function(_0x537926){if(_0x537926){return _0x537926?{'count':_0x76fffd,'rows':_0x537926}:null;}})['then'](respondWithResult(_0x108161,null))[_0xd180('0x4e')](handleError(_0x108161,null));};exports[_0xd180('0x69')]=function(_0x4cc439,_0x2de533,_0xa701fe){var _0x132847=_0x4cc439['body'][_0xd180('0x6a')];return db[_0xd180('0x68')]['findAll']({'where':{'id':_0x132847},'attributes':['id'],'include':[{'model':db['User'],'as':_0xd180('0x6b'),'attributes':['id',_0xd180('0x32'),_0xd180('0x6c'),_0xd180('0x6d'),'interface'],'raw':!![]}]})[_0xd180('0x2a')](function(_0x58bb50){if(_0x58bb50){var _0x20609b=_['flatMap'](_0x58bb50,function(_0x93f7f0){var _0x2360d0=_0x93f7f0[_0xd180('0x5a')]({'plain':!![]});return _0x2360d0['Agents'];});return db[_0xd180('0x48')][_0xd180('0x4d')]({'where':{'id':_0x4cc439[_0xd180('0x56')]['id']}})['then'](function(_0x146fdd){return db[_0xd180('0x6e')][_0xd180('0x6f')](function(_0x2738e8){return _0x146fdd[_0xd180('0x69')](_0x132847,{'transaction':_0x2738e8})[_0xd180('0x2a')](function(){return BPromise[_0xd180('0x70')](_0x20609b,function(_0x299045){return db[_0xd180('0x5b')][_0xd180('0x71')]({'where':{'UserId':_0x299045['id'],'MailQueueId':_0x4cc439[_0xd180('0x56')]['id']},'transaction':_0x2738e8});});})[_0xd180('0x2a')](function(){_0x20609b[_0xd180('0x72')](function(_0x31fffd){socket[_0xd180('0x73')](_0xd180('0x74'),{'UserId':_0x31fffd['id'],'MailQueueId':_0x146fdd['id']});});});});});}})[_0xd180('0x2a')](respondWithStatusCode(_0x2de533,null))[_0xd180('0x4e')](handleError(_0x2de533,null));};exports[_0xd180('0x75')]=function(_0x549c15,_0x551ef4,_0x123ca0){return db['Team'][_0xd180('0x60')]({'where':{'id':_0x549c15[_0xd180('0x3c')]['ids']},'attributes':['id'],'include':[{'model':db[_0xd180('0x76')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xd180('0x2a')](handleEntityNotFound(_0x551ef4,null))[_0xd180('0x2a')](function(_0x3a750d){var _0x21562a=_[_0xd180('0x35')](_0x3a750d,'id');var _0x147edd=[];var _0x419bd0=[];var _0x326995=squel[_0xd180('0x77')]();_0x326995['field']('tq.TeamId')[_0xd180('0x78')](_0xd180('0x79'),'tq')['join']('user_has_teams','ut',_0xd180('0x7a'))[_0xd180('0x5e')](_0xd180('0x7b'),_0x549c15['params']['id']);for(var _0x55b5ed=0x0;_0x55b5ed<_0x3a750d[_0xd180('0x41')];_0x55b5ed+=0x1){let _0x520497=_0x3a750d[_0x55b5ed];for(var _0x1d8ec1=0x0;_0x1d8ec1<_0x520497[_0xd180('0x6b')][_0xd180('0x41')];_0x1d8ec1+=0x1){let _0x4d8358=_0x520497['Agents'][_0x1d8ec1];var _0x23bdca=_0x326995[_0xd180('0x7c')]();_0x23bdca[_0xd180('0x5e')](_0xd180('0x7d'),_0x4d8358['id']);_0x419bd0[_0xd180('0x7e')](db[_0xd180('0x6e')][_0xd180('0x3c')](_0x23bdca['toString'](),{'type':db[_0xd180('0x6e')][_0xd180('0x7f')]['SELECT']})[_0xd180('0x2a')](function(_0x3a88ce){if(_0x3a88ce[_0xd180('0x41')]===0x1){return _0x4d8358['id'];}else{var _0x1e9b54=_[_0xd180('0x80')](_[_0xd180('0x35')](_0x3a88ce,_0xd180('0x81')),function(_0x316656){return _['includes'](_0x21562a,_0x316656);});if(_0x1e9b54){return _0x4d8358['id'];}}}));}}return BPromise[_0xd180('0x82')](_0x419bd0)['then'](function(_0x7471ca){_0x147edd=_(_0x147edd)[_0xd180('0x83')](_0x7471ca)['compact']()[_0xd180('0x84')]();return db[_0xd180('0x48')][_0xd180('0x4d')]({'where':{'id':_0x549c15[_0xd180('0x56')]['id']}})[_0xd180('0x2a')](function(_0xa4c466){return db['sequelize'][_0xd180('0x6f')](function(_0x29ee3b){return _0xa4c466['removeTeams'](_0x549c15['query'][_0xd180('0x6a')],{'transaction':_0x29ee3b})[_0xd180('0x2a')](function(){if(!_[_0xd180('0x85')](_0x147edd)){return _0xa4c466[_0xd180('0x86')](_0x147edd,{'transaction':_0x29ee3b});}})[_0xd180('0x2a')](function(){_0x147edd[_0xd180('0x72')](function(_0x237b03){socket['emit'](_0xd180('0x87'),{'UserId':_0x237b03,'MailQueueId':_0xa4c466['id']});});});});});});})[_0xd180('0x2a')](respondWithStatusCode(_0x551ef4,null))[_0xd180('0x4e')](handleError(_0x551ef4,null));};exports[_0xd180('0x88')]=function(_0xbf0d26,_0x197b0c,_0x1e526b){return db['MailQueue']['find']({'where':{'id':_0xbf0d26[_0xd180('0x56')]['id']}})[_0xd180('0x2a')](handleEntityNotFound(_0x197b0c,null))[_0xd180('0x2a')](function(_0x22e42e){if(_0x22e42e){return _0x22e42e[_0xd180('0x88')](_0xbf0d26[_0xd180('0x50')][_0xd180('0x6a')],_[_0xd180('0x89')](_0xbf0d26[_0xd180('0x50')],[_0xd180('0x6a'),'id'])||{})[_0xd180('0x8a')](function(_0x14a5c6){for(var _0x1ad48f=0x0;_0x1ad48f<_0xbf0d26[_0xd180('0x50')][_0xd180('0x6a')][_0xd180('0x41')];_0x1ad48f+=0x1){socket[_0xd180('0x73')](_0xd180('0x74'),{'UserId':_0xbf0d26[_0xd180('0x50')][_0xd180('0x6a')][_0x1ad48f],'MailQueueId':_0xbf0d26[_0xd180('0x56')]['id']});}return _0x14a5c6;});}})[_0xd180('0x2a')](respondWithResult(_0x197b0c,null))[_0xd180('0x4e')](handleError(_0x197b0c,null));};exports[_0xd180('0x86')]=function(_0x256a68,_0x512bed,_0x38692d){return db[_0xd180('0x48')][_0xd180('0x4d')]({'where':{'id':_0x256a68['params']['id']}})[_0xd180('0x2a')](handleEntityNotFound(_0x512bed,null))['then'](function(_0x3621cd){if(_0x3621cd){return _0x3621cd[_0xd180('0x86')](_0x256a68['query']['ids'])[_0xd180('0x2a')](function(){if(_[_0xd180('0x8b')](_0x256a68['query'][_0xd180('0x6a')])){for(var _0x4f75b3=0x0;_0x4f75b3<_0x256a68[_0xd180('0x3c')]['ids'][_0xd180('0x41')];_0x4f75b3+=0x1){socket[_0xd180('0x73')](_0xd180('0x87'),{'UserId':Number(_0x256a68[_0xd180('0x3c')][_0xd180('0x6a')][_0x4f75b3]),'MailQueueId':Number(_0x256a68[_0xd180('0x56')]['id'])});}}else{socket['emit'](_0xd180('0x87'),{'UserId':Number(_0x256a68['query'][_0xd180('0x6a')]),'MailQueueId':Number(_0x256a68[_0xd180('0x56')]['id'])});}});}})[_0xd180('0x2a')](respondWithStatusCode(_0x512bed,null))[_0xd180('0x4e')](handleError(_0x512bed,null));};exports[_0xd180('0x8c')]=function(_0x470508,_0xb02088,_0x342b76){var _0x928ff9={};var _0x53810d={};var _0x4052fd;var _0x9fd2b;return db[_0xd180('0x48')]['findOne']({'where':{'id':_0x470508['params']['id']}})[_0xd180('0x2a')](handleEntityNotFound(_0xb02088,null))[_0xd180('0x2a')](function(_0x5831f1){if(_0x5831f1){_0x4052fd=_0x5831f1;_0x53810d[_0xd180('0x3a')]=_['keys'](db[_0xd180('0x76')][_0xd180('0x36')]);_0x53810d[_0xd180('0x3c')]=_[_0xd180('0x3b')](_0x470508['query']);_0x53810d['filters']=_[_0xd180('0x3e')](_0x53810d[_0xd180('0x3a')],_0x53810d[_0xd180('0x3c')]);_0x928ff9[_0xd180('0x40')]=_[_0xd180('0x3e')](_0x53810d['model'],qs[_0xd180('0x3f')](_0x470508[_0xd180('0x3c')]['fields']));_0x928ff9[_0xd180('0x40')]=_0x928ff9['attributes'][_0xd180('0x41')]?_0x928ff9[_0xd180('0x40')]:_0x53810d[_0xd180('0x3a')];_0x928ff9[_0xd180('0x5d')]=qs[_0xd180('0x43')](_0x470508['query'][_0xd180('0x43')]);_0x928ff9[_0xd180('0x5e')]=qs[_0xd180('0x3d')](_[_0xd180('0x5f')](_0x470508[_0xd180('0x3c')],_0x53810d['filters']));if(_0x470508[_0xd180('0x3c')]['filter']){_0x928ff9[_0xd180('0x5e')]=_[_0xd180('0x46')](_0x928ff9[_0xd180('0x5e')],{'$or':_['map'](_0x928ff9[_0xd180('0x40')],function(_0x91316e){var _0x258add={};_0x258add[_0x91316e]={'$like':'%'+_0x470508[_0xd180('0x3c')][_0xd180('0x44')]+'%'};return _0x258add;})});}_0x928ff9=_['merge']({},_0x928ff9,_0x470508['options']);return _0x4052fd['getAgents'](_0x928ff9);}})[_0xd180('0x2a')](function(_0x18116d){if(_0x18116d){_0x9fd2b=_0x18116d['length'];if(!_0x470508[_0xd180('0x3c')][_0xd180('0x5c')](_0xd180('0x42'))){_0x928ff9[_0xd180('0x24')]=qs[_0xd180('0x24')](_0x470508['query'][_0xd180('0x24')]);_0x928ff9[_0xd180('0x23')]=qs[_0xd180('0x23')](_0x470508[_0xd180('0x3c')]['offset']);}return _0x4052fd[_0xd180('0x8c')](_0x928ff9);}})[_0xd180('0x2a')](function(_0x47c220){if(_0x47c220){return _0x47c220?{'count':_0x9fd2b,'rows':_0x47c220}:null;}})[_0xd180('0x2a')](respondWithResult(_0xb02088,null))[_0xd180('0x4e')](handleError(_0xb02088,null));};
\ No newline at end of file