Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 47c8fcd..5cb3ea4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb7ee=['agent','faxPause','createdAt','format','SIP','Team','getTeams','addTeams','User','online','flatMap','Agents','each','forEach','emit','userFaxQueue:save','removeTeams','ids','select','field','tq.TeamId','team_has_fax_queues','user_has_teams','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','userFaxQueue:remove','addAgents','omit','spread','removeAgents','isArray','getAgents','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxQueue.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','then','get','UserProfileResource','error','stack','name','send','index','map','fieldName','type','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','merge','VIRTUAL','options','where','FaxQueue','includeAll','include','rows','show','params','rawAttributes','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','FaxQueues','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','catch','describe','getMembers','findOne','UserFaxQueue','findAll','findAndCountAll','UserId'];(function(_0x3b380d,_0x4bf247){var _0x54502b=function(_0x35d207){while(--_0x35d207){_0x3b380d['push'](_0x3b380d['shift']());}};_0x54502b(++_0x4bf247);}(_0xb7ee,0xba));var _0xeb7e=function(_0x106777,_0x50cf24){_0x106777=_0x106777-0x0;var _0x1168c3=_0xb7ee[_0x106777];return _0x1168c3;};'use strict';var pdf=require(_0xeb7e('0x0'));var emlformat=require(_0xeb7e('0x1'));var rimraf=require(_0xeb7e('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xeb7e('0x3'));var rp=require(_0xeb7e('0x4'));var moment=require(_0xeb7e('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xeb7e('0x6'));var util=require(_0xeb7e('0x7'));var path=require(_0xeb7e('0x8'));var sox=require(_0xeb7e('0x9'));var csv=require(_0xeb7e('0xa'));var ejs=require(_0xeb7e('0xb'));var fs=require('fs');var _=require(_0xeb7e('0xc'));var squel=require(_0xeb7e('0xd'));var crypto=require(_0xeb7e('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xeb7e('0xf'));var toCsv=require('to-csv');var querystring=require(_0xeb7e('0x10'));var Papa=require(_0xeb7e('0x11'));var Redis=require(_0xeb7e('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xeb7e('0x13'));var logger=require(_0xeb7e('0x14'))('api');var utils=require('../../config/utils');var config=require(_0xeb7e('0x15'));var licenseUtil=require(_0xeb7e('0x16'));var db=require(_0xeb7e('0x17'))['db'];config[_0xeb7e('0x18')]=_['defaults'](config['redis'],{'host':_0xeb7e('0x19'),'port':0x18eb});var socket=require(_0xeb7e('0x1a'))(new Redis(config[_0xeb7e('0x18')]));require(_0xeb7e('0x1b'))[_0xeb7e('0x1c')](socket);function respondWithStatusCode(_0x50df8b,_0x3c67d6){_0x3c67d6=_0x3c67d6||0xcc;return function(_0x3d3c08){if(_0x3d3c08){return _0x50df8b[_0xeb7e('0x1d')](_0x3c67d6);}return _0x50df8b[_0xeb7e('0x1e')](_0x3c67d6)[_0xeb7e('0x1f')]();};}function respondWithResult(_0x120008,_0x49e32e){_0x49e32e=_0x49e32e||0xc8;return function(_0x5e9fa7){if(_0x5e9fa7){return _0x120008[_0xeb7e('0x1e')](_0x49e32e)[_0xeb7e('0x20')](_0x5e9fa7);}};}function respondWithFilteredResult(_0xc9f651,_0x25bdf6){return function(_0x49c60f){if(_0x49c60f){var _0x1699ca=_0x49c60f[_0xeb7e('0x21')],_0x3cfc4a=_0x25bdf6[_0xeb7e('0x22')],_0x4e81f4=_0x25bdf6[_0xeb7e('0x22')]+_0x25bdf6[_0xeb7e('0x23')],_0x4df811;if(_0x4e81f4>=_0x1699ca){_0x4e81f4=_0x1699ca;_0x4df811=0xc8;}else{_0x4df811=0xce;}_0xc9f651[_0xeb7e('0x1e')](_0x4df811);return _0xc9f651[_0xeb7e('0x24')](_0xeb7e('0x25'),_0x3cfc4a+'-'+_0x4e81f4+'/'+_0x1699ca)['json'](_0x49c60f);}return null;};}function patchUpdates(_0x1dbad4){return function(_0x33ac95){try{jsonpatch[_0xeb7e('0x26')](_0x33ac95,_0x1dbad4,!![]);}catch(_0x182f98){return BPromise[_0xeb7e('0x27')](_0x182f98);}return _0x33ac95[_0xeb7e('0x28')]();};}function saveUpdates(_0x5b7138,_0x3701c7){return function(_0x5301bb){if(_0x5301bb){return _0x5301bb[_0xeb7e('0x29')](_0x5b7138)['then'](function(_0x14349b){return _0x14349b;});}return null;};}function removeEntity(_0x4a98fc,_0x1802d2){return function(_0x34fc45){if(_0x34fc45){return _0x34fc45[_0xeb7e('0x2a')]()[_0xeb7e('0x2b')](function(){var _0x51485d=_0x34fc45[_0xeb7e('0x2c')]({'plain':!![]});var _0x36b26d='FaxQueues';return db[_0xeb7e('0x2d')][_0xeb7e('0x2a')]({'where':{'type':_0x36b26d,'resourceId':_0x51485d['id']}})[_0xeb7e('0x2b')](function(){return _0x34fc45;});})[_0xeb7e('0x2b')](function(){_0x4a98fc['status'](0xcc)[_0xeb7e('0x1f')]();});}};}function handleEntityNotFound(_0x243835,_0x3cd7e3){return function(_0x5e9d1a){if(!_0x5e9d1a){_0x243835[_0xeb7e('0x1d')](0x194);}return _0x5e9d1a;};}function handleError(_0x1334bd,_0xdc8d55){_0xdc8d55=_0xdc8d55||0x1f4;return function(_0x190c08){logger[_0xeb7e('0x2e')](_0x190c08[_0xeb7e('0x2f')]);if(_0x190c08[_0xeb7e('0x30')]){delete _0x190c08[_0xeb7e('0x30')];}_0x1334bd[_0xeb7e('0x1e')](_0xdc8d55)[_0xeb7e('0x31')](_0x190c08);};}exports[_0xeb7e('0x32')]=function(_0x4f1034,_0x5992b3){var _0x53b281={},_0x466840={},_0x338a77={'count':0x0,'rows':[]};var _0x4ab889=_[_0xeb7e('0x33')](db['FaxQueue']['rawAttributes'],function(_0x4d2c20){return{'name':_0x4d2c20[_0xeb7e('0x34')],'type':_0x4d2c20[_0xeb7e('0x35')]['key']};});_0x466840[_0xeb7e('0x36')]=_[_0xeb7e('0x33')](_0x4ab889,_0xeb7e('0x30'));_0x466840['query']=_[_0xeb7e('0x37')](_0x4f1034[_0xeb7e('0x38')]);_0x466840[_0xeb7e('0x39')]=_[_0xeb7e('0x3a')](_0x466840['model'],_0x466840[_0xeb7e('0x38')]);_0x53b281['attributes']=_[_0xeb7e('0x3a')](_0x466840[_0xeb7e('0x36')],qs[_0xeb7e('0x3b')](_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x3b')]));_0x53b281[_0xeb7e('0x3c')]=_0x53b281[_0xeb7e('0x3c')][_0xeb7e('0x3d')]?_0x53b281[_0xeb7e('0x3c')]:_0x466840[_0xeb7e('0x36')];if(!_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x3e')](_0xeb7e('0x3f'))){_0x53b281[_0xeb7e('0x23')]=qs[_0xeb7e('0x23')](_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x23')]);_0x53b281[_0xeb7e('0x22')]=qs[_0xeb7e('0x22')](_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x22')]);}_0x53b281[_0xeb7e('0x40')]=qs[_0xeb7e('0x41')](_0x4f1034[_0xeb7e('0x38')]['sort']);_0x53b281['where']=qs[_0xeb7e('0x39')](_[_0xeb7e('0x42')](_0x4f1034[_0xeb7e('0x38')],_0x466840['filters']),_0x4ab889);if(_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x43')]){_0x53b281['where']=_[_0xeb7e('0x44')](_0x53b281['where'],{'$or':_[_0xeb7e('0x33')](_0x4ab889,function(_0x360446){if(_0x360446['type']!==_0xeb7e('0x45')){var _0x11efbd={};_0x11efbd[_0x360446[_0xeb7e('0x30')]]={'$like':'%'+_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x43')]+'%'};return _0x11efbd;}})});}_0x53b281=_[_0xeb7e('0x44')]({},_0x53b281,_0x4f1034[_0xeb7e('0x46')]);var _0x248869={'where':_0x53b281[_0xeb7e('0x47')]};return db[_0xeb7e('0x48')][_0xeb7e('0x21')](_0x248869)[_0xeb7e('0x2b')](function(_0x436ede){_0x338a77[_0xeb7e('0x21')]=_0x436ede;if(_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x49')]){_0x53b281[_0xeb7e('0x4a')]=[{'all':!![]}];}return db[_0xeb7e('0x48')]['findAll'](_0x53b281);})['then'](function(_0x558330){_0x338a77[_0xeb7e('0x4b')]=_0x558330;return _0x338a77;})[_0xeb7e('0x2b')](respondWithFilteredResult(_0x5992b3,_0x53b281))['catch'](handleError(_0x5992b3,null));};exports[_0xeb7e('0x4c')]=function(_0x2798f6,_0x720da2){var _0x363aa0={'raw':!![],'where':{'id':_0x2798f6[_0xeb7e('0x4d')]['id']}},_0xcbedaa={};_0xcbedaa[_0xeb7e('0x36')]=_['keys'](db[_0xeb7e('0x48')][_0xeb7e('0x4e')]);_0xcbedaa['query']=_[_0xeb7e('0x37')](_0x2798f6[_0xeb7e('0x38')]);_0xcbedaa['filters']=_[_0xeb7e('0x3a')](_0xcbedaa[_0xeb7e('0x36')],_0xcbedaa['query']);_0x363aa0[_0xeb7e('0x3c')]=_[_0xeb7e('0x3a')](_0xcbedaa[_0xeb7e('0x36')],qs[_0xeb7e('0x3b')](_0x2798f6[_0xeb7e('0x38')][_0xeb7e('0x3b')]));_0x363aa0['attributes']=_0x363aa0[_0xeb7e('0x3c')]['length']?_0x363aa0['attributes']:_0xcbedaa[_0xeb7e('0x36')];if(_0x2798f6[_0xeb7e('0x38')]['includeAll']){_0x363aa0['include']=[{'all':!![]}];}_0x363aa0=_[_0xeb7e('0x44')]({},_0x363aa0,_0x2798f6['options']);return db[_0xeb7e('0x48')][_0xeb7e('0x4f')](_0x363aa0)['then'](handleEntityNotFound(_0x720da2,null))['then'](respondWithResult(_0x720da2,null))['catch'](handleError(_0x720da2,null));};exports[_0xeb7e('0x50')]=function(_0x1c4742,_0x1125b6){return db[_0xeb7e('0x48')]['create'](_0x1c4742[_0xeb7e('0x51')],{})['then'](function(_0x542aed){var _0x1598f4=_0x1c4742['user'][_0xeb7e('0x2c')]({'plain':!![]});if(!_0x1598f4)throw new Error(_0xeb7e('0x52'));if(_0x1598f4[_0xeb7e('0x53')]===_0xeb7e('0x54')){var _0x6719f6=_0x542aed[_0xeb7e('0x2c')]({'plain':!![]});var _0x291201=_0xeb7e('0x55');return db[_0xeb7e('0x56')][_0xeb7e('0x4f')]({'where':{'name':_0x291201,'userProfileId':_0x1598f4[_0xeb7e('0x57')]},'raw':!![]})[_0xeb7e('0x2b')](function(_0x270010){if(_0x270010&&_0x270010[_0xeb7e('0x58')]===0x0){return db[_0xeb7e('0x2d')]['create']({'name':_0x6719f6[_0xeb7e('0x30')],'resourceId':_0x6719f6['id'],'type':_0x270010['name'],'sectionId':_0x270010['id']},{})[_0xeb7e('0x2b')](function(){return _0x542aed;});}else{return _0x542aed;}})['catch'](function(_0x449c41){logger[_0xeb7e('0x2e')](_0xeb7e('0x59'),_0x449c41);throw _0x449c41;});}return _0x542aed;})[_0xeb7e('0x2b')](respondWithResult(_0x1125b6,0xc9))['catch'](handleError(_0x1125b6,null));};exports[_0xeb7e('0x29')]=function(_0x278437,_0x3ff698){if(_0x278437[_0xeb7e('0x51')]['id']){delete _0x278437[_0xeb7e('0x51')]['id'];}return db['FaxQueue'][_0xeb7e('0x4f')]({'where':{'id':_0x278437['params']['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x3ff698,null))[_0xeb7e('0x2b')](saveUpdates(_0x278437[_0xeb7e('0x51')],null))[_0xeb7e('0x2b')](respondWithResult(_0x3ff698,null))['catch'](handleError(_0x3ff698,null));};exports['destroy']=function(_0x51419c,_0x3a6cb7){return db[_0xeb7e('0x48')][_0xeb7e('0x4f')]({'where':{'id':_0x51419c['params']['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x3a6cb7,null))[_0xeb7e('0x2b')](removeEntity(_0x3a6cb7,null))[_0xeb7e('0x5a')](handleError(_0x3a6cb7,null));};exports[_0xeb7e('0x5b')]=function(_0x5ed3ff,_0x6fe130){return db[_0xeb7e('0x48')][_0xeb7e('0x5b')]()[_0xeb7e('0x2b')](respondWithResult(_0x6fe130,null))[_0xeb7e('0x5a')](handleError(_0x6fe130,null));};exports[_0xeb7e('0x5c')]=function(_0x5b765d,_0x7fbaee,_0x4d4800){var _0x5df357={'raw':!![],'where':{}},_0x4628f0={},_0x476bee;return db['FaxQueue'][_0xeb7e('0x5d')]({'where':{'id':_0x5b765d[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x7fbaee,null))[_0xeb7e('0x2b')](function(_0x22ef5d){if(_0x22ef5d){_0x476bee=_0x22ef5d[_0xeb7e('0x2c')]({'plain':!![]});_0x4628f0[_0xeb7e('0x36')]=_[_0xeb7e('0x37')](db[_0xeb7e('0x5e')][_0xeb7e('0x4e')]);_0x4628f0[_0xeb7e('0x38')]=_[_0xeb7e('0x37')](_0x5b765d[_0xeb7e('0x38')]);_0x4628f0[_0xeb7e('0x39')]=_[_0xeb7e('0x3a')](_0x4628f0[_0xeb7e('0x36')],_0x4628f0[_0xeb7e('0x38')]);_0x5df357[_0xeb7e('0x3c')]=_[_0xeb7e('0x3a')](_0x4628f0[_0xeb7e('0x36')],qs[_0xeb7e('0x3b')](_0x5b765d[_0xeb7e('0x38')][_0xeb7e('0x3b')]));_0x5df357[_0xeb7e('0x3c')]=_0x5df357[_0xeb7e('0x3c')][_0xeb7e('0x3d')]?_0x5df357[_0xeb7e('0x3c')]:_0x4628f0[_0xeb7e('0x36')];if(!_0x5b765d[_0xeb7e('0x38')][_0xeb7e('0x3e')](_0xeb7e('0x3f'))){_0x5df357['limit']=qs[_0xeb7e('0x23')](_0x5b765d[_0xeb7e('0x38')]['limit']);_0x5df357[_0xeb7e('0x22')]=qs[_0xeb7e('0x22')](_0x5b765d[_0xeb7e('0x38')][_0xeb7e('0x22')]);}_0x5df357[_0xeb7e('0x40')]=qs[_0xeb7e('0x41')](_0x5b765d['query'][_0xeb7e('0x41')]);_0x5df357[_0xeb7e('0x47')]=qs[_0xeb7e('0x39')](_['pick'](_0x5b765d['query'],_0x4628f0[_0xeb7e('0x39')]));_0x5df357[_0xeb7e('0x47')]['FaxQueueId']=_0x22ef5d['id'];if(_0x5b765d[_0xeb7e('0x38')][_0xeb7e('0x43')]){_0x5df357['where']=_[_0xeb7e('0x44')](_0x5df357[_0xeb7e('0x47')],{'$or':_[_0xeb7e('0x33')](_0x5df357['attributes'],function(_0x121a62){var _0x300704={};_0x300704[_0x121a62]={'$like':'%'+_0x5b765d['query'][_0xeb7e('0x43')]+'%'};return _0x300704;})});}_0x5df357=_['merge']({},_0x5df357,_0x5b765d[_0xeb7e('0x46')]);return db[_0xeb7e('0x5e')][_0xeb7e('0x5f')](_0x5df357);}})[_0xeb7e('0x2b')](function(_0x488aa0){if(_0x488aa0){return db['User'][_0xeb7e('0x60')]({'where':{'id':_[_0xeb7e('0x33')](_0x488aa0,_0xeb7e('0x61')),'role':_0xeb7e('0x62')},'attributes':['id','name',_0xeb7e('0x63'),'updatedAt',_0xeb7e('0x64')]});}})[_0xeb7e('0x2b')](function(_0x144b64){if(_0x144b64){return{'count':_0x144b64[_0xeb7e('0x21')],'rows':_[_0xeb7e('0x33')](_0x144b64[_0xeb7e('0x4b')],function(_0x4fb12b){return{'membername':_0x4fb12b[_0xeb7e('0x30')],'UserId':_0x4fb12b['id'],'queue_name':_0x476bee['name'],'FaxQueueId':_0x476bee['id'],'interface':util[_0xeb7e('0x65')]('%s/%s',_0xeb7e('0x66'),_0x4fb12b[_0xeb7e('0x30')]),'penalty':0x0,'paused':_0x4fb12b[_0xeb7e('0x63')],'createdAt':_0x4fb12b['createdAt'],'updatedAt':_0x4fb12b['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0xeb7e('0x2b')](respondWithFilteredResult(_0x7fbaee,_0x5df357))[_0xeb7e('0x5a')](handleError(_0x7fbaee,null));};exports['getTeams']=function(_0x2feed8,_0x476781,_0x56b73b){var _0x6fb807={};var _0x221479={};var _0x3adc91;var _0x5f59c5;return db[_0xeb7e('0x48')][_0xeb7e('0x5d')]({'where':{'id':_0x2feed8[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x476781,null))[_0xeb7e('0x2b')](function(_0x55702b){if(_0x55702b){_0x3adc91=_0x55702b;_0x221479[_0xeb7e('0x36')]=_[_0xeb7e('0x37')](db[_0xeb7e('0x67')][_0xeb7e('0x4e')]);_0x221479[_0xeb7e('0x38')]=_[_0xeb7e('0x37')](_0x2feed8[_0xeb7e('0x38')]);_0x221479[_0xeb7e('0x39')]=_['intersection'](_0x221479[_0xeb7e('0x36')],_0x221479[_0xeb7e('0x38')]);_0x6fb807[_0xeb7e('0x3c')]=_[_0xeb7e('0x3a')](_0x221479['model'],qs['fields'](_0x2feed8[_0xeb7e('0x38')]['fields']));_0x6fb807['attributes']=_0x6fb807['attributes'][_0xeb7e('0x3d')]?_0x6fb807[_0xeb7e('0x3c')]:_0x221479[_0xeb7e('0x36')];_0x6fb807[_0xeb7e('0x40')]=qs[_0xeb7e('0x41')](_0x2feed8[_0xeb7e('0x38')]['sort']);_0x6fb807['where']=qs[_0xeb7e('0x39')](_['pick'](_0x2feed8[_0xeb7e('0x38')],_0x221479[_0xeb7e('0x39')]));if(_0x2feed8['query'][_0xeb7e('0x43')]){_0x6fb807['where']=_[_0xeb7e('0x44')](_0x6fb807['where'],{'$or':_[_0xeb7e('0x33')](_0x6fb807['attributes'],function(_0x531552){var _0x342e87={};_0x342e87[_0x531552]={'$like':'%'+_0x2feed8['query']['filter']+'%'};return _0x342e87;})});}_0x6fb807=_[_0xeb7e('0x44')]({},_0x6fb807,_0x2feed8[_0xeb7e('0x46')]);return _0x3adc91[_0xeb7e('0x68')](_0x6fb807);}})[_0xeb7e('0x2b')](function(_0x58e945){if(_0x58e945){_0x5f59c5=_0x58e945[_0xeb7e('0x3d')];if(!_0x2feed8[_0xeb7e('0x38')][_0xeb7e('0x3e')](_0xeb7e('0x3f'))){_0x6fb807[_0xeb7e('0x23')]=qs['limit'](_0x2feed8[_0xeb7e('0x38')][_0xeb7e('0x23')]);_0x6fb807['offset']=qs[_0xeb7e('0x22')](_0x2feed8[_0xeb7e('0x38')][_0xeb7e('0x22')]);}return _0x3adc91[_0xeb7e('0x68')](_0x6fb807);}})[_0xeb7e('0x2b')](function(_0x2da8b9){if(_0x2da8b9){return _0x2da8b9?{'count':_0x5f59c5,'rows':_0x2da8b9}:null;}})[_0xeb7e('0x2b')](respondWithResult(_0x476781,null))[_0xeb7e('0x5a')](handleError(_0x476781,null));};exports[_0xeb7e('0x69')]=function(_0x3fa0c3,_0x3c60b6,_0x43ed14){var _0x5538ad=_0x3fa0c3[_0xeb7e('0x51')]['ids'];return db[_0xeb7e('0x67')][_0xeb7e('0x5f')]({'where':{'id':_0x5538ad},'attributes':['id'],'include':[{'model':db[_0xeb7e('0x6a')],'as':'Agents','attributes':['id',_0xeb7e('0x30'),_0xeb7e('0x6b'),'voicePause','interface'],'raw':!![]}]})['then'](function(_0x49e46a){if(_0x49e46a){var _0x10e383=_[_0xeb7e('0x6c')](_0x49e46a,function(_0x4ac21b){var _0x584ee8=_0x4ac21b[_0xeb7e('0x2c')]({'plain':!![]});return _0x584ee8[_0xeb7e('0x6d')];});return db['FaxQueue'][_0xeb7e('0x4f')]({'where':{'id':_0x3fa0c3['params']['id']}})['then'](function(_0x22bcc0){return db['sequelize']['transaction'](function(_0x1eb327){return _0x22bcc0[_0xeb7e('0x69')](_0x5538ad,{'transaction':_0x1eb327})[_0xeb7e('0x2b')](function(){return BPromise[_0xeb7e('0x6e')](_0x10e383,function(_0x2f503d){return db[_0xeb7e('0x5e')]['findOrCreate']({'where':{'UserId':_0x2f503d['id'],'FaxQueueId':_0x3fa0c3[_0xeb7e('0x4d')]['id']},'transaction':_0x1eb327});});})[_0xeb7e('0x2b')](function(){_0x10e383[_0xeb7e('0x6f')](function(_0x30ca5d){socket[_0xeb7e('0x70')](_0xeb7e('0x71'),{'UserId':_0x30ca5d['id'],'FaxQueueId':_0x22bcc0['id']});});});});});}})['then'](respondWithStatusCode(_0x3c60b6,null))['catch'](handleError(_0x3c60b6,null));};exports[_0xeb7e('0x72')]=function(_0x94a945,_0x1fedad,_0x6da153){return db['Team'][_0xeb7e('0x5f')]({'where':{'id':_0x94a945['query'][_0xeb7e('0x73')]},'attributes':['id'],'include':[{'model':db[_0xeb7e('0x6a')],'as':_0xeb7e('0x6d'),'attributes':['id'],'raw':!![]}]})[_0xeb7e('0x2b')](handleEntityNotFound(_0x1fedad,null))[_0xeb7e('0x2b')](function(_0x5a0758){var _0x1ea6da=_[_0xeb7e('0x33')](_0x5a0758,'id');var _0x317734=[];var _0x4372e1=[];var _0x2f0dcb=squel[_0xeb7e('0x74')]();_0x2f0dcb[_0xeb7e('0x75')](_0xeb7e('0x76'))['from'](_0xeb7e('0x77'),'tq')['join'](_0xeb7e('0x78'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0xeb7e('0x47')](_0xeb7e('0x79'),_0x94a945[_0xeb7e('0x4d')]['id']);for(var _0x59f680=0x0;_0x59f680<_0x5a0758['length'];_0x59f680+=0x1){let _0x18e673=_0x5a0758[_0x59f680];for(var _0x2e92b1=0x0;_0x2e92b1<_0x18e673['Agents'][_0xeb7e('0x3d')];_0x2e92b1+=0x1){let _0xbb3d60=_0x18e673[_0xeb7e('0x6d')][_0x2e92b1];var _0x147542=_0x2f0dcb[_0xeb7e('0x7a')]();_0x147542[_0xeb7e('0x47')](_0xeb7e('0x7b'),_0xbb3d60['id']);_0x4372e1[_0xeb7e('0x7c')](db[_0xeb7e('0x7d')]['query'](_0x147542['toString'](),{'type':db[_0xeb7e('0x7d')][_0xeb7e('0x7e')][_0xeb7e('0x7f')]})[_0xeb7e('0x2b')](function(_0x51cdd6){if(_0x51cdd6['length']===0x1){return _0xbb3d60['id'];}else{var _0x2451f2=_[_0xeb7e('0x80')](_['map'](_0x51cdd6,_0xeb7e('0x81')),function(_0x3af9e6){return _[_0xeb7e('0x82')](_0x1ea6da,_0x3af9e6);});if(_0x2451f2){return _0xbb3d60['id'];}}}));}}return BPromise[_0xeb7e('0x83')](_0x4372e1)[_0xeb7e('0x2b')](function(_0x585451){_0x317734=_(_0x317734)[_0xeb7e('0x84')](_0x585451)[_0xeb7e('0x85')]()[_0xeb7e('0x86')]();return db[_0xeb7e('0x48')][_0xeb7e('0x4f')]({'where':{'id':_0x94a945[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](function(_0x1b5e06){return db[_0xeb7e('0x7d')]['transaction'](function(_0x4fc251){return _0x1b5e06[_0xeb7e('0x72')](_0x94a945['query']['ids'],{'transaction':_0x4fc251})['then'](function(){if(!_['isEmpty'](_0x317734)){return _0x1b5e06['removeAgents'](_0x317734,{'transaction':_0x4fc251});}})[_0xeb7e('0x2b')](function(){_0x317734[_0xeb7e('0x6f')](function(_0x139474){socket[_0xeb7e('0x70')](_0xeb7e('0x87'),{'UserId':_0x139474,'FaxQueueId':_0x1b5e06['id']});});});});});});})[_0xeb7e('0x2b')](respondWithStatusCode(_0x1fedad,null))[_0xeb7e('0x5a')](handleError(_0x1fedad,null));};exports[_0xeb7e('0x88')]=function(_0x2250f0,_0x3497a1,_0xc9986b){return db[_0xeb7e('0x48')]['find']({'where':{'id':_0x2250f0[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x3497a1,null))[_0xeb7e('0x2b')](function(_0x594975){if(_0x594975){return _0x594975[_0xeb7e('0x88')](_0x2250f0[_0xeb7e('0x51')][_0xeb7e('0x73')],_[_0xeb7e('0x89')](_0x2250f0[_0xeb7e('0x51')],['ids','id'])||{})[_0xeb7e('0x8a')](function(_0x1c21f0){for(var _0x324b5c=0x0;_0x324b5c<_0x2250f0[_0xeb7e('0x51')][_0xeb7e('0x73')][_0xeb7e('0x3d')];_0x324b5c+=0x1){socket['emit'](_0xeb7e('0x71'),{'UserId':_0x2250f0['body']['ids'][_0x324b5c],'FaxQueueId':_0x2250f0[_0xeb7e('0x4d')]['id']});}return _0x1c21f0;});}})[_0xeb7e('0x2b')](respondWithResult(_0x3497a1,null))[_0xeb7e('0x5a')](handleError(_0x3497a1,null));};exports[_0xeb7e('0x8b')]=function(_0x5d0300,_0x2d1cff,_0x1729fe){return db[_0xeb7e('0x48')][_0xeb7e('0x4f')]({'where':{'id':_0x5d0300['params']['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x2d1cff,null))[_0xeb7e('0x2b')](function(_0x2480cc){if(_0x2480cc){return _0x2480cc['removeAgents'](_0x5d0300[_0xeb7e('0x38')][_0xeb7e('0x73')])[_0xeb7e('0x2b')](function(){if(_[_0xeb7e('0x8c')](_0x5d0300[_0xeb7e('0x38')][_0xeb7e('0x73')])){for(var _0x5a62f9=0x0;_0x5a62f9<_0x5d0300[_0xeb7e('0x38')]['ids']['length'];_0x5a62f9+=0x1){socket[_0xeb7e('0x70')](_0xeb7e('0x87'),{'UserId':Number(_0x5d0300[_0xeb7e('0x38')]['ids'][_0x5a62f9]),'FaxQueueId':Number(_0x5d0300[_0xeb7e('0x4d')]['id'])});}}else{socket['emit'](_0xeb7e('0x87'),{'UserId':Number(_0x5d0300['query']['ids']),'FaxQueueId':Number(_0x5d0300[_0xeb7e('0x4d')]['id'])});}});}})[_0xeb7e('0x2b')](respondWithStatusCode(_0x2d1cff,null))['catch'](handleError(_0x2d1cff,null));};exports[_0xeb7e('0x8d')]=function(_0x5f1c3c,_0xff2dab,_0x2eb904){var _0x5b9535={};var _0x9642fd={};var _0x32c4a7;var _0x4cdc14;return db[_0xeb7e('0x48')][_0xeb7e('0x5d')]({'where':{'id':_0x5f1c3c[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0xff2dab,null))[_0xeb7e('0x2b')](function(_0x32a25c){if(_0x32a25c){_0x32c4a7=_0x32a25c;_0x9642fd[_0xeb7e('0x36')]=_[_0xeb7e('0x37')](db[_0xeb7e('0x6a')][_0xeb7e('0x4e')]);_0x9642fd['query']=_[_0xeb7e('0x37')](_0x5f1c3c[_0xeb7e('0x38')]);_0x9642fd[_0xeb7e('0x39')]=_['intersection'](_0x9642fd[_0xeb7e('0x36')],_0x9642fd['query']);_0x5b9535['attributes']=_[_0xeb7e('0x3a')](_0x9642fd['model'],qs['fields'](_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x3b')]));_0x5b9535[_0xeb7e('0x3c')]=_0x5b9535['attributes']['length']?_0x5b9535[_0xeb7e('0x3c')]:_0x9642fd['model'];_0x5b9535['order']=qs[_0xeb7e('0x41')](_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x41')]);_0x5b9535[_0xeb7e('0x47')]=qs[_0xeb7e('0x39')](_[_0xeb7e('0x42')](_0x5f1c3c[_0xeb7e('0x38')],_0x9642fd['filters']));if(_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x43')]){_0x5b9535[_0xeb7e('0x47')]=_[_0xeb7e('0x44')](_0x5b9535['where'],{'$or':_[_0xeb7e('0x33')](_0x5b9535['attributes'],function(_0x1fbf03){var _0x24daa3={};_0x24daa3[_0x1fbf03]={'$like':'%'+_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x43')]+'%'};return _0x24daa3;})});}_0x5b9535=_['merge']({},_0x5b9535,_0x5f1c3c[_0xeb7e('0x46')]);return _0x32c4a7[_0xeb7e('0x8d')](_0x5b9535);}})['then'](function(_0x3f3488){if(_0x3f3488){_0x4cdc14=_0x3f3488[_0xeb7e('0x3d')];if(!_0x5f1c3c['query'][_0xeb7e('0x3e')](_0xeb7e('0x3f'))){_0x5b9535[_0xeb7e('0x23')]=qs[_0xeb7e('0x23')](_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x23')]);_0x5b9535[_0xeb7e('0x22')]=qs[_0xeb7e('0x22')](_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x22')]);}return _0x32c4a7[_0xeb7e('0x8d')](_0x5b9535);}})[_0xeb7e('0x2b')](function(_0x414961){if(_0x414961){return _0x414961?{'count':_0x4cdc14,'rows':_0x414961}:null;}})[_0xeb7e('0x2b')](respondWithResult(_0xff2dab,null))[_0xeb7e('0x5a')](handleError(_0xff2dab,null));};
\ No newline at end of file
+var _0xa8b0=['SELECT','every','TeamId','includes','all','union','value','ids','isEmpty','removeAgents','userFaxQueue:remove','omit','spread','isArray','getAgents','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./faxQueue.socket','register','sendStatus','status','end','json','offset','undefined','count','Content-Range','reject','save','update','then','destroy','get','FaxQueues','UserProfileResource','error','stack','name','send','index','map','FaxQueue','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','show','catch','create','body','user','role','UserProfileSection','find','userProfileId','params','describe','getMembers','findOne','UserFaxQueue','order','User','findAndCountAll','agent','updatedAt','createdAt','format','faxPause','getTeams','Team','addTeams','Agents','interface','transaction','findOrCreate','forEach','emit','userFaxQueue:save','removeTeams','select','tq.TeamId','from','team_has_fax_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes'];(function(_0x25dcb2,_0x4711bc){var _0x5740d2=function(_0x176195){while(--_0x176195){_0x25dcb2['push'](_0x25dcb2['shift']());}};_0x5740d2(++_0x4711bc);}(_0xa8b0,0x9b));var _0x0a8b=function(_0x2f5ac5,_0x1ee939){_0x2f5ac5=_0x2f5ac5-0x0;var _0x37c9a8=_0xa8b0[_0x2f5ac5];return _0x37c9a8;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0a8b('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0a8b('0x1'));var rp=require(_0x0a8b('0x2'));var moment=require(_0x0a8b('0x3'));var BPromise=require(_0x0a8b('0x4'));var Mustache=require(_0x0a8b('0x5'));var util=require(_0x0a8b('0x6'));var path=require(_0x0a8b('0x7'));var sox=require(_0x0a8b('0x8'));var csv=require(_0x0a8b('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x0a8b('0xa'));var _=require(_0x0a8b('0xb'));var squel=require(_0x0a8b('0xc'));var crypto=require(_0x0a8b('0xd'));var jsforce=require(_0x0a8b('0xe'));var deskjs=require(_0x0a8b('0xf'));var toCsv=require('to-csv');var querystring=require(_0x0a8b('0x10'));var Papa=require(_0x0a8b('0x11'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x0a8b('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0a8b('0x13'));var logger=require(_0x0a8b('0x14'))(_0x0a8b('0x15'));var utils=require(_0x0a8b('0x16'));var config=require(_0x0a8b('0x17'));var licenseUtil=require(_0x0a8b('0x18'));var db=require(_0x0a8b('0x19'))['db'];config[_0x0a8b('0x1a')]=_[_0x0a8b('0x1b')](config[_0x0a8b('0x1a')],{'host':_0x0a8b('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0a8b('0x1a')]));require(_0x0a8b('0x1d'))[_0x0a8b('0x1e')](socket);function respondWithStatusCode(_0x25795e,_0x2fe198){_0x2fe198=_0x2fe198||0xcc;return function(_0x1290db){if(_0x1290db){return _0x25795e[_0x0a8b('0x1f')](_0x2fe198);}return _0x25795e[_0x0a8b('0x20')](_0x2fe198)[_0x0a8b('0x21')]();};}function respondWithResult(_0x2dfeb2,_0x4b953a){_0x4b953a=_0x4b953a||0xc8;return function(_0x289bf6){if(_0x289bf6){return _0x2dfeb2[_0x0a8b('0x20')](_0x4b953a)[_0x0a8b('0x22')](_0x289bf6);}};}function respondWithFilteredResult(_0x313a9a,_0x47ce9e){return function(_0x27d1cc){if(_0x27d1cc){var _0xd30950=typeof _0x47ce9e[_0x0a8b('0x23')]===_0x0a8b('0x24')&&typeof _0x47ce9e['limit']===_0x0a8b('0x24');var _0x189636=_0x27d1cc[_0x0a8b('0x25')];var _0x51c902=_0xd30950?0x0:_0x47ce9e[_0x0a8b('0x23')];var _0x5c9473=_0xd30950?_0x27d1cc[_0x0a8b('0x25')]:_0x47ce9e[_0x0a8b('0x23')]+_0x47ce9e['limit'];var _0x1e3157;if(_0x5c9473>=_0x189636){_0x5c9473=_0x189636;_0x1e3157=0xc8;}else{_0x1e3157=0xce;}_0x313a9a[_0x0a8b('0x20')](_0x1e3157);return _0x313a9a['set'](_0x0a8b('0x26'),_0x51c902+'-'+_0x5c9473+'/'+_0x189636)[_0x0a8b('0x22')](_0x27d1cc);}return null;};}function patchUpdates(_0x5924af){return function(_0x9e4ffa){try{jsonpatch['apply'](_0x9e4ffa,_0x5924af,!![]);}catch(_0x18a538){return BPromise[_0x0a8b('0x27')](_0x18a538);}return _0x9e4ffa[_0x0a8b('0x28')]();};}function saveUpdates(_0x262c6a,_0x30b0e1){return function(_0x2c3424){if(_0x2c3424){return _0x2c3424[_0x0a8b('0x29')](_0x262c6a)[_0x0a8b('0x2a')](function(_0x2db1cf){return _0x2db1cf;});}return null;};}function removeEntity(_0x3eee64,_0x35babe){return function(_0x4b9a2b){if(_0x4b9a2b){return _0x4b9a2b[_0x0a8b('0x2b')]()[_0x0a8b('0x2a')](function(){var _0xd435b4=_0x4b9a2b[_0x0a8b('0x2c')]({'plain':!![]});var _0x4dfbad=_0x0a8b('0x2d');return db[_0x0a8b('0x2e')]['destroy']({'where':{'type':_0x4dfbad,'resourceId':_0xd435b4['id']}})['then'](function(){return _0x4b9a2b;});})[_0x0a8b('0x2a')](function(){_0x3eee64[_0x0a8b('0x20')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3348a3,_0x68c26c){return function(_0x1a143e){if(!_0x1a143e){_0x3348a3[_0x0a8b('0x1f')](0x194);}return _0x1a143e;};}function handleError(_0x43ca14,_0x2132b9){_0x2132b9=_0x2132b9||0x1f4;return function(_0xa1e87f){logger[_0x0a8b('0x2f')](_0xa1e87f[_0x0a8b('0x30')]);if(_0xa1e87f['name']){delete _0xa1e87f[_0x0a8b('0x31')];}_0x43ca14[_0x0a8b('0x20')](_0x2132b9)[_0x0a8b('0x32')](_0xa1e87f);};}exports[_0x0a8b('0x33')]=function(_0x178a01,_0x3b5c24){var _0x35372c={},_0x5e956d={},_0x5e2257={'count':0x0,'rows':[]};var _0x4dee0a=_[_0x0a8b('0x34')](db[_0x0a8b('0x35')][_0x0a8b('0x36')],function(_0x78b03a){return{'name':_0x78b03a[_0x0a8b('0x37')],'type':_0x78b03a[_0x0a8b('0x38')][_0x0a8b('0x39')]};});_0x5e956d[_0x0a8b('0x3a')]=_[_0x0a8b('0x34')](_0x4dee0a,_0x0a8b('0x31'));_0x5e956d['query']=_[_0x0a8b('0x3b')](_0x178a01[_0x0a8b('0x3c')]);_0x5e956d[_0x0a8b('0x3d')]=_[_0x0a8b('0x3e')](_0x5e956d['model'],_0x5e956d[_0x0a8b('0x3c')]);_0x35372c[_0x0a8b('0x3f')]=_['intersection'](_0x5e956d[_0x0a8b('0x3a')],qs[_0x0a8b('0x40')](_0x178a01[_0x0a8b('0x3c')]['fields']));_0x35372c[_0x0a8b('0x3f')]=_0x35372c['attributes'][_0x0a8b('0x41')]?_0x35372c[_0x0a8b('0x3f')]:_0x5e956d[_0x0a8b('0x3a')];if(!_0x178a01[_0x0a8b('0x3c')][_0x0a8b('0x42')](_0x0a8b('0x43'))){_0x35372c[_0x0a8b('0x44')]=qs[_0x0a8b('0x44')](_0x178a01[_0x0a8b('0x3c')][_0x0a8b('0x44')]);_0x35372c[_0x0a8b('0x23')]=qs[_0x0a8b('0x23')](_0x178a01[_0x0a8b('0x3c')][_0x0a8b('0x23')]);}_0x35372c['order']=qs[_0x0a8b('0x45')](_0x178a01[_0x0a8b('0x3c')][_0x0a8b('0x45')]);_0x35372c[_0x0a8b('0x46')]=qs['filters'](_[_0x0a8b('0x47')](_0x178a01[_0x0a8b('0x3c')],_0x5e956d[_0x0a8b('0x3d')]),_0x4dee0a);if(_0x178a01[_0x0a8b('0x3c')][_0x0a8b('0x48')]){_0x35372c[_0x0a8b('0x46')]=_[_0x0a8b('0x49')](_0x35372c[_0x0a8b('0x46')],{'$or':_['map'](_0x4dee0a,function(_0x20455c){if(_0x20455c[_0x0a8b('0x38')]!=='VIRTUAL'){var _0xbed6d2={};_0xbed6d2[_0x20455c[_0x0a8b('0x31')]]={'$like':'%'+_0x178a01[_0x0a8b('0x3c')][_0x0a8b('0x48')]+'%'};return _0xbed6d2;}})});}_0x35372c=_[_0x0a8b('0x49')]({},_0x35372c,_0x178a01[_0x0a8b('0x4a')]);var _0x5dfc46={'where':_0x35372c[_0x0a8b('0x46')]};return db[_0x0a8b('0x35')][_0x0a8b('0x25')](_0x5dfc46)[_0x0a8b('0x2a')](function(_0x538a1d){_0x5e2257[_0x0a8b('0x25')]=_0x538a1d;if(_0x178a01[_0x0a8b('0x3c')][_0x0a8b('0x4b')]){_0x35372c[_0x0a8b('0x4c')]=[{'all':!![]}];}return db[_0x0a8b('0x35')][_0x0a8b('0x4d')](_0x35372c);})[_0x0a8b('0x2a')](function(_0x416652){_0x5e2257[_0x0a8b('0x4e')]=_0x416652;return _0x5e2257;})[_0x0a8b('0x2a')](respondWithFilteredResult(_0x3b5c24,_0x35372c))['catch'](handleError(_0x3b5c24,null));};exports[_0x0a8b('0x4f')]=function(_0x2e4840,_0x54fac6){var _0x2c6254={'raw':!![],'where':{'id':_0x2e4840['params']['id']}},_0x15eaba={};_0x15eaba[_0x0a8b('0x3a')]=_[_0x0a8b('0x3b')](db[_0x0a8b('0x35')][_0x0a8b('0x36')]);_0x15eaba[_0x0a8b('0x3c')]=_[_0x0a8b('0x3b')](_0x2e4840[_0x0a8b('0x3c')]);_0x15eaba[_0x0a8b('0x3d')]=_['intersection'](_0x15eaba['model'],_0x15eaba[_0x0a8b('0x3c')]);_0x2c6254[_0x0a8b('0x3f')]=_[_0x0a8b('0x3e')](_0x15eaba['model'],qs['fields'](_0x2e4840[_0x0a8b('0x3c')]['fields']));_0x2c6254['attributes']=_0x2c6254[_0x0a8b('0x3f')]['length']?_0x2c6254[_0x0a8b('0x3f')]:_0x15eaba[_0x0a8b('0x3a')];if(_0x2e4840[_0x0a8b('0x3c')][_0x0a8b('0x4b')]){_0x2c6254[_0x0a8b('0x4c')]=[{'all':!![]}];}_0x2c6254=_[_0x0a8b('0x49')]({},_0x2c6254,_0x2e4840[_0x0a8b('0x4a')]);return db['FaxQueue']['find'](_0x2c6254)['then'](handleEntityNotFound(_0x54fac6,null))['then'](respondWithResult(_0x54fac6,null))[_0x0a8b('0x50')](handleError(_0x54fac6,null));};exports[_0x0a8b('0x51')]=function(_0x7a44d5,_0x1375e8){return db[_0x0a8b('0x35')][_0x0a8b('0x51')](_0x7a44d5[_0x0a8b('0x52')],{})['then'](function(_0x51b5ec){var _0x167f1f=_0x7a44d5[_0x0a8b('0x53')][_0x0a8b('0x2c')]({'plain':!![]});if(!_0x167f1f)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x167f1f[_0x0a8b('0x54')]===_0x0a8b('0x53')){var _0x3f1e09=_0x51b5ec[_0x0a8b('0x2c')]({'plain':!![]});var _0x427c3f=_0x0a8b('0x2d');return db[_0x0a8b('0x55')][_0x0a8b('0x56')]({'where':{'name':_0x427c3f,'userProfileId':_0x167f1f[_0x0a8b('0x57')]},'raw':!![]})[_0x0a8b('0x2a')](function(_0x29838d){if(_0x29838d&&_0x29838d['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x3f1e09[_0x0a8b('0x31')],'resourceId':_0x3f1e09['id'],'type':_0x29838d[_0x0a8b('0x31')],'sectionId':_0x29838d['id']},{})[_0x0a8b('0x2a')](function(){return _0x51b5ec;});}else{return _0x51b5ec;}})['catch'](function(_0x2a321f){logger[_0x0a8b('0x2f')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2a321f);throw _0x2a321f;});}return _0x51b5ec;})['then'](respondWithResult(_0x1375e8,0xc9))[_0x0a8b('0x50')](handleError(_0x1375e8,null));};exports['update']=function(_0x144844,_0x37a649){if(_0x144844[_0x0a8b('0x52')]['id']){delete _0x144844[_0x0a8b('0x52')]['id'];}return db['FaxQueue'][_0x0a8b('0x56')]({'where':{'id':_0x144844['params']['id']}})['then'](handleEntityNotFound(_0x37a649,null))[_0x0a8b('0x2a')](saveUpdates(_0x144844[_0x0a8b('0x52')],null))[_0x0a8b('0x2a')](respondWithResult(_0x37a649,null))[_0x0a8b('0x50')](handleError(_0x37a649,null));};exports['destroy']=function(_0xa7064f,_0x22bf73){return db[_0x0a8b('0x35')]['find']({'where':{'id':_0xa7064f[_0x0a8b('0x58')]['id']}})['then'](handleEntityNotFound(_0x22bf73,null))['then'](removeEntity(_0x22bf73,null))[_0x0a8b('0x50')](handleError(_0x22bf73,null));};exports[_0x0a8b('0x59')]=function(_0x547561,_0x22c174){return db[_0x0a8b('0x35')][_0x0a8b('0x59')]()[_0x0a8b('0x2a')](respondWithResult(_0x22c174,null))[_0x0a8b('0x50')](handleError(_0x22c174,null));};exports[_0x0a8b('0x5a')]=function(_0x274483,_0x25b15d,_0x27a6c6){var _0x5e9502={'raw':!![],'where':{}},_0x4bbdcd={},_0x178287;return db[_0x0a8b('0x35')][_0x0a8b('0x5b')]({'where':{'id':_0x274483[_0x0a8b('0x58')]['id']}})['then'](handleEntityNotFound(_0x25b15d,null))['then'](function(_0xec63f5){if(_0xec63f5){_0x178287=_0xec63f5[_0x0a8b('0x2c')]({'plain':!![]});_0x4bbdcd[_0x0a8b('0x3a')]=_['keys'](db[_0x0a8b('0x5c')][_0x0a8b('0x36')]);_0x4bbdcd['query']=_[_0x0a8b('0x3b')](_0x274483[_0x0a8b('0x3c')]);_0x4bbdcd[_0x0a8b('0x3d')]=_['intersection'](_0x4bbdcd[_0x0a8b('0x3a')],_0x4bbdcd[_0x0a8b('0x3c')]);_0x5e9502['attributes']=_[_0x0a8b('0x3e')](_0x4bbdcd[_0x0a8b('0x3a')],qs[_0x0a8b('0x40')](_0x274483[_0x0a8b('0x3c')][_0x0a8b('0x40')]));_0x5e9502[_0x0a8b('0x3f')]=_0x5e9502[_0x0a8b('0x3f')]['length']?_0x5e9502[_0x0a8b('0x3f')]:_0x4bbdcd[_0x0a8b('0x3a')];if(!_0x274483[_0x0a8b('0x3c')]['hasOwnProperty'](_0x0a8b('0x43'))){_0x5e9502[_0x0a8b('0x44')]=qs['limit'](_0x274483['query']['limit']);_0x5e9502[_0x0a8b('0x23')]=qs[_0x0a8b('0x23')](_0x274483[_0x0a8b('0x3c')]['offset']);}_0x5e9502[_0x0a8b('0x5d')]=qs[_0x0a8b('0x45')](_0x274483[_0x0a8b('0x3c')]['sort']);_0x5e9502[_0x0a8b('0x46')]=qs[_0x0a8b('0x3d')](_['pick'](_0x274483[_0x0a8b('0x3c')],_0x4bbdcd[_0x0a8b('0x3d')]));_0x5e9502[_0x0a8b('0x46')]['FaxQueueId']=_0xec63f5['id'];if(_0x274483[_0x0a8b('0x3c')][_0x0a8b('0x48')]){_0x5e9502[_0x0a8b('0x46')]=_[_0x0a8b('0x49')](_0x5e9502[_0x0a8b('0x46')],{'$or':_[_0x0a8b('0x34')](_0x5e9502['attributes'],function(_0x272bda){var _0x196165={};_0x196165[_0x272bda]={'$like':'%'+_0x274483[_0x0a8b('0x3c')][_0x0a8b('0x48')]+'%'};return _0x196165;})});}_0x5e9502=_[_0x0a8b('0x49')]({},_0x5e9502,_0x274483['options']);return db[_0x0a8b('0x5c')][_0x0a8b('0x4d')](_0x5e9502);}})[_0x0a8b('0x2a')](function(_0x4243dc){if(_0x4243dc){return db[_0x0a8b('0x5e')][_0x0a8b('0x5f')]({'where':{'id':_[_0x0a8b('0x34')](_0x4243dc,'UserId'),'role':_0x0a8b('0x60')},'attributes':['id',_0x0a8b('0x31'),'faxPause',_0x0a8b('0x61'),_0x0a8b('0x62')]});}})['then'](function(_0x4d2f6f){if(_0x4d2f6f){return{'count':_0x4d2f6f[_0x0a8b('0x25')],'rows':_['map'](_0x4d2f6f[_0x0a8b('0x4e')],function(_0x2fec2f){return{'membername':_0x2fec2f[_0x0a8b('0x31')],'UserId':_0x2fec2f['id'],'queue_name':_0x178287['name'],'FaxQueueId':_0x178287['id'],'interface':util[_0x0a8b('0x63')]('%s/%s','SIP',_0x2fec2f[_0x0a8b('0x31')]),'penalty':0x0,'paused':_0x2fec2f[_0x0a8b('0x64')],'createdAt':_0x2fec2f[_0x0a8b('0x62')],'updatedAt':_0x2fec2f[_0x0a8b('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x25b15d,_0x5e9502))[_0x0a8b('0x50')](handleError(_0x25b15d,null));};exports[_0x0a8b('0x65')]=function(_0x2d30aa,_0x504306,_0x3e7d9e){var _0x57bbf6={};var _0x303afa={};var _0x4a18c5;var _0x563e21;return db['FaxQueue'][_0x0a8b('0x5b')]({'where':{'id':_0x2d30aa[_0x0a8b('0x58')]['id']}})['then'](handleEntityNotFound(_0x504306,null))[_0x0a8b('0x2a')](function(_0x106931){if(_0x106931){_0x4a18c5=_0x106931;_0x303afa['model']=_[_0x0a8b('0x3b')](db[_0x0a8b('0x66')]['rawAttributes']);_0x303afa[_0x0a8b('0x3c')]=_[_0x0a8b('0x3b')](_0x2d30aa[_0x0a8b('0x3c')]);_0x303afa[_0x0a8b('0x3d')]=_[_0x0a8b('0x3e')](_0x303afa[_0x0a8b('0x3a')],_0x303afa[_0x0a8b('0x3c')]);_0x57bbf6[_0x0a8b('0x3f')]=_[_0x0a8b('0x3e')](_0x303afa['model'],qs[_0x0a8b('0x40')](_0x2d30aa['query'][_0x0a8b('0x40')]));_0x57bbf6[_0x0a8b('0x3f')]=_0x57bbf6[_0x0a8b('0x3f')][_0x0a8b('0x41')]?_0x57bbf6[_0x0a8b('0x3f')]:_0x303afa['model'];_0x57bbf6['order']=qs[_0x0a8b('0x45')](_0x2d30aa[_0x0a8b('0x3c')][_0x0a8b('0x45')]);_0x57bbf6[_0x0a8b('0x46')]=qs['filters'](_[_0x0a8b('0x47')](_0x2d30aa[_0x0a8b('0x3c')],_0x303afa[_0x0a8b('0x3d')]));if(_0x2d30aa[_0x0a8b('0x3c')][_0x0a8b('0x48')]){_0x57bbf6['where']=_[_0x0a8b('0x49')](_0x57bbf6[_0x0a8b('0x46')],{'$or':_[_0x0a8b('0x34')](_0x57bbf6['attributes'],function(_0x2251b1){var _0x55efc8={};_0x55efc8[_0x2251b1]={'$like':'%'+_0x2d30aa[_0x0a8b('0x3c')][_0x0a8b('0x48')]+'%'};return _0x55efc8;})});}_0x57bbf6=_[_0x0a8b('0x49')]({},_0x57bbf6,_0x2d30aa[_0x0a8b('0x4a')]);return _0x4a18c5['getTeams'](_0x57bbf6);}})[_0x0a8b('0x2a')](function(_0x2396c7){if(_0x2396c7){_0x563e21=_0x2396c7['length'];if(!_0x2d30aa['query'][_0x0a8b('0x42')](_0x0a8b('0x43'))){_0x57bbf6['limit']=qs['limit'](_0x2d30aa[_0x0a8b('0x3c')][_0x0a8b('0x44')]);_0x57bbf6[_0x0a8b('0x23')]=qs[_0x0a8b('0x23')](_0x2d30aa['query'][_0x0a8b('0x23')]);}return _0x4a18c5['getTeams'](_0x57bbf6);}})[_0x0a8b('0x2a')](function(_0x41d484){if(_0x41d484){return _0x41d484?{'count':_0x563e21,'rows':_0x41d484}:null;}})[_0x0a8b('0x2a')](respondWithResult(_0x504306,null))['catch'](handleError(_0x504306,null));};exports[_0x0a8b('0x67')]=function(_0x372778,_0x558d0d,_0x286b83){var _0x2f11f3=_0x372778['body']['ids'];return db[_0x0a8b('0x66')][_0x0a8b('0x4d')]({'where':{'id':_0x2f11f3},'attributes':['id'],'include':[{'model':db[_0x0a8b('0x5e')],'as':_0x0a8b('0x68'),'attributes':['id',_0x0a8b('0x31'),'online','voicePause',_0x0a8b('0x69')],'raw':!![]}]})[_0x0a8b('0x2a')](function(_0x1c3b53){if(_0x1c3b53){var _0x5eb080=_['flatMap'](_0x1c3b53,function(_0x241dae){var _0x4bad0e=_0x241dae[_0x0a8b('0x2c')]({'plain':!![]});return _0x4bad0e[_0x0a8b('0x68')];});return db[_0x0a8b('0x35')][_0x0a8b('0x56')]({'where':{'id':_0x372778[_0x0a8b('0x58')]['id']}})[_0x0a8b('0x2a')](function(_0xee3fb3){return db['sequelize'][_0x0a8b('0x6a')](function(_0x47f561){return _0xee3fb3[_0x0a8b('0x67')](_0x2f11f3,{'transaction':_0x47f561})[_0x0a8b('0x2a')](function(){return BPromise['each'](_0x5eb080,function(_0x51544d){return db[_0x0a8b('0x5c')][_0x0a8b('0x6b')]({'where':{'UserId':_0x51544d['id'],'FaxQueueId':_0x372778[_0x0a8b('0x58')]['id']},'transaction':_0x47f561});});})['then'](function(){_0x5eb080[_0x0a8b('0x6c')](function(_0x590b10){socket[_0x0a8b('0x6d')](_0x0a8b('0x6e'),{'UserId':_0x590b10['id'],'FaxQueueId':_0xee3fb3['id']});});});});});}})['then'](respondWithStatusCode(_0x558d0d,null))[_0x0a8b('0x50')](handleError(_0x558d0d,null));};exports[_0x0a8b('0x6f')]=function(_0x464d11,_0x1f1c00,_0x2199ee){return db[_0x0a8b('0x66')][_0x0a8b('0x4d')]({'where':{'id':_0x464d11[_0x0a8b('0x3c')]['ids']},'attributes':['id'],'include':[{'model':db['User'],'as':_0x0a8b('0x68'),'attributes':['id'],'raw':!![]}]})[_0x0a8b('0x2a')](handleEntityNotFound(_0x1f1c00,null))[_0x0a8b('0x2a')](function(_0x587ad4){var _0x6197b4=_[_0x0a8b('0x34')](_0x587ad4,'id');var _0x1e8017=[];var _0x5cd9d1=[];var _0x584e4f=squel[_0x0a8b('0x70')]();_0x584e4f['field'](_0x0a8b('0x71'))[_0x0a8b('0x72')](_0x0a8b('0x73'),'tq')['join'](_0x0a8b('0x74'),'ut',_0x0a8b('0x75'))[_0x0a8b('0x46')](_0x0a8b('0x76'),_0x464d11[_0x0a8b('0x58')]['id']);for(var _0x526f24=0x0;_0x526f24<_0x587ad4[_0x0a8b('0x41')];_0x526f24+=0x1){let _0x4aa144=_0x587ad4[_0x526f24];for(var _0x5168b2=0x0;_0x5168b2<_0x4aa144[_0x0a8b('0x68')][_0x0a8b('0x41')];_0x5168b2+=0x1){let _0x41ad33=_0x4aa144['Agents'][_0x5168b2];var _0x547f87=_0x584e4f[_0x0a8b('0x77')]();_0x547f87[_0x0a8b('0x46')](_0x0a8b('0x78'),_0x41ad33['id']);_0x5cd9d1[_0x0a8b('0x79')](db[_0x0a8b('0x7a')][_0x0a8b('0x3c')](_0x547f87[_0x0a8b('0x7b')](),{'type':db[_0x0a8b('0x7a')][_0x0a8b('0x7c')][_0x0a8b('0x7d')]})[_0x0a8b('0x2a')](function(_0x15c5b1){if(_0x15c5b1[_0x0a8b('0x41')]===0x1){return _0x41ad33['id'];}else{var _0x190b66=_[_0x0a8b('0x7e')](_[_0x0a8b('0x34')](_0x15c5b1,_0x0a8b('0x7f')),function(_0x191704){return _[_0x0a8b('0x80')](_0x6197b4,_0x191704);});if(_0x190b66){return _0x41ad33['id'];}}}));}}return BPromise[_0x0a8b('0x81')](_0x5cd9d1)[_0x0a8b('0x2a')](function(_0x48ab08){_0x1e8017=_(_0x1e8017)[_0x0a8b('0x82')](_0x48ab08)['compact']()[_0x0a8b('0x83')]();return db[_0x0a8b('0x35')][_0x0a8b('0x56')]({'where':{'id':_0x464d11[_0x0a8b('0x58')]['id']}})[_0x0a8b('0x2a')](function(_0x44f524){return db[_0x0a8b('0x7a')][_0x0a8b('0x6a')](function(_0x5a09f1){return _0x44f524[_0x0a8b('0x6f')](_0x464d11['query'][_0x0a8b('0x84')],{'transaction':_0x5a09f1})[_0x0a8b('0x2a')](function(){if(!_[_0x0a8b('0x85')](_0x1e8017)){return _0x44f524[_0x0a8b('0x86')](_0x1e8017,{'transaction':_0x5a09f1});}})['then'](function(){_0x1e8017[_0x0a8b('0x6c')](function(_0x312c2c){socket[_0x0a8b('0x6d')](_0x0a8b('0x87'),{'UserId':_0x312c2c,'FaxQueueId':_0x44f524['id']});});});});});});})['then'](respondWithStatusCode(_0x1f1c00,null))[_0x0a8b('0x50')](handleError(_0x1f1c00,null));};exports['addAgents']=function(_0x2dfdd5,_0x4649cb,_0x209e4c){return db[_0x0a8b('0x35')]['find']({'where':{'id':_0x2dfdd5[_0x0a8b('0x58')]['id']}})[_0x0a8b('0x2a')](handleEntityNotFound(_0x4649cb,null))[_0x0a8b('0x2a')](function(_0x244afe){if(_0x244afe){return _0x244afe['addAgents'](_0x2dfdd5[_0x0a8b('0x52')]['ids'],_[_0x0a8b('0x88')](_0x2dfdd5['body'],[_0x0a8b('0x84'),'id'])||{})[_0x0a8b('0x89')](function(_0x4e3d46){for(var _0x5d5f37=0x0;_0x5d5f37<_0x2dfdd5[_0x0a8b('0x52')]['ids'][_0x0a8b('0x41')];_0x5d5f37+=0x1){socket[_0x0a8b('0x6d')](_0x0a8b('0x6e'),{'UserId':_0x2dfdd5[_0x0a8b('0x52')]['ids'][_0x5d5f37],'FaxQueueId':_0x2dfdd5[_0x0a8b('0x58')]['id']});}return _0x4e3d46;});}})[_0x0a8b('0x2a')](respondWithResult(_0x4649cb,null))[_0x0a8b('0x50')](handleError(_0x4649cb,null));};exports[_0x0a8b('0x86')]=function(_0x59fba6,_0x2b859e,_0x41927d){return db[_0x0a8b('0x35')][_0x0a8b('0x56')]({'where':{'id':_0x59fba6[_0x0a8b('0x58')]['id']}})[_0x0a8b('0x2a')](handleEntityNotFound(_0x2b859e,null))['then'](function(_0x52070b){if(_0x52070b){return _0x52070b['removeAgents'](_0x59fba6['query'][_0x0a8b('0x84')])[_0x0a8b('0x2a')](function(){if(_[_0x0a8b('0x8a')](_0x59fba6['query'][_0x0a8b('0x84')])){for(var _0x580ff4=0x0;_0x580ff4<_0x59fba6[_0x0a8b('0x3c')][_0x0a8b('0x84')][_0x0a8b('0x41')];_0x580ff4+=0x1){socket[_0x0a8b('0x6d')](_0x0a8b('0x87'),{'UserId':Number(_0x59fba6[_0x0a8b('0x3c')][_0x0a8b('0x84')][_0x580ff4]),'FaxQueueId':Number(_0x59fba6[_0x0a8b('0x58')]['id'])});}}else{socket[_0x0a8b('0x6d')](_0x0a8b('0x87'),{'UserId':Number(_0x59fba6[_0x0a8b('0x3c')][_0x0a8b('0x84')]),'FaxQueueId':Number(_0x59fba6[_0x0a8b('0x58')]['id'])});}});}})[_0x0a8b('0x2a')](respondWithStatusCode(_0x2b859e,null))[_0x0a8b('0x50')](handleError(_0x2b859e,null));};exports[_0x0a8b('0x8b')]=function(_0x483bfa,_0x5edd35,_0x24442b){var _0xa6caad={};var _0x35a1d5={};var _0x4c644e;var _0x7652e6;return db['FaxQueue'][_0x0a8b('0x5b')]({'where':{'id':_0x483bfa[_0x0a8b('0x58')]['id']}})[_0x0a8b('0x2a')](handleEntityNotFound(_0x5edd35,null))[_0x0a8b('0x2a')](function(_0x54f749){if(_0x54f749){_0x4c644e=_0x54f749;_0x35a1d5[_0x0a8b('0x3a')]=_['keys'](db['User'][_0x0a8b('0x36')]);_0x35a1d5[_0x0a8b('0x3c')]=_[_0x0a8b('0x3b')](_0x483bfa['query']);_0x35a1d5[_0x0a8b('0x3d')]=_[_0x0a8b('0x3e')](_0x35a1d5[_0x0a8b('0x3a')],_0x35a1d5[_0x0a8b('0x3c')]);_0xa6caad['attributes']=_[_0x0a8b('0x3e')](_0x35a1d5[_0x0a8b('0x3a')],qs[_0x0a8b('0x40')](_0x483bfa[_0x0a8b('0x3c')]['fields']));_0xa6caad[_0x0a8b('0x3f')]=_0xa6caad[_0x0a8b('0x3f')][_0x0a8b('0x41')]?_0xa6caad[_0x0a8b('0x3f')]:_0x35a1d5[_0x0a8b('0x3a')];_0xa6caad[_0x0a8b('0x5d')]=qs[_0x0a8b('0x45')](_0x483bfa[_0x0a8b('0x3c')][_0x0a8b('0x45')]);_0xa6caad[_0x0a8b('0x46')]=qs[_0x0a8b('0x3d')](_['pick'](_0x483bfa[_0x0a8b('0x3c')],_0x35a1d5[_0x0a8b('0x3d')]));if(_0x483bfa[_0x0a8b('0x3c')][_0x0a8b('0x48')]){_0xa6caad[_0x0a8b('0x46')]=_[_0x0a8b('0x49')](_0xa6caad['where'],{'$or':_[_0x0a8b('0x34')](_0xa6caad['attributes'],function(_0x218434){var _0xc6b76={};_0xc6b76[_0x218434]={'$like':'%'+_0x483bfa[_0x0a8b('0x3c')][_0x0a8b('0x48')]+'%'};return _0xc6b76;})});}_0xa6caad=_[_0x0a8b('0x49')]({},_0xa6caad,_0x483bfa['options']);return _0x4c644e['getAgents'](_0xa6caad);}})['then'](function(_0x3efe01){if(_0x3efe01){_0x7652e6=_0x3efe01[_0x0a8b('0x41')];if(!_0x483bfa[_0x0a8b('0x3c')][_0x0a8b('0x42')](_0x0a8b('0x43'))){_0xa6caad['limit']=qs[_0x0a8b('0x44')](_0x483bfa[_0x0a8b('0x3c')]['limit']);_0xa6caad[_0x0a8b('0x23')]=qs['offset'](_0x483bfa['query']['offset']);}return _0x4c644e[_0x0a8b('0x8b')](_0xa6caad);}})[_0x0a8b('0x2a')](function(_0x13c878){if(_0x13c878){return _0x13c878?{'count':_0x7652e6,'rows':_0x13c878}:null;}})['then'](respondWithResult(_0x5edd35,null))[_0x0a8b('0x50')](handleError(_0x5edd35,null));};
\ No newline at end of file