Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index c296642..f1ea8bb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0xe829=['autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getMembers','findOne','UserMailQueue','order','sort','MailQueueId','User','findAndCountAll','mailPause','updatedAt','createdAt','format','getTeams','Team','addTeams','Agents','voicePause','interface','sequelize','transaction','each','findOrCreate','forEach','emit','userMailQueue:save','removeTeams','ids','select','field','tq.TeamId','from','team_has_mail_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','push','SELECT','every','TeamId','includes','union','compact','value','removeAgents','userMailQueue:remove','addAgents','omit','isArray','getAgents','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','./mailQueue.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','then','get','MailQueues','UserProfileResource','error','stack','name','send','index','map','MailQueue','fieldName','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','where','filters','pick','merge','type','VIRTUAL','filter','options','include','findAll','rows','catch','show','params','rawAttributes','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','userProfileId'];(function(_0x2a38b8,_0x11990d){var _0x35b9ea=function(_0x93acf9){while(--_0x93acf9){_0x2a38b8['push'](_0x2a38b8['shift']());}};_0x35b9ea(++_0x11990d);}(_0xe829,0x1d8));var _0x9e82=function(_0x4e5b60,_0x58b613){_0x4e5b60=_0x4e5b60-0x0;var _0x3b53bf=_0xe829[_0x4e5b60];return _0x3b53bf;};'use strict';var emlformat=require(_0x9e82('0x0'));var rimraf=require(_0x9e82('0x1'));var zipdir=require(_0x9e82('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x9e82('0x3'));var BPromise=require(_0x9e82('0x4'));var Mustache=require(_0x9e82('0x5'));var util=require(_0x9e82('0x6'));var path=require(_0x9e82('0x7'));var sox=require(_0x9e82('0x8'));var csv=require('to-csv');var ejs=require(_0x9e82('0x9'));var fs=require('fs');var fs_extra=require(_0x9e82('0xa'));var _=require(_0x9e82('0xb'));var squel=require(_0x9e82('0xc'));var crypto=require(_0x9e82('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x9e82('0xe'));var toCsv=require('to-csv');var querystring=require(_0x9e82('0xf'));var Papa=require(_0x9e82('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x9e82('0x11'));var as=require(_0x9e82('0x12'));var hardwareService=require(_0x9e82('0x13'));var logger=require(_0x9e82('0x14'))(_0x9e82('0x15'));var utils=require(_0x9e82('0x16'));var config=require(_0x9e82('0x17'));var licenseUtil=require(_0x9e82('0x18'));var db=require(_0x9e82('0x19'))['db'];config[_0x9e82('0x1a')]=_[_0x9e82('0x1b')](config[_0x9e82('0x1a')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9e82('0x1a')]));require(_0x9e82('0x1c'))[_0x9e82('0x1d')](socket);function respondWithStatusCode(_0x7f8584,_0x508234){_0x508234=_0x508234||0xcc;return function(_0x1319cc){if(_0x1319cc){return _0x7f8584[_0x9e82('0x1e')](_0x508234);}return _0x7f8584[_0x9e82('0x1f')](_0x508234)[_0x9e82('0x20')]();};}function respondWithResult(_0x51aa1e,_0x11b7ea){_0x11b7ea=_0x11b7ea||0xc8;return function(_0x5d7905){if(_0x5d7905){return _0x51aa1e[_0x9e82('0x1f')](_0x11b7ea)[_0x9e82('0x21')](_0x5d7905);}};}function respondWithFilteredResult(_0x50b85c,_0x588239){return function(_0x4815d8){if(_0x4815d8){var _0x40757e=typeof _0x588239[_0x9e82('0x22')]===_0x9e82('0x23')&&typeof _0x588239[_0x9e82('0x24')]===_0x9e82('0x23');var _0x4dce73=_0x4815d8[_0x9e82('0x25')];var _0xe39ae8=_0x40757e?0x0:_0x588239[_0x9e82('0x22')];var _0x199984=_0x40757e?_0x4815d8['count']:_0x588239['offset']+_0x588239[_0x9e82('0x24')];var _0x2c37ad;if(_0x199984>=_0x4dce73){_0x199984=_0x4dce73;_0x2c37ad=0xc8;}else{_0x2c37ad=0xce;}_0x50b85c[_0x9e82('0x1f')](_0x2c37ad);return _0x50b85c[_0x9e82('0x26')](_0x9e82('0x27'),_0xe39ae8+'-'+_0x199984+'/'+_0x4dce73)[_0x9e82('0x21')](_0x4815d8);}return null;};}function patchUpdates(_0x53d6a0){return function(_0x12a26f){try{jsonpatch[_0x9e82('0x28')](_0x12a26f,_0x53d6a0,!![]);}catch(_0x2fba02){return BPromise[_0x9e82('0x29')](_0x2fba02);}return _0x12a26f[_0x9e82('0x2a')]();};}function saveUpdates(_0x4e0570,_0x21519d){return function(_0x4a628c){if(_0x4a628c){return _0x4a628c[_0x9e82('0x2b')](_0x4e0570)['then'](function(_0x277fae){return _0x277fae;});}return null;};}function removeEntity(_0x3911cb,_0x2ff9ae){return function(_0x9b36c5){if(_0x9b36c5){return _0x9b36c5[_0x9e82('0x2c')]()[_0x9e82('0x2d')](function(){var _0x3724cb=_0x9b36c5[_0x9e82('0x2e')]({'plain':!![]});var _0xbcc412=_0x9e82('0x2f');return db[_0x9e82('0x30')]['destroy']({'where':{'type':_0xbcc412,'resourceId':_0x3724cb['id']}})[_0x9e82('0x2d')](function(){return _0x9b36c5;});})[_0x9e82('0x2d')](function(){_0x3911cb[_0x9e82('0x1f')](0xcc)[_0x9e82('0x20')]();});}};}function handleEntityNotFound(_0x41c723,_0x1a87e0){return function(_0xd3db2a){if(!_0xd3db2a){_0x41c723[_0x9e82('0x1e')](0x194);}return _0xd3db2a;};}function handleError(_0xa4a754,_0x159839){_0x159839=_0x159839||0x1f4;return function(_0x3c67d8){logger[_0x9e82('0x31')](_0x3c67d8[_0x9e82('0x32')]);if(_0x3c67d8[_0x9e82('0x33')]){delete _0x3c67d8['name'];}_0xa4a754['status'](_0x159839)[_0x9e82('0x34')](_0x3c67d8);};}exports[_0x9e82('0x35')]=function(_0xd5ce64,_0x32a2d2){var _0x133b48={},_0x70a276={},_0xad203e={'count':0x0,'rows':[]};var _0x5d357f=_[_0x9e82('0x36')](db[_0x9e82('0x37')]['rawAttributes'],function(_0x42a8c4){return{'name':_0x42a8c4[_0x9e82('0x38')],'type':_0x42a8c4['type'][_0x9e82('0x39')]};});_0x70a276[_0x9e82('0x3a')]=_[_0x9e82('0x36')](_0x5d357f,_0x9e82('0x33'));_0x70a276[_0x9e82('0x3b')]=_[_0x9e82('0x3c')](_0xd5ce64[_0x9e82('0x3b')]);_0x70a276['filters']=_[_0x9e82('0x3d')](_0x70a276['model'],_0x70a276['query']);_0x133b48[_0x9e82('0x3e')]=_[_0x9e82('0x3d')](_0x70a276[_0x9e82('0x3a')],qs[_0x9e82('0x3f')](_0xd5ce64['query']['fields']));_0x133b48[_0x9e82('0x3e')]=_0x133b48[_0x9e82('0x3e')][_0x9e82('0x40')]?_0x133b48[_0x9e82('0x3e')]:_0x70a276[_0x9e82('0x3a')];if(!_0xd5ce64[_0x9e82('0x3b')][_0x9e82('0x41')](_0x9e82('0x42'))){_0x133b48[_0x9e82('0x24')]=qs[_0x9e82('0x24')](_0xd5ce64['query'][_0x9e82('0x24')]);_0x133b48[_0x9e82('0x22')]=qs[_0x9e82('0x22')](_0xd5ce64[_0x9e82('0x3b')][_0x9e82('0x22')]);}_0x133b48['order']=qs['sort'](_0xd5ce64['query']['sort']);_0x133b48[_0x9e82('0x43')]=qs[_0x9e82('0x44')](_[_0x9e82('0x45')](_0xd5ce64[_0x9e82('0x3b')],_0x70a276[_0x9e82('0x44')]),_0x5d357f);if(_0xd5ce64['query']['filter']){_0x133b48[_0x9e82('0x43')]=_[_0x9e82('0x46')](_0x133b48[_0x9e82('0x43')],{'$or':_[_0x9e82('0x36')](_0x5d357f,function(_0x521c83){if(_0x521c83[_0x9e82('0x47')]!==_0x9e82('0x48')){var _0x146010={};_0x146010[_0x521c83['name']]={'$like':'%'+_0xd5ce64['query'][_0x9e82('0x49')]+'%'};return _0x146010;}})});}_0x133b48=_['merge']({},_0x133b48,_0xd5ce64[_0x9e82('0x4a')]);var _0x2a953={'where':_0x133b48['where']};return db[_0x9e82('0x37')][_0x9e82('0x25')](_0x2a953)[_0x9e82('0x2d')](function(_0x1ee8f7){_0xad203e[_0x9e82('0x25')]=_0x1ee8f7;if(_0xd5ce64[_0x9e82('0x3b')]['includeAll']){_0x133b48[_0x9e82('0x4b')]=[{'all':!![]}];}return db['MailQueue'][_0x9e82('0x4c')](_0x133b48);})[_0x9e82('0x2d')](function(_0x25ab20){_0xad203e[_0x9e82('0x4d')]=_0x25ab20;return _0xad203e;})['then'](respondWithFilteredResult(_0x32a2d2,_0x133b48))[_0x9e82('0x4e')](handleError(_0x32a2d2,null));};exports[_0x9e82('0x4f')]=function(_0x42bc9c,_0x4d5b2f){var _0x8b6f44={'raw':!![],'where':{'id':_0x42bc9c[_0x9e82('0x50')]['id']}},_0x40c875={};_0x40c875[_0x9e82('0x3a')]=_[_0x9e82('0x3c')](db['MailQueue'][_0x9e82('0x51')]);_0x40c875[_0x9e82('0x3b')]=_[_0x9e82('0x3c')](_0x42bc9c[_0x9e82('0x3b')]);_0x40c875['filters']=_['intersection'](_0x40c875[_0x9e82('0x3a')],_0x40c875[_0x9e82('0x3b')]);_0x8b6f44[_0x9e82('0x3e')]=_[_0x9e82('0x3d')](_0x40c875[_0x9e82('0x3a')],qs['fields'](_0x42bc9c[_0x9e82('0x3b')][_0x9e82('0x3f')]));_0x8b6f44[_0x9e82('0x3e')]=_0x8b6f44[_0x9e82('0x3e')]['length']?_0x8b6f44['attributes']:_0x40c875[_0x9e82('0x3a')];if(_0x42bc9c['query']['includeAll']){_0x8b6f44[_0x9e82('0x4b')]=[{'all':!![]}];}_0x8b6f44=_[_0x9e82('0x46')]({},_0x8b6f44,_0x42bc9c[_0x9e82('0x4a')]);return db[_0x9e82('0x37')][_0x9e82('0x52')](_0x8b6f44)[_0x9e82('0x2d')](handleEntityNotFound(_0x4d5b2f,null))[_0x9e82('0x2d')](respondWithResult(_0x4d5b2f,null))[_0x9e82('0x4e')](handleError(_0x4d5b2f,null));};exports[_0x9e82('0x53')]=function(_0x1e977a,_0x14ef67){return db[_0x9e82('0x37')]['create'](_0x1e977a[_0x9e82('0x54')],{})['then'](function(_0x3fb326){var _0x45746a=_0x1e977a['user'][_0x9e82('0x2e')]({'plain':!![]});if(!_0x45746a)throw new Error(_0x9e82('0x55'));if(_0x45746a['role']===_0x9e82('0x56')){var _0x6f8e6e=_0x3fb326[_0x9e82('0x2e')]({'plain':!![]});var _0x14f604=_0x9e82('0x2f');return db['UserProfileSection']['find']({'where':{'name':_0x14f604,'userProfileId':_0x45746a[_0x9e82('0x57')]},'raw':!![]})['then'](function(_0x5beca7){if(_0x5beca7&&_0x5beca7[_0x9e82('0x58')]===0x0){return db[_0x9e82('0x30')][_0x9e82('0x53')]({'name':_0x6f8e6e[_0x9e82('0x33')],'resourceId':_0x6f8e6e['id'],'type':_0x5beca7[_0x9e82('0x33')],'sectionId':_0x5beca7['id']},{})[_0x9e82('0x2d')](function(){return _0x3fb326;});}else{return _0x3fb326;}})[_0x9e82('0x4e')](function(_0x51f5a2){logger[_0x9e82('0x31')](_0x9e82('0x59'),_0x51f5a2);throw _0x51f5a2;});}return _0x3fb326;})['then'](respondWithResult(_0x14ef67,0xc9))['catch'](handleError(_0x14ef67,null));};exports[_0x9e82('0x2b')]=function(_0xc1f02b,_0x2ed5ef){if(_0xc1f02b[_0x9e82('0x54')]['id']){delete _0xc1f02b[_0x9e82('0x54')]['id'];}return db[_0x9e82('0x37')][_0x9e82('0x52')]({'where':{'id':_0xc1f02b[_0x9e82('0x50')]['id']}})['then'](handleEntityNotFound(_0x2ed5ef,null))['then'](saveUpdates(_0xc1f02b[_0x9e82('0x54')],null))[_0x9e82('0x2d')](respondWithResult(_0x2ed5ef,null))[_0x9e82('0x4e')](handleError(_0x2ed5ef,null));};exports[_0x9e82('0x2c')]=function(_0x14e9ad,_0x4bfb82){return db[_0x9e82('0x37')][_0x9e82('0x52')]({'where':{'id':_0x14e9ad[_0x9e82('0x50')]['id']}})[_0x9e82('0x2d')](handleEntityNotFound(_0x4bfb82,null))[_0x9e82('0x2d')](removeEntity(_0x4bfb82,null))[_0x9e82('0x4e')](handleError(_0x4bfb82,null));};exports['describe']=function(_0x440abe,_0x2ec0ac){return db[_0x9e82('0x37')]['describe']()['then'](respondWithResult(_0x2ec0ac,null))[_0x9e82('0x4e')](handleError(_0x2ec0ac,null));};exports[_0x9e82('0x5a')]=function(_0x53bf32,_0xbe43aa,_0x55c1d0){var _0x366492={'raw':!![],'where':{}},_0x540f36={},_0x1cb2d5;return db[_0x9e82('0x37')][_0x9e82('0x5b')]({'where':{'id':_0x53bf32[_0x9e82('0x50')]['id']}})[_0x9e82('0x2d')](handleEntityNotFound(_0xbe43aa,null))[_0x9e82('0x2d')](function(_0x118966){if(_0x118966){_0x1cb2d5=_0x118966[_0x9e82('0x2e')]({'plain':!![]});_0x540f36[_0x9e82('0x3a')]=_[_0x9e82('0x3c')](db[_0x9e82('0x5c')][_0x9e82('0x51')]);_0x540f36[_0x9e82('0x3b')]=_[_0x9e82('0x3c')](_0x53bf32[_0x9e82('0x3b')]);_0x540f36[_0x9e82('0x44')]=_[_0x9e82('0x3d')](_0x540f36[_0x9e82('0x3a')],_0x540f36[_0x9e82('0x3b')]);_0x366492[_0x9e82('0x3e')]=_[_0x9e82('0x3d')](_0x540f36[_0x9e82('0x3a')],qs[_0x9e82('0x3f')](_0x53bf32[_0x9e82('0x3b')]['fields']));_0x366492['attributes']=_0x366492[_0x9e82('0x3e')]['length']?_0x366492['attributes']:_0x540f36[_0x9e82('0x3a')];if(!_0x53bf32[_0x9e82('0x3b')][_0x9e82('0x41')]('nolimit')){_0x366492['limit']=qs[_0x9e82('0x24')](_0x53bf32['query'][_0x9e82('0x24')]);_0x366492[_0x9e82('0x22')]=qs['offset'](_0x53bf32[_0x9e82('0x3b')][_0x9e82('0x22')]);}_0x366492[_0x9e82('0x5d')]=qs[_0x9e82('0x5e')](_0x53bf32[_0x9e82('0x3b')][_0x9e82('0x5e')]);_0x366492[_0x9e82('0x43')]=qs['filters'](_['pick'](_0x53bf32[_0x9e82('0x3b')],_0x540f36['filters']));_0x366492[_0x9e82('0x43')][_0x9e82('0x5f')]=_0x118966['id'];if(_0x53bf32['query']['filter']){_0x366492[_0x9e82('0x43')]=_[_0x9e82('0x46')](_0x366492[_0x9e82('0x43')],{'$or':_[_0x9e82('0x36')](_0x366492[_0x9e82('0x3e')],function(_0x300ecf){var _0x969ffc={};_0x969ffc[_0x300ecf]={'$like':'%'+_0x53bf32['query'][_0x9e82('0x49')]+'%'};return _0x969ffc;})});}_0x366492=_[_0x9e82('0x46')]({},_0x366492,_0x53bf32[_0x9e82('0x4a')]);return db[_0x9e82('0x5c')][_0x9e82('0x4c')](_0x366492);}})[_0x9e82('0x2d')](function(_0x5153f1){if(_0x5153f1){return db[_0x9e82('0x60')][_0x9e82('0x61')]({'where':{'id':_[_0x9e82('0x36')](_0x5153f1,'UserId'),'role':'agent'},'attributes':['id',_0x9e82('0x33'),_0x9e82('0x62'),_0x9e82('0x63'),_0x9e82('0x64')]});}})[_0x9e82('0x2d')](function(_0x1e7ae5){if(_0x1e7ae5){return{'count':_0x1e7ae5[_0x9e82('0x25')],'rows':_[_0x9e82('0x36')](_0x1e7ae5[_0x9e82('0x4d')],function(_0x1463c0){return{'membername':_0x1463c0[_0x9e82('0x33')],'UserId':_0x1463c0['id'],'queue_name':_0x1cb2d5[_0x9e82('0x33')],'MailQueueId':_0x1cb2d5['id'],'interface':util[_0x9e82('0x65')]('%s/%s','SIP',_0x1463c0[_0x9e82('0x33')]),'penalty':0x0,'paused':_0x1463c0[_0x9e82('0x62')],'createdAt':_0x1463c0['createdAt'],'updatedAt':_0x1463c0[_0x9e82('0x63')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0xbe43aa,_0x366492))[_0x9e82('0x4e')](handleError(_0xbe43aa,null));};exports[_0x9e82('0x66')]=function(_0x91cab0,_0x4ad26c,_0x211922){var _0x1de75d={};var _0x4beba5={};var _0x47413b;var _0x1a08d8;return db[_0x9e82('0x37')]['findOne']({'where':{'id':_0x91cab0[_0x9e82('0x50')]['id']}})['then'](handleEntityNotFound(_0x4ad26c,null))[_0x9e82('0x2d')](function(_0x54ff7a){if(_0x54ff7a){_0x47413b=_0x54ff7a;_0x4beba5[_0x9e82('0x3a')]=_[_0x9e82('0x3c')](db[_0x9e82('0x67')][_0x9e82('0x51')]);_0x4beba5[_0x9e82('0x3b')]=_[_0x9e82('0x3c')](_0x91cab0[_0x9e82('0x3b')]);_0x4beba5[_0x9e82('0x44')]=_[_0x9e82('0x3d')](_0x4beba5[_0x9e82('0x3a')],_0x4beba5[_0x9e82('0x3b')]);_0x1de75d[_0x9e82('0x3e')]=_[_0x9e82('0x3d')](_0x4beba5[_0x9e82('0x3a')],qs[_0x9e82('0x3f')](_0x91cab0[_0x9e82('0x3b')][_0x9e82('0x3f')]));_0x1de75d['attributes']=_0x1de75d['attributes'][_0x9e82('0x40')]?_0x1de75d['attributes']:_0x4beba5[_0x9e82('0x3a')];_0x1de75d[_0x9e82('0x5d')]=qs['sort'](_0x91cab0[_0x9e82('0x3b')][_0x9e82('0x5e')]);_0x1de75d[_0x9e82('0x43')]=qs[_0x9e82('0x44')](_['pick'](_0x91cab0[_0x9e82('0x3b')],_0x4beba5[_0x9e82('0x44')]));if(_0x91cab0[_0x9e82('0x3b')]['filter']){_0x1de75d[_0x9e82('0x43')]=_[_0x9e82('0x46')](_0x1de75d[_0x9e82('0x43')],{'$or':_[_0x9e82('0x36')](_0x1de75d[_0x9e82('0x3e')],function(_0x29e1df){var _0x37fd71={};_0x37fd71[_0x29e1df]={'$like':'%'+_0x91cab0[_0x9e82('0x3b')][_0x9e82('0x49')]+'%'};return _0x37fd71;})});}_0x1de75d=_['merge']({},_0x1de75d,_0x91cab0['options']);return _0x47413b[_0x9e82('0x66')](_0x1de75d);}})['then'](function(_0x5b9eb6){if(_0x5b9eb6){_0x1a08d8=_0x5b9eb6[_0x9e82('0x40')];if(!_0x91cab0[_0x9e82('0x3b')][_0x9e82('0x41')]('nolimit')){_0x1de75d[_0x9e82('0x24')]=qs['limit'](_0x91cab0[_0x9e82('0x3b')][_0x9e82('0x24')]);_0x1de75d[_0x9e82('0x22')]=qs['offset'](_0x91cab0[_0x9e82('0x3b')]['offset']);}return _0x47413b[_0x9e82('0x66')](_0x1de75d);}})['then'](function(_0x5dc4){if(_0x5dc4){return _0x5dc4?{'count':_0x1a08d8,'rows':_0x5dc4}:null;}})[_0x9e82('0x2d')](respondWithResult(_0x4ad26c,null))['catch'](handleError(_0x4ad26c,null));};exports[_0x9e82('0x68')]=function(_0x442277,_0x595f90,_0x2a8e0e){var _0x458253=_0x442277[_0x9e82('0x54')]['ids'];return db[_0x9e82('0x67')][_0x9e82('0x4c')]({'where':{'id':_0x458253},'attributes':['id'],'include':[{'model':db[_0x9e82('0x60')],'as':_0x9e82('0x69'),'attributes':['id',_0x9e82('0x33'),'online',_0x9e82('0x6a'),_0x9e82('0x6b')],'raw':!![]}]})[_0x9e82('0x2d')](function(_0x5d0cc2){if(_0x5d0cc2){var _0x5b2ffb=_['flatMap'](_0x5d0cc2,function(_0x39892c){var _0x422e24=_0x39892c[_0x9e82('0x2e')]({'plain':!![]});return _0x422e24[_0x9e82('0x69')];});return db[_0x9e82('0x37')]['find']({'where':{'id':_0x442277['params']['id']}})['then'](function(_0x43adcc){return db[_0x9e82('0x6c')][_0x9e82('0x6d')](function(_0x40f46b){return _0x43adcc[_0x9e82('0x68')](_0x458253,{'transaction':_0x40f46b})[_0x9e82('0x2d')](function(){return BPromise[_0x9e82('0x6e')](_0x5b2ffb,function(_0x1647d4){return db['UserMailQueue'][_0x9e82('0x6f')]({'where':{'UserId':_0x1647d4['id'],'MailQueueId':_0x442277[_0x9e82('0x50')]['id']},'transaction':_0x40f46b});});})[_0x9e82('0x2d')](function(){_0x5b2ffb[_0x9e82('0x70')](function(_0x4d7224){socket[_0x9e82('0x71')](_0x9e82('0x72'),{'UserId':_0x4d7224['id'],'MailQueueId':_0x43adcc['id']});});});});});}})[_0x9e82('0x2d')](respondWithStatusCode(_0x595f90,null))[_0x9e82('0x4e')](handleError(_0x595f90,null));};exports[_0x9e82('0x73')]=function(_0x488ad9,_0x33bbd9,_0x505124){return db[_0x9e82('0x67')][_0x9e82('0x4c')]({'where':{'id':_0x488ad9[_0x9e82('0x3b')][_0x9e82('0x74')]},'attributes':['id'],'include':[{'model':db[_0x9e82('0x60')],'as':_0x9e82('0x69'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x33bbd9,null))['then'](function(_0x4f73c7){var _0x346008=_[_0x9e82('0x36')](_0x4f73c7,'id');var _0x3c4a16=[];var _0x500c59=[];var _0x1da351=squel[_0x9e82('0x75')]();_0x1da351[_0x9e82('0x76')](_0x9e82('0x77'))[_0x9e82('0x78')](_0x9e82('0x79'),'tq')[_0x9e82('0x7a')](_0x9e82('0x7b'),'ut',_0x9e82('0x7c'))[_0x9e82('0x43')]('MailQueueId\x20=\x20?',_0x488ad9[_0x9e82('0x50')]['id']);for(var _0xecfc79=0x0;_0xecfc79<_0x4f73c7[_0x9e82('0x40')];_0xecfc79+=0x1){let _0x425db4=_0x4f73c7[_0xecfc79];for(var _0x3b1547=0x0;_0x3b1547<_0x425db4['Agents'][_0x9e82('0x40')];_0x3b1547+=0x1){let _0x224bec=_0x425db4[_0x9e82('0x69')][_0x3b1547];var _0x19a883=_0x1da351['clone']();_0x19a883[_0x9e82('0x43')](_0x9e82('0x7d'),_0x224bec['id']);_0x500c59[_0x9e82('0x7e')](db[_0x9e82('0x6c')]['query'](_0x19a883['toString'](),{'type':db[_0x9e82('0x6c')]['QueryTypes'][_0x9e82('0x7f')]})[_0x9e82('0x2d')](function(_0xf53955){if(_0xf53955[_0x9e82('0x40')]===0x1){return _0x224bec['id'];}else{var _0x543aab=_[_0x9e82('0x80')](_[_0x9e82('0x36')](_0xf53955,_0x9e82('0x81')),function(_0x3190a4){return _[_0x9e82('0x82')](_0x346008,_0x3190a4);});if(_0x543aab){return _0x224bec['id'];}}}));}}return BPromise['all'](_0x500c59)['then'](function(_0x24ecb6){_0x3c4a16=_(_0x3c4a16)[_0x9e82('0x83')](_0x24ecb6)[_0x9e82('0x84')]()[_0x9e82('0x85')]();return db[_0x9e82('0x37')]['find']({'where':{'id':_0x488ad9[_0x9e82('0x50')]['id']}})[_0x9e82('0x2d')](function(_0x2ef180){return db[_0x9e82('0x6c')][_0x9e82('0x6d')](function(_0x3cde90){return _0x2ef180[_0x9e82('0x73')](_0x488ad9[_0x9e82('0x3b')][_0x9e82('0x74')],{'transaction':_0x3cde90})[_0x9e82('0x2d')](function(){if(!_['isEmpty'](_0x3c4a16)){return _0x2ef180[_0x9e82('0x86')](_0x3c4a16,{'transaction':_0x3cde90});}})[_0x9e82('0x2d')](function(){_0x3c4a16[_0x9e82('0x70')](function(_0x2cf42c){socket['emit'](_0x9e82('0x87'),{'UserId':_0x2cf42c,'MailQueueId':_0x2ef180['id']});});});});});});})[_0x9e82('0x2d')](respondWithStatusCode(_0x33bbd9,null))[_0x9e82('0x4e')](handleError(_0x33bbd9,null));};exports[_0x9e82('0x88')]=function(_0x18ae57,_0x1ed877,_0x4a81e0){return db['MailQueue'][_0x9e82('0x52')]({'where':{'id':_0x18ae57[_0x9e82('0x50')]['id']}})[_0x9e82('0x2d')](handleEntityNotFound(_0x1ed877,null))[_0x9e82('0x2d')](function(_0x9cfe38){if(_0x9cfe38){return _0x9cfe38[_0x9e82('0x88')](_0x18ae57[_0x9e82('0x54')][_0x9e82('0x74')],_[_0x9e82('0x89')](_0x18ae57[_0x9e82('0x54')],['ids','id'])||{})['spread'](function(_0x42647c){for(var _0x4de188=0x0;_0x4de188<_0x18ae57['body'][_0x9e82('0x74')][_0x9e82('0x40')];_0x4de188+=0x1){socket['emit']('userMailQueue:save',{'UserId':Number(_0x18ae57[_0x9e82('0x54')][_0x9e82('0x74')][_0x4de188]),'MailQueueId':Number(_0x18ae57[_0x9e82('0x50')]['id'])});}return _0x42647c;});}})[_0x9e82('0x2d')](respondWithResult(_0x1ed877,null))[_0x9e82('0x4e')](handleError(_0x1ed877,null));};exports[_0x9e82('0x86')]=function(_0x21b39b,_0x5d6146,_0x559149){return db[_0x9e82('0x37')][_0x9e82('0x52')]({'where':{'id':_0x21b39b[_0x9e82('0x50')]['id']}})[_0x9e82('0x2d')](handleEntityNotFound(_0x5d6146,null))[_0x9e82('0x2d')](function(_0x1489be){if(_0x1489be){return _0x1489be['removeAgents'](_0x21b39b[_0x9e82('0x3b')][_0x9e82('0x74')])['then'](function(){if(_[_0x9e82('0x8a')](_0x21b39b[_0x9e82('0x3b')][_0x9e82('0x74')])){for(var _0x5a86d2=0x0;_0x5a86d2<_0x21b39b[_0x9e82('0x3b')][_0x9e82('0x74')][_0x9e82('0x40')];_0x5a86d2+=0x1){socket['emit'](_0x9e82('0x87'),{'UserId':Number(_0x21b39b['query'][_0x9e82('0x74')][_0x5a86d2]),'MailQueueId':Number(_0x21b39b[_0x9e82('0x50')]['id'])});}}else{socket[_0x9e82('0x71')]('userMailQueue:remove',{'UserId':Number(_0x21b39b['query'][_0x9e82('0x74')]),'MailQueueId':Number(_0x21b39b['params']['id'])});}});}})[_0x9e82('0x2d')](respondWithStatusCode(_0x5d6146,null))[_0x9e82('0x4e')](handleError(_0x5d6146,null));};exports[_0x9e82('0x8b')]=function(_0x5d3524,_0x2a36f6,_0x967c96){var _0x8dd2c2={};var _0x3af6e9={};var _0x11c52f;var _0x5691a1;return db[_0x9e82('0x37')][_0x9e82('0x5b')]({'where':{'id':_0x5d3524[_0x9e82('0x50')]['id']}})[_0x9e82('0x2d')](handleEntityNotFound(_0x2a36f6,null))['then'](function(_0x589b44){if(_0x589b44){_0x11c52f=_0x589b44;_0x3af6e9['model']=_[_0x9e82('0x3c')](db[_0x9e82('0x60')]['rawAttributes']);_0x3af6e9['query']=_['keys'](_0x5d3524[_0x9e82('0x3b')]);_0x3af6e9[_0x9e82('0x44')]=_[_0x9e82('0x3d')](_0x3af6e9[_0x9e82('0x3a')],_0x3af6e9[_0x9e82('0x3b')]);_0x8dd2c2['attributes']=_[_0x9e82('0x3d')](_0x3af6e9[_0x9e82('0x3a')],qs[_0x9e82('0x3f')](_0x5d3524[_0x9e82('0x3b')][_0x9e82('0x3f')]));_0x8dd2c2['attributes']=_0x8dd2c2[_0x9e82('0x3e')][_0x9e82('0x40')]?_0x8dd2c2['attributes']:_0x3af6e9['model'];_0x8dd2c2[_0x9e82('0x5d')]=qs['sort'](_0x5d3524[_0x9e82('0x3b')]['sort']);_0x8dd2c2[_0x9e82('0x43')]=qs[_0x9e82('0x44')](_[_0x9e82('0x45')](_0x5d3524[_0x9e82('0x3b')],_0x3af6e9[_0x9e82('0x44')]));if(_0x5d3524[_0x9e82('0x3b')][_0x9e82('0x49')]){_0x8dd2c2['where']=_['merge'](_0x8dd2c2[_0x9e82('0x43')],{'$or':_[_0x9e82('0x36')](_0x8dd2c2[_0x9e82('0x3e')],function(_0x4ce1f7){var _0x5e9989={};_0x5e9989[_0x4ce1f7]={'$like':'%'+_0x5d3524[_0x9e82('0x3b')][_0x9e82('0x49')]+'%'};return _0x5e9989;})});}_0x8dd2c2=_[_0x9e82('0x46')]({},_0x8dd2c2,_0x5d3524[_0x9e82('0x4a')]);return _0x11c52f[_0x9e82('0x8b')](_0x8dd2c2);}})[_0x9e82('0x2d')](function(_0x516009){if(_0x516009){_0x5691a1=_0x516009[_0x9e82('0x40')];if(!_0x5d3524[_0x9e82('0x3b')][_0x9e82('0x41')](_0x9e82('0x42'))){_0x8dd2c2[_0x9e82('0x24')]=qs[_0x9e82('0x24')](_0x5d3524[_0x9e82('0x3b')][_0x9e82('0x24')]);_0x8dd2c2[_0x9e82('0x22')]=qs[_0x9e82('0x22')](_0x5d3524[_0x9e82('0x3b')]['offset']);}return _0x11c52f[_0x9e82('0x8b')](_0x8dd2c2);}})[_0x9e82('0x2d')](function(_0x1c98bb){if(_0x1c98bb){return _0x1c98bb?{'count':_0x5691a1,'rows':_0x1c98bb}:null;}})[_0x9e82('0x2d')](respondWithResult(_0x2a36f6,null))['catch'](handleError(_0x2a36f6,null));};
\ No newline at end of file