Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index d825759..d5fe9c1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb0a6=['SIP','getTeams','addTeams','ids','Team','Agents','online','voicePause','interface','flatMap','transaction','each','findOrCreate','forEach','emit','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','FaxQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','sequelize','QueryTypes','SELECT','every','all','union','compact','value','addAgents','omit','spread','removeAgents','isArray','userFaxQueue:remove','getAgents','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','status','undefined','offset','set','Content-Range','json','apply','reject','update','then','destroy','get','FaxQueues','UserProfileResource','end','error','stack','name','index','map','FaxQueue','fieldName','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','limit','order','sort','where','pick','merge','VIRTUAL','filter','options','count','includeAll','findAll','rows','catch','rawAttributes','include','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','findOne','UserFaxQueue','nolimit','FaxQueueId','User','UserId','agent','faxPause','updatedAt','createdAt','format','%s/%s'];(function(_0x2943c0,_0x34f534){var _0x41d810=function(_0x34cb41){while(--_0x34cb41){_0x2943c0['push'](_0x2943c0['shift']());}};_0x41d810(++_0x34f534);}(_0xb0a6,0x1c4));var _0x6b0a=function(_0x436c7e,_0x4fcc2d){_0x436c7e=_0x436c7e-0x0;var _0x534256=_0xb0a6[_0x436c7e];return _0x534256;};'use strict';var emlformat=require(_0x6b0a('0x0'));var rimraf=require(_0x6b0a('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x6b0a('0x2'));var rp=require(_0x6b0a('0x3'));var moment=require(_0x6b0a('0x4'));var BPromise=require(_0x6b0a('0x5'));var Mustache=require('mustache');var util=require(_0x6b0a('0x6'));var path=require(_0x6b0a('0x7'));var sox=require(_0x6b0a('0x8'));var csv=require(_0x6b0a('0x9'));var ejs=require(_0x6b0a('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x6b0a('0xb'));var squel=require('squel');var crypto=require(_0x6b0a('0xc'));var jsforce=require(_0x6b0a('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x6b0a('0x9'));var querystring=require(_0x6b0a('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x6b0a('0xf'));var qs=require(_0x6b0a('0x10'));var as=require(_0x6b0a('0x11'));var hardwareService=require(_0x6b0a('0x12'));var logger=require(_0x6b0a('0x13'))(_0x6b0a('0x14'));var utils=require(_0x6b0a('0x15'));var config=require(_0x6b0a('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x6b0a('0x17'))['db'];config[_0x6b0a('0x18')]=_[_0x6b0a('0x19')](config[_0x6b0a('0x18')],{'host':_0x6b0a('0x1a'),'port':0x18eb});var socket=require(_0x6b0a('0x1b'))(new Redis(config[_0x6b0a('0x18')]));require('./faxQueue.socket')['register'](socket);function respondWithStatusCode(_0x3f441c,_0xd4567d){_0xd4567d=_0xd4567d||0xcc;return function(_0x21a597){if(_0x21a597){return _0x3f441c[_0x6b0a('0x1c')](_0xd4567d);}return _0x3f441c[_0x6b0a('0x1d')](_0xd4567d)['end']();};}function respondWithResult(_0x2040f5,_0x3a3eee){_0x3a3eee=_0x3a3eee||0xc8;return function(_0x5f2642){if(_0x5f2642){return _0x2040f5['status'](_0x3a3eee)['json'](_0x5f2642);}};}function respondWithFilteredResult(_0x920ca6,_0x2d2137){return function(_0x1a6f8a){if(_0x1a6f8a){var _0x1d13ac=typeof _0x2d2137['offset']===_0x6b0a('0x1e')&&typeof _0x2d2137['limit']===_0x6b0a('0x1e');var _0x20f4fd=_0x1a6f8a['count'];var _0x3baa5d=_0x1d13ac?0x0:_0x2d2137[_0x6b0a('0x1f')];var _0x4c8be5=_0x1d13ac?_0x1a6f8a['count']:_0x2d2137[_0x6b0a('0x1f')]+_0x2d2137['limit'];var _0x5474e2;if(_0x4c8be5>=_0x20f4fd){_0x4c8be5=_0x20f4fd;_0x5474e2=0xc8;}else{_0x5474e2=0xce;}_0x920ca6['status'](_0x5474e2);return _0x920ca6[_0x6b0a('0x20')](_0x6b0a('0x21'),_0x3baa5d+'-'+_0x4c8be5+'/'+_0x20f4fd)[_0x6b0a('0x22')](_0x1a6f8a);}return null;};}function patchUpdates(_0xd20e9c){return function(_0x464755){try{jsonpatch[_0x6b0a('0x23')](_0x464755,_0xd20e9c,!![]);}catch(_0x3704e8){return BPromise[_0x6b0a('0x24')](_0x3704e8);}return _0x464755['save']();};}function saveUpdates(_0x40db7c,_0x159c3c){return function(_0x1b3ad3){if(_0x1b3ad3){return _0x1b3ad3[_0x6b0a('0x25')](_0x40db7c)[_0x6b0a('0x26')](function(_0x250efd){return _0x250efd;});}return null;};}function removeEntity(_0x180ea3,_0x3e909f){return function(_0x2bfe87){if(_0x2bfe87){return _0x2bfe87[_0x6b0a('0x27')]()[_0x6b0a('0x26')](function(){var _0x4e3b0b=_0x2bfe87[_0x6b0a('0x28')]({'plain':!![]});var _0x66bc04=_0x6b0a('0x29');return db[_0x6b0a('0x2a')]['destroy']({'where':{'type':_0x66bc04,'resourceId':_0x4e3b0b['id']}})[_0x6b0a('0x26')](function(){return _0x2bfe87;});})[_0x6b0a('0x26')](function(){_0x180ea3[_0x6b0a('0x1d')](0xcc)[_0x6b0a('0x2b')]();});}};}function handleEntityNotFound(_0x27c4af,_0x447771){return function(_0xb4a3e5){if(!_0xb4a3e5){_0x27c4af[_0x6b0a('0x1c')](0x194);}return _0xb4a3e5;};}function handleError(_0x379192,_0x3cf5d6){_0x3cf5d6=_0x3cf5d6||0x1f4;return function(_0x1bf058){logger[_0x6b0a('0x2c')](_0x1bf058[_0x6b0a('0x2d')]);if(_0x1bf058[_0x6b0a('0x2e')]){delete _0x1bf058[_0x6b0a('0x2e')];}_0x379192[_0x6b0a('0x1d')](_0x3cf5d6)['send'](_0x1bf058);};}exports[_0x6b0a('0x2f')]=function(_0x340354,_0x129ba5){var _0x422b99={},_0x8662cd={},_0x1ee863={'count':0x0,'rows':[]};var _0x133936=_[_0x6b0a('0x30')](db[_0x6b0a('0x31')]['rawAttributes'],function(_0x240072){return{'name':_0x240072[_0x6b0a('0x32')],'type':_0x240072['type']['key']};});_0x8662cd[_0x6b0a('0x33')]=_[_0x6b0a('0x30')](_0x133936,_0x6b0a('0x2e'));_0x8662cd[_0x6b0a('0x34')]=_[_0x6b0a('0x35')](_0x340354[_0x6b0a('0x34')]);_0x8662cd[_0x6b0a('0x36')]=_[_0x6b0a('0x37')](_0x8662cd['model'],_0x8662cd[_0x6b0a('0x34')]);_0x422b99[_0x6b0a('0x38')]=_[_0x6b0a('0x37')](_0x8662cd[_0x6b0a('0x33')],qs[_0x6b0a('0x39')](_0x340354[_0x6b0a('0x34')][_0x6b0a('0x39')]));_0x422b99[_0x6b0a('0x38')]=_0x422b99['attributes'][_0x6b0a('0x3a')]?_0x422b99['attributes']:_0x8662cd[_0x6b0a('0x33')];if(!_0x340354[_0x6b0a('0x34')][_0x6b0a('0x3b')]('nolimit')){_0x422b99[_0x6b0a('0x3c')]=qs[_0x6b0a('0x3c')](_0x340354[_0x6b0a('0x34')][_0x6b0a('0x3c')]);_0x422b99[_0x6b0a('0x1f')]=qs[_0x6b0a('0x1f')](_0x340354[_0x6b0a('0x34')][_0x6b0a('0x1f')]);}_0x422b99[_0x6b0a('0x3d')]=qs[_0x6b0a('0x3e')](_0x340354[_0x6b0a('0x34')][_0x6b0a('0x3e')]);_0x422b99[_0x6b0a('0x3f')]=qs[_0x6b0a('0x36')](_[_0x6b0a('0x40')](_0x340354[_0x6b0a('0x34')],_0x8662cd[_0x6b0a('0x36')]),_0x133936);if(_0x340354['query']['filter']){_0x422b99['where']=_[_0x6b0a('0x41')](_0x422b99[_0x6b0a('0x3f')],{'$or':_[_0x6b0a('0x30')](_0x133936,function(_0x2461e7){if(_0x2461e7['type']!==_0x6b0a('0x42')){var _0x1b12df={};_0x1b12df[_0x2461e7[_0x6b0a('0x2e')]]={'$like':'%'+_0x340354[_0x6b0a('0x34')][_0x6b0a('0x43')]+'%'};return _0x1b12df;}})});}_0x422b99=_[_0x6b0a('0x41')]({},_0x422b99,_0x340354[_0x6b0a('0x44')]);var _0x367562={'where':_0x422b99[_0x6b0a('0x3f')]};return db[_0x6b0a('0x31')][_0x6b0a('0x45')](_0x367562)['then'](function(_0x56bf9e){_0x1ee863[_0x6b0a('0x45')]=_0x56bf9e;if(_0x340354['query'][_0x6b0a('0x46')]){_0x422b99['include']=[{'all':!![]}];}return db[_0x6b0a('0x31')][_0x6b0a('0x47')](_0x422b99);})[_0x6b0a('0x26')](function(_0x215e99){_0x1ee863[_0x6b0a('0x48')]=_0x215e99;return _0x1ee863;})[_0x6b0a('0x26')](respondWithFilteredResult(_0x129ba5,_0x422b99))[_0x6b0a('0x49')](handleError(_0x129ba5,null));};exports['show']=function(_0x1b4f9b,_0x394143){var _0x1404f3={'raw':!![],'where':{'id':_0x1b4f9b['params']['id']}},_0x5ea763={};_0x5ea763[_0x6b0a('0x33')]=_['keys'](db['FaxQueue'][_0x6b0a('0x4a')]);_0x5ea763['query']=_[_0x6b0a('0x35')](_0x1b4f9b['query']);_0x5ea763[_0x6b0a('0x36')]=_[_0x6b0a('0x37')](_0x5ea763['model'],_0x5ea763['query']);_0x1404f3[_0x6b0a('0x38')]=_[_0x6b0a('0x37')](_0x5ea763['model'],qs[_0x6b0a('0x39')](_0x1b4f9b[_0x6b0a('0x34')]['fields']));_0x1404f3[_0x6b0a('0x38')]=_0x1404f3[_0x6b0a('0x38')][_0x6b0a('0x3a')]?_0x1404f3[_0x6b0a('0x38')]:_0x5ea763[_0x6b0a('0x33')];if(_0x1b4f9b['query'][_0x6b0a('0x46')]){_0x1404f3[_0x6b0a('0x4b')]=[{'all':!![]}];}_0x1404f3=_['merge']({},_0x1404f3,_0x1b4f9b[_0x6b0a('0x44')]);return db[_0x6b0a('0x31')][_0x6b0a('0x4c')](_0x1404f3)[_0x6b0a('0x26')](handleEntityNotFound(_0x394143,null))[_0x6b0a('0x26')](respondWithResult(_0x394143,null))['catch'](handleError(_0x394143,null));};exports[_0x6b0a('0x4d')]=function(_0x424d0f,_0x2df316){return db[_0x6b0a('0x31')][_0x6b0a('0x4d')](_0x424d0f[_0x6b0a('0x4e')],{})[_0x6b0a('0x26')](function(_0x216d8d){var _0x5c85a2=_0x424d0f[_0x6b0a('0x4f')][_0x6b0a('0x28')]({'plain':!![]});if(!_0x5c85a2)throw new Error(_0x6b0a('0x50'));if(_0x5c85a2[_0x6b0a('0x51')]===_0x6b0a('0x4f')){var _0x2abb43=_0x216d8d[_0x6b0a('0x28')]({'plain':!![]});var _0x546502='FaxQueues';return db[_0x6b0a('0x52')][_0x6b0a('0x4c')]({'where':{'name':_0x546502,'userProfileId':_0x5c85a2['userProfileId']},'raw':!![]})[_0x6b0a('0x26')](function(_0x34c481){if(_0x34c481&&_0x34c481[_0x6b0a('0x53')]===0x0){return db[_0x6b0a('0x2a')][_0x6b0a('0x4d')]({'name':_0x2abb43[_0x6b0a('0x2e')],'resourceId':_0x2abb43['id'],'type':_0x34c481[_0x6b0a('0x2e')],'sectionId':_0x34c481['id']},{})['then'](function(){return _0x216d8d;});}else{return _0x216d8d;}})['catch'](function(_0x51f01f){logger[_0x6b0a('0x2c')](_0x6b0a('0x54'),_0x51f01f);throw _0x51f01f;});}return _0x216d8d;})[_0x6b0a('0x26')](respondWithResult(_0x2df316,0xc9))[_0x6b0a('0x49')](handleError(_0x2df316,null));};exports[_0x6b0a('0x25')]=function(_0x5f4bbf,_0x2c058a){if(_0x5f4bbf[_0x6b0a('0x4e')]['id']){delete _0x5f4bbf[_0x6b0a('0x4e')]['id'];}return db[_0x6b0a('0x31')]['find']({'where':{'id':_0x5f4bbf[_0x6b0a('0x55')]['id']}})['then'](handleEntityNotFound(_0x2c058a,null))['then'](saveUpdates(_0x5f4bbf['body'],null))[_0x6b0a('0x26')](respondWithResult(_0x2c058a,null))[_0x6b0a('0x49')](handleError(_0x2c058a,null));};exports[_0x6b0a('0x27')]=function(_0x104150,_0x3b539a){return db['FaxQueue'][_0x6b0a('0x4c')]({'where':{'id':_0x104150[_0x6b0a('0x55')]['id']}})[_0x6b0a('0x26')](handleEntityNotFound(_0x3b539a,null))['then'](removeEntity(_0x3b539a,null))[_0x6b0a('0x49')](handleError(_0x3b539a,null));};exports[_0x6b0a('0x56')]=function(_0x38697c,_0x512916){return db[_0x6b0a('0x31')][_0x6b0a('0x56')]()[_0x6b0a('0x26')](respondWithResult(_0x512916,null))[_0x6b0a('0x49')](handleError(_0x512916,null));};exports[_0x6b0a('0x57')]=function(_0x54b923,_0x3cd9c9,_0x9450fd){var _0x4a616f={'raw':!![],'where':{}},_0x2caac7={},_0x4809af;return db['FaxQueue'][_0x6b0a('0x58')]({'where':{'id':_0x54b923[_0x6b0a('0x55')]['id']}})['then'](handleEntityNotFound(_0x3cd9c9,null))[_0x6b0a('0x26')](function(_0x4f5420){if(_0x4f5420){_0x4809af=_0x4f5420[_0x6b0a('0x28')]({'plain':!![]});_0x2caac7[_0x6b0a('0x33')]=_[_0x6b0a('0x35')](db[_0x6b0a('0x59')][_0x6b0a('0x4a')]);_0x2caac7[_0x6b0a('0x34')]=_[_0x6b0a('0x35')](_0x54b923[_0x6b0a('0x34')]);_0x2caac7[_0x6b0a('0x36')]=_[_0x6b0a('0x37')](_0x2caac7[_0x6b0a('0x33')],_0x2caac7['query']);_0x4a616f[_0x6b0a('0x38')]=_[_0x6b0a('0x37')](_0x2caac7[_0x6b0a('0x33')],qs[_0x6b0a('0x39')](_0x54b923[_0x6b0a('0x34')]['fields']));_0x4a616f[_0x6b0a('0x38')]=_0x4a616f['attributes'][_0x6b0a('0x3a')]?_0x4a616f['attributes']:_0x2caac7['model'];if(!_0x54b923[_0x6b0a('0x34')][_0x6b0a('0x3b')](_0x6b0a('0x5a'))){_0x4a616f[_0x6b0a('0x3c')]=qs[_0x6b0a('0x3c')](_0x54b923[_0x6b0a('0x34')]['limit']);_0x4a616f['offset']=qs[_0x6b0a('0x1f')](_0x54b923[_0x6b0a('0x34')][_0x6b0a('0x1f')]);}_0x4a616f['order']=qs[_0x6b0a('0x3e')](_0x54b923[_0x6b0a('0x34')][_0x6b0a('0x3e')]);_0x4a616f[_0x6b0a('0x3f')]=qs['filters'](_[_0x6b0a('0x40')](_0x54b923[_0x6b0a('0x34')],_0x2caac7[_0x6b0a('0x36')]));_0x4a616f['where'][_0x6b0a('0x5b')]=_0x4f5420['id'];if(_0x54b923[_0x6b0a('0x34')][_0x6b0a('0x43')]){_0x4a616f[_0x6b0a('0x3f')]=_[_0x6b0a('0x41')](_0x4a616f[_0x6b0a('0x3f')],{'$or':_[_0x6b0a('0x30')](_0x4a616f['attributes'],function(_0x381f9c){var _0x1801e7={};_0x1801e7[_0x381f9c]={'$like':'%'+_0x54b923[_0x6b0a('0x34')][_0x6b0a('0x43')]+'%'};return _0x1801e7;})});}_0x4a616f=_[_0x6b0a('0x41')]({},_0x4a616f,_0x54b923['options']);return db[_0x6b0a('0x59')]['findAll'](_0x4a616f);}})[_0x6b0a('0x26')](function(_0x2b7c17){if(_0x2b7c17){return db[_0x6b0a('0x5c')]['findAndCountAll']({'where':{'id':_['map'](_0x2b7c17,_0x6b0a('0x5d')),'role':_0x6b0a('0x5e')},'attributes':['id','name',_0x6b0a('0x5f'),_0x6b0a('0x60'),_0x6b0a('0x61')]});}})[_0x6b0a('0x26')](function(_0x5cf976){if(_0x5cf976){return{'count':_0x5cf976['count'],'rows':_[_0x6b0a('0x30')](_0x5cf976['rows'],function(_0x16ec59){return{'membername':_0x16ec59[_0x6b0a('0x2e')],'UserId':_0x16ec59['id'],'queue_name':_0x4809af['name'],'FaxQueueId':_0x4809af['id'],'interface':util[_0x6b0a('0x62')](_0x6b0a('0x63'),_0x6b0a('0x64'),_0x16ec59['name']),'penalty':0x0,'paused':_0x16ec59[_0x6b0a('0x5f')],'createdAt':_0x16ec59[_0x6b0a('0x61')],'updatedAt':_0x16ec59['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x6b0a('0x26')](respondWithFilteredResult(_0x3cd9c9,_0x4a616f))[_0x6b0a('0x49')](handleError(_0x3cd9c9,null));};exports[_0x6b0a('0x65')]=function(_0x5801e2,_0x19e7a9,_0x4ca067){var _0x38ae78={};var _0x5bfc6c={};var _0x1512d7;var _0x38bd19;return db['FaxQueue'][_0x6b0a('0x58')]({'where':{'id':_0x5801e2[_0x6b0a('0x55')]['id']}})[_0x6b0a('0x26')](handleEntityNotFound(_0x19e7a9,null))[_0x6b0a('0x26')](function(_0xaa629e){if(_0xaa629e){_0x1512d7=_0xaa629e;_0x5bfc6c[_0x6b0a('0x33')]=_[_0x6b0a('0x35')](db['Team'][_0x6b0a('0x4a')]);_0x5bfc6c[_0x6b0a('0x34')]=_['keys'](_0x5801e2['query']);_0x5bfc6c['filters']=_[_0x6b0a('0x37')](_0x5bfc6c['model'],_0x5bfc6c['query']);_0x38ae78[_0x6b0a('0x38')]=_[_0x6b0a('0x37')](_0x5bfc6c['model'],qs[_0x6b0a('0x39')](_0x5801e2[_0x6b0a('0x34')]['fields']));_0x38ae78[_0x6b0a('0x38')]=_0x38ae78['attributes']['length']?_0x38ae78[_0x6b0a('0x38')]:_0x5bfc6c['model'];_0x38ae78['order']=qs['sort'](_0x5801e2[_0x6b0a('0x34')][_0x6b0a('0x3e')]);_0x38ae78[_0x6b0a('0x3f')]=qs[_0x6b0a('0x36')](_['pick'](_0x5801e2[_0x6b0a('0x34')],_0x5bfc6c[_0x6b0a('0x36')]));if(_0x5801e2[_0x6b0a('0x34')][_0x6b0a('0x43')]){_0x38ae78[_0x6b0a('0x3f')]=_['merge'](_0x38ae78[_0x6b0a('0x3f')],{'$or':_[_0x6b0a('0x30')](_0x38ae78[_0x6b0a('0x38')],function(_0x14cb40){var _0x591fac={};_0x591fac[_0x14cb40]={'$like':'%'+_0x5801e2[_0x6b0a('0x34')][_0x6b0a('0x43')]+'%'};return _0x591fac;})});}_0x38ae78=_['merge']({},_0x38ae78,_0x5801e2['options']);return _0x1512d7[_0x6b0a('0x65')](_0x38ae78);}})[_0x6b0a('0x26')](function(_0x53fb7a){if(_0x53fb7a){_0x38bd19=_0x53fb7a[_0x6b0a('0x3a')];if(!_0x5801e2[_0x6b0a('0x34')]['hasOwnProperty']('nolimit')){_0x38ae78['limit']=qs[_0x6b0a('0x3c')](_0x5801e2[_0x6b0a('0x34')][_0x6b0a('0x3c')]);_0x38ae78[_0x6b0a('0x1f')]=qs[_0x6b0a('0x1f')](_0x5801e2[_0x6b0a('0x34')][_0x6b0a('0x1f')]);}return _0x1512d7[_0x6b0a('0x65')](_0x38ae78);}})[_0x6b0a('0x26')](function(_0x5c521e){if(_0x5c521e){return _0x5c521e?{'count':_0x38bd19,'rows':_0x5c521e}:null;}})[_0x6b0a('0x26')](respondWithResult(_0x19e7a9,null))[_0x6b0a('0x49')](handleError(_0x19e7a9,null));};exports[_0x6b0a('0x66')]=function(_0x1a7ce1,_0x4729bb,_0x284068){var _0x31935f=_0x1a7ce1['body'][_0x6b0a('0x67')];return db[_0x6b0a('0x68')]['findAll']({'where':{'id':_0x31935f},'attributes':['id'],'include':[{'model':db[_0x6b0a('0x5c')],'as':_0x6b0a('0x69'),'attributes':['id','name',_0x6b0a('0x6a'),_0x6b0a('0x6b'),_0x6b0a('0x6c')],'raw':!![]}]})['then'](function(_0x37e1c0){if(_0x37e1c0){var _0x11ca67=_[_0x6b0a('0x6d')](_0x37e1c0,function(_0x5c44c8){var _0x4e99e1=_0x5c44c8[_0x6b0a('0x28')]({'plain':!![]});return _0x4e99e1['Agents'];});return db['FaxQueue'][_0x6b0a('0x4c')]({'where':{'id':_0x1a7ce1[_0x6b0a('0x55')]['id']}})['then'](function(_0x2bed9f){return db['sequelize'][_0x6b0a('0x6e')](function(_0x4aabb3){return _0x2bed9f[_0x6b0a('0x66')](_0x31935f,{'transaction':_0x4aabb3})[_0x6b0a('0x26')](function(){return BPromise[_0x6b0a('0x6f')](_0x11ca67,function(_0x34ae57){return db[_0x6b0a('0x59')][_0x6b0a('0x70')]({'where':{'UserId':_0x34ae57['id'],'FaxQueueId':_0x1a7ce1['params']['id']},'transaction':_0x4aabb3});});})[_0x6b0a('0x26')](function(){_0x11ca67[_0x6b0a('0x71')](function(_0x3c6791){socket[_0x6b0a('0x72')]('userFaxQueue:save',{'UserId':_0x3c6791['id'],'FaxQueueId':_0x2bed9f['id']});});});});});}})[_0x6b0a('0x26')](respondWithStatusCode(_0x4729bb,null))[_0x6b0a('0x49')](handleError(_0x4729bb,null));};exports['removeTeams']=function(_0x286eff,_0x5eba83,_0x212d18){return db[_0x6b0a('0x68')][_0x6b0a('0x47')]({'where':{'id':_0x286eff['query'][_0x6b0a('0x67')]},'attributes':['id'],'include':[{'model':db[_0x6b0a('0x5c')],'as':_0x6b0a('0x69'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x5eba83,null))[_0x6b0a('0x26')](function(_0x24e049){var _0x1498b7=_['map'](_0x24e049,'id');var _0x5665bb=[];var _0x164ca4=[];var _0x482b7b=squel['select']();_0x482b7b['field'](_0x6b0a('0x73'))[_0x6b0a('0x74')](_0x6b0a('0x75'),'tq')[_0x6b0a('0x76')](_0x6b0a('0x77'),'ut','ut.TeamId\x20=\x20tq.TeamId')['where'](_0x6b0a('0x78'),_0x286eff[_0x6b0a('0x55')]['id']);for(var _0x22641e=0x0;_0x22641e<_0x24e049['length'];_0x22641e+=0x1){let _0x58b18d=_0x24e049[_0x22641e];for(var _0x2d68d5=0x0;_0x2d68d5<_0x58b18d[_0x6b0a('0x69')][_0x6b0a('0x3a')];_0x2d68d5+=0x1){let _0x357d8a=_0x58b18d[_0x6b0a('0x69')][_0x2d68d5];var _0x3b2bc2=_0x482b7b['clone']();_0x3b2bc2[_0x6b0a('0x3f')](_0x6b0a('0x79'),_0x357d8a['id']);_0x164ca4[_0x6b0a('0x7a')](db[_0x6b0a('0x7b')][_0x6b0a('0x34')](_0x3b2bc2['toString'](),{'type':db[_0x6b0a('0x7b')][_0x6b0a('0x7c')][_0x6b0a('0x7d')]})[_0x6b0a('0x26')](function(_0x30da91){if(_0x30da91[_0x6b0a('0x3a')]===0x1){return _0x357d8a['id'];}else{var _0x3f3491=_[_0x6b0a('0x7e')](_[_0x6b0a('0x30')](_0x30da91,'TeamId'),function(_0x91034){return _['includes'](_0x1498b7,_0x91034);});if(_0x3f3491){return _0x357d8a['id'];}}}));}}return BPromise[_0x6b0a('0x7f')](_0x164ca4)['then'](function(_0x5acf99){_0x5665bb=_(_0x5665bb)[_0x6b0a('0x80')](_0x5acf99)[_0x6b0a('0x81')]()[_0x6b0a('0x82')]();return db[_0x6b0a('0x31')][_0x6b0a('0x4c')]({'where':{'id':_0x286eff[_0x6b0a('0x55')]['id']}})[_0x6b0a('0x26')](function(_0x237d78){return db[_0x6b0a('0x7b')]['transaction'](function(_0x149b71){return _0x237d78['removeTeams'](_0x286eff[_0x6b0a('0x34')][_0x6b0a('0x67')],{'transaction':_0x149b71})[_0x6b0a('0x26')](function(){if(!_['isEmpty'](_0x5665bb)){return _0x237d78['removeAgents'](_0x5665bb,{'transaction':_0x149b71});}})[_0x6b0a('0x26')](function(){_0x5665bb[_0x6b0a('0x71')](function(_0xe6ffcb){socket[_0x6b0a('0x72')]('userFaxQueue:remove',{'UserId':_0xe6ffcb,'FaxQueueId':_0x237d78['id']});});});});});});})[_0x6b0a('0x26')](respondWithStatusCode(_0x5eba83,null))[_0x6b0a('0x49')](handleError(_0x5eba83,null));};exports[_0x6b0a('0x83')]=function(_0x271bbe,_0x26bc4d,_0x2de6e2){return db['FaxQueue'][_0x6b0a('0x4c')]({'where':{'id':_0x271bbe['params']['id']}})[_0x6b0a('0x26')](handleEntityNotFound(_0x26bc4d,null))[_0x6b0a('0x26')](function(_0x289cbd){if(_0x289cbd){return _0x289cbd[_0x6b0a('0x83')](_0x271bbe['body']['ids'],_[_0x6b0a('0x84')](_0x271bbe[_0x6b0a('0x4e')],['ids','id'])||{})[_0x6b0a('0x85')](function(_0xcdd64f){for(var _0x2e1e27=0x0;_0x2e1e27<_0x271bbe[_0x6b0a('0x4e')][_0x6b0a('0x67')]['length'];_0x2e1e27+=0x1){socket[_0x6b0a('0x72')]('userFaxQueue:save',{'UserId':Number(_0x271bbe[_0x6b0a('0x4e')][_0x6b0a('0x67')][_0x2e1e27]),'FaxQueueId':Number(_0x271bbe[_0x6b0a('0x55')]['id'])});}return _0xcdd64f;});}})[_0x6b0a('0x26')](respondWithResult(_0x26bc4d,null))[_0x6b0a('0x49')](handleError(_0x26bc4d,null));};exports[_0x6b0a('0x86')]=function(_0x54a8b5,_0x271e9b,_0x36b79d){return db[_0x6b0a('0x31')]['find']({'where':{'id':_0x54a8b5[_0x6b0a('0x55')]['id']}})[_0x6b0a('0x26')](handleEntityNotFound(_0x271e9b,null))['then'](function(_0x3f6bf1){if(_0x3f6bf1){return _0x3f6bf1[_0x6b0a('0x86')](_0x54a8b5[_0x6b0a('0x34')][_0x6b0a('0x67')])[_0x6b0a('0x26')](function(){if(_[_0x6b0a('0x87')](_0x54a8b5[_0x6b0a('0x34')][_0x6b0a('0x67')])){for(var _0x3c8474=0x0;_0x3c8474<_0x54a8b5[_0x6b0a('0x34')][_0x6b0a('0x67')][_0x6b0a('0x3a')];_0x3c8474+=0x1){socket['emit'](_0x6b0a('0x88'),{'UserId':Number(_0x54a8b5[_0x6b0a('0x34')][_0x6b0a('0x67')][_0x3c8474]),'FaxQueueId':Number(_0x54a8b5[_0x6b0a('0x55')]['id'])});}}else{socket[_0x6b0a('0x72')](_0x6b0a('0x88'),{'UserId':Number(_0x54a8b5[_0x6b0a('0x34')][_0x6b0a('0x67')]),'FaxQueueId':Number(_0x54a8b5['params']['id'])});}});}})[_0x6b0a('0x26')](respondWithStatusCode(_0x271e9b,null))[_0x6b0a('0x49')](handleError(_0x271e9b,null));};exports[_0x6b0a('0x89')]=function(_0x11cc50,_0x20fbb2,_0x5293c9){var _0x379983={};var _0x3ef934={};var _0xffcc85;var _0x949e30;return db[_0x6b0a('0x31')][_0x6b0a('0x58')]({'where':{'id':_0x11cc50[_0x6b0a('0x55')]['id']}})[_0x6b0a('0x26')](handleEntityNotFound(_0x20fbb2,null))[_0x6b0a('0x26')](function(_0x2be201){if(_0x2be201){_0xffcc85=_0x2be201;_0x3ef934[_0x6b0a('0x33')]=_['keys'](db[_0x6b0a('0x5c')][_0x6b0a('0x4a')]);_0x3ef934['query']=_[_0x6b0a('0x35')](_0x11cc50[_0x6b0a('0x34')]);_0x3ef934[_0x6b0a('0x36')]=_['intersection'](_0x3ef934['model'],_0x3ef934[_0x6b0a('0x34')]);_0x379983[_0x6b0a('0x38')]=_[_0x6b0a('0x37')](_0x3ef934[_0x6b0a('0x33')],qs[_0x6b0a('0x39')](_0x11cc50[_0x6b0a('0x34')]['fields']));_0x379983['attributes']=_0x379983['attributes']['length']?_0x379983[_0x6b0a('0x38')]:_0x3ef934[_0x6b0a('0x33')];_0x379983[_0x6b0a('0x3d')]=qs[_0x6b0a('0x3e')](_0x11cc50['query']['sort']);_0x379983[_0x6b0a('0x3f')]=qs[_0x6b0a('0x36')](_['pick'](_0x11cc50[_0x6b0a('0x34')],_0x3ef934['filters']));if(_0x11cc50[_0x6b0a('0x34')][_0x6b0a('0x43')]){_0x379983['where']=_[_0x6b0a('0x41')](_0x379983[_0x6b0a('0x3f')],{'$or':_[_0x6b0a('0x30')](_0x379983['attributes'],function(_0x409d2f){var _0x26e99d={};_0x26e99d[_0x409d2f]={'$like':'%'+_0x11cc50[_0x6b0a('0x34')][_0x6b0a('0x43')]+'%'};return _0x26e99d;})});}_0x379983=_['merge']({},_0x379983,_0x11cc50['options']);return _0xffcc85[_0x6b0a('0x89')](_0x379983);}})[_0x6b0a('0x26')](function(_0x38b13a){if(_0x38b13a){_0x949e30=_0x38b13a[_0x6b0a('0x3a')];if(!_0x11cc50['query'][_0x6b0a('0x3b')](_0x6b0a('0x5a'))){_0x379983['limit']=qs[_0x6b0a('0x3c')](_0x11cc50[_0x6b0a('0x34')]['limit']);_0x379983[_0x6b0a('0x1f')]=qs[_0x6b0a('0x1f')](_0x11cc50[_0x6b0a('0x34')]['offset']);}return _0xffcc85[_0x6b0a('0x89')](_0x379983);}})[_0x6b0a('0x26')](function(_0x467edb){if(_0x467edb){return _0x467edb?{'count':_0x949e30,'rows':_0x467edb}:null;}})[_0x6b0a('0x26')](respondWithResult(_0x20fbb2,null))['catch'](handleError(_0x20fbb2,null));};
\ No newline at end of file
+var _0xb5f5=['register','sendStatus','status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','destroy','then','get','FaxQueues','UserProfileResource','end','stack','name','send','index','rawAttributes','type','key','model','map','query','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filters','filter','where','merge','options','FaxQueue','includeAll','include','findAll','catch','params','keys','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','getMembers','findOne','UserFaxQueue','FaxQueueId','User','findAndCountAll','UserId','agent','faxPause','updatedAt','createdAt','rows','%s/%s','getTeams','Team','addTeams','ids','Agents','online','voicePause','interface','flatMap','sequelize','transaction','each','findOrCreate','forEach','emit','userFaxQueue:save','select','tq.TeamId','from','team_has_fax_queues','join','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','removeTeams','removeAgents','userFaxQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxQueue.socket'];(function(_0x415acb,_0x41b213){var _0x213b8c=function(_0x3e507b){while(--_0x3e507b){_0x415acb['push'](_0x415acb['shift']());}};_0x213b8c(++_0x41b213);}(_0xb5f5,0x74));var _0x5b5f=function(_0x29f026,_0x41d610){_0x29f026=_0x29f026-0x0;var _0x202e66=_0xb5f5[_0x29f026];return _0x202e66;};'use strict';var emlformat=require(_0x5b5f('0x0'));var rimraf=require(_0x5b5f('0x1'));var zipdir=require(_0x5b5f('0x2'));var jsonpatch=require(_0x5b5f('0x3'));var rp=require(_0x5b5f('0x4'));var moment=require('moment');var BPromise=require(_0x5b5f('0x5'));var Mustache=require(_0x5b5f('0x6'));var util=require('util');var path=require(_0x5b5f('0x7'));var sox=require('sox');var csv=require(_0x5b5f('0x8'));var ejs=require(_0x5b5f('0x9'));var fs=require('fs');var fs_extra=require(_0x5b5f('0xa'));var _=require(_0x5b5f('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x5b5f('0xc'));var deskjs=require(_0x5b5f('0xd'));var toCsv=require(_0x5b5f('0x8'));var querystring=require(_0x5b5f('0xe'));var Papa=require(_0x5b5f('0xf'));var Redis=require(_0x5b5f('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x5b5f('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5b5f('0x12'));var logger=require('../../config/logger')(_0x5b5f('0x13'));var utils=require(_0x5b5f('0x14'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x5b5f('0x15'))['db'];config[_0x5b5f('0x16')]=_[_0x5b5f('0x17')](config[_0x5b5f('0x16')],{'host':_0x5b5f('0x18'),'port':0x18eb});var socket=require(_0x5b5f('0x19'))(new Redis(config[_0x5b5f('0x16')]));require(_0x5b5f('0x1a'))[_0x5b5f('0x1b')](socket);function respondWithStatusCode(_0x28b424,_0x2956ec){_0x2956ec=_0x2956ec||0xcc;return function(_0x1bf6b8){if(_0x1bf6b8){return _0x28b424[_0x5b5f('0x1c')](_0x2956ec);}return _0x28b424[_0x5b5f('0x1d')](_0x2956ec)['end']();};}function respondWithResult(_0x80a1d0,_0x594fdd){_0x594fdd=_0x594fdd||0xc8;return function(_0x4ad162){if(_0x4ad162){return _0x80a1d0[_0x5b5f('0x1d')](_0x594fdd)[_0x5b5f('0x1e')](_0x4ad162);}};}function respondWithFilteredResult(_0x406099,_0x2a5ccb){return function(_0x179582){if(_0x179582){var _0x3580a9=typeof _0x2a5ccb[_0x5b5f('0x1f')]===_0x5b5f('0x20')&&typeof _0x2a5ccb['limit']==='undefined';var _0x409a4f=_0x179582[_0x5b5f('0x21')];var _0x620f82=_0x3580a9?0x0:_0x2a5ccb[_0x5b5f('0x1f')];var _0xaa5fb5=_0x3580a9?_0x179582[_0x5b5f('0x21')]:_0x2a5ccb[_0x5b5f('0x1f')]+_0x2a5ccb[_0x5b5f('0x22')];var _0x54645f;if(_0xaa5fb5>=_0x409a4f){_0xaa5fb5=_0x409a4f;_0x54645f=0xc8;}else{_0x54645f=0xce;}_0x406099['status'](_0x54645f);return _0x406099[_0x5b5f('0x23')](_0x5b5f('0x24'),_0x620f82+'-'+_0xaa5fb5+'/'+_0x409a4f)[_0x5b5f('0x1e')](_0x179582);}return null;};}function patchUpdates(_0x5b811d){return function(_0xbed6c7){try{jsonpatch[_0x5b5f('0x25')](_0xbed6c7,_0x5b811d,!![]);}catch(_0x151053){return BPromise[_0x5b5f('0x26')](_0x151053);}return _0xbed6c7[_0x5b5f('0x27')]();};}function saveUpdates(_0x2a7386,_0x5075d){return function(_0x2269d5){if(_0x2269d5){return _0x2269d5['update'](_0x2a7386)['then'](function(_0x4d6a48){return _0x4d6a48;});}return null;};}function removeEntity(_0x58a52b,_0x1d9496){return function(_0x5e6653){if(_0x5e6653){return _0x5e6653[_0x5b5f('0x28')]()[_0x5b5f('0x29')](function(){var _0x4a28f0=_0x5e6653[_0x5b5f('0x2a')]({'plain':!![]});var _0x131048=_0x5b5f('0x2b');return db[_0x5b5f('0x2c')][_0x5b5f('0x28')]({'where':{'type':_0x131048,'resourceId':_0x4a28f0['id']}})['then'](function(){return _0x5e6653;});})['then'](function(){_0x58a52b[_0x5b5f('0x1d')](0xcc)[_0x5b5f('0x2d')]();});}};}function handleEntityNotFound(_0x1dad7c,_0x10166b){return function(_0x4489f9){if(!_0x4489f9){_0x1dad7c[_0x5b5f('0x1c')](0x194);}return _0x4489f9;};}function handleError(_0x19aae3,_0x4f94c2){_0x4f94c2=_0x4f94c2||0x1f4;return function(_0x750aa2){logger['error'](_0x750aa2[_0x5b5f('0x2e')]);if(_0x750aa2[_0x5b5f('0x2f')]){delete _0x750aa2[_0x5b5f('0x2f')];}_0x19aae3[_0x5b5f('0x1d')](_0x4f94c2)[_0x5b5f('0x30')](_0x750aa2);};}exports[_0x5b5f('0x31')]=function(_0xf50675,_0x4aa3df){var _0x4d5521={},_0x5f3a1e={},_0x3e20f4={'count':0x0,'rows':[]};var _0x5a6298=_['map'](db['FaxQueue'][_0x5b5f('0x32')],function(_0x279bdd){return{'name':_0x279bdd['fieldName'],'type':_0x279bdd[_0x5b5f('0x33')][_0x5b5f('0x34')]};});_0x5f3a1e[_0x5b5f('0x35')]=_[_0x5b5f('0x36')](_0x5a6298,'name');_0x5f3a1e[_0x5b5f('0x37')]=_['keys'](_0xf50675[_0x5b5f('0x37')]);_0x5f3a1e['filters']=_[_0x5b5f('0x38')](_0x5f3a1e[_0x5b5f('0x35')],_0x5f3a1e[_0x5b5f('0x37')]);_0x4d5521['attributes']=_['intersection'](_0x5f3a1e[_0x5b5f('0x35')],qs['fields'](_0xf50675[_0x5b5f('0x37')][_0x5b5f('0x39')]));_0x4d5521[_0x5b5f('0x3a')]=_0x4d5521[_0x5b5f('0x3a')][_0x5b5f('0x3b')]?_0x4d5521[_0x5b5f('0x3a')]:_0x5f3a1e[_0x5b5f('0x35')];if(!_0xf50675[_0x5b5f('0x37')][_0x5b5f('0x3c')](_0x5b5f('0x3d'))){_0x4d5521[_0x5b5f('0x22')]=qs[_0x5b5f('0x22')](_0xf50675[_0x5b5f('0x37')][_0x5b5f('0x22')]);_0x4d5521[_0x5b5f('0x1f')]=qs['offset'](_0xf50675[_0x5b5f('0x37')]['offset']);}_0x4d5521[_0x5b5f('0x3e')]=qs[_0x5b5f('0x3f')](_0xf50675[_0x5b5f('0x37')][_0x5b5f('0x3f')]);_0x4d5521['where']=qs['filters'](_[_0x5b5f('0x40')](_0xf50675[_0x5b5f('0x37')],_0x5f3a1e[_0x5b5f('0x41')]),_0x5a6298);if(_0xf50675['query'][_0x5b5f('0x42')]){_0x4d5521[_0x5b5f('0x43')]=_['merge'](_0x4d5521[_0x5b5f('0x43')],{'$or':_['map'](_0x5a6298,function(_0x3fcdfa){if(_0x3fcdfa[_0x5b5f('0x33')]!=='VIRTUAL'){var _0x5200f4={};_0x5200f4[_0x3fcdfa[_0x5b5f('0x2f')]]={'$like':'%'+_0xf50675[_0x5b5f('0x37')][_0x5b5f('0x42')]+'%'};return _0x5200f4;}})});}_0x4d5521=_[_0x5b5f('0x44')]({},_0x4d5521,_0xf50675[_0x5b5f('0x45')]);var _0x46664f={'where':_0x4d5521[_0x5b5f('0x43')]};return db[_0x5b5f('0x46')][_0x5b5f('0x21')](_0x46664f)['then'](function(_0x4fdd9e){_0x3e20f4[_0x5b5f('0x21')]=_0x4fdd9e;if(_0xf50675[_0x5b5f('0x37')][_0x5b5f('0x47')]){_0x4d5521[_0x5b5f('0x48')]=[{'all':!![]}];}return db[_0x5b5f('0x46')][_0x5b5f('0x49')](_0x4d5521);})['then'](function(_0x31e69a){_0x3e20f4['rows']=_0x31e69a;return _0x3e20f4;})[_0x5b5f('0x29')](respondWithFilteredResult(_0x4aa3df,_0x4d5521))[_0x5b5f('0x4a')](handleError(_0x4aa3df,null));};exports['show']=function(_0x2dafd7,_0x3479e7){var _0x3f635f={'raw':!![],'where':{'id':_0x2dafd7[_0x5b5f('0x4b')]['id']}},_0x44a41a={};_0x44a41a[_0x5b5f('0x35')]=_[_0x5b5f('0x4c')](db[_0x5b5f('0x46')]['rawAttributes']);_0x44a41a[_0x5b5f('0x37')]=_['keys'](_0x2dafd7[_0x5b5f('0x37')]);_0x44a41a[_0x5b5f('0x41')]=_[_0x5b5f('0x38')](_0x44a41a[_0x5b5f('0x35')],_0x44a41a['query']);_0x3f635f['attributes']=_['intersection'](_0x44a41a[_0x5b5f('0x35')],qs['fields'](_0x2dafd7[_0x5b5f('0x37')][_0x5b5f('0x39')]));_0x3f635f['attributes']=_0x3f635f['attributes'][_0x5b5f('0x3b')]?_0x3f635f[_0x5b5f('0x3a')]:_0x44a41a['model'];if(_0x2dafd7[_0x5b5f('0x37')][_0x5b5f('0x47')]){_0x3f635f['include']=[{'all':!![]}];}_0x3f635f=_[_0x5b5f('0x44')]({},_0x3f635f,_0x2dafd7[_0x5b5f('0x45')]);return db[_0x5b5f('0x46')][_0x5b5f('0x4d')](_0x3f635f)['then'](handleEntityNotFound(_0x3479e7,null))[_0x5b5f('0x29')](respondWithResult(_0x3479e7,null))[_0x5b5f('0x4a')](handleError(_0x3479e7,null));};exports[_0x5b5f('0x4e')]=function(_0x3e3bb8,_0x372892){return db[_0x5b5f('0x46')][_0x5b5f('0x4e')](_0x3e3bb8[_0x5b5f('0x4f')],{})['then'](function(_0x469531){var _0x2ef682=_0x3e3bb8[_0x5b5f('0x50')][_0x5b5f('0x2a')]({'plain':!![]});if(!_0x2ef682)throw new Error(_0x5b5f('0x51'));if(_0x2ef682[_0x5b5f('0x52')]===_0x5b5f('0x50')){var _0x48f881=_0x469531[_0x5b5f('0x2a')]({'plain':!![]});var _0x1b81cc=_0x5b5f('0x2b');return db[_0x5b5f('0x53')][_0x5b5f('0x4d')]({'where':{'name':_0x1b81cc,'userProfileId':_0x2ef682['userProfileId']},'raw':!![]})[_0x5b5f('0x29')](function(_0xd9c9f5){if(_0xd9c9f5&&_0xd9c9f5['autoAssociation']===0x0){return db['UserProfileResource']['create']({'name':_0x48f881['name'],'resourceId':_0x48f881['id'],'type':_0xd9c9f5[_0x5b5f('0x2f')],'sectionId':_0xd9c9f5['id']},{})[_0x5b5f('0x29')](function(){return _0x469531;});}else{return _0x469531;}})[_0x5b5f('0x4a')](function(_0x987dce){logger[_0x5b5f('0x54')](_0x5b5f('0x55'),_0x987dce);throw _0x987dce;});}return _0x469531;})[_0x5b5f('0x29')](respondWithResult(_0x372892,0xc9))[_0x5b5f('0x4a')](handleError(_0x372892,null));};exports[_0x5b5f('0x56')]=function(_0x588ba0,_0x2405c4){if(_0x588ba0[_0x5b5f('0x4f')]['id']){delete _0x588ba0[_0x5b5f('0x4f')]['id'];}return db[_0x5b5f('0x46')][_0x5b5f('0x4d')]({'where':{'id':_0x588ba0['params']['id']}})['then'](handleEntityNotFound(_0x2405c4,null))[_0x5b5f('0x29')](saveUpdates(_0x588ba0[_0x5b5f('0x4f')],null))[_0x5b5f('0x29')](respondWithResult(_0x2405c4,null))[_0x5b5f('0x4a')](handleError(_0x2405c4,null));};exports[_0x5b5f('0x28')]=function(_0x1a0343,_0x145809){return db['FaxQueue'][_0x5b5f('0x4d')]({'where':{'id':_0x1a0343[_0x5b5f('0x4b')]['id']}})[_0x5b5f('0x29')](handleEntityNotFound(_0x145809,null))['then'](removeEntity(_0x145809,null))[_0x5b5f('0x4a')](handleError(_0x145809,null));};exports[_0x5b5f('0x57')]=function(_0x56d8fe,_0x250f8c){return db[_0x5b5f('0x46')][_0x5b5f('0x57')]()[_0x5b5f('0x29')](respondWithResult(_0x250f8c,null))[_0x5b5f('0x4a')](handleError(_0x250f8c,null));};exports[_0x5b5f('0x58')]=function(_0xd9dfcd,_0x577c2a,_0x39158a){var _0x21900c={'raw':!![],'where':{}},_0x5d2f08={},_0x39eb47;return db[_0x5b5f('0x46')][_0x5b5f('0x59')]({'where':{'id':_0xd9dfcd['params']['id']}})[_0x5b5f('0x29')](handleEntityNotFound(_0x577c2a,null))[_0x5b5f('0x29')](function(_0x56eeac){if(_0x56eeac){_0x39eb47=_0x56eeac['get']({'plain':!![]});_0x5d2f08[_0x5b5f('0x35')]=_['keys'](db[_0x5b5f('0x5a')][_0x5b5f('0x32')]);_0x5d2f08[_0x5b5f('0x37')]=_['keys'](_0xd9dfcd[_0x5b5f('0x37')]);_0x5d2f08[_0x5b5f('0x41')]=_[_0x5b5f('0x38')](_0x5d2f08[_0x5b5f('0x35')],_0x5d2f08[_0x5b5f('0x37')]);_0x21900c['attributes']=_['intersection'](_0x5d2f08[_0x5b5f('0x35')],qs['fields'](_0xd9dfcd[_0x5b5f('0x37')][_0x5b5f('0x39')]));_0x21900c['attributes']=_0x21900c[_0x5b5f('0x3a')][_0x5b5f('0x3b')]?_0x21900c['attributes']:_0x5d2f08['model'];if(!_0xd9dfcd[_0x5b5f('0x37')][_0x5b5f('0x3c')]('nolimit')){_0x21900c[_0x5b5f('0x22')]=qs[_0x5b5f('0x22')](_0xd9dfcd['query'][_0x5b5f('0x22')]);_0x21900c[_0x5b5f('0x1f')]=qs[_0x5b5f('0x1f')](_0xd9dfcd[_0x5b5f('0x37')]['offset']);}_0x21900c['order']=qs[_0x5b5f('0x3f')](_0xd9dfcd[_0x5b5f('0x37')][_0x5b5f('0x3f')]);_0x21900c[_0x5b5f('0x43')]=qs[_0x5b5f('0x41')](_[_0x5b5f('0x40')](_0xd9dfcd[_0x5b5f('0x37')],_0x5d2f08[_0x5b5f('0x41')]));_0x21900c[_0x5b5f('0x43')][_0x5b5f('0x5b')]=_0x56eeac['id'];if(_0xd9dfcd[_0x5b5f('0x37')][_0x5b5f('0x42')]){_0x21900c['where']=_[_0x5b5f('0x44')](_0x21900c[_0x5b5f('0x43')],{'$or':_[_0x5b5f('0x36')](_0x21900c[_0x5b5f('0x3a')],function(_0x33f054){var _0x529545={};_0x529545[_0x33f054]={'$like':'%'+_0xd9dfcd[_0x5b5f('0x37')][_0x5b5f('0x42')]+'%'};return _0x529545;})});}_0x21900c=_[_0x5b5f('0x44')]({},_0x21900c,_0xd9dfcd[_0x5b5f('0x45')]);return db[_0x5b5f('0x5a')][_0x5b5f('0x49')](_0x21900c);}})[_0x5b5f('0x29')](function(_0x1fe7ae){if(_0x1fe7ae){return db[_0x5b5f('0x5c')][_0x5b5f('0x5d')]({'where':{'id':_[_0x5b5f('0x36')](_0x1fe7ae,_0x5b5f('0x5e')),'role':_0x5b5f('0x5f')},'attributes':['id',_0x5b5f('0x2f'),_0x5b5f('0x60'),_0x5b5f('0x61'),_0x5b5f('0x62')]});}})['then'](function(_0xf2e9){if(_0xf2e9){return{'count':_0xf2e9['count'],'rows':_[_0x5b5f('0x36')](_0xf2e9[_0x5b5f('0x63')],function(_0x6ec3fb){return{'membername':_0x6ec3fb[_0x5b5f('0x2f')],'UserId':_0x6ec3fb['id'],'queue_name':_0x39eb47[_0x5b5f('0x2f')],'FaxQueueId':_0x39eb47['id'],'interface':util['format'](_0x5b5f('0x64'),'SIP',_0x6ec3fb['name']),'penalty':0x0,'paused':_0x6ec3fb[_0x5b5f('0x60')],'createdAt':_0x6ec3fb['createdAt'],'updatedAt':_0x6ec3fb['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0x5b5f('0x29')](respondWithFilteredResult(_0x577c2a,_0x21900c))[_0x5b5f('0x4a')](handleError(_0x577c2a,null));};exports[_0x5b5f('0x65')]=function(_0xc63f96,_0x4d75f2,_0x547430){var _0x183976={};var _0x40ca2d={};var _0x253e8f;var _0x5c1800;return db[_0x5b5f('0x46')][_0x5b5f('0x59')]({'where':{'id':_0xc63f96[_0x5b5f('0x4b')]['id']}})[_0x5b5f('0x29')](handleEntityNotFound(_0x4d75f2,null))[_0x5b5f('0x29')](function(_0x3416b2){if(_0x3416b2){_0x253e8f=_0x3416b2;_0x40ca2d[_0x5b5f('0x35')]=_[_0x5b5f('0x4c')](db[_0x5b5f('0x66')][_0x5b5f('0x32')]);_0x40ca2d['query']=_[_0x5b5f('0x4c')](_0xc63f96[_0x5b5f('0x37')]);_0x40ca2d['filters']=_[_0x5b5f('0x38')](_0x40ca2d['model'],_0x40ca2d[_0x5b5f('0x37')]);_0x183976['attributes']=_[_0x5b5f('0x38')](_0x40ca2d[_0x5b5f('0x35')],qs[_0x5b5f('0x39')](_0xc63f96[_0x5b5f('0x37')][_0x5b5f('0x39')]));_0x183976['attributes']=_0x183976[_0x5b5f('0x3a')][_0x5b5f('0x3b')]?_0x183976['attributes']:_0x40ca2d['model'];_0x183976[_0x5b5f('0x3e')]=qs['sort'](_0xc63f96['query'][_0x5b5f('0x3f')]);_0x183976[_0x5b5f('0x43')]=qs['filters'](_[_0x5b5f('0x40')](_0xc63f96[_0x5b5f('0x37')],_0x40ca2d[_0x5b5f('0x41')]));if(_0xc63f96[_0x5b5f('0x37')][_0x5b5f('0x42')]){_0x183976[_0x5b5f('0x43')]=_['merge'](_0x183976['where'],{'$or':_[_0x5b5f('0x36')](_0x183976[_0x5b5f('0x3a')],function(_0x5e0e06){var _0x4b846f={};_0x4b846f[_0x5e0e06]={'$like':'%'+_0xc63f96[_0x5b5f('0x37')][_0x5b5f('0x42')]+'%'};return _0x4b846f;})});}_0x183976=_[_0x5b5f('0x44')]({},_0x183976,_0xc63f96['options']);return _0x253e8f[_0x5b5f('0x65')](_0x183976);}})[_0x5b5f('0x29')](function(_0x26c9f4){if(_0x26c9f4){_0x5c1800=_0x26c9f4['length'];if(!_0xc63f96[_0x5b5f('0x37')][_0x5b5f('0x3c')](_0x5b5f('0x3d'))){_0x183976[_0x5b5f('0x22')]=qs[_0x5b5f('0x22')](_0xc63f96[_0x5b5f('0x37')][_0x5b5f('0x22')]);_0x183976['offset']=qs['offset'](_0xc63f96[_0x5b5f('0x37')][_0x5b5f('0x1f')]);}return _0x253e8f[_0x5b5f('0x65')](_0x183976);}})['then'](function(_0x584b6c){if(_0x584b6c){return _0x584b6c?{'count':_0x5c1800,'rows':_0x584b6c}:null;}})[_0x5b5f('0x29')](respondWithResult(_0x4d75f2,null))[_0x5b5f('0x4a')](handleError(_0x4d75f2,null));};exports[_0x5b5f('0x67')]=function(_0x5512fb,_0x1aeb2e,_0x4c88fe){var _0x535ea6=_0x5512fb[_0x5b5f('0x4f')][_0x5b5f('0x68')];return db['Team']['findAll']({'where':{'id':_0x535ea6},'attributes':['id'],'include':[{'model':db[_0x5b5f('0x5c')],'as':_0x5b5f('0x69'),'attributes':['id',_0x5b5f('0x2f'),_0x5b5f('0x6a'),_0x5b5f('0x6b'),_0x5b5f('0x6c')],'raw':!![]}]})[_0x5b5f('0x29')](function(_0x4b90bf){if(_0x4b90bf){var _0x9ac1a=_[_0x5b5f('0x6d')](_0x4b90bf,function(_0x4a09e5){var _0x5270b6=_0x4a09e5[_0x5b5f('0x2a')]({'plain':!![]});return _0x5270b6[_0x5b5f('0x69')];});return db[_0x5b5f('0x46')][_0x5b5f('0x4d')]({'where':{'id':_0x5512fb[_0x5b5f('0x4b')]['id']}})['then'](function(_0x38cb43){return db[_0x5b5f('0x6e')][_0x5b5f('0x6f')](function(_0x21fb07){return _0x38cb43[_0x5b5f('0x67')](_0x535ea6,{'transaction':_0x21fb07})[_0x5b5f('0x29')](function(){return BPromise[_0x5b5f('0x70')](_0x9ac1a,function(_0x3590b0){return db[_0x5b5f('0x5a')][_0x5b5f('0x71')]({'where':{'UserId':_0x3590b0['id'],'FaxQueueId':_0x5512fb[_0x5b5f('0x4b')]['id']},'transaction':_0x21fb07});});})['then'](function(){_0x9ac1a[_0x5b5f('0x72')](function(_0x5296d4){socket[_0x5b5f('0x73')](_0x5b5f('0x74'),{'UserId':_0x5296d4['id'],'FaxQueueId':_0x38cb43['id']});});});});});}})[_0x5b5f('0x29')](respondWithStatusCode(_0x1aeb2e,null))['catch'](handleError(_0x1aeb2e,null));};exports['removeTeams']=function(_0x58d2d4,_0x1185ad,_0x1c85ca){return db[_0x5b5f('0x66')][_0x5b5f('0x49')]({'where':{'id':_0x58d2d4['query'][_0x5b5f('0x68')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x5b5f('0x69'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x1185ad,null))[_0x5b5f('0x29')](function(_0x5275eb){var _0x1b5412=_['map'](_0x5275eb,'id');var _0x604fe5=[];var _0x55c7b9=[];var _0x1cd951=squel[_0x5b5f('0x75')]();_0x1cd951['field'](_0x5b5f('0x76'))[_0x5b5f('0x77')](_0x5b5f('0x78'),'tq')[_0x5b5f('0x79')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0x5b5f('0x43')](_0x5b5f('0x7a'),_0x58d2d4[_0x5b5f('0x4b')]['id']);for(var _0x16bacc=0x0;_0x16bacc<_0x5275eb[_0x5b5f('0x3b')];_0x16bacc+=0x1){let _0x362c75=_0x5275eb[_0x16bacc];for(var _0xce3460=0x0;_0xce3460<_0x362c75[_0x5b5f('0x69')][_0x5b5f('0x3b')];_0xce3460+=0x1){let _0xf84097=_0x362c75[_0x5b5f('0x69')][_0xce3460];var _0x2cc79b=_0x1cd951[_0x5b5f('0x7b')]();_0x2cc79b[_0x5b5f('0x43')](_0x5b5f('0x7c'),_0xf84097['id']);_0x55c7b9[_0x5b5f('0x7d')](db[_0x5b5f('0x6e')]['query'](_0x2cc79b['toString'](),{'type':db['sequelize'][_0x5b5f('0x7e')][_0x5b5f('0x7f')]})[_0x5b5f('0x29')](function(_0x5d6e9a){if(_0x5d6e9a[_0x5b5f('0x3b')]===0x1){return _0xf84097['id'];}else{var _0x420813=_[_0x5b5f('0x80')](_['map'](_0x5d6e9a,_0x5b5f('0x81')),function(_0x6af2a){return _[_0x5b5f('0x82')](_0x1b5412,_0x6af2a);});if(_0x420813){return _0xf84097['id'];}}}));}}return BPromise[_0x5b5f('0x83')](_0x55c7b9)[_0x5b5f('0x29')](function(_0xa8776){_0x604fe5=_(_0x604fe5)[_0x5b5f('0x84')](_0xa8776)[_0x5b5f('0x85')]()[_0x5b5f('0x86')]();return db['FaxQueue'][_0x5b5f('0x4d')]({'where':{'id':_0x58d2d4[_0x5b5f('0x4b')]['id']}})[_0x5b5f('0x29')](function(_0x1bfd93){return db['sequelize'][_0x5b5f('0x6f')](function(_0x1a303e){return _0x1bfd93[_0x5b5f('0x87')](_0x58d2d4[_0x5b5f('0x37')][_0x5b5f('0x68')],{'transaction':_0x1a303e})[_0x5b5f('0x29')](function(){if(!_['isEmpty'](_0x604fe5)){return _0x1bfd93[_0x5b5f('0x88')](_0x604fe5,{'transaction':_0x1a303e});}})[_0x5b5f('0x29')](function(){_0x604fe5['forEach'](function(_0x1bc383){socket[_0x5b5f('0x73')](_0x5b5f('0x89'),{'UserId':_0x1bc383,'FaxQueueId':_0x1bfd93['id']});});});});});});})[_0x5b5f('0x29')](respondWithStatusCode(_0x1185ad,null))[_0x5b5f('0x4a')](handleError(_0x1185ad,null));};exports[_0x5b5f('0x8a')]=function(_0x93ff6d,_0x184717,_0x3f3cf6){return db['FaxQueue']['find']({'where':{'id':_0x93ff6d[_0x5b5f('0x4b')]['id']}})[_0x5b5f('0x29')](handleEntityNotFound(_0x184717,null))[_0x5b5f('0x29')](function(_0x4c2997){if(_0x4c2997){return _0x4c2997[_0x5b5f('0x8a')](_0x93ff6d[_0x5b5f('0x4f')][_0x5b5f('0x68')],_[_0x5b5f('0x8b')](_0x93ff6d[_0x5b5f('0x4f')],['ids','id'])||{})[_0x5b5f('0x8c')](function(_0x46ba41){for(var _0x1c6b72=0x0;_0x1c6b72<_0x93ff6d['body'][_0x5b5f('0x68')][_0x5b5f('0x3b')];_0x1c6b72+=0x1){socket[_0x5b5f('0x73')](_0x5b5f('0x74'),{'UserId':Number(_0x93ff6d[_0x5b5f('0x4f')][_0x5b5f('0x68')][_0x1c6b72]),'FaxQueueId':Number(_0x93ff6d[_0x5b5f('0x4b')]['id'])});}return _0x46ba41;});}})[_0x5b5f('0x29')](respondWithResult(_0x184717,null))[_0x5b5f('0x4a')](handleError(_0x184717,null));};exports['removeAgents']=function(_0x3df268,_0x5bb9bb,_0x4bebe7){return db[_0x5b5f('0x46')]['find']({'where':{'id':_0x3df268[_0x5b5f('0x4b')]['id']}})[_0x5b5f('0x29')](handleEntityNotFound(_0x5bb9bb,null))[_0x5b5f('0x29')](function(_0x471087){if(_0x471087){return _0x471087['removeAgents'](_0x3df268[_0x5b5f('0x37')][_0x5b5f('0x68')])[_0x5b5f('0x29')](function(){if(_[_0x5b5f('0x8d')](_0x3df268['query'][_0x5b5f('0x68')])){for(var _0x1db5f0=0x0;_0x1db5f0<_0x3df268[_0x5b5f('0x37')][_0x5b5f('0x68')][_0x5b5f('0x3b')];_0x1db5f0+=0x1){socket[_0x5b5f('0x73')]('userFaxQueue:remove',{'UserId':Number(_0x3df268['query'][_0x5b5f('0x68')][_0x1db5f0]),'FaxQueueId':Number(_0x3df268[_0x5b5f('0x4b')]['id'])});}}else{socket[_0x5b5f('0x73')]('userFaxQueue:remove',{'UserId':Number(_0x3df268[_0x5b5f('0x37')]['ids']),'FaxQueueId':Number(_0x3df268['params']['id'])});}});}})[_0x5b5f('0x29')](respondWithStatusCode(_0x5bb9bb,null))[_0x5b5f('0x4a')](handleError(_0x5bb9bb,null));};exports[_0x5b5f('0x8e')]=function(_0x54c928,_0x58324b,_0x128dfd){var _0x306e9b={};var _0x292b27={};var _0x138306;var _0x1929de;return db[_0x5b5f('0x46')][_0x5b5f('0x59')]({'where':{'id':_0x54c928[_0x5b5f('0x4b')]['id']}})['then'](handleEntityNotFound(_0x58324b,null))[_0x5b5f('0x29')](function(_0x2c4b2f){if(_0x2c4b2f){_0x138306=_0x2c4b2f;_0x292b27[_0x5b5f('0x35')]=_['keys'](db['User'][_0x5b5f('0x32')]);_0x292b27[_0x5b5f('0x37')]=_['keys'](_0x54c928[_0x5b5f('0x37')]);_0x292b27[_0x5b5f('0x41')]=_['intersection'](_0x292b27['model'],_0x292b27[_0x5b5f('0x37')]);_0x306e9b[_0x5b5f('0x3a')]=_[_0x5b5f('0x38')](_0x292b27[_0x5b5f('0x35')],qs[_0x5b5f('0x39')](_0x54c928[_0x5b5f('0x37')][_0x5b5f('0x39')]));_0x306e9b[_0x5b5f('0x3a')]=_0x306e9b[_0x5b5f('0x3a')][_0x5b5f('0x3b')]?_0x306e9b[_0x5b5f('0x3a')]:_0x292b27['model'];_0x306e9b[_0x5b5f('0x3e')]=qs[_0x5b5f('0x3f')](_0x54c928[_0x5b5f('0x37')]['sort']);_0x306e9b[_0x5b5f('0x43')]=qs[_0x5b5f('0x41')](_[_0x5b5f('0x40')](_0x54c928[_0x5b5f('0x37')],_0x292b27['filters']));if(_0x54c928[_0x5b5f('0x37')][_0x5b5f('0x42')]){_0x306e9b[_0x5b5f('0x43')]=_[_0x5b5f('0x44')](_0x306e9b[_0x5b5f('0x43')],{'$or':_['map'](_0x306e9b[_0x5b5f('0x3a')],function(_0x5645eb){var _0x5a48b9={};_0x5a48b9[_0x5645eb]={'$like':'%'+_0x54c928[_0x5b5f('0x37')][_0x5b5f('0x42')]+'%'};return _0x5a48b9;})});}_0x306e9b=_[_0x5b5f('0x44')]({},_0x306e9b,_0x54c928['options']);return _0x138306[_0x5b5f('0x8e')](_0x306e9b);}})[_0x5b5f('0x29')](function(_0x5e4801){if(_0x5e4801){_0x1929de=_0x5e4801['length'];if(!_0x54c928[_0x5b5f('0x37')][_0x5b5f('0x3c')](_0x5b5f('0x3d'))){_0x306e9b['limit']=qs['limit'](_0x54c928[_0x5b5f('0x37')][_0x5b5f('0x22')]);_0x306e9b[_0x5b5f('0x1f')]=qs[_0x5b5f('0x1f')](_0x54c928[_0x5b5f('0x37')][_0x5b5f('0x1f')]);}return _0x138306[_0x5b5f('0x8e')](_0x306e9b);}})[_0x5b5f('0x29')](function(_0x716e35){if(_0x716e35){return _0x716e35?{'count':_0x1929de,'rows':_0x716e35}:null;}})['then'](respondWithResult(_0x58324b,null))[_0x5b5f('0x4a')](handleError(_0x58324b,null));};
\ No newline at end of file