18 var _0x96b4=['TeamId','includes','all','union','compact','value','isEmpty','removeAgents','addAgents','omit','spread','isArray','userFaxQueue:remove','getAgents','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','util','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxQueue.socket','register','status','end','json','offset','undefined','count','limit','Content-Range','reject','save','update','destroy','then','get','FaxQueues','UserProfileResource','sendStatus','error','stack','index','map','FaxQueue','rawAttributes','fieldName','type','model','name','query','keys','filters','intersection','fields','attributes','length','nolimit','order','sort','where','pick','VIRTUAL','merge','includeAll','findAll','rows','catch','show','params','options','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','getMembers','findOne','UserFaxQueue','hasOwnProperty','filter','User','findAndCountAll','agent','faxPause','updatedAt','%s/%s','SIP','getTeams','Team','addTeams','Agents','online','interface','sequelize','transaction','each','findOrCreate','emit','userFaxQueue:save','ids','select','tq.TeamId','from','join','user_has_teams','FaxQueueId\x20=\x20?','push','toString','QueryTypes','SELECT'];(function(_0x25886f,_0x492785){var _0x12e414=function(_0x18d124){while(--_0x18d124){_0x25886f['push'](_0x25886f['shift']());}};_0x12e414(++_0x492785);}(_0x96b4,0x110));var _0x496b=function(_0x454f0a,_0xff10e0){_0x454f0a=_0x454f0a-0x0;var _0x368215=_0x96b4[_0x454f0a];return _0x368215;};'use strict';var emlformat=require(_0x496b('0x0'));var rimraf=require(_0x496b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x496b('0x2'));var rp=require(_0x496b('0x3'));var moment=require(_0x496b('0x4'));var BPromise=require(_0x496b('0x5'));var Mustache=require('mustache');var util=require(_0x496b('0x6'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x496b('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x496b('0x8'));var squel=require(_0x496b('0x9'));var crypto=require(_0x496b('0xa'));var jsforce=require(_0x496b('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x496b('0xc'));var Papa=require(_0x496b('0xd'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x496b('0xe'));var hardwareService=require(_0x496b('0xf'));var logger=require('../../config/logger')(_0x496b('0x10'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x496b('0x11'));var db=require(_0x496b('0x12'))['db'];config['redis']=_['defaults'](config[_0x496b('0x13')],{'host':_0x496b('0x14'),'port':0x18eb});var socket=require(_0x496b('0x15'))(new Redis(config['redis']));require(_0x496b('0x16'))[_0x496b('0x17')](socket);function respondWithStatusCode(_0x39939b,_0x250a4a){_0x250a4a=_0x250a4a||0xcc;return function(_0x5a9148){if(_0x5a9148){return _0x39939b['sendStatus'](_0x250a4a);}return _0x39939b[_0x496b('0x18')](_0x250a4a)[_0x496b('0x19')]();};}function respondWithResult(_0x12f59c,_0x377988){_0x377988=_0x377988||0xc8;return function(_0x3dd9fc){if(_0x3dd9fc){return _0x12f59c['status'](_0x377988)[_0x496b('0x1a')](_0x3dd9fc);}};}function respondWithFilteredResult(_0x9899ab,_0x2517d1){return function(_0x456625){if(_0x456625){var _0x56d97d=typeof _0x2517d1[_0x496b('0x1b')]===_0x496b('0x1c')&&typeof _0x2517d1['limit']===_0x496b('0x1c');var _0x4bb066=_0x456625['count'];var _0x565774=_0x56d97d?0x0:_0x2517d1[_0x496b('0x1b')];var _0x459695=_0x56d97d?_0x456625[_0x496b('0x1d')]:_0x2517d1[_0x496b('0x1b')]+_0x2517d1[_0x496b('0x1e')];var _0x35147b;if(_0x459695>=_0x4bb066){_0x459695=_0x4bb066;_0x35147b=0xc8;}else{_0x35147b=0xce;}_0x9899ab[_0x496b('0x18')](_0x35147b);return _0x9899ab['set'](_0x496b('0x1f'),_0x565774+'-'+_0x459695+'/'+_0x4bb066)['json'](_0x456625);}return null;};}function patchUpdates(_0x1442d0){return function(_0x2b3ff2){try{jsonpatch['apply'](_0x2b3ff2,_0x1442d0,!![]);}catch(_0x4f63c3){return BPromise[_0x496b('0x20')](_0x4f63c3);}return _0x2b3ff2[_0x496b('0x21')]();};}function saveUpdates(_0x49a73c,_0x520225){return function(_0x596665){if(_0x596665){return _0x596665[_0x496b('0x22')](_0x49a73c)['then'](function(_0x5b9dfe){return _0x5b9dfe;});}return null;};}function removeEntity(_0x2ca43d,_0x504fb5){return function(_0x21d930){if(_0x21d930){return _0x21d930[_0x496b('0x23')]()[_0x496b('0x24')](function(){var _0x273ed9=_0x21d930[_0x496b('0x25')]({'plain':!![]});var _0x4d8f86=_0x496b('0x26');return db[_0x496b('0x27')][_0x496b('0x23')]({'where':{'type':_0x4d8f86,'resourceId':_0x273ed9['id']}})[_0x496b('0x24')](function(){return _0x21d930;});})[_0x496b('0x24')](function(){_0x2ca43d['status'](0xcc)[_0x496b('0x19')]();});}};}function handleEntityNotFound(_0x1832b1,_0x561939){return function(_0x2e809b){if(!_0x2e809b){_0x1832b1[_0x496b('0x28')](0x194);}return _0x2e809b;};}function handleError(_0x48c48d,_0x592d57){_0x592d57=_0x592d57||0x1f4;return function(_0x17981b){logger[_0x496b('0x29')](_0x17981b[_0x496b('0x2a')]);if(_0x17981b['name']){delete _0x17981b['name'];}_0x48c48d['status'](_0x592d57)['send'](_0x17981b);};}exports[_0x496b('0x2b')]=function(_0x4a3434,_0x427f73){var _0x2a6ae8={},_0x40a338={},_0x101232={'count':0x0,'rows':[]};var _0x30565a=_[_0x496b('0x2c')](db[_0x496b('0x2d')][_0x496b('0x2e')],function(_0xb31c5a){return{'name':_0xb31c5a[_0x496b('0x2f')],'type':_0xb31c5a[_0x496b('0x30')]['key']};});_0x40a338[_0x496b('0x31')]=_[_0x496b('0x2c')](_0x30565a,_0x496b('0x32'));_0x40a338[_0x496b('0x33')]=_[_0x496b('0x34')](_0x4a3434[_0x496b('0x33')]);_0x40a338[_0x496b('0x35')]=_['intersection'](_0x40a338[_0x496b('0x31')],_0x40a338[_0x496b('0x33')]);_0x2a6ae8['attributes']=_[_0x496b('0x36')](_0x40a338[_0x496b('0x31')],qs[_0x496b('0x37')](_0x4a3434[_0x496b('0x33')]['fields']));_0x2a6ae8[_0x496b('0x38')]=_0x2a6ae8[_0x496b('0x38')][_0x496b('0x39')]?_0x2a6ae8['attributes']:_0x40a338[_0x496b('0x31')];if(!_0x4a3434[_0x496b('0x33')]['hasOwnProperty'](_0x496b('0x3a'))){_0x2a6ae8['limit']=qs[_0x496b('0x1e')](_0x4a3434[_0x496b('0x33')]['limit']);_0x2a6ae8[_0x496b('0x1b')]=qs[_0x496b('0x1b')](_0x4a3434[_0x496b('0x33')][_0x496b('0x1b')]);}_0x2a6ae8[_0x496b('0x3b')]=qs[_0x496b('0x3c')](_0x4a3434[_0x496b('0x33')][_0x496b('0x3c')]);_0x2a6ae8[_0x496b('0x3d')]=qs[_0x496b('0x35')](_[_0x496b('0x3e')](_0x4a3434[_0x496b('0x33')],_0x40a338[_0x496b('0x35')]),_0x30565a);if(_0x4a3434[_0x496b('0x33')]['filter']){_0x2a6ae8[_0x496b('0x3d')]=_['merge'](_0x2a6ae8[_0x496b('0x3d')],{'$or':_['map'](_0x30565a,function(_0x2207b9){if(_0x2207b9[_0x496b('0x30')]!==_0x496b('0x3f')){var _0x238aa8={};_0x238aa8[_0x2207b9['name']]={'$like':'%'+_0x4a3434[_0x496b('0x33')]['filter']+'%'};return _0x238aa8;}})});}_0x2a6ae8=_[_0x496b('0x40')]({},_0x2a6ae8,_0x4a3434['options']);var _0x4b7ae3={'where':_0x2a6ae8['where']};return db[_0x496b('0x2d')]['count'](_0x4b7ae3)[_0x496b('0x24')](function(_0x561a59){_0x101232['count']=_0x561a59;if(_0x4a3434[_0x496b('0x33')][_0x496b('0x41')]){_0x2a6ae8['include']=[{'all':!![]}];}return db['FaxQueue'][_0x496b('0x42')](_0x2a6ae8);})['then'](function(_0x4f3f37){_0x101232[_0x496b('0x43')]=_0x4f3f37;return _0x101232;})[_0x496b('0x24')](respondWithFilteredResult(_0x427f73,_0x2a6ae8))[_0x496b('0x44')](handleError(_0x427f73,null));};exports[_0x496b('0x45')]=function(_0x57f01c,_0x2aea62){var _0x171c6d={'raw':!![],'where':{'id':_0x57f01c[_0x496b('0x46')]['id']}},_0x2ff45d={};_0x2ff45d['model']=_['keys'](db[_0x496b('0x2d')][_0x496b('0x2e')]);_0x2ff45d[_0x496b('0x33')]=_[_0x496b('0x34')](_0x57f01c[_0x496b('0x33')]);_0x2ff45d[_0x496b('0x35')]=_[_0x496b('0x36')](_0x2ff45d[_0x496b('0x31')],_0x2ff45d[_0x496b('0x33')]);_0x171c6d[_0x496b('0x38')]=_['intersection'](_0x2ff45d['model'],qs['fields'](_0x57f01c[_0x496b('0x33')][_0x496b('0x37')]));_0x171c6d['attributes']=_0x171c6d['attributes'][_0x496b('0x39')]?_0x171c6d[_0x496b('0x38')]:_0x2ff45d['model'];if(_0x57f01c[_0x496b('0x33')][_0x496b('0x41')]){_0x171c6d['include']=[{'all':!![]}];}_0x171c6d=_['merge']({},_0x171c6d,_0x57f01c[_0x496b('0x47')]);return db[_0x496b('0x2d')][_0x496b('0x48')](_0x171c6d)[_0x496b('0x24')](handleEntityNotFound(_0x2aea62,null))['then'](respondWithResult(_0x2aea62,null))[_0x496b('0x44')](handleError(_0x2aea62,null));};exports[_0x496b('0x49')]=function(_0x72c4f7,_0x41bf7a){return db[_0x496b('0x2d')][_0x496b('0x49')](_0x72c4f7[_0x496b('0x4a')],{})[_0x496b('0x24')](function(_0x19bce6){var _0xb19305=_0x72c4f7[_0x496b('0x4b')][_0x496b('0x25')]({'plain':!![]});if(!_0xb19305)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0xb19305[_0x496b('0x4c')]===_0x496b('0x4b')){var _0xff9cad=_0x19bce6['get']({'plain':!![]});var _0x15752a='FaxQueues';return db[_0x496b('0x4d')]['find']({'where':{'name':_0x15752a,'userProfileId':_0xb19305[_0x496b('0x4e')]},'raw':!![]})[_0x496b('0x24')](function(_0x58697b){if(_0x58697b&&_0x58697b[_0x496b('0x4f')]===0x0){return db[_0x496b('0x27')]['create']({'name':_0xff9cad[_0x496b('0x32')],'resourceId':_0xff9cad['id'],'type':_0x58697b[_0x496b('0x32')],'sectionId':_0x58697b['id']},{})[_0x496b('0x24')](function(){return _0x19bce6;});}else{return _0x19bce6;}})['catch'](function(_0x39ee08){logger[_0x496b('0x29')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x39ee08);throw _0x39ee08;});}return _0x19bce6;})[_0x496b('0x24')](respondWithResult(_0x41bf7a,0xc9))[_0x496b('0x44')](handleError(_0x41bf7a,null));};exports[_0x496b('0x22')]=function(_0x224512,_0x5ba62d){if(_0x224512[_0x496b('0x4a')]['id']){delete _0x224512[_0x496b('0x4a')]['id'];}return db[_0x496b('0x2d')][_0x496b('0x48')]({'where':{'id':_0x224512[_0x496b('0x46')]['id']}})[_0x496b('0x24')](handleEntityNotFound(_0x5ba62d,null))['then'](saveUpdates(_0x224512[_0x496b('0x4a')],null))['then'](respondWithResult(_0x5ba62d,null))[_0x496b('0x44')](handleError(_0x5ba62d,null));};exports[_0x496b('0x23')]=function(_0x568358,_0x8fb86c){return db[_0x496b('0x2d')][_0x496b('0x48')]({'where':{'id':_0x568358[_0x496b('0x46')]['id']}})[_0x496b('0x24')](handleEntityNotFound(_0x8fb86c,null))[_0x496b('0x24')](removeEntity(_0x8fb86c,null))['catch'](handleError(_0x8fb86c,null));};exports['describe']=function(_0xdcd30c,_0x5ae241){return db[_0x496b('0x2d')]['describe']()[_0x496b('0x24')](respondWithResult(_0x5ae241,null))[_0x496b('0x44')](handleError(_0x5ae241,null));};exports[_0x496b('0x50')]=function(_0x287de3,_0x4cc894,_0xb96448){var _0x7b401b={'raw':!![],'where':{}},_0x57fc24={},_0x26d0d1;return db['FaxQueue'][_0x496b('0x51')]({'where':{'id':_0x287de3['params']['id']}})[_0x496b('0x24')](handleEntityNotFound(_0x4cc894,null))[_0x496b('0x24')](function(_0x5262d0){if(_0x5262d0){_0x26d0d1=_0x5262d0[_0x496b('0x25')]({'plain':!![]});_0x57fc24[_0x496b('0x31')]=_[_0x496b('0x34')](db[_0x496b('0x52')][_0x496b('0x2e')]);_0x57fc24[_0x496b('0x33')]=_[_0x496b('0x34')](_0x287de3[_0x496b('0x33')]);_0x57fc24['filters']=_[_0x496b('0x36')](_0x57fc24[_0x496b('0x31')],_0x57fc24[_0x496b('0x33')]);_0x7b401b['attributes']=_['intersection'](_0x57fc24['model'],qs[_0x496b('0x37')](_0x287de3['query'][_0x496b('0x37')]));_0x7b401b['attributes']=_0x7b401b['attributes'][_0x496b('0x39')]?_0x7b401b[_0x496b('0x38')]:_0x57fc24[_0x496b('0x31')];if(!_0x287de3[_0x496b('0x33')][_0x496b('0x53')]('nolimit')){_0x7b401b['limit']=qs[_0x496b('0x1e')](_0x287de3[_0x496b('0x33')]['limit']);_0x7b401b[_0x496b('0x1b')]=qs[_0x496b('0x1b')](_0x287de3[_0x496b('0x33')][_0x496b('0x1b')]);}_0x7b401b['order']=qs['sort'](_0x287de3[_0x496b('0x33')][_0x496b('0x3c')]);_0x7b401b[_0x496b('0x3d')]=qs[_0x496b('0x35')](_['pick'](_0x287de3[_0x496b('0x33')],_0x57fc24[_0x496b('0x35')]));_0x7b401b[_0x496b('0x3d')]['FaxQueueId']=_0x5262d0['id'];if(_0x287de3['query'][_0x496b('0x54')]){_0x7b401b[_0x496b('0x3d')]=_[_0x496b('0x40')](_0x7b401b[_0x496b('0x3d')],{'$or':_[_0x496b('0x2c')](_0x7b401b['attributes'],function(_0x17d5da){var _0x522b96={};_0x522b96[_0x17d5da]={'$like':'%'+_0x287de3[_0x496b('0x33')][_0x496b('0x54')]+'%'};return _0x522b96;})});}_0x7b401b=_['merge']({},_0x7b401b,_0x287de3[_0x496b('0x47')]);return db[_0x496b('0x52')]['findAll'](_0x7b401b);}})['then'](function(_0x4ee34a){if(_0x4ee34a){return db[_0x496b('0x55')][_0x496b('0x56')]({'where':{'id':_[_0x496b('0x2c')](_0x4ee34a,'UserId'),'role':_0x496b('0x57')},'attributes':['id','name',_0x496b('0x58'),_0x496b('0x59'),'createdAt']});}})[_0x496b('0x24')](function(_0x25a92d){if(_0x25a92d){return{'count':_0x25a92d[_0x496b('0x1d')],'rows':_['map'](_0x25a92d[_0x496b('0x43')],function(_0x4fd432){return{'membername':_0x4fd432['name'],'UserId':_0x4fd432['id'],'queue_name':_0x26d0d1[_0x496b('0x32')],'FaxQueueId':_0x26d0d1['id'],'interface':util['format'](_0x496b('0x5a'),_0x496b('0x5b'),_0x4fd432[_0x496b('0x32')]),'penalty':0x0,'paused':_0x4fd432[_0x496b('0x58')],'createdAt':_0x4fd432['createdAt'],'updatedAt':_0x4fd432[_0x496b('0x59')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x4cc894,_0x7b401b))[_0x496b('0x44')](handleError(_0x4cc894,null));};exports[_0x496b('0x5c')]=function(_0x2a2b38,_0x4faf03,_0x44bf07){var _0x4f69b1={};var _0x3a0826={};var _0x431161;var _0x1078de;return db[_0x496b('0x2d')][_0x496b('0x51')]({'where':{'id':_0x2a2b38[_0x496b('0x46')]['id']}})[_0x496b('0x24')](handleEntityNotFound(_0x4faf03,null))[_0x496b('0x24')](function(_0x422a7e){if(_0x422a7e){_0x431161=_0x422a7e;_0x3a0826['model']=_[_0x496b('0x34')](db[_0x496b('0x5d')]['rawAttributes']);_0x3a0826['query']=_['keys'](_0x2a2b38[_0x496b('0x33')]);_0x3a0826['filters']=_[_0x496b('0x36')](_0x3a0826[_0x496b('0x31')],_0x3a0826['query']);_0x4f69b1['attributes']=_[_0x496b('0x36')](_0x3a0826[_0x496b('0x31')],qs[_0x496b('0x37')](_0x2a2b38['query']['fields']));_0x4f69b1[_0x496b('0x38')]=_0x4f69b1['attributes'][_0x496b('0x39')]?_0x4f69b1[_0x496b('0x38')]:_0x3a0826['model'];_0x4f69b1[_0x496b('0x3b')]=qs[_0x496b('0x3c')](_0x2a2b38['query'][_0x496b('0x3c')]);_0x4f69b1[_0x496b('0x3d')]=qs[_0x496b('0x35')](_[_0x496b('0x3e')](_0x2a2b38['query'],_0x3a0826['filters']));if(_0x2a2b38[_0x496b('0x33')][_0x496b('0x54')]){_0x4f69b1[_0x496b('0x3d')]=_[_0x496b('0x40')](_0x4f69b1[_0x496b('0x3d')],{'$or':_[_0x496b('0x2c')](_0x4f69b1[_0x496b('0x38')],function(_0x600385){var _0x3950dd={};_0x3950dd[_0x600385]={'$like':'%'+_0x2a2b38[_0x496b('0x33')][_0x496b('0x54')]+'%'};return _0x3950dd;})});}_0x4f69b1=_[_0x496b('0x40')]({},_0x4f69b1,_0x2a2b38[_0x496b('0x47')]);return _0x431161[_0x496b('0x5c')](_0x4f69b1);}})[_0x496b('0x24')](function(_0x34c7e5){if(_0x34c7e5){_0x1078de=_0x34c7e5[_0x496b('0x39')];if(!_0x2a2b38[_0x496b('0x33')][_0x496b('0x53')](_0x496b('0x3a'))){_0x4f69b1[_0x496b('0x1e')]=qs['limit'](_0x2a2b38[_0x496b('0x33')]['limit']);_0x4f69b1['offset']=qs[_0x496b('0x1b')](_0x2a2b38[_0x496b('0x33')][_0x496b('0x1b')]);}return _0x431161[_0x496b('0x5c')](_0x4f69b1);}})[_0x496b('0x24')](function(_0x1eeee3){if(_0x1eeee3){return _0x1eeee3?{'count':_0x1078de,'rows':_0x1eeee3}:null;}})[_0x496b('0x24')](respondWithResult(_0x4faf03,null))['catch'](handleError(_0x4faf03,null));};exports[_0x496b('0x5e')]=function(_0x529e63,_0x14f3bb,_0x1aa5cb){var _0x3f8498=_0x529e63[_0x496b('0x4a')]['ids'];return db[_0x496b('0x5d')][_0x496b('0x42')]({'where':{'id':_0x3f8498},'attributes':['id'],'include':[{'model':db[_0x496b('0x55')],'as':_0x496b('0x5f'),'attributes':['id',_0x496b('0x32'),_0x496b('0x60'),'voicePause',_0x496b('0x61')],'raw':!![]}]})[_0x496b('0x24')](function(_0x117858){if(_0x117858){var _0x1ca157=_['flatMap'](_0x117858,function(_0x4ac585){var _0x1245eb=_0x4ac585[_0x496b('0x25')]({'plain':!![]});return _0x1245eb[_0x496b('0x5f')];});return db[_0x496b('0x2d')][_0x496b('0x48')]({'where':{'id':_0x529e63[_0x496b('0x46')]['id']}})[_0x496b('0x24')](function(_0x16b5f8){return db[_0x496b('0x62')][_0x496b('0x63')](function(_0x2dda34){return _0x16b5f8['addTeams'](_0x3f8498,{'transaction':_0x2dda34})[_0x496b('0x24')](function(){return BPromise[_0x496b('0x64')](_0x1ca157,function(_0x303d9e){return db[_0x496b('0x52')][_0x496b('0x65')]({'where':{'UserId':_0x303d9e['id'],'FaxQueueId':_0x529e63[_0x496b('0x46')]['id']},'transaction':_0x2dda34});});})[_0x496b('0x24')](function(){_0x1ca157['forEach'](function(_0x1c3508){socket[_0x496b('0x66')](_0x496b('0x67'),{'UserId':_0x1c3508['id'],'FaxQueueId':_0x16b5f8['id']});});});});});}})['then'](respondWithStatusCode(_0x14f3bb,null))['catch'](handleError(_0x14f3bb,null));};exports['removeTeams']=function(_0x1bc4c9,_0x450d0b,_0x303389){return db['Team'][_0x496b('0x42')]({'where':{'id':_0x1bc4c9['query'][_0x496b('0x68')]},'attributes':['id'],'include':[{'model':db[_0x496b('0x55')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x496b('0x24')](handleEntityNotFound(_0x450d0b,null))['then'](function(_0x147cea){var _0x3e8c79=_[_0x496b('0x2c')](_0x147cea,'id');var _0xd52d10=[];var _0x463ff6=[];var _0x5eff6e=squel[_0x496b('0x69')]();_0x5eff6e['field'](_0x496b('0x6a'))[_0x496b('0x6b')]('team_has_fax_queues','tq')[_0x496b('0x6c')](_0x496b('0x6d'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x496b('0x3d')](_0x496b('0x6e'),_0x1bc4c9[_0x496b('0x46')]['id']);for(var _0x2913e2=0x0;_0x2913e2<_0x147cea['length'];_0x2913e2+=0x1){let _0x5a9fc2=_0x147cea[_0x2913e2];for(var _0x56e8af=0x0;_0x56e8af<_0x5a9fc2[_0x496b('0x5f')][_0x496b('0x39')];_0x56e8af+=0x1){let _0x5c67ec=_0x5a9fc2[_0x496b('0x5f')][_0x56e8af];var _0x338929=_0x5eff6e['clone']();_0x338929['where']('ut.UserId\x20=\x20?',_0x5c67ec['id']);_0x463ff6[_0x496b('0x6f')](db[_0x496b('0x62')][_0x496b('0x33')](_0x338929[_0x496b('0x70')](),{'type':db[_0x496b('0x62')][_0x496b('0x71')][_0x496b('0x72')]})['then'](function(_0xb4d6e7){if(_0xb4d6e7[_0x496b('0x39')]===0x1){return _0x5c67ec['id'];}else{var _0x5f14c1=_['every'](_[_0x496b('0x2c')](_0xb4d6e7,_0x496b('0x73')),function(_0x5a8fb4){return _[_0x496b('0x74')](_0x3e8c79,_0x5a8fb4);});if(_0x5f14c1){return _0x5c67ec['id'];}}}));}}return BPromise[_0x496b('0x75')](_0x463ff6)[_0x496b('0x24')](function(_0x4bbc6f){_0xd52d10=_(_0xd52d10)[_0x496b('0x76')](_0x4bbc6f)[_0x496b('0x77')]()[_0x496b('0x78')]();return db[_0x496b('0x2d')]['find']({'where':{'id':_0x1bc4c9['params']['id']}})[_0x496b('0x24')](function(_0x271f36){return db[_0x496b('0x62')][_0x496b('0x63')](function(_0x1a6c60){return _0x271f36['removeTeams'](_0x1bc4c9[_0x496b('0x33')][_0x496b('0x68')],{'transaction':_0x1a6c60})['then'](function(){if(!_[_0x496b('0x79')](_0xd52d10)){return _0x271f36[_0x496b('0x7a')](_0xd52d10,{'transaction':_0x1a6c60});}})['then'](function(){_0xd52d10['forEach'](function(_0xbbbebc){socket['emit']('userFaxQueue:remove',{'UserId':_0xbbbebc,'FaxQueueId':_0x271f36['id']});});});});});});})[_0x496b('0x24')](respondWithStatusCode(_0x450d0b,null))[_0x496b('0x44')](handleError(_0x450d0b,null));};exports[_0x496b('0x7b')]=function(_0x36a55e,_0x527dfc,_0xa21b60){return db[_0x496b('0x2d')][_0x496b('0x48')]({'where':{'id':_0x36a55e['params']['id']}})['then'](handleEntityNotFound(_0x527dfc,null))[_0x496b('0x24')](function(_0x1480ca){if(_0x1480ca){return _0x1480ca[_0x496b('0x7b')](_0x36a55e[_0x496b('0x4a')][_0x496b('0x68')],_[_0x496b('0x7c')](_0x36a55e[_0x496b('0x4a')],[_0x496b('0x68'),'id'])||{})[_0x496b('0x7d')](function(_0xe40b12){for(var _0x2111dc=0x0;_0x2111dc<_0x36a55e[_0x496b('0x4a')][_0x496b('0x68')][_0x496b('0x39')];_0x2111dc+=0x1){socket['emit'](_0x496b('0x67'),{'UserId':Number(_0x36a55e['body'][_0x496b('0x68')][_0x2111dc]),'FaxQueueId':Number(_0x36a55e[_0x496b('0x46')]['id'])});}return _0xe40b12;});}})[_0x496b('0x24')](respondWithResult(_0x527dfc,null))[_0x496b('0x44')](handleError(_0x527dfc,null));};exports['removeAgents']=function(_0x15f557,_0xdf8186,_0x3862ad){return db[_0x496b('0x2d')][_0x496b('0x48')]({'where':{'id':_0x15f557[_0x496b('0x46')]['id']}})[_0x496b('0x24')](handleEntityNotFound(_0xdf8186,null))[_0x496b('0x24')](function(_0x3ed89b){if(_0x3ed89b){return _0x3ed89b[_0x496b('0x7a')](_0x15f557[_0x496b('0x33')][_0x496b('0x68')])['then'](function(){if(_[_0x496b('0x7e')](_0x15f557[_0x496b('0x33')][_0x496b('0x68')])){for(var _0x49ada8=0x0;_0x49ada8<_0x15f557[_0x496b('0x33')]['ids'][_0x496b('0x39')];_0x49ada8+=0x1){socket[_0x496b('0x66')](_0x496b('0x7f'),{'UserId':Number(_0x15f557[_0x496b('0x33')][_0x496b('0x68')][_0x49ada8]),'FaxQueueId':Number(_0x15f557[_0x496b('0x46')]['id'])});}}else{socket[_0x496b('0x66')](_0x496b('0x7f'),{'UserId':Number(_0x15f557[_0x496b('0x33')]['ids']),'FaxQueueId':Number(_0x15f557[_0x496b('0x46')]['id'])});}});}})['then'](respondWithStatusCode(_0xdf8186,null))[_0x496b('0x44')](handleError(_0xdf8186,null));};exports[_0x496b('0x80')]=function(_0x343f73,_0x3e21dd,_0x1bf1f4){var _0x14bc56={};var _0x129048={};var _0x7a5f85;var _0x5d0cb9;return db[_0x496b('0x2d')][_0x496b('0x51')]({'where':{'id':_0x343f73['params']['id']}})['then'](handleEntityNotFound(_0x3e21dd,null))[_0x496b('0x24')](function(_0x27d5b9){if(_0x27d5b9){_0x7a5f85=_0x27d5b9;_0x129048[_0x496b('0x31')]=_[_0x496b('0x34')](db['User'][_0x496b('0x2e')]);_0x129048[_0x496b('0x33')]=_[_0x496b('0x34')](_0x343f73[_0x496b('0x33')]);_0x129048['filters']=_['intersection'](_0x129048['model'],_0x129048[_0x496b('0x33')]);_0x14bc56[_0x496b('0x38')]=_[_0x496b('0x36')](_0x129048[_0x496b('0x31')],qs[_0x496b('0x37')](_0x343f73[_0x496b('0x33')][_0x496b('0x37')]));_0x14bc56['attributes']=_0x14bc56[_0x496b('0x38')][_0x496b('0x39')]?_0x14bc56['attributes']:_0x129048[_0x496b('0x31')];_0x14bc56[_0x496b('0x3b')]=qs[_0x496b('0x3c')](_0x343f73['query'][_0x496b('0x3c')]);_0x14bc56[_0x496b('0x3d')]=qs[_0x496b('0x35')](_['pick'](_0x343f73[_0x496b('0x33')],_0x129048[_0x496b('0x35')]));if(_0x343f73['query'][_0x496b('0x54')]){_0x14bc56[_0x496b('0x3d')]=_['merge'](_0x14bc56[_0x496b('0x3d')],{'$or':_[_0x496b('0x2c')](_0x14bc56[_0x496b('0x38')],function(_0x310e23){var _0x23dd19={};_0x23dd19[_0x310e23]={'$like':'%'+_0x343f73['query'][_0x496b('0x54')]+'%'};return _0x23dd19;})});}_0x14bc56=_[_0x496b('0x40')]({},_0x14bc56,_0x343f73[_0x496b('0x47')]);return _0x7a5f85['getAgents'](_0x14bc56);}})[_0x496b('0x24')](function(_0x478108){if(_0x478108){_0x5d0cb9=_0x478108[_0x496b('0x39')];if(!_0x343f73[_0x496b('0x33')][_0x496b('0x53')](_0x496b('0x3a'))){_0x14bc56['limit']=qs[_0x496b('0x1e')](_0x343f73['query']['limit']);_0x14bc56['offset']=qs['offset'](_0x343f73[_0x496b('0x33')][_0x496b('0x1b')]);}return _0x7a5f85[_0x496b('0x80')](_0x14bc56);}})['then'](function(_0x3d8db4){if(_0x3d8db4){return _0x3d8db4?{'count':_0x5d0cb9,'rows':_0x3d8db4}:null;}})['then'](respondWithResult(_0x3e21dd,null))[_0x496b('0x44')](handleError(_0x3e21dd,null));};