Built motion from commit (unavailable).|2.5.13
[motion2.git] / server / api / mailQueue / mailQueue.controller.js
index c296642..5633cf5 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 _0x77f1=['create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserMailQueue','MailQueueId','findAll','User','findAndCountAll','UserId','agent','mailPause','updatedAt','createdAt','format','%s/%s','getTeams','Team','addTeams','Agents','online','voicePause','interface','flatMap','sequelize','transaction','findOrCreate','forEach','emit','removeTeams','tq.TeamId','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','MailQueueId\x20=\x20?','clone','push','toString','every','TeamId','all','compact','value','isEmpty','removeAgents','addAgents','omit','spread','ids','userMailQueue:save','isArray','userMailQueue:remove','getAgents','eml-format','rimraf','zip-dir','bluebird','mustache','path','sox','to-csv','ejs','lodash','crypto','jsforce','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','register','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','destroy','then','MailQueues','UserProfileResource','sendStatus','stack','name','send','map','MailQueue','rawAttributes','fieldName','type','key','model','keys','query','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','filters','pick','filter','where','merge','VIRTUAL','options','include','rows','catch','show','params','find'];(function(_0x123935,_0x1670ba){var _0x1a8ebf=function(_0xa6933e){while(--_0xa6933e){_0x123935['push'](_0x123935['shift']());}};_0x1a8ebf(++_0x1670ba);}(_0x77f1,0x1dd));var _0x177f=function(_0x12851c,_0x11b0ce){_0x12851c=_0x12851c-0x0;var _0x4f28b5=_0x77f1[_0x12851c];return _0x4f28b5;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x177f('0x0'));var rimraf=require(_0x177f('0x1'));var zipdir=require(_0x177f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x177f('0x3'));var Mustache=require(_0x177f('0x4'));var util=require('util');var path=require(_0x177f('0x5'));var sox=require(_0x177f('0x6'));var csv=require(_0x177f('0x7'));var ejs=require(_0x177f('0x8'));var fs=require('fs');var _=require(_0x177f('0x9'));var squel=require('squel');var crypto=require(_0x177f('0xa'));var jsforce=require(_0x177f('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x177f('0x7'));var querystring=require('querystring');var Papa=require(_0x177f('0xc'));var Redis=require('ioredis');var authService=require(_0x177f('0xd'));var qs=require(_0x177f('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x177f('0xf'));var logger=require(_0x177f('0x10'))(_0x177f('0x11'));var utils=require(_0x177f('0x12'));var config=require(_0x177f('0x13'));var licenseUtil=require(_0x177f('0x14'));var db=require(_0x177f('0x15'))['db'];config[_0x177f('0x16')]=_['defaults'](config[_0x177f('0x16')],{'host':_0x177f('0x17'),'port':0x18eb});var socket=require(_0x177f('0x18'))(new Redis(config[_0x177f('0x16')]));require('./mailQueue.socket')[_0x177f('0x19')](socket);function respondWithStatusCode(_0x578d19,_0x1c947f){_0x1c947f=_0x1c947f||0xcc;return function(_0x526c95){if(_0x526c95){return _0x578d19['sendStatus'](_0x1c947f);}return _0x578d19[_0x177f('0x1a')](_0x1c947f)[_0x177f('0x1b')]();};}function respondWithResult(_0x457d8b,_0x3eefd9){_0x3eefd9=_0x3eefd9||0xc8;return function(_0x360e4b){if(_0x360e4b){return _0x457d8b[_0x177f('0x1a')](_0x3eefd9)[_0x177f('0x1c')](_0x360e4b);}};}function respondWithFilteredResult(_0x2f0db5,_0x2389d5){return function(_0x43f1d6){if(_0x43f1d6){var _0x4d8aa3=_0x43f1d6[_0x177f('0x1d')],_0x2acac8=_0x2389d5[_0x177f('0x1e')],_0xac6972=_0x2389d5[_0x177f('0x1e')]+_0x2389d5[_0x177f('0x1f')],_0x4d1c1e;if(_0xac6972>=_0x4d8aa3){_0xac6972=_0x4d8aa3;_0x4d1c1e=0xc8;}else{_0x4d1c1e=0xce;}_0x2f0db5[_0x177f('0x1a')](_0x4d1c1e);return _0x2f0db5[_0x177f('0x20')](_0x177f('0x21'),_0x2acac8+'-'+_0xac6972+'/'+_0x4d8aa3)[_0x177f('0x1c')](_0x43f1d6);}return null;};}function patchUpdates(_0x3d48eb){return function(_0x377b95){try{jsonpatch['apply'](_0x377b95,_0x3d48eb,!![]);}catch(_0x415ece){return BPromise[_0x177f('0x22')](_0x415ece);}return _0x377b95[_0x177f('0x23')]();};}function saveUpdates(_0x34eeb9,_0x2880e6){return function(_0x28c762){if(_0x28c762){return _0x28c762[_0x177f('0x24')](_0x34eeb9)['then'](function(_0x59f00f){return _0x59f00f;});}return null;};}function removeEntity(_0x298d75,_0x148c17){return function(_0x43f2f0){if(_0x43f2f0){return _0x43f2f0[_0x177f('0x25')]()[_0x177f('0x26')](function(){var _0x14a251=_0x43f2f0['get']({'plain':!![]});var _0x248e4c=_0x177f('0x27');return db[_0x177f('0x28')][_0x177f('0x25')]({'where':{'type':_0x248e4c,'resourceId':_0x14a251['id']}})[_0x177f('0x26')](function(){return _0x43f2f0;});})[_0x177f('0x26')](function(){_0x298d75[_0x177f('0x1a')](0xcc)[_0x177f('0x1b')]();});}};}function handleEntityNotFound(_0x1ae57e,_0x2a64d7){return function(_0x13f570){if(!_0x13f570){_0x1ae57e[_0x177f('0x29')](0x194);}return _0x13f570;};}function handleError(_0x25d876,_0x30655b){_0x30655b=_0x30655b||0x1f4;return function(_0xdf7bd){logger['error'](_0xdf7bd[_0x177f('0x2a')]);if(_0xdf7bd[_0x177f('0x2b')]){delete _0xdf7bd['name'];}_0x25d876[_0x177f('0x1a')](_0x30655b)[_0x177f('0x2c')](_0xdf7bd);};}exports['index']=function(_0x3a83c9,_0x27cfb3){var _0x4af04d={},_0x55d804={},_0x4a3cc9={'count':0x0,'rows':[]};var _0x59d542=_[_0x177f('0x2d')](db[_0x177f('0x2e')][_0x177f('0x2f')],function(_0x15681b){return{'name':_0x15681b[_0x177f('0x30')],'type':_0x15681b[_0x177f('0x31')][_0x177f('0x32')]};});_0x55d804[_0x177f('0x33')]=_[_0x177f('0x2d')](_0x59d542,_0x177f('0x2b'));_0x55d804['query']=_[_0x177f('0x34')](_0x3a83c9[_0x177f('0x35')]);_0x55d804['filters']=_[_0x177f('0x36')](_0x55d804[_0x177f('0x33')],_0x55d804['query']);_0x4af04d['attributes']=_[_0x177f('0x36')](_0x55d804[_0x177f('0x33')],qs[_0x177f('0x37')](_0x3a83c9[_0x177f('0x35')]['fields']));_0x4af04d['attributes']=_0x4af04d[_0x177f('0x38')][_0x177f('0x39')]?_0x4af04d[_0x177f('0x38')]:_0x55d804[_0x177f('0x33')];if(!_0x3a83c9[_0x177f('0x35')][_0x177f('0x3a')](_0x177f('0x3b'))){_0x4af04d['limit']=qs[_0x177f('0x1f')](_0x3a83c9['query'][_0x177f('0x1f')]);_0x4af04d[_0x177f('0x1e')]=qs['offset'](_0x3a83c9[_0x177f('0x35')][_0x177f('0x1e')]);}_0x4af04d[_0x177f('0x3c')]=qs[_0x177f('0x3d')](_0x3a83c9['query']['sort']);_0x4af04d['where']=qs[_0x177f('0x3e')](_[_0x177f('0x3f')](_0x3a83c9[_0x177f('0x35')],_0x55d804[_0x177f('0x3e')]),_0x59d542);if(_0x3a83c9[_0x177f('0x35')][_0x177f('0x40')]){_0x4af04d[_0x177f('0x41')]=_[_0x177f('0x42')](_0x4af04d[_0x177f('0x41')],{'$or':_[_0x177f('0x2d')](_0x59d542,function(_0x21aa43){if(_0x21aa43['type']!==_0x177f('0x43')){var _0x2b7d74={};_0x2b7d74[_0x21aa43[_0x177f('0x2b')]]={'$like':'%'+_0x3a83c9[_0x177f('0x35')][_0x177f('0x40')]+'%'};return _0x2b7d74;}})});}_0x4af04d=_[_0x177f('0x42')]({},_0x4af04d,_0x3a83c9[_0x177f('0x44')]);var _0x537d03={'where':_0x4af04d[_0x177f('0x41')]};return db['MailQueue'][_0x177f('0x1d')](_0x537d03)[_0x177f('0x26')](function(_0x59f112){_0x4a3cc9[_0x177f('0x1d')]=_0x59f112;if(_0x3a83c9[_0x177f('0x35')]['includeAll']){_0x4af04d[_0x177f('0x45')]=[{'all':!![]}];}return db['MailQueue']['findAll'](_0x4af04d);})[_0x177f('0x26')](function(_0x3852e9){_0x4a3cc9[_0x177f('0x46')]=_0x3852e9;return _0x4a3cc9;})['then'](respondWithFilteredResult(_0x27cfb3,_0x4af04d))[_0x177f('0x47')](handleError(_0x27cfb3,null));};exports[_0x177f('0x48')]=function(_0x1bbfe6,_0x1ea1cf){var _0x5af875={'raw':!![],'where':{'id':_0x1bbfe6[_0x177f('0x49')]['id']}},_0x42e47c={};_0x42e47c['model']=_[_0x177f('0x34')](db['MailQueue'][_0x177f('0x2f')]);_0x42e47c['query']=_[_0x177f('0x34')](_0x1bbfe6[_0x177f('0x35')]);_0x42e47c[_0x177f('0x3e')]=_[_0x177f('0x36')](_0x42e47c[_0x177f('0x33')],_0x42e47c['query']);_0x5af875[_0x177f('0x38')]=_[_0x177f('0x36')](_0x42e47c[_0x177f('0x33')],qs[_0x177f('0x37')](_0x1bbfe6['query'][_0x177f('0x37')]));_0x5af875[_0x177f('0x38')]=_0x5af875['attributes']['length']?_0x5af875[_0x177f('0x38')]:_0x42e47c[_0x177f('0x33')];if(_0x1bbfe6[_0x177f('0x35')]['includeAll']){_0x5af875[_0x177f('0x45')]=[{'all':!![]}];}_0x5af875=_[_0x177f('0x42')]({},_0x5af875,_0x1bbfe6[_0x177f('0x44')]);return db['MailQueue'][_0x177f('0x4a')](_0x5af875)[_0x177f('0x26')](handleEntityNotFound(_0x1ea1cf,null))[_0x177f('0x26')](respondWithResult(_0x1ea1cf,null))[_0x177f('0x47')](handleError(_0x1ea1cf,null));};exports[_0x177f('0x4b')]=function(_0x1b0951,_0x5562c0){return db[_0x177f('0x2e')][_0x177f('0x4b')](_0x1b0951[_0x177f('0x4c')],{})[_0x177f('0x26')](function(_0x1840c4){var _0x434016=_0x1b0951[_0x177f('0x4d')][_0x177f('0x4e')]({'plain':!![]});if(!_0x434016)throw new Error(_0x177f('0x4f'));if(_0x434016[_0x177f('0x50')]==='user'){var _0x47eff6=_0x1840c4[_0x177f('0x4e')]({'plain':!![]});var _0x1ff9f2=_0x177f('0x27');return db[_0x177f('0x51')]['find']({'where':{'name':_0x1ff9f2,'userProfileId':_0x434016[_0x177f('0x52')]},'raw':!![]})[_0x177f('0x26')](function(_0x8a0594){if(_0x8a0594&&_0x8a0594[_0x177f('0x53')]===0x0){return db[_0x177f('0x28')][_0x177f('0x4b')]({'name':_0x47eff6[_0x177f('0x2b')],'resourceId':_0x47eff6['id'],'type':_0x8a0594[_0x177f('0x2b')],'sectionId':_0x8a0594['id']},{})[_0x177f('0x26')](function(){return _0x1840c4;});}else{return _0x1840c4;}})[_0x177f('0x47')](function(_0x45bf7a){logger[_0x177f('0x54')](_0x177f('0x55'),_0x45bf7a);throw _0x45bf7a;});}return _0x1840c4;})[_0x177f('0x26')](respondWithResult(_0x5562c0,0xc9))[_0x177f('0x47')](handleError(_0x5562c0,null));};exports[_0x177f('0x24')]=function(_0x59eb4d,_0x424904){if(_0x59eb4d['body']['id']){delete _0x59eb4d[_0x177f('0x4c')]['id'];}return db[_0x177f('0x2e')]['find']({'where':{'id':_0x59eb4d['params']['id']}})['then'](handleEntityNotFound(_0x424904,null))[_0x177f('0x26')](saveUpdates(_0x59eb4d['body'],null))[_0x177f('0x26')](respondWithResult(_0x424904,null))['catch'](handleError(_0x424904,null));};exports['destroy']=function(_0xb9560c,_0x1e5915){return db['MailQueue'][_0x177f('0x4a')]({'where':{'id':_0xb9560c[_0x177f('0x49')]['id']}})[_0x177f('0x26')](handleEntityNotFound(_0x1e5915,null))['then'](removeEntity(_0x1e5915,null))[_0x177f('0x47')](handleError(_0x1e5915,null));};exports[_0x177f('0x56')]=function(_0x523ff3,_0x45d252){return db[_0x177f('0x2e')][_0x177f('0x56')]()[_0x177f('0x26')](respondWithResult(_0x45d252,null))[_0x177f('0x47')](handleError(_0x45d252,null));};exports[_0x177f('0x57')]=function(_0xb10483,_0x33e8fe,_0x1ea5a1){var _0x4bf284={'raw':!![],'where':{}},_0x12b544={},_0x37348d;return db[_0x177f('0x2e')][_0x177f('0x58')]({'where':{'id':_0xb10483[_0x177f('0x49')]['id']}})['then'](handleEntityNotFound(_0x33e8fe,null))[_0x177f('0x26')](function(_0x1d5c15){if(_0x1d5c15){_0x37348d=_0x1d5c15['get']({'plain':!![]});_0x12b544[_0x177f('0x33')]=_[_0x177f('0x34')](db[_0x177f('0x59')]['rawAttributes']);_0x12b544['query']=_[_0x177f('0x34')](_0xb10483[_0x177f('0x35')]);_0x12b544['filters']=_[_0x177f('0x36')](_0x12b544[_0x177f('0x33')],_0x12b544['query']);_0x4bf284[_0x177f('0x38')]=_[_0x177f('0x36')](_0x12b544[_0x177f('0x33')],qs[_0x177f('0x37')](_0xb10483['query'][_0x177f('0x37')]));_0x4bf284[_0x177f('0x38')]=_0x4bf284[_0x177f('0x38')][_0x177f('0x39')]?_0x4bf284[_0x177f('0x38')]:_0x12b544[_0x177f('0x33')];if(!_0xb10483[_0x177f('0x35')][_0x177f('0x3a')](_0x177f('0x3b'))){_0x4bf284['limit']=qs[_0x177f('0x1f')](_0xb10483[_0x177f('0x35')][_0x177f('0x1f')]);_0x4bf284['offset']=qs[_0x177f('0x1e')](_0xb10483[_0x177f('0x35')][_0x177f('0x1e')]);}_0x4bf284['order']=qs[_0x177f('0x3d')](_0xb10483[_0x177f('0x35')][_0x177f('0x3d')]);_0x4bf284[_0x177f('0x41')]=qs['filters'](_['pick'](_0xb10483['query'],_0x12b544[_0x177f('0x3e')]));_0x4bf284[_0x177f('0x41')][_0x177f('0x5a')]=_0x1d5c15['id'];if(_0xb10483[_0x177f('0x35')][_0x177f('0x40')]){_0x4bf284['where']=_[_0x177f('0x42')](_0x4bf284['where'],{'$or':_[_0x177f('0x2d')](_0x4bf284['attributes'],function(_0x4f7bd1){var _0x181624={};_0x181624[_0x4f7bd1]={'$like':'%'+_0xb10483[_0x177f('0x35')][_0x177f('0x40')]+'%'};return _0x181624;})});}_0x4bf284=_[_0x177f('0x42')]({},_0x4bf284,_0xb10483['options']);return db[_0x177f('0x59')][_0x177f('0x5b')](_0x4bf284);}})[_0x177f('0x26')](function(_0x171f01){if(_0x171f01){return db[_0x177f('0x5c')][_0x177f('0x5d')]({'where':{'id':_[_0x177f('0x2d')](_0x171f01,_0x177f('0x5e')),'role':_0x177f('0x5f')},'attributes':['id',_0x177f('0x2b'),_0x177f('0x60'),_0x177f('0x61'),_0x177f('0x62')]});}})[_0x177f('0x26')](function(_0x5e6e56){if(_0x5e6e56){return{'count':_0x5e6e56[_0x177f('0x1d')],'rows':_[_0x177f('0x2d')](_0x5e6e56['rows'],function(_0x30f884){return{'membername':_0x30f884['name'],'UserId':_0x30f884['id'],'queue_name':_0x37348d[_0x177f('0x2b')],'MailQueueId':_0x37348d['id'],'interface':util[_0x177f('0x63')](_0x177f('0x64'),'SIP',_0x30f884[_0x177f('0x2b')]),'penalty':0x0,'paused':_0x30f884[_0x177f('0x60')],'createdAt':_0x30f884[_0x177f('0x62')],'updatedAt':_0x30f884[_0x177f('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x177f('0x26')](respondWithFilteredResult(_0x33e8fe,_0x4bf284))[_0x177f('0x47')](handleError(_0x33e8fe,null));};exports[_0x177f('0x65')]=function(_0x481c23,_0x1a124f,_0x588382){var _0x4e9efb={};var _0xbe6a9b={};var _0x2b1347;var _0x18b695;return db[_0x177f('0x2e')][_0x177f('0x58')]({'where':{'id':_0x481c23['params']['id']}})['then'](handleEntityNotFound(_0x1a124f,null))[_0x177f('0x26')](function(_0x340df7){if(_0x340df7){_0x2b1347=_0x340df7;_0xbe6a9b[_0x177f('0x33')]=_['keys'](db[_0x177f('0x66')][_0x177f('0x2f')]);_0xbe6a9b[_0x177f('0x35')]=_[_0x177f('0x34')](_0x481c23['query']);_0xbe6a9b['filters']=_['intersection'](_0xbe6a9b[_0x177f('0x33')],_0xbe6a9b[_0x177f('0x35')]);_0x4e9efb[_0x177f('0x38')]=_[_0x177f('0x36')](_0xbe6a9b['model'],qs['fields'](_0x481c23[_0x177f('0x35')][_0x177f('0x37')]));_0x4e9efb['attributes']=_0x4e9efb['attributes'][_0x177f('0x39')]?_0x4e9efb[_0x177f('0x38')]:_0xbe6a9b[_0x177f('0x33')];_0x4e9efb[_0x177f('0x3c')]=qs[_0x177f('0x3d')](_0x481c23[_0x177f('0x35')]['sort']);_0x4e9efb[_0x177f('0x41')]=qs[_0x177f('0x3e')](_[_0x177f('0x3f')](_0x481c23[_0x177f('0x35')],_0xbe6a9b[_0x177f('0x3e')]));if(_0x481c23[_0x177f('0x35')][_0x177f('0x40')]){_0x4e9efb[_0x177f('0x41')]=_[_0x177f('0x42')](_0x4e9efb[_0x177f('0x41')],{'$or':_[_0x177f('0x2d')](_0x4e9efb['attributes'],function(_0x3e4f7b){var _0x56a3fa={};_0x56a3fa[_0x3e4f7b]={'$like':'%'+_0x481c23[_0x177f('0x35')][_0x177f('0x40')]+'%'};return _0x56a3fa;})});}_0x4e9efb=_[_0x177f('0x42')]({},_0x4e9efb,_0x481c23[_0x177f('0x44')]);return _0x2b1347['getTeams'](_0x4e9efb);}})[_0x177f('0x26')](function(_0x5ab823){if(_0x5ab823){_0x18b695=_0x5ab823[_0x177f('0x39')];if(!_0x481c23['query'][_0x177f('0x3a')]('nolimit')){_0x4e9efb[_0x177f('0x1f')]=qs['limit'](_0x481c23[_0x177f('0x35')]['limit']);_0x4e9efb[_0x177f('0x1e')]=qs[_0x177f('0x1e')](_0x481c23['query'][_0x177f('0x1e')]);}return _0x2b1347['getTeams'](_0x4e9efb);}})[_0x177f('0x26')](function(_0x42ed68){if(_0x42ed68){return _0x42ed68?{'count':_0x18b695,'rows':_0x42ed68}:null;}})[_0x177f('0x26')](respondWithResult(_0x1a124f,null))['catch'](handleError(_0x1a124f,null));};exports[_0x177f('0x67')]=function(_0x378b8f,_0x41952d,_0xbc41b4){var _0x4210e6=_0x378b8f[_0x177f('0x4c')]['ids'];return db['Team'][_0x177f('0x5b')]({'where':{'id':_0x4210e6},'attributes':['id'],'include':[{'model':db[_0x177f('0x5c')],'as':_0x177f('0x68'),'attributes':['id',_0x177f('0x2b'),_0x177f('0x69'),_0x177f('0x6a'),_0x177f('0x6b')],'raw':!![]}]})[_0x177f('0x26')](function(_0x518788){if(_0x518788){var _0x1dee85=_[_0x177f('0x6c')](_0x518788,function(_0xa65221){var _0x3f3790=_0xa65221[_0x177f('0x4e')]({'plain':!![]});return _0x3f3790[_0x177f('0x68')];});return db['MailQueue'][_0x177f('0x4a')]({'where':{'id':_0x378b8f[_0x177f('0x49')]['id']}})[_0x177f('0x26')](function(_0xd852cb){return db[_0x177f('0x6d')][_0x177f('0x6e')](function(_0x910e9c){return _0xd852cb['addTeams'](_0x4210e6,{'transaction':_0x910e9c})[_0x177f('0x26')](function(){return BPromise['each'](_0x1dee85,function(_0x3f44b0){return db[_0x177f('0x59')][_0x177f('0x6f')]({'where':{'UserId':_0x3f44b0['id'],'MailQueueId':_0x378b8f[_0x177f('0x49')]['id']},'transaction':_0x910e9c});});})[_0x177f('0x26')](function(){_0x1dee85[_0x177f('0x70')](function(_0x32f81a){socket[_0x177f('0x71')]('userMailQueue:save',{'UserId':_0x32f81a['id'],'MailQueueId':_0xd852cb['id']});});});});});}})['then'](respondWithStatusCode(_0x41952d,null))[_0x177f('0x47')](handleError(_0x41952d,null));};exports[_0x177f('0x72')]=function(_0x36996e,_0x5a273f,_0x22273d){return db['Team']['findAll']({'where':{'id':_0x36996e[_0x177f('0x35')]['ids']},'attributes':['id'],'include':[{'model':db[_0x177f('0x5c')],'as':_0x177f('0x68'),'attributes':['id'],'raw':!![]}]})[_0x177f('0x26')](handleEntityNotFound(_0x5a273f,null))[_0x177f('0x26')](function(_0x390305){var _0x3bb04c=_[_0x177f('0x2d')](_0x390305,'id');var _0x2dd0e9=[];var _0x44d6ce=[];var _0x303364=squel['select']();_0x303364['field'](_0x177f('0x73'))['from']('team_has_mail_queues','tq')[_0x177f('0x74')](_0x177f('0x75'),'ut',_0x177f('0x76'))[_0x177f('0x41')](_0x177f('0x77'),_0x36996e[_0x177f('0x49')]['id']);for(var _0x4dc36b=0x0;_0x4dc36b<_0x390305[_0x177f('0x39')];_0x4dc36b+=0x1){let _0x2febdf=_0x390305[_0x4dc36b];for(var _0x5a8b6a=0x0;_0x5a8b6a<_0x2febdf[_0x177f('0x68')][_0x177f('0x39')];_0x5a8b6a+=0x1){let _0x4c5ef6=_0x2febdf[_0x177f('0x68')][_0x5a8b6a];var _0x54ddca=_0x303364[_0x177f('0x78')]();_0x54ddca[_0x177f('0x41')]('ut.UserId\x20=\x20?',_0x4c5ef6['id']);_0x44d6ce[_0x177f('0x79')](db['sequelize'][_0x177f('0x35')](_0x54ddca[_0x177f('0x7a')](),{'type':db['sequelize']['QueryTypes']['SELECT']})[_0x177f('0x26')](function(_0x5f1af2){if(_0x5f1af2['length']===0x1){return _0x4c5ef6['id'];}else{var _0x5418f6=_[_0x177f('0x7b')](_['map'](_0x5f1af2,_0x177f('0x7c')),function(_0x5ac04c){return _['includes'](_0x3bb04c,_0x5ac04c);});if(_0x5418f6){return _0x4c5ef6['id'];}}}));}}return BPromise[_0x177f('0x7d')](_0x44d6ce)['then'](function(_0x153edc){_0x2dd0e9=_(_0x2dd0e9)['union'](_0x153edc)[_0x177f('0x7e')]()[_0x177f('0x7f')]();return db[_0x177f('0x2e')][_0x177f('0x4a')]({'where':{'id':_0x36996e['params']['id']}})[_0x177f('0x26')](function(_0x49c15e){return db[_0x177f('0x6d')][_0x177f('0x6e')](function(_0x27542f){return _0x49c15e[_0x177f('0x72')](_0x36996e[_0x177f('0x35')]['ids'],{'transaction':_0x27542f})['then'](function(){if(!_[_0x177f('0x80')](_0x2dd0e9)){return _0x49c15e[_0x177f('0x81')](_0x2dd0e9,{'transaction':_0x27542f});}})['then'](function(){_0x2dd0e9[_0x177f('0x70')](function(_0x54a11f){socket[_0x177f('0x71')]('userMailQueue:remove',{'UserId':_0x54a11f,'MailQueueId':_0x49c15e['id']});});});});});});})[_0x177f('0x26')](respondWithStatusCode(_0x5a273f,null))[_0x177f('0x47')](handleError(_0x5a273f,null));};exports['addAgents']=function(_0xc2fa80,_0x4cbe24,_0x532084){return db['MailQueue'][_0x177f('0x4a')]({'where':{'id':_0xc2fa80[_0x177f('0x49')]['id']}})['then'](handleEntityNotFound(_0x4cbe24,null))[_0x177f('0x26')](function(_0x34ed38){if(_0x34ed38){return _0x34ed38[_0x177f('0x82')](_0xc2fa80[_0x177f('0x4c')]['ids'],_[_0x177f('0x83')](_0xc2fa80[_0x177f('0x4c')],['ids','id'])||{})[_0x177f('0x84')](function(_0x4228a9){for(var _0x1ba5f5=0x0;_0x1ba5f5<_0xc2fa80[_0x177f('0x4c')][_0x177f('0x85')][_0x177f('0x39')];_0x1ba5f5+=0x1){socket['emit'](_0x177f('0x86'),{'UserId':_0xc2fa80[_0x177f('0x4c')][_0x177f('0x85')][_0x1ba5f5],'MailQueueId':_0xc2fa80[_0x177f('0x49')]['id']});}return _0x4228a9;});}})[_0x177f('0x26')](respondWithResult(_0x4cbe24,null))['catch'](handleError(_0x4cbe24,null));};exports[_0x177f('0x81')]=function(_0x24aa1d,_0x3561ef,_0x588780){return db[_0x177f('0x2e')][_0x177f('0x4a')]({'where':{'id':_0x24aa1d[_0x177f('0x49')]['id']}})[_0x177f('0x26')](handleEntityNotFound(_0x3561ef,null))[_0x177f('0x26')](function(_0x292d6c){if(_0x292d6c){return _0x292d6c[_0x177f('0x81')](_0x24aa1d[_0x177f('0x35')][_0x177f('0x85')])[_0x177f('0x26')](function(){if(_[_0x177f('0x87')](_0x24aa1d[_0x177f('0x35')][_0x177f('0x85')])){for(var _0x2cf49a=0x0;_0x2cf49a<_0x24aa1d['query'][_0x177f('0x85')][_0x177f('0x39')];_0x2cf49a+=0x1){socket[_0x177f('0x71')](_0x177f('0x88'),{'UserId':Number(_0x24aa1d['query'][_0x177f('0x85')][_0x2cf49a]),'MailQueueId':Number(_0x24aa1d[_0x177f('0x49')]['id'])});}}else{socket[_0x177f('0x71')](_0x177f('0x88'),{'UserId':Number(_0x24aa1d['query'][_0x177f('0x85')]),'MailQueueId':Number(_0x24aa1d[_0x177f('0x49')]['id'])});}});}})[_0x177f('0x26')](respondWithStatusCode(_0x3561ef,null))['catch'](handleError(_0x3561ef,null));};exports[_0x177f('0x89')]=function(_0x17190a,_0x25213e,_0x29ade7){var _0xafc372={};var _0x2c5595={};var _0x7ca5ce;var _0x4f35ab;return db[_0x177f('0x2e')][_0x177f('0x58')]({'where':{'id':_0x17190a[_0x177f('0x49')]['id']}})[_0x177f('0x26')](handleEntityNotFound(_0x25213e,null))[_0x177f('0x26')](function(_0x56fbfb){if(_0x56fbfb){_0x7ca5ce=_0x56fbfb;_0x2c5595[_0x177f('0x33')]=_[_0x177f('0x34')](db['User'][_0x177f('0x2f')]);_0x2c5595[_0x177f('0x35')]=_[_0x177f('0x34')](_0x17190a[_0x177f('0x35')]);_0x2c5595['filters']=_[_0x177f('0x36')](_0x2c5595[_0x177f('0x33')],_0x2c5595[_0x177f('0x35')]);_0xafc372[_0x177f('0x38')]=_[_0x177f('0x36')](_0x2c5595['model'],qs[_0x177f('0x37')](_0x17190a[_0x177f('0x35')][_0x177f('0x37')]));_0xafc372[_0x177f('0x38')]=_0xafc372[_0x177f('0x38')][_0x177f('0x39')]?_0xafc372['attributes']:_0x2c5595[_0x177f('0x33')];_0xafc372['order']=qs['sort'](_0x17190a[_0x177f('0x35')]['sort']);_0xafc372[_0x177f('0x41')]=qs[_0x177f('0x3e')](_[_0x177f('0x3f')](_0x17190a[_0x177f('0x35')],_0x2c5595['filters']));if(_0x17190a['query'][_0x177f('0x40')]){_0xafc372[_0x177f('0x41')]=_[_0x177f('0x42')](_0xafc372[_0x177f('0x41')],{'$or':_['map'](_0xafc372[_0x177f('0x38')],function(_0x2f7639){var _0x30f7d5={};_0x30f7d5[_0x2f7639]={'$like':'%'+_0x17190a['query'][_0x177f('0x40')]+'%'};return _0x30f7d5;})});}_0xafc372=_[_0x177f('0x42')]({},_0xafc372,_0x17190a[_0x177f('0x44')]);return _0x7ca5ce[_0x177f('0x89')](_0xafc372);}})['then'](function(_0x1498d2){if(_0x1498d2){_0x4f35ab=_0x1498d2['length'];if(!_0x17190a[_0x177f('0x35')][_0x177f('0x3a')](_0x177f('0x3b'))){_0xafc372[_0x177f('0x1f')]=qs['limit'](_0x17190a['query'][_0x177f('0x1f')]);_0xafc372['offset']=qs[_0x177f('0x1e')](_0x17190a['query'][_0x177f('0x1e')]);}return _0x7ca5ce[_0x177f('0x89')](_0xafc372);}})['then'](function(_0x277e4f){if(_0x277e4f){return _0x277e4f?{'count':_0x4f35ab,'rows':_0x277e4f}:null;}})[_0x177f('0x26')](respondWithResult(_0x25213e,null))[_0x177f('0x47')](handleError(_0x25213e,null));};
\ No newline at end of file