Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 56a55e7..b107833 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x31f1=['createdAt','%s/%s','faxPause','getTeams','Team','order','pick','addTeams','online','voicePause','interface','Agents','sequelize','each','forEach','emit','userFaxQueue:save','ids','field','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','includes','union','compact','value','removeTeams','userFaxQueue:remove','addAgents','omit','spread','removeAgents','isArray','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','squel','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/license/util','defaults','redis','localhost','socket.io-emitter','./faxQueue.socket','register','sendStatus','status','end','offset','undefined','limit','count','set','reject','save','update','then','destroy','get','FaxQueues','UserProfileResource','error','name','send','index','map','FaxQueue','rawAttributes','fieldName','type','key','query','intersection','model','attributes','length','hasOwnProperty','sort','filters','filter','where','merge','options','includeAll','rows','keys','fields','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','findOne','UserFaxQueue','nolimit','FaxQueueId','findAll','User','findAndCountAll','UserId','agent'];(function(_0x5bc22a,_0xffecf5){var _0x3a831f=function(_0x2261bc){while(--_0x2261bc){_0x5bc22a['push'](_0x5bc22a['shift']());}};_0x3a831f(++_0xffecf5);}(_0x31f1,0xae));var _0x131f=function(_0x5f394a,_0x22a74f){_0x5f394a=_0x5f394a-0x0;var _0x5834d3=_0x31f1[_0x5f394a];return _0x5834d3;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x131f('0x0'));var jsonpatch=require(_0x131f('0x1'));var rp=require(_0x131f('0x2'));var moment=require(_0x131f('0x3'));var BPromise=require(_0x131f('0x4'));var Mustache=require(_0x131f('0x5'));var util=require(_0x131f('0x6'));var path=require(_0x131f('0x7'));var sox=require(_0x131f('0x8'));var csv=require('to-csv');var ejs=require(_0x131f('0x9'));var fs=require('fs');var fs_extra=require(_0x131f('0xa'));var _=require('lodash');var squel=require(_0x131f('0xb'));var crypto=require(_0x131f('0xc'));var jsforce=require(_0x131f('0xd'));var deskjs=require(_0x131f('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x131f('0xf'));var authService=require(_0x131f('0x10'));var qs=require(_0x131f('0x11'));var as=require(_0x131f('0x12'));var hardwareService=require(_0x131f('0x13'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x131f('0x14'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x131f('0x15')](config[_0x131f('0x16')],{'host':_0x131f('0x17'),'port':0x18eb});var socket=require(_0x131f('0x18'))(new Redis(config['redis']));require(_0x131f('0x19'))[_0x131f('0x1a')](socket);function respondWithStatusCode(_0x2444a1,_0x3e1d31){_0x3e1d31=_0x3e1d31||0xcc;return function(_0x34bc14){if(_0x34bc14){return _0x2444a1[_0x131f('0x1b')](_0x3e1d31);}return _0x2444a1[_0x131f('0x1c')](_0x3e1d31)[_0x131f('0x1d')]();};}function respondWithResult(_0x194a79,_0x1eb328){_0x1eb328=_0x1eb328||0xc8;return function(_0x466aa7){if(_0x466aa7){return _0x194a79[_0x131f('0x1c')](_0x1eb328)['json'](_0x466aa7);}};}function respondWithFilteredResult(_0x458942,_0x3b7f42){return function(_0x1cb3cb){if(_0x1cb3cb){var _0x1b8e4f=typeof _0x3b7f42[_0x131f('0x1e')]===_0x131f('0x1f')&&typeof _0x3b7f42[_0x131f('0x20')]===_0x131f('0x1f');var _0x47da98=_0x1cb3cb[_0x131f('0x21')];var _0x1b0627=_0x1b8e4f?0x0:_0x3b7f42['offset'];var _0x4699e1=_0x1b8e4f?_0x1cb3cb['count']:_0x3b7f42['offset']+_0x3b7f42[_0x131f('0x20')];var _0x30b5ce;if(_0x4699e1>=_0x47da98){_0x4699e1=_0x47da98;_0x30b5ce=0xc8;}else{_0x30b5ce=0xce;}_0x458942[_0x131f('0x1c')](_0x30b5ce);return _0x458942[_0x131f('0x22')]('Content-Range',_0x1b0627+'-'+_0x4699e1+'/'+_0x47da98)['json'](_0x1cb3cb);}return null;};}function patchUpdates(_0x3c88b7){return function(_0x18de00){try{jsonpatch['apply'](_0x18de00,_0x3c88b7,!![]);}catch(_0x4e0952){return BPromise[_0x131f('0x23')](_0x4e0952);}return _0x18de00[_0x131f('0x24')]();};}function saveUpdates(_0x5b22b8,_0x4c5ffe){return function(_0x54acfa){if(_0x54acfa){return _0x54acfa[_0x131f('0x25')](_0x5b22b8)[_0x131f('0x26')](function(_0x3a669c){return _0x3a669c;});}return null;};}function removeEntity(_0x407d45,_0x5e05c3){return function(_0x419663){if(_0x419663){return _0x419663[_0x131f('0x27')]()[_0x131f('0x26')](function(){var _0x500316=_0x419663[_0x131f('0x28')]({'plain':!![]});var _0x4a2383=_0x131f('0x29');return db[_0x131f('0x2a')][_0x131f('0x27')]({'where':{'type':_0x4a2383,'resourceId':_0x500316['id']}})[_0x131f('0x26')](function(){return _0x419663;});})[_0x131f('0x26')](function(){_0x407d45[_0x131f('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2b33ef,_0x32e8cb){return function(_0x2d96f7){if(!_0x2d96f7){_0x2b33ef[_0x131f('0x1b')](0x194);}return _0x2d96f7;};}function handleError(_0x29cc62,_0x51aab6){_0x51aab6=_0x51aab6||0x1f4;return function(_0x3c0554){logger[_0x131f('0x2b')](_0x3c0554['stack']);if(_0x3c0554[_0x131f('0x2c')]){delete _0x3c0554[_0x131f('0x2c')];}_0x29cc62['status'](_0x51aab6)[_0x131f('0x2d')](_0x3c0554);};}exports[_0x131f('0x2e')]=function(_0x11e22d,_0x315472){var _0x38b883={},_0x3b40a9={},_0x5b4544={'count':0x0,'rows':[]};var _0x44a7fc=_[_0x131f('0x2f')](db[_0x131f('0x30')][_0x131f('0x31')],function(_0x149bba){return{'name':_0x149bba[_0x131f('0x32')],'type':_0x149bba[_0x131f('0x33')][_0x131f('0x34')]};});_0x3b40a9['model']=_[_0x131f('0x2f')](_0x44a7fc,_0x131f('0x2c'));_0x3b40a9[_0x131f('0x35')]=_['keys'](_0x11e22d[_0x131f('0x35')]);_0x3b40a9['filters']=_[_0x131f('0x36')](_0x3b40a9[_0x131f('0x37')],_0x3b40a9[_0x131f('0x35')]);_0x38b883['attributes']=_['intersection'](_0x3b40a9[_0x131f('0x37')],qs['fields'](_0x11e22d['query']['fields']));_0x38b883[_0x131f('0x38')]=_0x38b883[_0x131f('0x38')][_0x131f('0x39')]?_0x38b883[_0x131f('0x38')]:_0x3b40a9[_0x131f('0x37')];if(!_0x11e22d['query'][_0x131f('0x3a')]('nolimit')){_0x38b883[_0x131f('0x20')]=qs[_0x131f('0x20')](_0x11e22d[_0x131f('0x35')]['limit']);_0x38b883['offset']=qs[_0x131f('0x1e')](_0x11e22d[_0x131f('0x35')][_0x131f('0x1e')]);}_0x38b883['order']=qs[_0x131f('0x3b')](_0x11e22d[_0x131f('0x35')][_0x131f('0x3b')]);_0x38b883['where']=qs[_0x131f('0x3c')](_['pick'](_0x11e22d[_0x131f('0x35')],_0x3b40a9[_0x131f('0x3c')]),_0x44a7fc);if(_0x11e22d['query'][_0x131f('0x3d')]){_0x38b883[_0x131f('0x3e')]=_[_0x131f('0x3f')](_0x38b883[_0x131f('0x3e')],{'$or':_['map'](_0x44a7fc,function(_0x494817){if(_0x494817[_0x131f('0x33')]!=='VIRTUAL'){var _0x54a0d8={};_0x54a0d8[_0x494817['name']]={'$like':'%'+_0x11e22d['query'][_0x131f('0x3d')]+'%'};return _0x54a0d8;}})});}_0x38b883=_[_0x131f('0x3f')]({},_0x38b883,_0x11e22d[_0x131f('0x40')]);var _0x381e00={'where':_0x38b883[_0x131f('0x3e')]};return db[_0x131f('0x30')][_0x131f('0x21')](_0x381e00)[_0x131f('0x26')](function(_0x348321){_0x5b4544[_0x131f('0x21')]=_0x348321;if(_0x11e22d['query'][_0x131f('0x41')]){_0x38b883['include']=[{'all':!![]}];}return db['FaxQueue']['findAll'](_0x38b883);})[_0x131f('0x26')](function(_0x345c8e){_0x5b4544[_0x131f('0x42')]=_0x345c8e;return _0x5b4544;})[_0x131f('0x26')](respondWithFilteredResult(_0x315472,_0x38b883))['catch'](handleError(_0x315472,null));};exports['show']=function(_0x41f614,_0x55ee2b){var _0x145cd7={'raw':!![],'where':{'id':_0x41f614['params']['id']}},_0x29559c={};_0x29559c[_0x131f('0x37')]=_[_0x131f('0x43')](db[_0x131f('0x30')]['rawAttributes']);_0x29559c[_0x131f('0x35')]=_[_0x131f('0x43')](_0x41f614[_0x131f('0x35')]);_0x29559c[_0x131f('0x3c')]=_['intersection'](_0x29559c['model'],_0x29559c['query']);_0x145cd7[_0x131f('0x38')]=_['intersection'](_0x29559c[_0x131f('0x37')],qs[_0x131f('0x44')](_0x41f614[_0x131f('0x35')][_0x131f('0x44')]));_0x145cd7[_0x131f('0x38')]=_0x145cd7[_0x131f('0x38')]['length']?_0x145cd7[_0x131f('0x38')]:_0x29559c['model'];if(_0x41f614[_0x131f('0x35')][_0x131f('0x41')]){_0x145cd7['include']=[{'all':!![]}];}_0x145cd7=_[_0x131f('0x3f')]({},_0x145cd7,_0x41f614[_0x131f('0x40')]);return db[_0x131f('0x30')][_0x131f('0x45')](_0x145cd7)[_0x131f('0x26')](handleEntityNotFound(_0x55ee2b,null))[_0x131f('0x26')](respondWithResult(_0x55ee2b,null))[_0x131f('0x46')](handleError(_0x55ee2b,null));};exports[_0x131f('0x47')]=function(_0x3ff498,_0x299e67){return db[_0x131f('0x30')]['create'](_0x3ff498[_0x131f('0x48')],{})[_0x131f('0x26')](function(_0x3a49e6){var _0x3a54b9=_0x3ff498[_0x131f('0x49')][_0x131f('0x28')]({'plain':!![]});if(!_0x3a54b9)throw new Error(_0x131f('0x4a'));if(_0x3a54b9[_0x131f('0x4b')]==='user'){var _0x4966e4=_0x3a49e6[_0x131f('0x28')]({'plain':!![]});var _0x222e88='FaxQueues';return db[_0x131f('0x4c')][_0x131f('0x45')]({'where':{'name':_0x222e88,'userProfileId':_0x3a54b9[_0x131f('0x4d')]},'raw':!![]})[_0x131f('0x26')](function(_0x14733b){if(_0x14733b&&_0x14733b[_0x131f('0x4e')]===0x0){return db[_0x131f('0x2a')][_0x131f('0x47')]({'name':_0x4966e4[_0x131f('0x2c')],'resourceId':_0x4966e4['id'],'type':_0x14733b[_0x131f('0x2c')],'sectionId':_0x14733b['id']},{})[_0x131f('0x26')](function(){return _0x3a49e6;});}else{return _0x3a49e6;}})['catch'](function(_0x5379a2){logger[_0x131f('0x2b')](_0x131f('0x4f'),_0x5379a2);throw _0x5379a2;});}return _0x3a49e6;})[_0x131f('0x26')](respondWithResult(_0x299e67,0xc9))['catch'](handleError(_0x299e67,null));};exports[_0x131f('0x25')]=function(_0x21e0d3,_0x29bc97){if(_0x21e0d3[_0x131f('0x48')]['id']){delete _0x21e0d3[_0x131f('0x48')]['id'];}return db['FaxQueue'][_0x131f('0x45')]({'where':{'id':_0x21e0d3[_0x131f('0x50')]['id']}})[_0x131f('0x26')](handleEntityNotFound(_0x29bc97,null))['then'](saveUpdates(_0x21e0d3[_0x131f('0x48')],null))[_0x131f('0x26')](respondWithResult(_0x29bc97,null))[_0x131f('0x46')](handleError(_0x29bc97,null));};exports[_0x131f('0x27')]=function(_0x41431f,_0x30dc22){return db[_0x131f('0x30')][_0x131f('0x45')]({'where':{'id':_0x41431f['params']['id']}})[_0x131f('0x26')](handleEntityNotFound(_0x30dc22,null))[_0x131f('0x26')](removeEntity(_0x30dc22,null))[_0x131f('0x46')](handleError(_0x30dc22,null));};exports[_0x131f('0x51')]=function(_0x517543,_0x39f30b){return db[_0x131f('0x30')][_0x131f('0x51')]()[_0x131f('0x26')](respondWithResult(_0x39f30b,null))[_0x131f('0x46')](handleError(_0x39f30b,null));};exports[_0x131f('0x52')]=function(_0x37acb0,_0x1c810e,_0x19e8be){var _0x1c6333={'raw':!![],'where':{}},_0x464267={},_0x4289c5;return db[_0x131f('0x30')][_0x131f('0x53')]({'where':{'id':_0x37acb0[_0x131f('0x50')]['id']}})['then'](handleEntityNotFound(_0x1c810e,null))[_0x131f('0x26')](function(_0x463ac8){if(_0x463ac8){_0x4289c5=_0x463ac8['get']({'plain':!![]});_0x464267[_0x131f('0x37')]=_[_0x131f('0x43')](db[_0x131f('0x54')][_0x131f('0x31')]);_0x464267[_0x131f('0x35')]=_['keys'](_0x37acb0[_0x131f('0x35')]);_0x464267['filters']=_[_0x131f('0x36')](_0x464267[_0x131f('0x37')],_0x464267['query']);_0x1c6333[_0x131f('0x38')]=_['intersection'](_0x464267[_0x131f('0x37')],qs[_0x131f('0x44')](_0x37acb0[_0x131f('0x35')]['fields']));_0x1c6333[_0x131f('0x38')]=_0x1c6333[_0x131f('0x38')][_0x131f('0x39')]?_0x1c6333[_0x131f('0x38')]:_0x464267[_0x131f('0x37')];if(!_0x37acb0[_0x131f('0x35')]['hasOwnProperty'](_0x131f('0x55'))){_0x1c6333['limit']=qs[_0x131f('0x20')](_0x37acb0['query']['limit']);_0x1c6333[_0x131f('0x1e')]=qs[_0x131f('0x1e')](_0x37acb0[_0x131f('0x35')]['offset']);}_0x1c6333['order']=qs['sort'](_0x37acb0[_0x131f('0x35')]['sort']);_0x1c6333[_0x131f('0x3e')]=qs[_0x131f('0x3c')](_['pick'](_0x37acb0[_0x131f('0x35')],_0x464267['filters']));_0x1c6333[_0x131f('0x3e')][_0x131f('0x56')]=_0x463ac8['id'];if(_0x37acb0[_0x131f('0x35')][_0x131f('0x3d')]){_0x1c6333['where']=_[_0x131f('0x3f')](_0x1c6333[_0x131f('0x3e')],{'$or':_['map'](_0x1c6333[_0x131f('0x38')],function(_0x28db36){var _0x2eb35c={};_0x2eb35c[_0x28db36]={'$like':'%'+_0x37acb0[_0x131f('0x35')][_0x131f('0x3d')]+'%'};return _0x2eb35c;})});}_0x1c6333=_[_0x131f('0x3f')]({},_0x1c6333,_0x37acb0[_0x131f('0x40')]);return db[_0x131f('0x54')][_0x131f('0x57')](_0x1c6333);}})[_0x131f('0x26')](function(_0x1f8ff4){if(_0x1f8ff4){return db[_0x131f('0x58')][_0x131f('0x59')]({'where':{'id':_['map'](_0x1f8ff4,_0x131f('0x5a')),'role':_0x131f('0x5b')},'attributes':['id',_0x131f('0x2c'),'faxPause','updatedAt',_0x131f('0x5c')]});}})['then'](function(_0x320fe4){if(_0x320fe4){return{'count':_0x320fe4[_0x131f('0x21')],'rows':_[_0x131f('0x2f')](_0x320fe4['rows'],function(_0x50162b){return{'membername':_0x50162b[_0x131f('0x2c')],'UserId':_0x50162b['id'],'queue_name':_0x4289c5[_0x131f('0x2c')],'FaxQueueId':_0x4289c5['id'],'interface':util['format'](_0x131f('0x5d'),'SIP',_0x50162b[_0x131f('0x2c')]),'penalty':0x0,'paused':_0x50162b[_0x131f('0x5e')],'createdAt':_0x50162b['createdAt'],'updatedAt':_0x50162b['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x1c810e,_0x1c6333))[_0x131f('0x46')](handleError(_0x1c810e,null));};exports[_0x131f('0x5f')]=function(_0x12bd4c,_0x5ebd16,_0x4440bc){var _0x151b4b={};var _0x4ab404={};var _0x142219;var _0x1f8db8;return db[_0x131f('0x30')][_0x131f('0x53')]({'where':{'id':_0x12bd4c[_0x131f('0x50')]['id']}})[_0x131f('0x26')](handleEntityNotFound(_0x5ebd16,null))[_0x131f('0x26')](function(_0x34c0e1){if(_0x34c0e1){_0x142219=_0x34c0e1;_0x4ab404[_0x131f('0x37')]=_[_0x131f('0x43')](db[_0x131f('0x60')]['rawAttributes']);_0x4ab404[_0x131f('0x35')]=_[_0x131f('0x43')](_0x12bd4c['query']);_0x4ab404[_0x131f('0x3c')]=_['intersection'](_0x4ab404[_0x131f('0x37')],_0x4ab404[_0x131f('0x35')]);_0x151b4b[_0x131f('0x38')]=_[_0x131f('0x36')](_0x4ab404[_0x131f('0x37')],qs['fields'](_0x12bd4c['query']['fields']));_0x151b4b[_0x131f('0x38')]=_0x151b4b[_0x131f('0x38')]['length']?_0x151b4b[_0x131f('0x38')]:_0x4ab404[_0x131f('0x37')];_0x151b4b[_0x131f('0x61')]=qs[_0x131f('0x3b')](_0x12bd4c[_0x131f('0x35')][_0x131f('0x3b')]);_0x151b4b['where']=qs[_0x131f('0x3c')](_[_0x131f('0x62')](_0x12bd4c[_0x131f('0x35')],_0x4ab404[_0x131f('0x3c')]));if(_0x12bd4c['query'][_0x131f('0x3d')]){_0x151b4b[_0x131f('0x3e')]=_[_0x131f('0x3f')](_0x151b4b[_0x131f('0x3e')],{'$or':_['map'](_0x151b4b[_0x131f('0x38')],function(_0x211272){var _0x10f8b6={};_0x10f8b6[_0x211272]={'$like':'%'+_0x12bd4c[_0x131f('0x35')]['filter']+'%'};return _0x10f8b6;})});}_0x151b4b=_[_0x131f('0x3f')]({},_0x151b4b,_0x12bd4c[_0x131f('0x40')]);return _0x142219['getTeams'](_0x151b4b);}})['then'](function(_0x21daf8){if(_0x21daf8){_0x1f8db8=_0x21daf8[_0x131f('0x39')];if(!_0x12bd4c['query'][_0x131f('0x3a')](_0x131f('0x55'))){_0x151b4b[_0x131f('0x20')]=qs[_0x131f('0x20')](_0x12bd4c['query'][_0x131f('0x20')]);_0x151b4b[_0x131f('0x1e')]=qs[_0x131f('0x1e')](_0x12bd4c[_0x131f('0x35')][_0x131f('0x1e')]);}return _0x142219[_0x131f('0x5f')](_0x151b4b);}})[_0x131f('0x26')](function(_0xcffe14){if(_0xcffe14){return _0xcffe14?{'count':_0x1f8db8,'rows':_0xcffe14}:null;}})[_0x131f('0x26')](respondWithResult(_0x5ebd16,null))[_0x131f('0x46')](handleError(_0x5ebd16,null));};exports[_0x131f('0x63')]=function(_0xbe92bf,_0x555572,_0x11b375){var _0x2d5803=_0xbe92bf[_0x131f('0x48')]['ids'];return db[_0x131f('0x60')][_0x131f('0x57')]({'where':{'id':_0x2d5803},'attributes':['id'],'include':[{'model':db[_0x131f('0x58')],'as':'Agents','attributes':['id',_0x131f('0x2c'),_0x131f('0x64'),_0x131f('0x65'),_0x131f('0x66')],'raw':!![]}]})[_0x131f('0x26')](function(_0x39e03e){if(_0x39e03e){var _0xd69549=_['flatMap'](_0x39e03e,function(_0x56f6e2){var _0x3fd357=_0x56f6e2[_0x131f('0x28')]({'plain':!![]});return _0x3fd357[_0x131f('0x67')];});return db['FaxQueue'][_0x131f('0x45')]({'where':{'id':_0xbe92bf[_0x131f('0x50')]['id']}})[_0x131f('0x26')](function(_0x2d5273){return db[_0x131f('0x68')]['transaction'](function(_0x4a27b0){return _0x2d5273[_0x131f('0x63')](_0x2d5803,{'transaction':_0x4a27b0})[_0x131f('0x26')](function(){return BPromise[_0x131f('0x69')](_0xd69549,function(_0x2bae66){return db[_0x131f('0x54')]['findOrCreate']({'where':{'UserId':_0x2bae66['id'],'FaxQueueId':_0xbe92bf[_0x131f('0x50')]['id']},'transaction':_0x4a27b0});});})[_0x131f('0x26')](function(){_0xd69549[_0x131f('0x6a')](function(_0x59d2cb){socket[_0x131f('0x6b')](_0x131f('0x6c'),{'UserId':_0x59d2cb['id'],'FaxQueueId':_0x2d5273['id']});});});});});}})[_0x131f('0x26')](respondWithStatusCode(_0x555572,null))['catch'](handleError(_0x555572,null));};exports['removeTeams']=function(_0x52c299,_0x59b434,_0x5db4c5){return db[_0x131f('0x60')][_0x131f('0x57')]({'where':{'id':_0x52c299[_0x131f('0x35')][_0x131f('0x6d')]},'attributes':['id'],'include':[{'model':db[_0x131f('0x58')],'as':_0x131f('0x67'),'attributes':['id'],'raw':!![]}]})[_0x131f('0x26')](handleEntityNotFound(_0x59b434,null))['then'](function(_0x479a6e){var _0x3d1dc4=_[_0x131f('0x2f')](_0x479a6e,'id');var _0x1ae49f=[];var _0x26595b=[];var _0x2f6367=squel['select']();_0x2f6367[_0x131f('0x6e')](_0x131f('0x6f'))[_0x131f('0x70')](_0x131f('0x71'),'tq')[_0x131f('0x72')](_0x131f('0x73'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x131f('0x3e')](_0x131f('0x74'),_0x52c299[_0x131f('0x50')]['id']);for(var _0x1b5185=0x0;_0x1b5185<_0x479a6e['length'];_0x1b5185+=0x1){let _0x46e463=_0x479a6e[_0x1b5185];for(var _0x36f4f5=0x0;_0x36f4f5<_0x46e463[_0x131f('0x67')]['length'];_0x36f4f5+=0x1){let _0x152af1=_0x46e463[_0x131f('0x67')][_0x36f4f5];var _0x5337be=_0x2f6367[_0x131f('0x75')]();_0x5337be[_0x131f('0x3e')](_0x131f('0x76'),_0x152af1['id']);_0x26595b['push'](db[_0x131f('0x68')][_0x131f('0x35')](_0x5337be[_0x131f('0x77')](),{'type':db[_0x131f('0x68')][_0x131f('0x78')][_0x131f('0x79')]})['then'](function(_0x17c8bd){if(_0x17c8bd[_0x131f('0x39')]===0x1){return _0x152af1['id'];}else{var _0x4858a3=_['every'](_[_0x131f('0x2f')](_0x17c8bd,'TeamId'),function(_0x430437){return _[_0x131f('0x7a')](_0x3d1dc4,_0x430437);});if(_0x4858a3){return _0x152af1['id'];}}}));}}return BPromise['all'](_0x26595b)['then'](function(_0x2fed87){_0x1ae49f=_(_0x1ae49f)[_0x131f('0x7b')](_0x2fed87)[_0x131f('0x7c')]()[_0x131f('0x7d')]();return db['FaxQueue']['find']({'where':{'id':_0x52c299['params']['id']}})['then'](function(_0x5d0f27){return db[_0x131f('0x68')]['transaction'](function(_0x21e617){return _0x5d0f27[_0x131f('0x7e')](_0x52c299[_0x131f('0x35')][_0x131f('0x6d')],{'transaction':_0x21e617})['then'](function(){if(!_['isEmpty'](_0x1ae49f)){return _0x5d0f27['removeAgents'](_0x1ae49f,{'transaction':_0x21e617});}})[_0x131f('0x26')](function(){_0x1ae49f['forEach'](function(_0x326b1b){socket[_0x131f('0x6b')](_0x131f('0x7f'),{'UserId':_0x326b1b,'FaxQueueId':_0x5d0f27['id']});});});});});});})[_0x131f('0x26')](respondWithStatusCode(_0x59b434,null))[_0x131f('0x46')](handleError(_0x59b434,null));};exports[_0x131f('0x80')]=function(_0x34d8f2,_0xd9df84,_0x43b415){return db[_0x131f('0x30')]['find']({'where':{'id':_0x34d8f2['params']['id']}})[_0x131f('0x26')](handleEntityNotFound(_0xd9df84,null))['then'](function(_0xf7ed1a){if(_0xf7ed1a){return _0xf7ed1a[_0x131f('0x80')](_0x34d8f2[_0x131f('0x48')][_0x131f('0x6d')],_[_0x131f('0x81')](_0x34d8f2[_0x131f('0x48')],[_0x131f('0x6d'),'id'])||{})[_0x131f('0x82')](function(_0x3cc077){for(var _0x253780=0x0;_0x253780<_0x34d8f2[_0x131f('0x48')]['ids'][_0x131f('0x39')];_0x253780+=0x1){socket[_0x131f('0x6b')](_0x131f('0x6c'),{'UserId':_0x34d8f2['body'][_0x131f('0x6d')][_0x253780],'FaxQueueId':_0x34d8f2[_0x131f('0x50')]['id']});}return _0x3cc077;});}})[_0x131f('0x26')](respondWithResult(_0xd9df84,null))['catch'](handleError(_0xd9df84,null));};exports[_0x131f('0x83')]=function(_0x5cb7b5,_0x2cde7d,_0x54651c){return db[_0x131f('0x30')][_0x131f('0x45')]({'where':{'id':_0x5cb7b5[_0x131f('0x50')]['id']}})[_0x131f('0x26')](handleEntityNotFound(_0x2cde7d,null))[_0x131f('0x26')](function(_0x178d2a){if(_0x178d2a){return _0x178d2a[_0x131f('0x83')](_0x5cb7b5[_0x131f('0x35')][_0x131f('0x6d')])['then'](function(){if(_[_0x131f('0x84')](_0x5cb7b5[_0x131f('0x35')][_0x131f('0x6d')])){for(var _0x1035ad=0x0;_0x1035ad<_0x5cb7b5['query'][_0x131f('0x6d')]['length'];_0x1035ad+=0x1){socket[_0x131f('0x6b')](_0x131f('0x7f'),{'UserId':Number(_0x5cb7b5['query']['ids'][_0x1035ad]),'FaxQueueId':Number(_0x5cb7b5[_0x131f('0x50')]['id'])});}}else{socket[_0x131f('0x6b')](_0x131f('0x7f'),{'UserId':Number(_0x5cb7b5['query']['ids']),'FaxQueueId':Number(_0x5cb7b5['params']['id'])});}});}})[_0x131f('0x26')](respondWithStatusCode(_0x2cde7d,null))[_0x131f('0x46')](handleError(_0x2cde7d,null));};exports['getAgents']=function(_0x23f5c6,_0x28b752,_0x183337){var _0x1e0314={};var _0x2667c5={};var _0x57158c;var _0x1c20a7;return db[_0x131f('0x30')]['findOne']({'where':{'id':_0x23f5c6[_0x131f('0x50')]['id']}})[_0x131f('0x26')](handleEntityNotFound(_0x28b752,null))['then'](function(_0x502f1e){if(_0x502f1e){_0x57158c=_0x502f1e;_0x2667c5[_0x131f('0x37')]=_['keys'](db[_0x131f('0x58')][_0x131f('0x31')]);_0x2667c5[_0x131f('0x35')]=_[_0x131f('0x43')](_0x23f5c6[_0x131f('0x35')]);_0x2667c5[_0x131f('0x3c')]=_[_0x131f('0x36')](_0x2667c5[_0x131f('0x37')],_0x2667c5[_0x131f('0x35')]);_0x1e0314[_0x131f('0x38')]=_[_0x131f('0x36')](_0x2667c5['model'],qs[_0x131f('0x44')](_0x23f5c6['query'][_0x131f('0x44')]));_0x1e0314['attributes']=_0x1e0314[_0x131f('0x38')]['length']?_0x1e0314[_0x131f('0x38')]:_0x2667c5[_0x131f('0x37')];_0x1e0314[_0x131f('0x61')]=qs[_0x131f('0x3b')](_0x23f5c6[_0x131f('0x35')]['sort']);_0x1e0314['where']=qs['filters'](_[_0x131f('0x62')](_0x23f5c6['query'],_0x2667c5[_0x131f('0x3c')]));if(_0x23f5c6['query'][_0x131f('0x3d')]){_0x1e0314['where']=_['merge'](_0x1e0314[_0x131f('0x3e')],{'$or':_[_0x131f('0x2f')](_0x1e0314[_0x131f('0x38')],function(_0x14ed52){var _0x25717c={};_0x25717c[_0x14ed52]={'$like':'%'+_0x23f5c6[_0x131f('0x35')][_0x131f('0x3d')]+'%'};return _0x25717c;})});}_0x1e0314=_['merge']({},_0x1e0314,_0x23f5c6['options']);return _0x57158c['getAgents'](_0x1e0314);}})[_0x131f('0x26')](function(_0xb9959f){if(_0xb9959f){_0x1c20a7=_0xb9959f[_0x131f('0x39')];if(!_0x23f5c6[_0x131f('0x35')][_0x131f('0x3a')](_0x131f('0x55'))){_0x1e0314[_0x131f('0x20')]=qs['limit'](_0x23f5c6[_0x131f('0x35')][_0x131f('0x20')]);_0x1e0314[_0x131f('0x1e')]=qs['offset'](_0x23f5c6[_0x131f('0x35')][_0x131f('0x1e')]);}return _0x57158c['getAgents'](_0x1e0314);}})['then'](function(_0x5756d7){if(_0x5756d7){return _0x5756d7?{'count':_0x1c20a7,'rows':_0x5756d7}:null;}})['then'](respondWithResult(_0x28b752,null))['catch'](handleError(_0x28b752,null));};
\ No newline at end of file
+var _0x785f=['ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','./faxQueue.socket','register','sendStatus','status','json','offset','undefined','limit','count','set','apply','save','update','then','get','FaxQueues','destroy','end','error','send','index','FaxQueue','rawAttributes','fieldName','type','model','map','query','filters','attributes','intersection','fields','nolimit','order','sort','where','pick','merge','VIRTUAL','name','filter','options','include','findAll','catch','show','params','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','keys','length','hasOwnProperty','UserFaxQueue','UserId','agent','faxPause','updatedAt','createdAt','rows','format','getTeams','Team','addTeams','ids','User','Agents','online','voicePause','interface','flatMap','sequelize','each','emit','userFaxQueue:save','removeTeams','field','tq.TeamId','from','team_has_fax_queues','join','ut.TeamId\x20=\x20tq.TeamId','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','transaction','removeAgents','forEach','userFaxQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path'];(function(_0x4e8947,_0x5ca04d){var _0x29abde=function(_0x4c5158){while(--_0x4c5158){_0x4e8947['push'](_0x4e8947['shift']());}};_0x29abde(++_0x5ca04d);}(_0x785f,0x1a4));var _0xf785=function(_0x334841,_0x2bbc4c){_0x334841=_0x334841-0x0;var _0x5beb4b=_0x785f[_0x334841];return _0x5beb4b;};'use strict';var emlformat=require(_0xf785('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf785('0x1'));var jsonpatch=require(_0xf785('0x2'));var rp=require(_0xf785('0x3'));var moment=require(_0xf785('0x4'));var BPromise=require(_0xf785('0x5'));var Mustache=require(_0xf785('0x6'));var util=require(_0xf785('0x7'));var path=require(_0xf785('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xf785('0x9'));var fs=require('fs');var fs_extra=require(_0xf785('0xa'));var _=require(_0xf785('0xb'));var squel=require(_0xf785('0xc'));var crypto=require(_0xf785('0xd'));var jsforce=require(_0xf785('0xe'));var deskjs=require(_0xf785('0xf'));var toCsv=require(_0xf785('0x10'));var querystring=require(_0xf785('0x11'));var Papa=require(_0xf785('0x12'));var Redis=require(_0xf785('0x13'));var authService=require('../../components/auth/service');var qs=require(_0xf785('0x14'));var as=require(_0xf785('0x15'));var hardwareService=require(_0xf785('0x16'));var logger=require(_0xf785('0x17'))('api');var utils=require(_0xf785('0x18'));var config=require(_0xf785('0x19'));var licenseUtil=require(_0xf785('0x1a'));var db=require(_0xf785('0x1b'))['db'];config['redis']=_[_0xf785('0x1c')](config[_0xf785('0x1d')],{'host':_0xf785('0x1e'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xf785('0x1f'))[_0xf785('0x20')](socket);function respondWithStatusCode(_0x189207,_0x4dbddd){_0x4dbddd=_0x4dbddd||0xcc;return function(_0x1d4038){if(_0x1d4038){return _0x189207[_0xf785('0x21')](_0x4dbddd);}return _0x189207['status'](_0x4dbddd)['end']();};}function respondWithResult(_0x4c72a2,_0x1174d8){_0x1174d8=_0x1174d8||0xc8;return function(_0x5ee7cb){if(_0x5ee7cb){return _0x4c72a2[_0xf785('0x22')](_0x1174d8)[_0xf785('0x23')](_0x5ee7cb);}};}function respondWithFilteredResult(_0x102416,_0x36a439){return function(_0x3c0ada){if(_0x3c0ada){var _0x9bb07c=typeof _0x36a439[_0xf785('0x24')]===_0xf785('0x25')&&typeof _0x36a439[_0xf785('0x26')]===_0xf785('0x25');var _0xdc77a5=_0x3c0ada[_0xf785('0x27')];var _0x209c77=_0x9bb07c?0x0:_0x36a439[_0xf785('0x24')];var _0x54d25d=_0x9bb07c?_0x3c0ada[_0xf785('0x27')]:_0x36a439[_0xf785('0x24')]+_0x36a439[_0xf785('0x26')];var _0x3321b3;if(_0x54d25d>=_0xdc77a5){_0x54d25d=_0xdc77a5;_0x3321b3=0xc8;}else{_0x3321b3=0xce;}_0x102416['status'](_0x3321b3);return _0x102416[_0xf785('0x28')]('Content-Range',_0x209c77+'-'+_0x54d25d+'/'+_0xdc77a5)[_0xf785('0x23')](_0x3c0ada);}return null;};}function patchUpdates(_0x4b36db){return function(_0x835377){try{jsonpatch[_0xf785('0x29')](_0x835377,_0x4b36db,!![]);}catch(_0x3b7f2d){return BPromise['reject'](_0x3b7f2d);}return _0x835377[_0xf785('0x2a')]();};}function saveUpdates(_0x3cfe65,_0x58d9be){return function(_0x8060b3){if(_0x8060b3){return _0x8060b3[_0xf785('0x2b')](_0x3cfe65)[_0xf785('0x2c')](function(_0x1af9df){return _0x1af9df;});}return null;};}function removeEntity(_0x3baa0b,_0x39f9be){return function(_0xe1e616){if(_0xe1e616){return _0xe1e616['destroy']()[_0xf785('0x2c')](function(){var _0x50d25b=_0xe1e616[_0xf785('0x2d')]({'plain':!![]});var _0x15b190=_0xf785('0x2e');return db['UserProfileResource'][_0xf785('0x2f')]({'where':{'type':_0x15b190,'resourceId':_0x50d25b['id']}})[_0xf785('0x2c')](function(){return _0xe1e616;});})[_0xf785('0x2c')](function(){_0x3baa0b['status'](0xcc)[_0xf785('0x30')]();});}};}function handleEntityNotFound(_0x5237b7,_0x1d685e){return function(_0x239b7f){if(!_0x239b7f){_0x5237b7[_0xf785('0x21')](0x194);}return _0x239b7f;};}function handleError(_0x5bc371,_0x43acf0){_0x43acf0=_0x43acf0||0x1f4;return function(_0x566779){logger[_0xf785('0x31')](_0x566779['stack']);if(_0x566779['name']){delete _0x566779['name'];}_0x5bc371[_0xf785('0x22')](_0x43acf0)[_0xf785('0x32')](_0x566779);};}exports[_0xf785('0x33')]=function(_0x492ce3,_0x2fbd4a){var _0x401d3b={},_0x322709={},_0x247fcb={'count':0x0,'rows':[]};var _0x58f4b7=_['map'](db[_0xf785('0x34')][_0xf785('0x35')],function(_0x46ba94){return{'name':_0x46ba94[_0xf785('0x36')],'type':_0x46ba94[_0xf785('0x37')]['key']};});_0x322709[_0xf785('0x38')]=_[_0xf785('0x39')](_0x58f4b7,'name');_0x322709['query']=_['keys'](_0x492ce3[_0xf785('0x3a')]);_0x322709[_0xf785('0x3b')]=_['intersection'](_0x322709['model'],_0x322709['query']);_0x401d3b[_0xf785('0x3c')]=_[_0xf785('0x3d')](_0x322709[_0xf785('0x38')],qs[_0xf785('0x3e')](_0x492ce3[_0xf785('0x3a')][_0xf785('0x3e')]));_0x401d3b[_0xf785('0x3c')]=_0x401d3b[_0xf785('0x3c')]['length']?_0x401d3b[_0xf785('0x3c')]:_0x322709[_0xf785('0x38')];if(!_0x492ce3[_0xf785('0x3a')]['hasOwnProperty'](_0xf785('0x3f'))){_0x401d3b[_0xf785('0x26')]=qs[_0xf785('0x26')](_0x492ce3[_0xf785('0x3a')][_0xf785('0x26')]);_0x401d3b[_0xf785('0x24')]=qs[_0xf785('0x24')](_0x492ce3[_0xf785('0x3a')][_0xf785('0x24')]);}_0x401d3b[_0xf785('0x40')]=qs[_0xf785('0x41')](_0x492ce3[_0xf785('0x3a')][_0xf785('0x41')]);_0x401d3b[_0xf785('0x42')]=qs[_0xf785('0x3b')](_[_0xf785('0x43')](_0x492ce3['query'],_0x322709[_0xf785('0x3b')]),_0x58f4b7);if(_0x492ce3[_0xf785('0x3a')]['filter']){_0x401d3b['where']=_[_0xf785('0x44')](_0x401d3b['where'],{'$or':_[_0xf785('0x39')](_0x58f4b7,function(_0x46961d){if(_0x46961d['type']!==_0xf785('0x45')){var _0x1498a9={};_0x1498a9[_0x46961d[_0xf785('0x46')]]={'$like':'%'+_0x492ce3['query'][_0xf785('0x47')]+'%'};return _0x1498a9;}})});}_0x401d3b=_[_0xf785('0x44')]({},_0x401d3b,_0x492ce3[_0xf785('0x48')]);var _0xdb62e8={'where':_0x401d3b[_0xf785('0x42')]};return db[_0xf785('0x34')]['count'](_0xdb62e8)[_0xf785('0x2c')](function(_0x3d9bdb){_0x247fcb['count']=_0x3d9bdb;if(_0x492ce3[_0xf785('0x3a')]['includeAll']){_0x401d3b[_0xf785('0x49')]=[{'all':!![]}];}return db['FaxQueue'][_0xf785('0x4a')](_0x401d3b);})[_0xf785('0x2c')](function(_0x5c5bd8){_0x247fcb['rows']=_0x5c5bd8;return _0x247fcb;})[_0xf785('0x2c')](respondWithFilteredResult(_0x2fbd4a,_0x401d3b))[_0xf785('0x4b')](handleError(_0x2fbd4a,null));};exports[_0xf785('0x4c')]=function(_0xd99858,_0xf86d0){var _0x14cf4c={'raw':!![],'where':{'id':_0xd99858[_0xf785('0x4d')]['id']}},_0x306f20={};_0x306f20[_0xf785('0x38')]=_['keys'](db[_0xf785('0x34')][_0xf785('0x35')]);_0x306f20[_0xf785('0x3a')]=_['keys'](_0xd99858[_0xf785('0x3a')]);_0x306f20[_0xf785('0x3b')]=_['intersection'](_0x306f20[_0xf785('0x38')],_0x306f20[_0xf785('0x3a')]);_0x14cf4c[_0xf785('0x3c')]=_[_0xf785('0x3d')](_0x306f20[_0xf785('0x38')],qs['fields'](_0xd99858[_0xf785('0x3a')][_0xf785('0x3e')]));_0x14cf4c['attributes']=_0x14cf4c[_0xf785('0x3c')]['length']?_0x14cf4c[_0xf785('0x3c')]:_0x306f20[_0xf785('0x38')];if(_0xd99858[_0xf785('0x3a')][_0xf785('0x4e')]){_0x14cf4c[_0xf785('0x49')]=[{'all':!![]}];}_0x14cf4c=_[_0xf785('0x44')]({},_0x14cf4c,_0xd99858[_0xf785('0x48')]);return db[_0xf785('0x34')][_0xf785('0x4f')](_0x14cf4c)[_0xf785('0x2c')](handleEntityNotFound(_0xf86d0,null))[_0xf785('0x2c')](respondWithResult(_0xf86d0,null))['catch'](handleError(_0xf86d0,null));};exports[_0xf785('0x50')]=function(_0x2fd254,_0x55f677){return db[_0xf785('0x34')][_0xf785('0x50')](_0x2fd254[_0xf785('0x51')],{})['then'](function(_0x3d5981){var _0x3f3acd=_0x2fd254[_0xf785('0x52')]['get']({'plain':!![]});if(!_0x3f3acd)throw new Error(_0xf785('0x53'));if(_0x3f3acd[_0xf785('0x54')]==='user'){var _0x4027c1=_0x3d5981[_0xf785('0x2d')]({'plain':!![]});var _0x2ae855='FaxQueues';return db['UserProfileSection']['find']({'where':{'name':_0x2ae855,'userProfileId':_0x3f3acd['userProfileId']},'raw':!![]})[_0xf785('0x2c')](function(_0x546b53){if(_0x546b53&&_0x546b53[_0xf785('0x55')]===0x0){return db[_0xf785('0x56')][_0xf785('0x50')]({'name':_0x4027c1[_0xf785('0x46')],'resourceId':_0x4027c1['id'],'type':_0x546b53[_0xf785('0x46')],'sectionId':_0x546b53['id']},{})[_0xf785('0x2c')](function(){return _0x3d5981;});}else{return _0x3d5981;}})['catch'](function(_0x4dff77){logger[_0xf785('0x31')](_0xf785('0x57'),_0x4dff77);throw _0x4dff77;});}return _0x3d5981;})[_0xf785('0x2c')](respondWithResult(_0x55f677,0xc9))[_0xf785('0x4b')](handleError(_0x55f677,null));};exports[_0xf785('0x2b')]=function(_0x4807e1,_0x3a7e10){if(_0x4807e1[_0xf785('0x51')]['id']){delete _0x4807e1[_0xf785('0x51')]['id'];}return db[_0xf785('0x34')][_0xf785('0x4f')]({'where':{'id':_0x4807e1[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x3a7e10,null))[_0xf785('0x2c')](saveUpdates(_0x4807e1[_0xf785('0x51')],null))[_0xf785('0x2c')](respondWithResult(_0x3a7e10,null))[_0xf785('0x4b')](handleError(_0x3a7e10,null));};exports[_0xf785('0x2f')]=function(_0x2a69b0,_0x1e57ec){return db[_0xf785('0x34')][_0xf785('0x4f')]({'where':{'id':_0x2a69b0[_0xf785('0x4d')]['id']}})['then'](handleEntityNotFound(_0x1e57ec,null))[_0xf785('0x2c')](removeEntity(_0x1e57ec,null))[_0xf785('0x4b')](handleError(_0x1e57ec,null));};exports[_0xf785('0x58')]=function(_0x3d3ba5,_0x2ac6dc){return db[_0xf785('0x34')][_0xf785('0x58')]()['then'](respondWithResult(_0x2ac6dc,null))[_0xf785('0x4b')](handleError(_0x2ac6dc,null));};exports[_0xf785('0x59')]=function(_0x2bc609,_0xc75ec9,_0x291eab){var _0x4764d8={'raw':!![],'where':{}},_0x209b33={},_0x3579f3;return db[_0xf785('0x34')][_0xf785('0x5a')]({'where':{'id':_0x2bc609[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0xc75ec9,null))[_0xf785('0x2c')](function(_0x107794){if(_0x107794){_0x3579f3=_0x107794[_0xf785('0x2d')]({'plain':!![]});_0x209b33[_0xf785('0x38')]=_[_0xf785('0x5b')](db['UserFaxQueue']['rawAttributes']);_0x209b33[_0xf785('0x3a')]=_[_0xf785('0x5b')](_0x2bc609['query']);_0x209b33[_0xf785('0x3b')]=_[_0xf785('0x3d')](_0x209b33[_0xf785('0x38')],_0x209b33['query']);_0x4764d8['attributes']=_[_0xf785('0x3d')](_0x209b33[_0xf785('0x38')],qs[_0xf785('0x3e')](_0x2bc609[_0xf785('0x3a')][_0xf785('0x3e')]));_0x4764d8['attributes']=_0x4764d8[_0xf785('0x3c')][_0xf785('0x5c')]?_0x4764d8['attributes']:_0x209b33[_0xf785('0x38')];if(!_0x2bc609[_0xf785('0x3a')][_0xf785('0x5d')]('nolimit')){_0x4764d8[_0xf785('0x26')]=qs[_0xf785('0x26')](_0x2bc609['query'][_0xf785('0x26')]);_0x4764d8[_0xf785('0x24')]=qs[_0xf785('0x24')](_0x2bc609[_0xf785('0x3a')][_0xf785('0x24')]);}_0x4764d8['order']=qs['sort'](_0x2bc609['query'][_0xf785('0x41')]);_0x4764d8['where']=qs[_0xf785('0x3b')](_[_0xf785('0x43')](_0x2bc609[_0xf785('0x3a')],_0x209b33[_0xf785('0x3b')]));_0x4764d8['where']['FaxQueueId']=_0x107794['id'];if(_0x2bc609[_0xf785('0x3a')]['filter']){_0x4764d8['where']=_[_0xf785('0x44')](_0x4764d8[_0xf785('0x42')],{'$or':_[_0xf785('0x39')](_0x4764d8[_0xf785('0x3c')],function(_0x1bc1bc){var _0x3da02d={};_0x3da02d[_0x1bc1bc]={'$like':'%'+_0x2bc609['query'][_0xf785('0x47')]+'%'};return _0x3da02d;})});}_0x4764d8=_[_0xf785('0x44')]({},_0x4764d8,_0x2bc609[_0xf785('0x48')]);return db[_0xf785('0x5e')][_0xf785('0x4a')](_0x4764d8);}})[_0xf785('0x2c')](function(_0x4a3a06){if(_0x4a3a06){return db['User']['findAndCountAll']({'where':{'id':_[_0xf785('0x39')](_0x4a3a06,_0xf785('0x5f')),'role':_0xf785('0x60')},'attributes':['id',_0xf785('0x46'),_0xf785('0x61'),_0xf785('0x62'),_0xf785('0x63')]});}})['then'](function(_0x30c455){if(_0x30c455){return{'count':_0x30c455['count'],'rows':_['map'](_0x30c455[_0xf785('0x64')],function(_0x40b25c){return{'membername':_0x40b25c[_0xf785('0x46')],'UserId':_0x40b25c['id'],'queue_name':_0x3579f3[_0xf785('0x46')],'FaxQueueId':_0x3579f3['id'],'interface':util[_0xf785('0x65')]('%s/%s','SIP',_0x40b25c[_0xf785('0x46')]),'penalty':0x0,'paused':_0x40b25c['faxPause'],'createdAt':_0x40b25c[_0xf785('0x63')],'updatedAt':_0x40b25c[_0xf785('0x62')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xf785('0x2c')](respondWithFilteredResult(_0xc75ec9,_0x4764d8))['catch'](handleError(_0xc75ec9,null));};exports[_0xf785('0x66')]=function(_0x4331d3,_0x5b3739,_0x338780){var _0x16f774={};var _0x4e697c={};var _0x5d2761;var _0xfc1e4;return db[_0xf785('0x34')][_0xf785('0x5a')]({'where':{'id':_0x4331d3[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x5b3739,null))[_0xf785('0x2c')](function(_0x579f6b){if(_0x579f6b){_0x5d2761=_0x579f6b;_0x4e697c[_0xf785('0x38')]=_[_0xf785('0x5b')](db[_0xf785('0x67')][_0xf785('0x35')]);_0x4e697c[_0xf785('0x3a')]=_[_0xf785('0x5b')](_0x4331d3[_0xf785('0x3a')]);_0x4e697c[_0xf785('0x3b')]=_[_0xf785('0x3d')](_0x4e697c[_0xf785('0x38')],_0x4e697c['query']);_0x16f774[_0xf785('0x3c')]=_['intersection'](_0x4e697c[_0xf785('0x38')],qs[_0xf785('0x3e')](_0x4331d3[_0xf785('0x3a')][_0xf785('0x3e')]));_0x16f774[_0xf785('0x3c')]=_0x16f774['attributes']['length']?_0x16f774['attributes']:_0x4e697c['model'];_0x16f774[_0xf785('0x40')]=qs[_0xf785('0x41')](_0x4331d3[_0xf785('0x3a')]['sort']);_0x16f774[_0xf785('0x42')]=qs[_0xf785('0x3b')](_['pick'](_0x4331d3[_0xf785('0x3a')],_0x4e697c[_0xf785('0x3b')]));if(_0x4331d3[_0xf785('0x3a')][_0xf785('0x47')]){_0x16f774['where']=_[_0xf785('0x44')](_0x16f774[_0xf785('0x42')],{'$or':_['map'](_0x16f774[_0xf785('0x3c')],function(_0x2477c0){var _0x529fff={};_0x529fff[_0x2477c0]={'$like':'%'+_0x4331d3['query'][_0xf785('0x47')]+'%'};return _0x529fff;})});}_0x16f774=_[_0xf785('0x44')]({},_0x16f774,_0x4331d3[_0xf785('0x48')]);return _0x5d2761['getTeams'](_0x16f774);}})['then'](function(_0x1c0fe0){if(_0x1c0fe0){_0xfc1e4=_0x1c0fe0[_0xf785('0x5c')];if(!_0x4331d3[_0xf785('0x3a')]['hasOwnProperty'](_0xf785('0x3f'))){_0x16f774['limit']=qs['limit'](_0x4331d3[_0xf785('0x3a')][_0xf785('0x26')]);_0x16f774[_0xf785('0x24')]=qs[_0xf785('0x24')](_0x4331d3[_0xf785('0x3a')][_0xf785('0x24')]);}return _0x5d2761[_0xf785('0x66')](_0x16f774);}})[_0xf785('0x2c')](function(_0x4635b1){if(_0x4635b1){return _0x4635b1?{'count':_0xfc1e4,'rows':_0x4635b1}:null;}})[_0xf785('0x2c')](respondWithResult(_0x5b3739,null))['catch'](handleError(_0x5b3739,null));};exports[_0xf785('0x68')]=function(_0x53b24d,_0x52c283,_0x3f3c5a){var _0x18746e=_0x53b24d[_0xf785('0x51')][_0xf785('0x69')];return db[_0xf785('0x67')][_0xf785('0x4a')]({'where':{'id':_0x18746e},'attributes':['id'],'include':[{'model':db[_0xf785('0x6a')],'as':_0xf785('0x6b'),'attributes':['id',_0xf785('0x46'),_0xf785('0x6c'),_0xf785('0x6d'),_0xf785('0x6e')],'raw':!![]}]})['then'](function(_0xbb6ee4){if(_0xbb6ee4){var _0x533ee4=_[_0xf785('0x6f')](_0xbb6ee4,function(_0x5b5ed4){var _0x691ffa=_0x5b5ed4['get']({'plain':!![]});return _0x691ffa['Agents'];});return db[_0xf785('0x34')]['find']({'where':{'id':_0x53b24d['params']['id']}})[_0xf785('0x2c')](function(_0x4d5b36){return db[_0xf785('0x70')]['transaction'](function(_0x15bfa1){return _0x4d5b36['addTeams'](_0x18746e,{'transaction':_0x15bfa1})[_0xf785('0x2c')](function(){return BPromise[_0xf785('0x71')](_0x533ee4,function(_0x15aca4){return db[_0xf785('0x5e')]['findOrCreate']({'where':{'UserId':_0x15aca4['id'],'FaxQueueId':_0x53b24d[_0xf785('0x4d')]['id']},'transaction':_0x15bfa1});});})[_0xf785('0x2c')](function(){_0x533ee4['forEach'](function(_0x30539){socket[_0xf785('0x72')](_0xf785('0x73'),{'UserId':_0x30539['id'],'FaxQueueId':_0x4d5b36['id']});});});});});}})[_0xf785('0x2c')](respondWithStatusCode(_0x52c283,null))[_0xf785('0x4b')](handleError(_0x52c283,null));};exports[_0xf785('0x74')]=function(_0x457047,_0xfcec26,_0x42fa7c){return db[_0xf785('0x67')][_0xf785('0x4a')]({'where':{'id':_0x457047['query'][_0xf785('0x69')]},'attributes':['id'],'include':[{'model':db[_0xf785('0x6a')],'as':_0xf785('0x6b'),'attributes':['id'],'raw':!![]}]})[_0xf785('0x2c')](handleEntityNotFound(_0xfcec26,null))['then'](function(_0x428e30){var _0x48156c=_[_0xf785('0x39')](_0x428e30,'id');var _0x330b28=[];var _0x50f526=[];var _0x58189c=squel['select']();_0x58189c[_0xf785('0x75')](_0xf785('0x76'))[_0xf785('0x77')](_0xf785('0x78'),'tq')[_0xf785('0x79')]('user_has_teams','ut',_0xf785('0x7a'))['where']('FaxQueueId\x20=\x20?',_0x457047[_0xf785('0x4d')]['id']);for(var _0x1981e0=0x0;_0x1981e0<_0x428e30['length'];_0x1981e0+=0x1){let _0x42b787=_0x428e30[_0x1981e0];for(var _0x4838fd=0x0;_0x4838fd<_0x42b787[_0xf785('0x6b')][_0xf785('0x5c')];_0x4838fd+=0x1){let _0x1f7906=_0x42b787[_0xf785('0x6b')][_0x4838fd];var _0xe9ca2a=_0x58189c['clone']();_0xe9ca2a[_0xf785('0x42')]('ut.UserId\x20=\x20?',_0x1f7906['id']);_0x50f526[_0xf785('0x7b')](db[_0xf785('0x70')]['query'](_0xe9ca2a[_0xf785('0x7c')](),{'type':db['sequelize'][_0xf785('0x7d')][_0xf785('0x7e')]})['then'](function(_0x5f4012){if(_0x5f4012[_0xf785('0x5c')]===0x1){return _0x1f7906['id'];}else{var _0x2a235a=_[_0xf785('0x7f')](_[_0xf785('0x39')](_0x5f4012,_0xf785('0x80')),function(_0x551126){return _[_0xf785('0x81')](_0x48156c,_0x551126);});if(_0x2a235a){return _0x1f7906['id'];}}}));}}return BPromise[_0xf785('0x82')](_0x50f526)['then'](function(_0x25d0a2){_0x330b28=_(_0x330b28)[_0xf785('0x83')](_0x25d0a2)[_0xf785('0x84')]()[_0xf785('0x85')]();return db['FaxQueue']['find']({'where':{'id':_0x457047['params']['id']}})[_0xf785('0x2c')](function(_0x38446d){return db[_0xf785('0x70')][_0xf785('0x86')](function(_0x3d7a10){return _0x38446d[_0xf785('0x74')](_0x457047[_0xf785('0x3a')][_0xf785('0x69')],{'transaction':_0x3d7a10})['then'](function(){if(!_['isEmpty'](_0x330b28)){return _0x38446d[_0xf785('0x87')](_0x330b28,{'transaction':_0x3d7a10});}})[_0xf785('0x2c')](function(){_0x330b28[_0xf785('0x88')](function(_0x461fc4){socket[_0xf785('0x72')](_0xf785('0x89'),{'UserId':_0x461fc4,'FaxQueueId':_0x38446d['id']});});});});});});})['then'](respondWithStatusCode(_0xfcec26,null))[_0xf785('0x4b')](handleError(_0xfcec26,null));};exports[_0xf785('0x8a')]=function(_0x26fce6,_0x3862ea,_0x190385){return db['FaxQueue'][_0xf785('0x4f')]({'where':{'id':_0x26fce6['params']['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x3862ea,null))[_0xf785('0x2c')](function(_0x417864){if(_0x417864){return _0x417864['addAgents'](_0x26fce6['body']['ids'],_[_0xf785('0x8b')](_0x26fce6[_0xf785('0x51')],['ids','id'])||{})[_0xf785('0x8c')](function(_0x4a5b85){for(var _0x577b3b=0x0;_0x577b3b<_0x26fce6[_0xf785('0x51')][_0xf785('0x69')][_0xf785('0x5c')];_0x577b3b+=0x1){socket['emit'](_0xf785('0x73'),{'UserId':Number(_0x26fce6[_0xf785('0x51')][_0xf785('0x69')][_0x577b3b]),'FaxQueueId':Number(_0x26fce6[_0xf785('0x4d')]['id'])});}return _0x4a5b85;});}})[_0xf785('0x2c')](respondWithResult(_0x3862ea,null))['catch'](handleError(_0x3862ea,null));};exports[_0xf785('0x87')]=function(_0x2196a9,_0x404e92,_0x3ceb14){return db[_0xf785('0x34')][_0xf785('0x4f')]({'where':{'id':_0x2196a9[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x404e92,null))[_0xf785('0x2c')](function(_0x3e966f){if(_0x3e966f){return _0x3e966f[_0xf785('0x87')](_0x2196a9[_0xf785('0x3a')][_0xf785('0x69')])[_0xf785('0x2c')](function(){if(_[_0xf785('0x8d')](_0x2196a9[_0xf785('0x3a')]['ids'])){for(var _0x1039bb=0x0;_0x1039bb<_0x2196a9[_0xf785('0x3a')][_0xf785('0x69')][_0xf785('0x5c')];_0x1039bb+=0x1){socket[_0xf785('0x72')](_0xf785('0x89'),{'UserId':Number(_0x2196a9[_0xf785('0x3a')][_0xf785('0x69')][_0x1039bb]),'FaxQueueId':Number(_0x2196a9[_0xf785('0x4d')]['id'])});}}else{socket[_0xf785('0x72')](_0xf785('0x89'),{'UserId':Number(_0x2196a9[_0xf785('0x3a')][_0xf785('0x69')]),'FaxQueueId':Number(_0x2196a9['params']['id'])});}});}})[_0xf785('0x2c')](respondWithStatusCode(_0x404e92,null))[_0xf785('0x4b')](handleError(_0x404e92,null));};exports[_0xf785('0x8e')]=function(_0x3a64ae,_0x45e10c,_0x3cd6e6){var _0x4c95c9={};var _0x4f5cbe={};var _0x56d601;var _0xafb953;return db[_0xf785('0x34')]['findOne']({'where':{'id':_0x3a64ae[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x45e10c,null))[_0xf785('0x2c')](function(_0x482e3e){if(_0x482e3e){_0x56d601=_0x482e3e;_0x4f5cbe['model']=_['keys'](db[_0xf785('0x6a')][_0xf785('0x35')]);_0x4f5cbe[_0xf785('0x3a')]=_['keys'](_0x3a64ae['query']);_0x4f5cbe[_0xf785('0x3b')]=_[_0xf785('0x3d')](_0x4f5cbe[_0xf785('0x38')],_0x4f5cbe[_0xf785('0x3a')]);_0x4c95c9[_0xf785('0x3c')]=_[_0xf785('0x3d')](_0x4f5cbe[_0xf785('0x38')],qs['fields'](_0x3a64ae[_0xf785('0x3a')]['fields']));_0x4c95c9['attributes']=_0x4c95c9[_0xf785('0x3c')][_0xf785('0x5c')]?_0x4c95c9['attributes']:_0x4f5cbe[_0xf785('0x38')];_0x4c95c9[_0xf785('0x40')]=qs['sort'](_0x3a64ae['query']['sort']);_0x4c95c9[_0xf785('0x42')]=qs[_0xf785('0x3b')](_[_0xf785('0x43')](_0x3a64ae[_0xf785('0x3a')],_0x4f5cbe['filters']));if(_0x3a64ae['query'][_0xf785('0x47')]){_0x4c95c9[_0xf785('0x42')]=_[_0xf785('0x44')](_0x4c95c9[_0xf785('0x42')],{'$or':_[_0xf785('0x39')](_0x4c95c9['attributes'],function(_0x5b3d3e){var _0xc236f2={};_0xc236f2[_0x5b3d3e]={'$like':'%'+_0x3a64ae[_0xf785('0x3a')][_0xf785('0x47')]+'%'};return _0xc236f2;})});}_0x4c95c9=_[_0xf785('0x44')]({},_0x4c95c9,_0x3a64ae[_0xf785('0x48')]);return _0x56d601['getAgents'](_0x4c95c9);}})[_0xf785('0x2c')](function(_0x3b77b4){if(_0x3b77b4){_0xafb953=_0x3b77b4[_0xf785('0x5c')];if(!_0x3a64ae['query'][_0xf785('0x5d')](_0xf785('0x3f'))){_0x4c95c9[_0xf785('0x26')]=qs[_0xf785('0x26')](_0x3a64ae[_0xf785('0x3a')][_0xf785('0x26')]);_0x4c95c9[_0xf785('0x24')]=qs[_0xf785('0x24')](_0x3a64ae[_0xf785('0x3a')][_0xf785('0x24')]);}return _0x56d601[_0xf785('0x8e')](_0x4c95c9);}})[_0xf785('0x2c')](function(_0x432080){if(_0x432080){return _0x432080?{'count':_0xafb953,'rows':_0x432080}:null;}})['then'](respondWithResult(_0x45e10c,null))['catch'](handleError(_0x45e10c,null));};
\ No newline at end of file