Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 54e576e..eb858d0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x26f9=['map','FaxQueue','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','include','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','describe','findOne','UserFaxQueue','nolimit','order','FaxQueueId','User','UserId','agent','faxPause','updatedAt','format','%s/%s','SIP','createdAt','getTeams','addTeams','Agents','online','interface','flatMap','sequelize','each','findOrCreate','emit','Team','ids','select','field','tq.TeamId','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','includes','value','removeAgents','userFaxQueue:remove','addAgents','omit','spread','userFaxQueue:save','isArray','getAgents','html-pdf','eml-format','zip-dir','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','status','count','offset','limit','Content-Range','json','apply','reject','save','update','then','get','FaxQueues','UserProfileResource','end','name','send','index'];(function(_0x2f8c05,_0x551e3d){var _0x14cfde=function(_0x282d66){while(--_0x282d66){_0x2f8c05['push'](_0x2f8c05['shift']());}};_0x14cfde(++_0x551e3d);}(_0x26f9,0x16f));var _0x926f=function(_0x37c006,_0x1f647a){_0x37c006=_0x37c006-0x0;var _0x3f306e=_0x26f9[_0x37c006];return _0x3f306e;};'use strict';var pdf=require(_0x926f('0x0'));var emlformat=require(_0x926f('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x926f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x926f('0x3'));var BPromise=require(_0x926f('0x4'));var Mustache=require('mustache');var util=require(_0x926f('0x5'));var path=require(_0x926f('0x6'));var sox=require(_0x926f('0x7'));var csv=require(_0x926f('0x8'));var ejs=require(_0x926f('0x9'));var fs=require('fs');var _=require(_0x926f('0xa'));var squel=require(_0x926f('0xb'));var crypto=require(_0x926f('0xc'));var jsforce=require(_0x926f('0xd'));var deskjs=require(_0x926f('0xe'));var toCsv=require('to-csv');var querystring=require(_0x926f('0xf'));var Papa=require('papaparse');var Redis=require(_0x926f('0x10'));var authService=require(_0x926f('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x926f('0x12'));var hardwareService=require(_0x926f('0x13'));var logger=require(_0x926f('0x14'))(_0x926f('0x15'));var utils=require(_0x926f('0x16'));var config=require('../../config/environment');var db=require(_0x926f('0x17'))['db'];config[_0x926f('0x18')]=_[_0x926f('0x19')](config[_0x926f('0x18')],{'host':_0x926f('0x1a'),'port':0x18eb});var socket=require(_0x926f('0x1b'))(new Redis(config[_0x926f('0x18')]));require('./faxQueue.socket')['register'](socket);function respondWithStatusCode(_0x5e6fb1,_0x11197b){_0x11197b=_0x11197b||0xcc;return function(_0x3f88ea){if(_0x3f88ea){return _0x5e6fb1[_0x926f('0x1c')](_0x11197b);}return _0x5e6fb1[_0x926f('0x1d')](_0x11197b)['end']();};}function respondWithResult(_0x37035c,_0x385fad){_0x385fad=_0x385fad||0xc8;return function(_0x5812cb){if(_0x5812cb){return _0x37035c[_0x926f('0x1d')](_0x385fad)['json'](_0x5812cb);}};}function respondWithFilteredResult(_0x32522d,_0x5ad99f){return function(_0x5a8609){if(_0x5a8609){var _0x36ead3=_0x5a8609[_0x926f('0x1e')],_0xab29b3=_0x5ad99f[_0x926f('0x1f')],_0x4f25e3=_0x5ad99f['offset']+_0x5ad99f[_0x926f('0x20')],_0x3ed07d;if(_0x4f25e3>=_0x36ead3){_0x4f25e3=_0x36ead3;_0x3ed07d=0xc8;}else{_0x3ed07d=0xce;}_0x32522d[_0x926f('0x1d')](_0x3ed07d);return _0x32522d['set'](_0x926f('0x21'),_0xab29b3+'-'+_0x4f25e3+'/'+_0x36ead3)[_0x926f('0x22')](_0x5a8609);}return null;};}function patchUpdates(_0x56fef1){return function(_0x1cf218){try{jsonpatch[_0x926f('0x23')](_0x1cf218,_0x56fef1,!![]);}catch(_0x1561ae){return BPromise[_0x926f('0x24')](_0x1561ae);}return _0x1cf218[_0x926f('0x25')]();};}function saveUpdates(_0x3b7179,_0x412260){return function(_0x1694c3){if(_0x1694c3){return _0x1694c3[_0x926f('0x26')](_0x3b7179)[_0x926f('0x27')](function(_0x2be66b){return _0x2be66b;});}return null;};}function removeEntity(_0x4a93a4,_0x2d76eb){return function(_0x151f71){if(_0x151f71){return _0x151f71['destroy']()[_0x926f('0x27')](function(){var _0x84bccd=_0x151f71[_0x926f('0x28')]({'plain':!![]});var _0x26391d=_0x926f('0x29');return db[_0x926f('0x2a')]['destroy']({'where':{'type':_0x26391d,'resourceId':_0x84bccd['id']}})[_0x926f('0x27')](function(){return _0x151f71;});})['then'](function(){_0x4a93a4[_0x926f('0x1d')](0xcc)[_0x926f('0x2b')]();});}};}function handleEntityNotFound(_0x2a8fff,_0x3fdfdd){return function(_0x5def30){if(!_0x5def30){_0x2a8fff[_0x926f('0x1c')](0x194);}return _0x5def30;};}function handleError(_0x5a4d40,_0xc88ea4){_0xc88ea4=_0xc88ea4||0x1f4;return function(_0x2556ce){logger['error'](_0x2556ce['stack']);if(_0x2556ce[_0x926f('0x2c')]){delete _0x2556ce[_0x926f('0x2c')];}_0x5a4d40['status'](_0xc88ea4)[_0x926f('0x2d')](_0x2556ce);};}exports[_0x926f('0x2e')]=function(_0x558a62,_0x5cae09){var _0x39966d={},_0x1d61d6={},_0x155e7e={'count':0x0,'rows':[]};var _0x5db97b=_[_0x926f('0x2f')](db[_0x926f('0x30')][_0x926f('0x31')],function(_0x553d93){return{'name':_0x553d93[_0x926f('0x32')],'type':_0x553d93[_0x926f('0x33')][_0x926f('0x34')]};});_0x1d61d6[_0x926f('0x35')]=_[_0x926f('0x2f')](_0x5db97b,_0x926f('0x2c'));_0x1d61d6['query']=_[_0x926f('0x36')](_0x558a62[_0x926f('0x37')]);_0x1d61d6[_0x926f('0x38')]=_[_0x926f('0x39')](_0x1d61d6['model'],_0x1d61d6[_0x926f('0x37')]);_0x39966d[_0x926f('0x3a')]=_[_0x926f('0x39')](_0x1d61d6[_0x926f('0x35')],qs[_0x926f('0x3b')](_0x558a62[_0x926f('0x37')][_0x926f('0x3b')]));_0x39966d[_0x926f('0x3a')]=_0x39966d[_0x926f('0x3a')][_0x926f('0x3c')]?_0x39966d[_0x926f('0x3a')]:_0x1d61d6['model'];if(!_0x558a62[_0x926f('0x37')][_0x926f('0x3d')]('nolimit')){_0x39966d[_0x926f('0x20')]=qs[_0x926f('0x20')](_0x558a62[_0x926f('0x37')][_0x926f('0x20')]);_0x39966d[_0x926f('0x1f')]=qs[_0x926f('0x1f')](_0x558a62[_0x926f('0x37')][_0x926f('0x1f')]);}_0x39966d['order']=qs[_0x926f('0x3e')](_0x558a62['query'][_0x926f('0x3e')]);_0x39966d[_0x926f('0x3f')]=qs[_0x926f('0x38')](_[_0x926f('0x40')](_0x558a62[_0x926f('0x37')],_0x1d61d6[_0x926f('0x38')]));if(_0x558a62[_0x926f('0x37')][_0x926f('0x41')]){_0x39966d[_0x926f('0x3f')]=_[_0x926f('0x42')](_0x39966d[_0x926f('0x3f')],{'$or':_[_0x926f('0x2f')](_0x5db97b,function(_0x15b298){if(_0x15b298[_0x926f('0x33')]!==_0x926f('0x43')){var _0x486840={};_0x486840[_0x15b298[_0x926f('0x2c')]]={'$like':'%'+_0x558a62[_0x926f('0x37')][_0x926f('0x41')]+'%'};return _0x486840;}})});}_0x39966d=_[_0x926f('0x42')]({},_0x39966d,_0x558a62[_0x926f('0x44')]);var _0x1c542d={'where':_0x39966d[_0x926f('0x3f')]};return db[_0x926f('0x30')]['count'](_0x1c542d)[_0x926f('0x27')](function(_0x16a7c9){_0x155e7e[_0x926f('0x1e')]=_0x16a7c9;if(_0x558a62[_0x926f('0x37')][_0x926f('0x45')]){_0x39966d['include']=[{'all':!![]}];}return db[_0x926f('0x30')][_0x926f('0x46')](_0x39966d);})[_0x926f('0x27')](function(_0x39cb80){_0x155e7e[_0x926f('0x47')]=_0x39cb80;return _0x155e7e;})['then'](respondWithFilteredResult(_0x5cae09,_0x39966d))[_0x926f('0x48')](handleError(_0x5cae09,null));};exports[_0x926f('0x49')]=function(_0x10e03f,_0x156a3e){var _0x1a7949={'raw':!![],'where':{'id':_0x10e03f[_0x926f('0x4a')]['id']}},_0x48c0db={};_0x48c0db['model']=_[_0x926f('0x36')](db[_0x926f('0x30')][_0x926f('0x31')]);_0x48c0db[_0x926f('0x37')]=_[_0x926f('0x36')](_0x10e03f[_0x926f('0x37')]);_0x48c0db[_0x926f('0x38')]=_['intersection'](_0x48c0db[_0x926f('0x35')],_0x48c0db[_0x926f('0x37')]);_0x1a7949[_0x926f('0x3a')]=_[_0x926f('0x39')](_0x48c0db[_0x926f('0x35')],qs[_0x926f('0x3b')](_0x10e03f[_0x926f('0x37')][_0x926f('0x3b')]));_0x1a7949[_0x926f('0x3a')]=_0x1a7949[_0x926f('0x3a')]['length']?_0x1a7949[_0x926f('0x3a')]:_0x48c0db['model'];if(_0x10e03f[_0x926f('0x37')][_0x926f('0x45')]){_0x1a7949[_0x926f('0x4b')]=[{'all':!![]}];}_0x1a7949=_[_0x926f('0x42')]({},_0x1a7949,_0x10e03f[_0x926f('0x44')]);return db['FaxQueue'][_0x926f('0x4c')](_0x1a7949)[_0x926f('0x27')](handleEntityNotFound(_0x156a3e,null))[_0x926f('0x27')](respondWithResult(_0x156a3e,null))[_0x926f('0x48')](handleError(_0x156a3e,null));};exports[_0x926f('0x4d')]=function(_0x5c9434,_0x380087){return db[_0x926f('0x30')][_0x926f('0x4d')](_0x5c9434[_0x926f('0x4e')],{})[_0x926f('0x27')](function(_0x40e7c2){var _0x47d007=_0x5c9434[_0x926f('0x4f')]['get']({'plain':!![]});if(!_0x47d007)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x47d007[_0x926f('0x50')]===_0x926f('0x4f')){var _0x2865ea=_0x40e7c2[_0x926f('0x28')]({'plain':!![]});var _0x30de10='FaxQueues';return db[_0x926f('0x51')][_0x926f('0x4c')]({'where':{'name':_0x30de10,'userProfileId':_0x47d007[_0x926f('0x52')]},'raw':!![]})['then'](function(_0x2c8487){if(_0x2c8487&&_0x2c8487[_0x926f('0x53')]===0x0){return db[_0x926f('0x2a')][_0x926f('0x4d')]({'name':_0x2865ea['name'],'resourceId':_0x2865ea['id'],'type':_0x2c8487[_0x926f('0x2c')],'sectionId':_0x2c8487['id']},{})['then'](function(){return _0x40e7c2;});}else{return _0x40e7c2;}})[_0x926f('0x48')](function(_0x5ab042){logger[_0x926f('0x54')](_0x926f('0x55'),_0x5ab042);throw _0x5ab042;});}return _0x40e7c2;})['then'](respondWithResult(_0x380087,0xc9))[_0x926f('0x48')](handleError(_0x380087,null));};exports[_0x926f('0x26')]=function(_0x430f97,_0x13d416){if(_0x430f97[_0x926f('0x4e')]['id']){delete _0x430f97['body']['id'];}return db[_0x926f('0x30')][_0x926f('0x4c')]({'where':{'id':_0x430f97[_0x926f('0x4a')]['id']}})[_0x926f('0x27')](handleEntityNotFound(_0x13d416,null))[_0x926f('0x27')](saveUpdates(_0x430f97[_0x926f('0x4e')],null))[_0x926f('0x27')](respondWithResult(_0x13d416,null))[_0x926f('0x48')](handleError(_0x13d416,null));};exports[_0x926f('0x56')]=function(_0x14940e,_0x205014){return db[_0x926f('0x30')][_0x926f('0x4c')]({'where':{'id':_0x14940e[_0x926f('0x4a')]['id']}})[_0x926f('0x27')](handleEntityNotFound(_0x205014,null))[_0x926f('0x27')](removeEntity(_0x205014,null))[_0x926f('0x48')](handleError(_0x205014,null));};exports[_0x926f('0x57')]=function(_0x25f95b,_0xc74fb2){return db[_0x926f('0x30')][_0x926f('0x57')]()['then'](respondWithResult(_0xc74fb2,null))[_0x926f('0x48')](handleError(_0xc74fb2,null));};exports['getMembers']=function(_0x4351fd,_0x39c37c,_0x152823){var _0x390031={'raw':!![],'where':{}},_0x8d90eb={},_0x153cda;return db[_0x926f('0x30')][_0x926f('0x58')]({'where':{'id':_0x4351fd[_0x926f('0x4a')]['id']}})[_0x926f('0x27')](handleEntityNotFound(_0x39c37c,null))[_0x926f('0x27')](function(_0x36cff1){if(_0x36cff1){_0x153cda=_0x36cff1[_0x926f('0x28')]({'plain':!![]});_0x8d90eb[_0x926f('0x35')]=_[_0x926f('0x36')](db[_0x926f('0x59')][_0x926f('0x31')]);_0x8d90eb[_0x926f('0x37')]=_[_0x926f('0x36')](_0x4351fd[_0x926f('0x37')]);_0x8d90eb[_0x926f('0x38')]=_[_0x926f('0x39')](_0x8d90eb[_0x926f('0x35')],_0x8d90eb[_0x926f('0x37')]);_0x390031[_0x926f('0x3a')]=_['intersection'](_0x8d90eb['model'],qs['fields'](_0x4351fd[_0x926f('0x37')][_0x926f('0x3b')]));_0x390031[_0x926f('0x3a')]=_0x390031[_0x926f('0x3a')][_0x926f('0x3c')]?_0x390031[_0x926f('0x3a')]:_0x8d90eb['model'];if(!_0x4351fd[_0x926f('0x37')][_0x926f('0x3d')](_0x926f('0x5a'))){_0x390031[_0x926f('0x20')]=qs[_0x926f('0x20')](_0x4351fd[_0x926f('0x37')][_0x926f('0x20')]);_0x390031[_0x926f('0x1f')]=qs['offset'](_0x4351fd[_0x926f('0x37')][_0x926f('0x1f')]);}_0x390031[_0x926f('0x5b')]=qs[_0x926f('0x3e')](_0x4351fd[_0x926f('0x37')]['sort']);_0x390031[_0x926f('0x3f')]=qs[_0x926f('0x38')](_[_0x926f('0x40')](_0x4351fd['query'],_0x8d90eb[_0x926f('0x38')]));_0x390031[_0x926f('0x3f')][_0x926f('0x5c')]=_0x36cff1['id'];if(_0x4351fd[_0x926f('0x37')][_0x926f('0x41')]){_0x390031[_0x926f('0x3f')]=_['merge'](_0x390031[_0x926f('0x3f')],{'$or':_[_0x926f('0x2f')](_0x390031[_0x926f('0x3a')],function(_0x209966){var _0x913989={};_0x913989[_0x209966]={'$like':'%'+_0x4351fd[_0x926f('0x37')][_0x926f('0x41')]+'%'};return _0x913989;})});}_0x390031=_[_0x926f('0x42')]({},_0x390031,_0x4351fd[_0x926f('0x44')]);return db[_0x926f('0x59')][_0x926f('0x46')](_0x390031);}})[_0x926f('0x27')](function(_0x19e51f){if(_0x19e51f){return db[_0x926f('0x5d')]['findAndCountAll']({'where':{'id':_[_0x926f('0x2f')](_0x19e51f,_0x926f('0x5e')),'role':_0x926f('0x5f')},'attributes':['id','name',_0x926f('0x60'),_0x926f('0x61'),'createdAt']});}})[_0x926f('0x27')](function(_0x4dc63f){if(_0x4dc63f){return{'count':_0x4dc63f[_0x926f('0x1e')],'rows':_[_0x926f('0x2f')](_0x4dc63f[_0x926f('0x47')],function(_0x19c317){return{'membername':_0x19c317['name'],'UserId':_0x19c317['id'],'queue_name':_0x153cda['name'],'FaxQueueId':_0x153cda['id'],'interface':util[_0x926f('0x62')](_0x926f('0x63'),_0x926f('0x64'),_0x19c317['name']),'penalty':0x0,'paused':_0x19c317[_0x926f('0x60')],'createdAt':_0x19c317[_0x926f('0x65')],'updatedAt':_0x19c317['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x39c37c,_0x390031))[_0x926f('0x48')](handleError(_0x39c37c,null));};exports[_0x926f('0x66')]=function(_0x3d75a4,_0x2f4c58,_0x326f20){var _0xcf703c={};var _0xc31092={};var _0x36935d;var _0x37860a;return db[_0x926f('0x30')][_0x926f('0x58')]({'where':{'id':_0x3d75a4[_0x926f('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2f4c58,null))[_0x926f('0x27')](function(_0x1534b3){if(_0x1534b3){_0x36935d=_0x1534b3;_0xc31092['model']=_[_0x926f('0x36')](db['Team']['rawAttributes']);_0xc31092['query']=_[_0x926f('0x36')](_0x3d75a4[_0x926f('0x37')]);_0xc31092[_0x926f('0x38')]=_['intersection'](_0xc31092['model'],_0xc31092[_0x926f('0x37')]);_0xcf703c[_0x926f('0x3a')]=_[_0x926f('0x39')](_0xc31092[_0x926f('0x35')],qs[_0x926f('0x3b')](_0x3d75a4[_0x926f('0x37')][_0x926f('0x3b')]));_0xcf703c['attributes']=_0xcf703c['attributes']['length']?_0xcf703c[_0x926f('0x3a')]:_0xc31092[_0x926f('0x35')];_0xcf703c[_0x926f('0x5b')]=qs['sort'](_0x3d75a4[_0x926f('0x37')]['sort']);_0xcf703c[_0x926f('0x3f')]=qs[_0x926f('0x38')](_['pick'](_0x3d75a4['query'],_0xc31092[_0x926f('0x38')]));if(_0x3d75a4['query'][_0x926f('0x41')]){_0xcf703c[_0x926f('0x3f')]=_[_0x926f('0x42')](_0xcf703c[_0x926f('0x3f')],{'$or':_[_0x926f('0x2f')](_0xcf703c[_0x926f('0x3a')],function(_0xc1766){var _0x4bf477={};_0x4bf477[_0xc1766]={'$like':'%'+_0x3d75a4['query'][_0x926f('0x41')]+'%'};return _0x4bf477;})});}_0xcf703c=_[_0x926f('0x42')]({},_0xcf703c,_0x3d75a4[_0x926f('0x44')]);return _0x36935d[_0x926f('0x66')](_0xcf703c);}})['then'](function(_0x3a408b){if(_0x3a408b){_0x37860a=_0x3a408b['length'];if(!_0x3d75a4[_0x926f('0x37')]['hasOwnProperty'](_0x926f('0x5a'))){_0xcf703c[_0x926f('0x20')]=qs[_0x926f('0x20')](_0x3d75a4[_0x926f('0x37')][_0x926f('0x20')]);_0xcf703c['offset']=qs[_0x926f('0x1f')](_0x3d75a4[_0x926f('0x37')][_0x926f('0x1f')]);}return _0x36935d[_0x926f('0x66')](_0xcf703c);}})['then'](function(_0x4cefe2){if(_0x4cefe2){return _0x4cefe2?{'count':_0x37860a,'rows':_0x4cefe2}:null;}})[_0x926f('0x27')](respondWithResult(_0x2f4c58,null))[_0x926f('0x48')](handleError(_0x2f4c58,null));};exports[_0x926f('0x67')]=function(_0x3d05c8,_0x237f63,_0x2541c9){var _0x5eb506=_0x3d05c8[_0x926f('0x4e')]['ids'];return db['Team']['findAll']({'where':{'id':_0x5eb506},'attributes':['id'],'include':[{'model':db[_0x926f('0x5d')],'as':_0x926f('0x68'),'attributes':['id',_0x926f('0x2c'),_0x926f('0x69'),'voicePause',_0x926f('0x6a')],'raw':!![]}]})[_0x926f('0x27')](function(_0x41c196){if(_0x41c196){var _0x2a0c4d=_[_0x926f('0x6b')](_0x41c196,function(_0x5bc24d){var _0x2a4135=_0x5bc24d[_0x926f('0x28')]({'plain':!![]});return _0x2a4135[_0x926f('0x68')];});return db['FaxQueue']['find']({'where':{'id':_0x3d05c8['params']['id']}})['then'](function(_0x5ee2f5){return db[_0x926f('0x6c')]['transaction'](function(_0xc1326c){return _0x5ee2f5[_0x926f('0x67')](_0x5eb506,{'transaction':_0xc1326c})[_0x926f('0x27')](function(){return BPromise[_0x926f('0x6d')](_0x2a0c4d,function(_0x36193e){return db[_0x926f('0x59')][_0x926f('0x6e')]({'where':{'UserId':_0x36193e['id'],'FaxQueueId':_0x3d05c8['params']['id']},'transaction':_0xc1326c});});})[_0x926f('0x27')](function(){_0x2a0c4d['forEach'](function(_0x3d3b29){socket[_0x926f('0x6f')]('userFaxQueue:save',{'UserId':_0x3d3b29['id'],'FaxQueueId':_0x5ee2f5['id']});});});});});}})[_0x926f('0x27')](respondWithStatusCode(_0x237f63,null))[_0x926f('0x48')](handleError(_0x237f63,null));};exports['removeTeams']=function(_0x2d9568,_0x27a9e0,_0x1039e5){return db[_0x926f('0x70')][_0x926f('0x46')]({'where':{'id':_0x2d9568[_0x926f('0x37')][_0x926f('0x71')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x926f('0x68'),'attributes':['id'],'raw':!![]}]})[_0x926f('0x27')](handleEntityNotFound(_0x27a9e0,null))[_0x926f('0x27')](function(_0x116a53){var _0x447840=_[_0x926f('0x2f')](_0x116a53,'id');var _0x3d395d=[];var _0x5f4818=[];var _0x240f76=squel[_0x926f('0x72')]();_0x240f76[_0x926f('0x73')](_0x926f('0x74'))[_0x926f('0x75')]('team_has_fax_queues','tq')[_0x926f('0x76')](_0x926f('0x77'),'ut',_0x926f('0x78'))[_0x926f('0x3f')]('FaxQueueId\x20=\x20?',_0x2d9568[_0x926f('0x4a')]['id']);for(var _0x438fa9=0x0;_0x438fa9<_0x116a53[_0x926f('0x3c')];_0x438fa9+=0x1){let _0x581f33=_0x116a53[_0x438fa9];for(var _0x11724b=0x0;_0x11724b<_0x581f33[_0x926f('0x68')][_0x926f('0x3c')];_0x11724b+=0x1){let _0x2b0925=_0x581f33[_0x926f('0x68')][_0x11724b];var _0x2f9ea9=_0x240f76[_0x926f('0x79')]();_0x2f9ea9[_0x926f('0x3f')](_0x926f('0x7a'),_0x2b0925['id']);_0x5f4818['push'](db['sequelize']['query'](_0x2f9ea9[_0x926f('0x7b')](),{'type':db[_0x926f('0x6c')][_0x926f('0x7c')][_0x926f('0x7d')]})[_0x926f('0x27')](function(_0x10e42c){if(_0x10e42c['length']===0x1){return _0x2b0925['id'];}else{var _0x1a9be5=_[_0x926f('0x7e')](_[_0x926f('0x2f')](_0x10e42c,_0x926f('0x7f')),function(_0x326829){return _[_0x926f('0x80')](_0x447840,_0x326829);});if(_0x1a9be5){return _0x2b0925['id'];}}}));}}return BPromise['all'](_0x5f4818)[_0x926f('0x27')](function(_0x1e9c02){_0x3d395d=_(_0x3d395d)['union'](_0x1e9c02)['compact']()[_0x926f('0x81')]();return db['FaxQueue'][_0x926f('0x4c')]({'where':{'id':_0x2d9568[_0x926f('0x4a')]['id']}})['then'](function(_0x444382){return db[_0x926f('0x6c')]['transaction'](function(_0x515192){return _0x444382['removeTeams'](_0x2d9568[_0x926f('0x37')][_0x926f('0x71')],{'transaction':_0x515192})['then'](function(){if(!_['isEmpty'](_0x3d395d)){return _0x444382[_0x926f('0x82')](_0x3d395d,{'transaction':_0x515192});}})[_0x926f('0x27')](function(){_0x3d395d['forEach'](function(_0x5e4bc8){socket[_0x926f('0x6f')](_0x926f('0x83'),{'UserId':_0x5e4bc8,'FaxQueueId':_0x444382['id']});});});});});});})[_0x926f('0x27')](respondWithStatusCode(_0x27a9e0,null))[_0x926f('0x48')](handleError(_0x27a9e0,null));};exports[_0x926f('0x84')]=function(_0x182157,_0x49429c,_0x557ed1){return db['FaxQueue'][_0x926f('0x4c')]({'where':{'id':_0x182157[_0x926f('0x4a')]['id']}})[_0x926f('0x27')](handleEntityNotFound(_0x49429c,null))[_0x926f('0x27')](function(_0x28242){if(_0x28242){return _0x28242['addAgents'](_0x182157[_0x926f('0x4e')]['ids'],_[_0x926f('0x85')](_0x182157[_0x926f('0x4e')],[_0x926f('0x71'),'id'])||{})[_0x926f('0x86')](function(_0x329e1e){for(var _0x5f19a6=0x0;_0x5f19a6<_0x182157[_0x926f('0x4e')][_0x926f('0x71')][_0x926f('0x3c')];_0x5f19a6+=0x1){socket[_0x926f('0x6f')](_0x926f('0x87'),{'UserId':_0x182157[_0x926f('0x4e')][_0x926f('0x71')][_0x5f19a6],'FaxQueueId':_0x182157[_0x926f('0x4a')]['id']});}return _0x329e1e;});}})[_0x926f('0x27')](respondWithResult(_0x49429c,null))[_0x926f('0x48')](handleError(_0x49429c,null));};exports[_0x926f('0x82')]=function(_0x3f9cd4,_0x1a33a9,_0x14a2ba){return db['FaxQueue'][_0x926f('0x4c')]({'where':{'id':_0x3f9cd4['params']['id']}})['then'](handleEntityNotFound(_0x1a33a9,null))['then'](function(_0x3de941){if(_0x3de941){return _0x3de941[_0x926f('0x82')](_0x3f9cd4[_0x926f('0x37')]['ids'])[_0x926f('0x27')](function(){if(_[_0x926f('0x88')](_0x3f9cd4['query'][_0x926f('0x71')])){for(var _0x15d1dc=0x0;_0x15d1dc<_0x3f9cd4[_0x926f('0x37')][_0x926f('0x71')][_0x926f('0x3c')];_0x15d1dc+=0x1){socket[_0x926f('0x6f')](_0x926f('0x83'),{'UserId':Number(_0x3f9cd4[_0x926f('0x37')]['ids'][_0x15d1dc]),'FaxQueueId':Number(_0x3f9cd4['params']['id'])});}}else{socket['emit'](_0x926f('0x83'),{'UserId':Number(_0x3f9cd4['query']['ids']),'FaxQueueId':Number(_0x3f9cd4[_0x926f('0x4a')]['id'])});}});}})[_0x926f('0x27')](respondWithStatusCode(_0x1a33a9,null))[_0x926f('0x48')](handleError(_0x1a33a9,null));};exports['getAgents']=function(_0x35b402,_0x138ed0,_0xab9d12){var _0x1378b4={};var _0x144011={};var _0x37a294;var _0x3fab00;return db[_0x926f('0x30')][_0x926f('0x58')]({'where':{'id':_0x35b402[_0x926f('0x4a')]['id']}})[_0x926f('0x27')](handleEntityNotFound(_0x138ed0,null))[_0x926f('0x27')](function(_0x18093c){if(_0x18093c){_0x37a294=_0x18093c;_0x144011[_0x926f('0x35')]=_[_0x926f('0x36')](db['User'][_0x926f('0x31')]);_0x144011[_0x926f('0x37')]=_[_0x926f('0x36')](_0x35b402[_0x926f('0x37')]);_0x144011['filters']=_[_0x926f('0x39')](_0x144011[_0x926f('0x35')],_0x144011['query']);_0x1378b4['attributes']=_['intersection'](_0x144011[_0x926f('0x35')],qs['fields'](_0x35b402[_0x926f('0x37')][_0x926f('0x3b')]));_0x1378b4['attributes']=_0x1378b4['attributes'][_0x926f('0x3c')]?_0x1378b4[_0x926f('0x3a')]:_0x144011[_0x926f('0x35')];_0x1378b4[_0x926f('0x5b')]=qs['sort'](_0x35b402[_0x926f('0x37')][_0x926f('0x3e')]);_0x1378b4[_0x926f('0x3f')]=qs[_0x926f('0x38')](_['pick'](_0x35b402[_0x926f('0x37')],_0x144011[_0x926f('0x38')]));if(_0x35b402[_0x926f('0x37')][_0x926f('0x41')]){_0x1378b4[_0x926f('0x3f')]=_['merge'](_0x1378b4[_0x926f('0x3f')],{'$or':_[_0x926f('0x2f')](_0x1378b4['attributes'],function(_0x59eddc){var _0xfa52b1={};_0xfa52b1[_0x59eddc]={'$like':'%'+_0x35b402['query'][_0x926f('0x41')]+'%'};return _0xfa52b1;})});}_0x1378b4=_[_0x926f('0x42')]({},_0x1378b4,_0x35b402[_0x926f('0x44')]);return _0x37a294[_0x926f('0x89')](_0x1378b4);}})[_0x926f('0x27')](function(_0x4cfb12){if(_0x4cfb12){_0x3fab00=_0x4cfb12['length'];if(!_0x35b402[_0x926f('0x37')]['hasOwnProperty'](_0x926f('0x5a'))){_0x1378b4[_0x926f('0x20')]=qs['limit'](_0x35b402['query'][_0x926f('0x20')]);_0x1378b4[_0x926f('0x1f')]=qs[_0x926f('0x1f')](_0x35b402[_0x926f('0x37')]['offset']);}return _0x37a294[_0x926f('0x89')](_0x1378b4);}})['then'](function(_0x15d26a){if(_0x15d26a){return _0x15d26a?{'count':_0x3fab00,'rows':_0x15d26a}:null;}})[_0x926f('0x27')](respondWithResult(_0x138ed0,null))[_0x926f('0x48')](handleError(_0x138ed0,null));};
\ No newline at end of file
+var _0x0453=['querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxQueue.socket','register','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','get','FaxQueues','sendStatus','stack','name','send','index','map','FaxQueue','rawAttributes','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','include','catch','show','params','keys','includeAll','find','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','autoAssociation','UserProfileResource','create','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserFaxQueue','pick','FaxQueueId','User','findAndCountAll','UserId','agent','faxPause','updatedAt','createdAt','rows','format','%s/%s','SIP','getTeams','Team','addTeams','ids','online','voicePause','flatMap','Agents','transaction','each','findOrCreate','forEach','emit','userFaxQueue:save','removeTeams','findAll','select','field','tq.TeamId','from','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','SELECT','every','includes','all','union','compact','value','isEmpty','userFaxQueue:remove','addAgents','spread','removeAgents','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','fs-extra','lodash','squel','crypto','jsforce','to-csv'];(function(_0x5de188,_0x39024f){var _0x1d3f95=function(_0x16f64e){while(--_0x16f64e){_0x5de188['push'](_0x5de188['shift']());}};_0x1d3f95(++_0x39024f);}(_0x0453,0x11e));var _0x3045=function(_0x5748e5,_0x10dbd4){_0x5748e5=_0x5748e5-0x0;var _0x57ce15=_0x0453[_0x5748e5];return _0x57ce15;};'use strict';var emlformat=require(_0x3045('0x0'));var rimraf=require(_0x3045('0x1'));var zipdir=require(_0x3045('0x2'));var jsonpatch=require(_0x3045('0x3'));var rp=require(_0x3045('0x4'));var moment=require(_0x3045('0x5'));var BPromise=require(_0x3045('0x6'));var Mustache=require(_0x3045('0x7'));var util=require(_0x3045('0x8'));var path=require('path');var sox=require(_0x3045('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x3045('0xa'));var _=require(_0x3045('0xb'));var squel=require(_0x3045('0xc'));var crypto=require(_0x3045('0xd'));var jsforce=require(_0x3045('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x3045('0xf'));var querystring=require(_0x3045('0x10'));var Papa=require(_0x3045('0x11'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x3045('0x12'));var as=require(_0x3045('0x13'));var hardwareService=require(_0x3045('0x14'));var logger=require(_0x3045('0x15'))(_0x3045('0x16'));var utils=require(_0x3045('0x17'));var config=require(_0x3045('0x18'));var licenseUtil=require(_0x3045('0x19'));var db=require(_0x3045('0x1a'))['db'];config[_0x3045('0x1b')]=_['defaults'](config[_0x3045('0x1b')],{'host':_0x3045('0x1c'),'port':0x18eb});var socket=require(_0x3045('0x1d'))(new Redis(config[_0x3045('0x1b')]));require(_0x3045('0x1e'))[_0x3045('0x1f')](socket);function respondWithStatusCode(_0x4d7800,_0x19c28d){_0x19c28d=_0x19c28d||0xcc;return function(_0x5664da){if(_0x5664da){return _0x4d7800['sendStatus'](_0x19c28d);}return _0x4d7800[_0x3045('0x20')](_0x19c28d)[_0x3045('0x21')]();};}function respondWithResult(_0x1a152b,_0x490f3a){_0x490f3a=_0x490f3a||0xc8;return function(_0x5ac3d5){if(_0x5ac3d5){return _0x1a152b[_0x3045('0x20')](_0x490f3a)[_0x3045('0x22')](_0x5ac3d5);}};}function respondWithFilteredResult(_0x892bb4,_0x3ae904){return function(_0x389fe4){if(_0x389fe4){var _0x3e21cd=typeof _0x3ae904[_0x3045('0x23')]===_0x3045('0x24')&&typeof _0x3ae904['limit']===_0x3045('0x24');var _0x24fd19=_0x389fe4[_0x3045('0x25')];var _0x5c59b1=_0x3e21cd?0x0:_0x3ae904[_0x3045('0x23')];var _0x22969e=_0x3e21cd?_0x389fe4[_0x3045('0x25')]:_0x3ae904[_0x3045('0x23')]+_0x3ae904[_0x3045('0x26')];var _0x517dae;if(_0x22969e>=_0x24fd19){_0x22969e=_0x24fd19;_0x517dae=0xc8;}else{_0x517dae=0xce;}_0x892bb4[_0x3045('0x20')](_0x517dae);return _0x892bb4[_0x3045('0x27')](_0x3045('0x28'),_0x5c59b1+'-'+_0x22969e+'/'+_0x24fd19)['json'](_0x389fe4);}return null;};}function patchUpdates(_0x158f72){return function(_0x4cf71b){try{jsonpatch[_0x3045('0x29')](_0x4cf71b,_0x158f72,!![]);}catch(_0x54e1f7){return BPromise[_0x3045('0x2a')](_0x54e1f7);}return _0x4cf71b[_0x3045('0x2b')]();};}function saveUpdates(_0x4f42c5,_0x61d8c1){return function(_0x514d1a){if(_0x514d1a){return _0x514d1a[_0x3045('0x2c')](_0x4f42c5)[_0x3045('0x2d')](function(_0x464723){return _0x464723;});}return null;};}function removeEntity(_0x51e627,_0x3dadeb){return function(_0x119380){if(_0x119380){return _0x119380[_0x3045('0x2e')]()[_0x3045('0x2d')](function(){var _0x3577d7=_0x119380[_0x3045('0x2f')]({'plain':!![]});var _0x57a648=_0x3045('0x30');return db['UserProfileResource'][_0x3045('0x2e')]({'where':{'type':_0x57a648,'resourceId':_0x3577d7['id']}})[_0x3045('0x2d')](function(){return _0x119380;});})[_0x3045('0x2d')](function(){_0x51e627['status'](0xcc)[_0x3045('0x21')]();});}};}function handleEntityNotFound(_0x436092,_0x4fffa0){return function(_0x15f573){if(!_0x15f573){_0x436092[_0x3045('0x31')](0x194);}return _0x15f573;};}function handleError(_0x23955f,_0x38d8d5){_0x38d8d5=_0x38d8d5||0x1f4;return function(_0x3efe8b){logger['error'](_0x3efe8b[_0x3045('0x32')]);if(_0x3efe8b[_0x3045('0x33')]){delete _0x3efe8b['name'];}_0x23955f['status'](_0x38d8d5)[_0x3045('0x34')](_0x3efe8b);};}exports[_0x3045('0x35')]=function(_0x2daa59,_0x3beb71){var _0x51044b={},_0x485bf7={},_0x10a730={'count':0x0,'rows':[]};var _0x2acdf0=_[_0x3045('0x36')](db[_0x3045('0x37')][_0x3045('0x38')],function(_0x552d41){return{'name':_0x552d41['fieldName'],'type':_0x552d41['type'][_0x3045('0x39')]};});_0x485bf7[_0x3045('0x3a')]=_[_0x3045('0x36')](_0x2acdf0,'name');_0x485bf7[_0x3045('0x3b')]=_['keys'](_0x2daa59[_0x3045('0x3b')]);_0x485bf7[_0x3045('0x3c')]=_['intersection'](_0x485bf7['model'],_0x485bf7[_0x3045('0x3b')]);_0x51044b['attributes']=_[_0x3045('0x3d')](_0x485bf7['model'],qs['fields'](_0x2daa59[_0x3045('0x3b')][_0x3045('0x3e')]));_0x51044b['attributes']=_0x51044b[_0x3045('0x3f')][_0x3045('0x40')]?_0x51044b[_0x3045('0x3f')]:_0x485bf7['model'];if(!_0x2daa59[_0x3045('0x3b')][_0x3045('0x41')](_0x3045('0x42'))){_0x51044b['limit']=qs[_0x3045('0x26')](_0x2daa59[_0x3045('0x3b')][_0x3045('0x26')]);_0x51044b[_0x3045('0x23')]=qs[_0x3045('0x23')](_0x2daa59[_0x3045('0x3b')][_0x3045('0x23')]);}_0x51044b[_0x3045('0x43')]=qs[_0x3045('0x44')](_0x2daa59[_0x3045('0x3b')]['sort']);_0x51044b[_0x3045('0x45')]=qs[_0x3045('0x3c')](_['pick'](_0x2daa59[_0x3045('0x3b')],_0x485bf7[_0x3045('0x3c')]),_0x2acdf0);if(_0x2daa59[_0x3045('0x3b')][_0x3045('0x46')]){_0x51044b[_0x3045('0x45')]=_[_0x3045('0x47')](_0x51044b[_0x3045('0x45')],{'$or':_[_0x3045('0x36')](_0x2acdf0,function(_0x37204e){if(_0x37204e['type']!==_0x3045('0x48')){var _0x2afddf={};_0x2afddf[_0x37204e[_0x3045('0x33')]]={'$like':'%'+_0x2daa59[_0x3045('0x3b')][_0x3045('0x46')]+'%'};return _0x2afddf;}})});}_0x51044b=_['merge']({},_0x51044b,_0x2daa59[_0x3045('0x49')]);var _0x3e63fe={'where':_0x51044b['where']};return db[_0x3045('0x37')]['count'](_0x3e63fe)['then'](function(_0x545b68){_0x10a730['count']=_0x545b68;if(_0x2daa59[_0x3045('0x3b')]['includeAll']){_0x51044b[_0x3045('0x4a')]=[{'all':!![]}];}return db[_0x3045('0x37')]['findAll'](_0x51044b);})['then'](function(_0x1320c1){_0x10a730['rows']=_0x1320c1;return _0x10a730;})[_0x3045('0x2d')](respondWithFilteredResult(_0x3beb71,_0x51044b))[_0x3045('0x4b')](handleError(_0x3beb71,null));};exports[_0x3045('0x4c')]=function(_0x41bb6b,_0x346c77){var _0x39480c={'raw':!![],'where':{'id':_0x41bb6b[_0x3045('0x4d')]['id']}},_0x4e3cd6={};_0x4e3cd6[_0x3045('0x3a')]=_[_0x3045('0x4e')](db[_0x3045('0x37')][_0x3045('0x38')]);_0x4e3cd6[_0x3045('0x3b')]=_[_0x3045('0x4e')](_0x41bb6b[_0x3045('0x3b')]);_0x4e3cd6[_0x3045('0x3c')]=_['intersection'](_0x4e3cd6[_0x3045('0x3a')],_0x4e3cd6['query']);_0x39480c['attributes']=_[_0x3045('0x3d')](_0x4e3cd6[_0x3045('0x3a')],qs[_0x3045('0x3e')](_0x41bb6b[_0x3045('0x3b')][_0x3045('0x3e')]));_0x39480c[_0x3045('0x3f')]=_0x39480c['attributes'][_0x3045('0x40')]?_0x39480c[_0x3045('0x3f')]:_0x4e3cd6['model'];if(_0x41bb6b['query'][_0x3045('0x4f')]){_0x39480c[_0x3045('0x4a')]=[{'all':!![]}];}_0x39480c=_[_0x3045('0x47')]({},_0x39480c,_0x41bb6b[_0x3045('0x49')]);return db['FaxQueue'][_0x3045('0x50')](_0x39480c)[_0x3045('0x2d')](handleEntityNotFound(_0x346c77,null))[_0x3045('0x2d')](respondWithResult(_0x346c77,null))['catch'](handleError(_0x346c77,null));};exports['create']=function(_0x1b6dab,_0x40b64e){return db[_0x3045('0x37')]['create'](_0x1b6dab[_0x3045('0x51')],{})['then'](function(_0x3dc357){var _0xd48477=_0x1b6dab['user'][_0x3045('0x2f')]({'plain':!![]});if(!_0xd48477)throw new Error(_0x3045('0x52'));if(_0xd48477['role']===_0x3045('0x53')){var _0x47b129=_0x3dc357[_0x3045('0x2f')]({'plain':!![]});var _0x502ef0=_0x3045('0x30');return db[_0x3045('0x54')][_0x3045('0x50')]({'where':{'name':_0x502ef0,'userProfileId':_0xd48477['userProfileId']},'raw':!![]})[_0x3045('0x2d')](function(_0x76eec2){if(_0x76eec2&&_0x76eec2[_0x3045('0x55')]===0x0){return db[_0x3045('0x56')][_0x3045('0x57')]({'name':_0x47b129[_0x3045('0x33')],'resourceId':_0x47b129['id'],'type':_0x76eec2[_0x3045('0x33')],'sectionId':_0x76eec2['id']},{})['then'](function(){return _0x3dc357;});}else{return _0x3dc357;}})[_0x3045('0x4b')](function(_0x1b3099){logger[_0x3045('0x58')](_0x3045('0x59'),_0x1b3099);throw _0x1b3099;});}return _0x3dc357;})['then'](respondWithResult(_0x40b64e,0xc9))[_0x3045('0x4b')](handleError(_0x40b64e,null));};exports[_0x3045('0x2c')]=function(_0x36fedf,_0x17e8f1){if(_0x36fedf[_0x3045('0x51')]['id']){delete _0x36fedf[_0x3045('0x51')]['id'];}return db['FaxQueue'][_0x3045('0x50')]({'where':{'id':_0x36fedf['params']['id']}})[_0x3045('0x2d')](handleEntityNotFound(_0x17e8f1,null))[_0x3045('0x2d')](saveUpdates(_0x36fedf[_0x3045('0x51')],null))[_0x3045('0x2d')](respondWithResult(_0x17e8f1,null))['catch'](handleError(_0x17e8f1,null));};exports[_0x3045('0x2e')]=function(_0x4b5600,_0x13ec3c){return db[_0x3045('0x37')][_0x3045('0x50')]({'where':{'id':_0x4b5600[_0x3045('0x4d')]['id']}})[_0x3045('0x2d')](handleEntityNotFound(_0x13ec3c,null))[_0x3045('0x2d')](removeEntity(_0x13ec3c,null))[_0x3045('0x4b')](handleError(_0x13ec3c,null));};exports[_0x3045('0x5a')]=function(_0x53b788,_0x1d947b){return db[_0x3045('0x37')]['describe']()[_0x3045('0x2d')](respondWithResult(_0x1d947b,null))['catch'](handleError(_0x1d947b,null));};exports[_0x3045('0x5b')]=function(_0x2b1535,_0x48458d,_0x17a9d0){var _0x218db={'raw':!![],'where':{}},_0x338c89={},_0x459ab5;return db[_0x3045('0x37')][_0x3045('0x5c')]({'where':{'id':_0x2b1535[_0x3045('0x4d')]['id']}})[_0x3045('0x2d')](handleEntityNotFound(_0x48458d,null))['then'](function(_0x38d20b){if(_0x38d20b){_0x459ab5=_0x38d20b[_0x3045('0x2f')]({'plain':!![]});_0x338c89[_0x3045('0x3a')]=_[_0x3045('0x4e')](db[_0x3045('0x5d')][_0x3045('0x38')]);_0x338c89[_0x3045('0x3b')]=_['keys'](_0x2b1535[_0x3045('0x3b')]);_0x338c89[_0x3045('0x3c')]=_[_0x3045('0x3d')](_0x338c89[_0x3045('0x3a')],_0x338c89['query']);_0x218db[_0x3045('0x3f')]=_[_0x3045('0x3d')](_0x338c89[_0x3045('0x3a')],qs['fields'](_0x2b1535[_0x3045('0x3b')]['fields']));_0x218db[_0x3045('0x3f')]=_0x218db[_0x3045('0x3f')][_0x3045('0x40')]?_0x218db[_0x3045('0x3f')]:_0x338c89[_0x3045('0x3a')];if(!_0x2b1535[_0x3045('0x3b')][_0x3045('0x41')](_0x3045('0x42'))){_0x218db['limit']=qs['limit'](_0x2b1535[_0x3045('0x3b')][_0x3045('0x26')]);_0x218db[_0x3045('0x23')]=qs[_0x3045('0x23')](_0x2b1535[_0x3045('0x3b')][_0x3045('0x23')]);}_0x218db[_0x3045('0x43')]=qs[_0x3045('0x44')](_0x2b1535[_0x3045('0x3b')][_0x3045('0x44')]);_0x218db[_0x3045('0x45')]=qs[_0x3045('0x3c')](_[_0x3045('0x5e')](_0x2b1535[_0x3045('0x3b')],_0x338c89['filters']));_0x218db[_0x3045('0x45')][_0x3045('0x5f')]=_0x38d20b['id'];if(_0x2b1535[_0x3045('0x3b')]['filter']){_0x218db['where']=_[_0x3045('0x47')](_0x218db[_0x3045('0x45')],{'$or':_[_0x3045('0x36')](_0x218db[_0x3045('0x3f')],function(_0x3d1ee1){var _0x39dbde={};_0x39dbde[_0x3d1ee1]={'$like':'%'+_0x2b1535[_0x3045('0x3b')][_0x3045('0x46')]+'%'};return _0x39dbde;})});}_0x218db=_[_0x3045('0x47')]({},_0x218db,_0x2b1535['options']);return db[_0x3045('0x5d')]['findAll'](_0x218db);}})[_0x3045('0x2d')](function(_0x224545){if(_0x224545){return db[_0x3045('0x60')][_0x3045('0x61')]({'where':{'id':_['map'](_0x224545,_0x3045('0x62')),'role':_0x3045('0x63')},'attributes':['id',_0x3045('0x33'),_0x3045('0x64'),_0x3045('0x65'),_0x3045('0x66')]});}})[_0x3045('0x2d')](function(_0x1215c1){if(_0x1215c1){return{'count':_0x1215c1[_0x3045('0x25')],'rows':_[_0x3045('0x36')](_0x1215c1[_0x3045('0x67')],function(_0x42bd6b){return{'membername':_0x42bd6b[_0x3045('0x33')],'UserId':_0x42bd6b['id'],'queue_name':_0x459ab5[_0x3045('0x33')],'FaxQueueId':_0x459ab5['id'],'interface':util[_0x3045('0x68')](_0x3045('0x69'),_0x3045('0x6a'),_0x42bd6b[_0x3045('0x33')]),'penalty':0x0,'paused':_0x42bd6b['faxPause'],'createdAt':_0x42bd6b[_0x3045('0x66')],'updatedAt':_0x42bd6b['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x3045('0x2d')](respondWithFilteredResult(_0x48458d,_0x218db))[_0x3045('0x4b')](handleError(_0x48458d,null));};exports[_0x3045('0x6b')]=function(_0x3a4d6c,_0x3c0736,_0x2118b3){var _0x912ba={};var _0x369585={};var _0x1354c8;var _0x54eb73;return db[_0x3045('0x37')][_0x3045('0x5c')]({'where':{'id':_0x3a4d6c[_0x3045('0x4d')]['id']}})[_0x3045('0x2d')](handleEntityNotFound(_0x3c0736,null))[_0x3045('0x2d')](function(_0x311795){if(_0x311795){_0x1354c8=_0x311795;_0x369585[_0x3045('0x3a')]=_['keys'](db[_0x3045('0x6c')][_0x3045('0x38')]);_0x369585[_0x3045('0x3b')]=_[_0x3045('0x4e')](_0x3a4d6c[_0x3045('0x3b')]);_0x369585[_0x3045('0x3c')]=_[_0x3045('0x3d')](_0x369585['model'],_0x369585[_0x3045('0x3b')]);_0x912ba[_0x3045('0x3f')]=_['intersection'](_0x369585[_0x3045('0x3a')],qs[_0x3045('0x3e')](_0x3a4d6c[_0x3045('0x3b')][_0x3045('0x3e')]));_0x912ba[_0x3045('0x3f')]=_0x912ba[_0x3045('0x3f')][_0x3045('0x40')]?_0x912ba[_0x3045('0x3f')]:_0x369585['model'];_0x912ba['order']=qs[_0x3045('0x44')](_0x3a4d6c['query']['sort']);_0x912ba[_0x3045('0x45')]=qs[_0x3045('0x3c')](_['pick'](_0x3a4d6c[_0x3045('0x3b')],_0x369585[_0x3045('0x3c')]));if(_0x3a4d6c['query']['filter']){_0x912ba[_0x3045('0x45')]=_[_0x3045('0x47')](_0x912ba['where'],{'$or':_[_0x3045('0x36')](_0x912ba['attributes'],function(_0x4484a8){var _0xc0556f={};_0xc0556f[_0x4484a8]={'$like':'%'+_0x3a4d6c['query'][_0x3045('0x46')]+'%'};return _0xc0556f;})});}_0x912ba=_['merge']({},_0x912ba,_0x3a4d6c[_0x3045('0x49')]);return _0x1354c8[_0x3045('0x6b')](_0x912ba);}})[_0x3045('0x2d')](function(_0x2300b9){if(_0x2300b9){_0x54eb73=_0x2300b9[_0x3045('0x40')];if(!_0x3a4d6c[_0x3045('0x3b')][_0x3045('0x41')]('nolimit')){_0x912ba['limit']=qs[_0x3045('0x26')](_0x3a4d6c['query'][_0x3045('0x26')]);_0x912ba[_0x3045('0x23')]=qs[_0x3045('0x23')](_0x3a4d6c['query'][_0x3045('0x23')]);}return _0x1354c8[_0x3045('0x6b')](_0x912ba);}})[_0x3045('0x2d')](function(_0x11d808){if(_0x11d808){return _0x11d808?{'count':_0x54eb73,'rows':_0x11d808}:null;}})[_0x3045('0x2d')](respondWithResult(_0x3c0736,null))[_0x3045('0x4b')](handleError(_0x3c0736,null));};exports[_0x3045('0x6d')]=function(_0x45df4b,_0x2af9a5,_0x2bb301){var _0x312b11=_0x45df4b[_0x3045('0x51')][_0x3045('0x6e')];return db[_0x3045('0x6c')]['findAll']({'where':{'id':_0x312b11},'attributes':['id'],'include':[{'model':db[_0x3045('0x60')],'as':'Agents','attributes':['id',_0x3045('0x33'),_0x3045('0x6f'),_0x3045('0x70'),'interface'],'raw':!![]}]})[_0x3045('0x2d')](function(_0x77658b){if(_0x77658b){var _0x5c675e=_[_0x3045('0x71')](_0x77658b,function(_0x34bd4e){var _0x16c258=_0x34bd4e[_0x3045('0x2f')]({'plain':!![]});return _0x16c258[_0x3045('0x72')];});return db['FaxQueue'][_0x3045('0x50')]({'where':{'id':_0x45df4b['params']['id']}})[_0x3045('0x2d')](function(_0x12f3eb){return db['sequelize'][_0x3045('0x73')](function(_0x38b742){return _0x12f3eb[_0x3045('0x6d')](_0x312b11,{'transaction':_0x38b742})[_0x3045('0x2d')](function(){return BPromise[_0x3045('0x74')](_0x5c675e,function(_0x3081f9){return db[_0x3045('0x5d')][_0x3045('0x75')]({'where':{'UserId':_0x3081f9['id'],'FaxQueueId':_0x45df4b[_0x3045('0x4d')]['id']},'transaction':_0x38b742});});})[_0x3045('0x2d')](function(){_0x5c675e[_0x3045('0x76')](function(_0x496e2c){socket[_0x3045('0x77')](_0x3045('0x78'),{'UserId':_0x496e2c['id'],'FaxQueueId':_0x12f3eb['id']});});});});});}})[_0x3045('0x2d')](respondWithStatusCode(_0x2af9a5,null))['catch'](handleError(_0x2af9a5,null));};exports[_0x3045('0x79')]=function(_0x15557c,_0xc7304f,_0x59233c){return db['Team'][_0x3045('0x7a')]({'where':{'id':_0x15557c[_0x3045('0x3b')][_0x3045('0x6e')]},'attributes':['id'],'include':[{'model':db[_0x3045('0x60')],'as':_0x3045('0x72'),'attributes':['id'],'raw':!![]}]})[_0x3045('0x2d')](handleEntityNotFound(_0xc7304f,null))[_0x3045('0x2d')](function(_0x14de27){var _0x4163b2=_['map'](_0x14de27,'id');var _0x1150e2=[];var _0x22592b=[];var _0x3e5af2=squel[_0x3045('0x7b')]();_0x3e5af2[_0x3045('0x7c')](_0x3045('0x7d'))[_0x3045('0x7e')]('team_has_fax_queues','tq')[_0x3045('0x7f')](_0x3045('0x80'),'ut',_0x3045('0x81'))[_0x3045('0x45')](_0x3045('0x82'),_0x15557c[_0x3045('0x4d')]['id']);for(var _0x313b5f=0x0;_0x313b5f<_0x14de27[_0x3045('0x40')];_0x313b5f+=0x1){let _0x1ece71=_0x14de27[_0x313b5f];for(var _0x9ddd5d=0x0;_0x9ddd5d<_0x1ece71[_0x3045('0x72')][_0x3045('0x40')];_0x9ddd5d+=0x1){let _0x398785=_0x1ece71[_0x3045('0x72')][_0x9ddd5d];var _0x3c4409=_0x3e5af2[_0x3045('0x83')]();_0x3c4409[_0x3045('0x45')](_0x3045('0x84'),_0x398785['id']);_0x22592b[_0x3045('0x85')](db[_0x3045('0x86')][_0x3045('0x3b')](_0x3c4409[_0x3045('0x87')](),{'type':db[_0x3045('0x86')][_0x3045('0x88')][_0x3045('0x89')]})[_0x3045('0x2d')](function(_0x10fa91){if(_0x10fa91['length']===0x1){return _0x398785['id'];}else{var _0x14b195=_[_0x3045('0x8a')](_[_0x3045('0x36')](_0x10fa91,'TeamId'),function(_0x33e5ca){return _[_0x3045('0x8b')](_0x4163b2,_0x33e5ca);});if(_0x14b195){return _0x398785['id'];}}}));}}return BPromise[_0x3045('0x8c')](_0x22592b)[_0x3045('0x2d')](function(_0xbac28b){_0x1150e2=_(_0x1150e2)[_0x3045('0x8d')](_0xbac28b)[_0x3045('0x8e')]()[_0x3045('0x8f')]();return db['FaxQueue']['find']({'where':{'id':_0x15557c[_0x3045('0x4d')]['id']}})[_0x3045('0x2d')](function(_0x19e792){return db['sequelize']['transaction'](function(_0x51557c){return _0x19e792['removeTeams'](_0x15557c[_0x3045('0x3b')][_0x3045('0x6e')],{'transaction':_0x51557c})[_0x3045('0x2d')](function(){if(!_[_0x3045('0x90')](_0x1150e2)){return _0x19e792['removeAgents'](_0x1150e2,{'transaction':_0x51557c});}})[_0x3045('0x2d')](function(){_0x1150e2[_0x3045('0x76')](function(_0x4ea0ea){socket[_0x3045('0x77')](_0x3045('0x91'),{'UserId':_0x4ea0ea,'FaxQueueId':_0x19e792['id']});});});});});});})[_0x3045('0x2d')](respondWithStatusCode(_0xc7304f,null))['catch'](handleError(_0xc7304f,null));};exports[_0x3045('0x92')]=function(_0x4fbd88,_0x403bb3,_0x1ee02c){return db['FaxQueue'][_0x3045('0x50')]({'where':{'id':_0x4fbd88[_0x3045('0x4d')]['id']}})['then'](handleEntityNotFound(_0x403bb3,null))[_0x3045('0x2d')](function(_0x23bed2){if(_0x23bed2){return _0x23bed2[_0x3045('0x92')](_0x4fbd88[_0x3045('0x51')]['ids'],_['omit'](_0x4fbd88[_0x3045('0x51')],['ids','id'])||{})[_0x3045('0x93')](function(_0xd355f9){for(var _0x1af06d=0x0;_0x1af06d<_0x4fbd88[_0x3045('0x51')]['ids'][_0x3045('0x40')];_0x1af06d+=0x1){socket['emit'](_0x3045('0x78'),{'UserId':Number(_0x4fbd88[_0x3045('0x51')][_0x3045('0x6e')][_0x1af06d]),'FaxQueueId':Number(_0x4fbd88['params']['id'])});}return _0xd355f9;});}})[_0x3045('0x2d')](respondWithResult(_0x403bb3,null))[_0x3045('0x4b')](handleError(_0x403bb3,null));};exports[_0x3045('0x94')]=function(_0x41f84f,_0x452724,_0x156715){return db['FaxQueue'][_0x3045('0x50')]({'where':{'id':_0x41f84f[_0x3045('0x4d')]['id']}})[_0x3045('0x2d')](handleEntityNotFound(_0x452724,null))[_0x3045('0x2d')](function(_0x227dca){if(_0x227dca){return _0x227dca[_0x3045('0x94')](_0x41f84f['query'][_0x3045('0x6e')])[_0x3045('0x2d')](function(){if(_[_0x3045('0x95')](_0x41f84f[_0x3045('0x3b')][_0x3045('0x6e')])){for(var _0x1f01f4=0x0;_0x1f01f4<_0x41f84f[_0x3045('0x3b')][_0x3045('0x6e')]['length'];_0x1f01f4+=0x1){socket[_0x3045('0x77')](_0x3045('0x91'),{'UserId':Number(_0x41f84f[_0x3045('0x3b')][_0x3045('0x6e')][_0x1f01f4]),'FaxQueueId':Number(_0x41f84f[_0x3045('0x4d')]['id'])});}}else{socket['emit'](_0x3045('0x91'),{'UserId':Number(_0x41f84f[_0x3045('0x3b')][_0x3045('0x6e')]),'FaxQueueId':Number(_0x41f84f[_0x3045('0x4d')]['id'])});}});}})[_0x3045('0x2d')](respondWithStatusCode(_0x452724,null))[_0x3045('0x4b')](handleError(_0x452724,null));};exports[_0x3045('0x96')]=function(_0x47f05f,_0x323d93,_0x50ba51){var _0x53f114={};var _0x4c6905={};var _0x36789e;var _0x4b08ab;return db[_0x3045('0x37')]['findOne']({'where':{'id':_0x47f05f['params']['id']}})[_0x3045('0x2d')](handleEntityNotFound(_0x323d93,null))[_0x3045('0x2d')](function(_0x2a7d06){if(_0x2a7d06){_0x36789e=_0x2a7d06;_0x4c6905['model']=_['keys'](db[_0x3045('0x60')][_0x3045('0x38')]);_0x4c6905[_0x3045('0x3b')]=_['keys'](_0x47f05f[_0x3045('0x3b')]);_0x4c6905[_0x3045('0x3c')]=_[_0x3045('0x3d')](_0x4c6905[_0x3045('0x3a')],_0x4c6905[_0x3045('0x3b')]);_0x53f114['attributes']=_[_0x3045('0x3d')](_0x4c6905[_0x3045('0x3a')],qs[_0x3045('0x3e')](_0x47f05f[_0x3045('0x3b')][_0x3045('0x3e')]));_0x53f114[_0x3045('0x3f')]=_0x53f114[_0x3045('0x3f')]['length']?_0x53f114[_0x3045('0x3f')]:_0x4c6905[_0x3045('0x3a')];_0x53f114[_0x3045('0x43')]=qs[_0x3045('0x44')](_0x47f05f[_0x3045('0x3b')][_0x3045('0x44')]);_0x53f114[_0x3045('0x45')]=qs[_0x3045('0x3c')](_[_0x3045('0x5e')](_0x47f05f['query'],_0x4c6905[_0x3045('0x3c')]));if(_0x47f05f[_0x3045('0x3b')][_0x3045('0x46')]){_0x53f114[_0x3045('0x45')]=_[_0x3045('0x47')](_0x53f114[_0x3045('0x45')],{'$or':_[_0x3045('0x36')](_0x53f114[_0x3045('0x3f')],function(_0x45d8e2){var _0x22d54a={};_0x22d54a[_0x45d8e2]={'$like':'%'+_0x47f05f[_0x3045('0x3b')]['filter']+'%'};return _0x22d54a;})});}_0x53f114=_[_0x3045('0x47')]({},_0x53f114,_0x47f05f['options']);return _0x36789e[_0x3045('0x96')](_0x53f114);}})[_0x3045('0x2d')](function(_0x4cd87d){if(_0x4cd87d){_0x4b08ab=_0x4cd87d[_0x3045('0x40')];if(!_0x47f05f[_0x3045('0x3b')][_0x3045('0x41')]('nolimit')){_0x53f114[_0x3045('0x26')]=qs[_0x3045('0x26')](_0x47f05f[_0x3045('0x3b')][_0x3045('0x26')]);_0x53f114[_0x3045('0x23')]=qs[_0x3045('0x23')](_0x47f05f[_0x3045('0x3b')][_0x3045('0x23')]);}return _0x36789e[_0x3045('0x96')](_0x53f114);}})[_0x3045('0x2d')](function(_0x25cd6a){if(_0x25cd6a){return _0x25cd6a?{'count':_0x4b08ab,'rows':_0x25cd6a}:null;}})['then'](respondWithResult(_0x323d93,null))['catch'](handleError(_0x323d93,null));};
\ No newline at end of file