Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 8cf927c..09d0cb3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc165=['zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','register','status','end','json','offset','undefined','count','limit','Content-Range','apply','reject','save','update','then','destroy','get','sendStatus','error','stack','name','send','index','map','FaxQueue','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','rows','catch','params','length','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserFaxQueue','FaxQueueId','findAll','User','findAndCountAll','UserId','agent','createdAt','format','faxPause','updatedAt','getTeams','Team','addTeams','ids','online','voicePause','flatMap','Agents','sequelize','transaction','each','forEach','userFaxQueue:save','field','tq.TeamId','team_has_fax_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','push','TeamId','includes','all','compact','value','removeTeams','removeAgents','emit','addAgents','omit','spread','isArray','userFaxQueue:remove','getAgents','nolimit','eml-format','rimraf'];(function(_0xfed9fb,_0x4f6836){var _0x545f3b=function(_0x114de0){while(--_0x114de0){_0xfed9fb['push'](_0xfed9fb['shift']());}};_0x545f3b(++_0x4f6836);}(_0xc165,0x199));var _0x5c16=function(_0x2a5864,_0x2b9396){_0x2a5864=_0x2a5864-0x0;var _0x490ab6=_0xc165[_0x2a5864];return _0x490ab6;};'use strict';var emlformat=require(_0x5c16('0x0'));var rimraf=require(_0x5c16('0x1'));var zipdir=require(_0x5c16('0x2'));var jsonpatch=require(_0x5c16('0x3'));var rp=require(_0x5c16('0x4'));var moment=require(_0x5c16('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x5c16('0x6'));var util=require(_0x5c16('0x7'));var path=require(_0x5c16('0x8'));var sox=require('sox');var csv=require(_0x5c16('0x9'));var ejs=require(_0x5c16('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x5c16('0xb'));var squel=require(_0x5c16('0xc'));var crypto=require(_0x5c16('0xd'));var jsforce=require(_0x5c16('0xe'));var deskjs=require(_0x5c16('0xf'));var toCsv=require('to-csv');var querystring=require(_0x5c16('0x10'));var Papa=require(_0x5c16('0x11'));var Redis=require(_0x5c16('0x12'));var authService=require(_0x5c16('0x13'));var qs=require(_0x5c16('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5c16('0x15'));var logger=require(_0x5c16('0x16'))('api');var utils=require(_0x5c16('0x17'));var config=require(_0x5c16('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x5c16('0x19'))['db'];config[_0x5c16('0x1a')]=_['defaults'](config[_0x5c16('0x1a')],{'host':_0x5c16('0x1b'),'port':0x18eb});var socket=require(_0x5c16('0x1c'))(new Redis(config[_0x5c16('0x1a')]));require('./faxQueue.socket')[_0x5c16('0x1d')](socket);function respondWithStatusCode(_0x37075c,_0x4786f9){_0x4786f9=_0x4786f9||0xcc;return function(_0x29ef28){if(_0x29ef28){return _0x37075c['sendStatus'](_0x4786f9);}return _0x37075c[_0x5c16('0x1e')](_0x4786f9)[_0x5c16('0x1f')]();};}function respondWithResult(_0x28d2f6,_0x41e6da){_0x41e6da=_0x41e6da||0xc8;return function(_0x26e50){if(_0x26e50){return _0x28d2f6[_0x5c16('0x1e')](_0x41e6da)[_0x5c16('0x20')](_0x26e50);}};}function respondWithFilteredResult(_0x2115b5,_0x523146){return function(_0x3d54b0){if(_0x3d54b0){var _0x328288=typeof _0x523146[_0x5c16('0x21')]===_0x5c16('0x22')&&typeof _0x523146['limit']===_0x5c16('0x22');var _0xf8cfbc=_0x3d54b0[_0x5c16('0x23')];var _0xd82b27=_0x328288?0x0:_0x523146[_0x5c16('0x21')];var _0x4fe38d=_0x328288?_0x3d54b0[_0x5c16('0x23')]:_0x523146[_0x5c16('0x21')]+_0x523146[_0x5c16('0x24')];var _0x1fb45a;if(_0x4fe38d>=_0xf8cfbc){_0x4fe38d=_0xf8cfbc;_0x1fb45a=0xc8;}else{_0x1fb45a=0xce;}_0x2115b5['status'](_0x1fb45a);return _0x2115b5['set'](_0x5c16('0x25'),_0xd82b27+'-'+_0x4fe38d+'/'+_0xf8cfbc)[_0x5c16('0x20')](_0x3d54b0);}return null;};}function patchUpdates(_0x223dc2){return function(_0x4d04f1){try{jsonpatch[_0x5c16('0x26')](_0x4d04f1,_0x223dc2,!![]);}catch(_0x49ce00){return BPromise[_0x5c16('0x27')](_0x49ce00);}return _0x4d04f1[_0x5c16('0x28')]();};}function saveUpdates(_0x261235,_0x240488){return function(_0x27ed01){if(_0x27ed01){return _0x27ed01[_0x5c16('0x29')](_0x261235)[_0x5c16('0x2a')](function(_0x1b1520){return _0x1b1520;});}return null;};}function removeEntity(_0x8a9247,_0x1c31fa){return function(_0x2a1393){if(_0x2a1393){return _0x2a1393[_0x5c16('0x2b')]()['then'](function(){var _0x537a87=_0x2a1393[_0x5c16('0x2c')]({'plain':!![]});var _0x2d97f2='FaxQueues';return db['UserProfileResource'][_0x5c16('0x2b')]({'where':{'type':_0x2d97f2,'resourceId':_0x537a87['id']}})[_0x5c16('0x2a')](function(){return _0x2a1393;});})['then'](function(){_0x8a9247[_0x5c16('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x39e21b,_0x3cf870){return function(_0x2795ea){if(!_0x2795ea){_0x39e21b[_0x5c16('0x2d')](0x194);}return _0x2795ea;};}function handleError(_0x29158e,_0x584b07){_0x584b07=_0x584b07||0x1f4;return function(_0x5e4200){logger[_0x5c16('0x2e')](_0x5e4200[_0x5c16('0x2f')]);if(_0x5e4200[_0x5c16('0x30')]){delete _0x5e4200[_0x5c16('0x30')];}_0x29158e[_0x5c16('0x1e')](_0x584b07)[_0x5c16('0x31')](_0x5e4200);};}exports[_0x5c16('0x32')]=function(_0x5d6404,_0x5c76da){var _0x1f3784={},_0x41a672={},_0x534734={'count':0x0,'rows':[]};var _0x2a14f3=_[_0x5c16('0x33')](db[_0x5c16('0x34')][_0x5c16('0x35')],function(_0x24acd3){return{'name':_0x24acd3[_0x5c16('0x36')],'type':_0x24acd3[_0x5c16('0x37')][_0x5c16('0x38')]};});_0x41a672[_0x5c16('0x39')]=_[_0x5c16('0x33')](_0x2a14f3,_0x5c16('0x30'));_0x41a672[_0x5c16('0x3a')]=_[_0x5c16('0x3b')](_0x5d6404[_0x5c16('0x3a')]);_0x41a672[_0x5c16('0x3c')]=_[_0x5c16('0x3d')](_0x41a672[_0x5c16('0x39')],_0x41a672[_0x5c16('0x3a')]);_0x1f3784[_0x5c16('0x3e')]=_[_0x5c16('0x3d')](_0x41a672['model'],qs[_0x5c16('0x3f')](_0x5d6404['query'][_0x5c16('0x3f')]));_0x1f3784['attributes']=_0x1f3784[_0x5c16('0x3e')]['length']?_0x1f3784[_0x5c16('0x3e')]:_0x41a672[_0x5c16('0x39')];if(!_0x5d6404[_0x5c16('0x3a')][_0x5c16('0x40')]('nolimit')){_0x1f3784[_0x5c16('0x24')]=qs[_0x5c16('0x24')](_0x5d6404[_0x5c16('0x3a')][_0x5c16('0x24')]);_0x1f3784[_0x5c16('0x21')]=qs[_0x5c16('0x21')](_0x5d6404[_0x5c16('0x3a')][_0x5c16('0x21')]);}_0x1f3784[_0x5c16('0x41')]=qs[_0x5c16('0x42')](_0x5d6404[_0x5c16('0x3a')][_0x5c16('0x42')]);_0x1f3784[_0x5c16('0x43')]=qs[_0x5c16('0x3c')](_[_0x5c16('0x44')](_0x5d6404['query'],_0x41a672['filters']),_0x2a14f3);if(_0x5d6404[_0x5c16('0x3a')][_0x5c16('0x45')]){_0x1f3784[_0x5c16('0x43')]=_['merge'](_0x1f3784[_0x5c16('0x43')],{'$or':_[_0x5c16('0x33')](_0x2a14f3,function(_0x91b7e1){if(_0x91b7e1['type']!==_0x5c16('0x46')){var _0x47424a={};_0x47424a[_0x91b7e1['name']]={'$like':'%'+_0x5d6404[_0x5c16('0x3a')][_0x5c16('0x45')]+'%'};return _0x47424a;}})});}_0x1f3784=_[_0x5c16('0x47')]({},_0x1f3784,_0x5d6404[_0x5c16('0x48')]);var _0x346ca0={'where':_0x1f3784['where']};return db['FaxQueue'][_0x5c16('0x23')](_0x346ca0)['then'](function(_0x5bc506){_0x534734[_0x5c16('0x23')]=_0x5bc506;if(_0x5d6404[_0x5c16('0x3a')][_0x5c16('0x49')]){_0x1f3784['include']=[{'all':!![]}];}return db['FaxQueue']['findAll'](_0x1f3784);})['then'](function(_0x29e8c8){_0x534734[_0x5c16('0x4a')]=_0x29e8c8;return _0x534734;})['then'](respondWithFilteredResult(_0x5c76da,_0x1f3784))[_0x5c16('0x4b')](handleError(_0x5c76da,null));};exports['show']=function(_0x4f866c,_0x3fad59){var _0x125c7f={'raw':!![],'where':{'id':_0x4f866c[_0x5c16('0x4c')]['id']}},_0x3ce11a={};_0x3ce11a['model']=_['keys'](db[_0x5c16('0x34')][_0x5c16('0x35')]);_0x3ce11a[_0x5c16('0x3a')]=_['keys'](_0x4f866c[_0x5c16('0x3a')]);_0x3ce11a[_0x5c16('0x3c')]=_[_0x5c16('0x3d')](_0x3ce11a['model'],_0x3ce11a[_0x5c16('0x3a')]);_0x125c7f[_0x5c16('0x3e')]=_['intersection'](_0x3ce11a[_0x5c16('0x39')],qs[_0x5c16('0x3f')](_0x4f866c[_0x5c16('0x3a')][_0x5c16('0x3f')]));_0x125c7f['attributes']=_0x125c7f[_0x5c16('0x3e')][_0x5c16('0x4d')]?_0x125c7f['attributes']:_0x3ce11a[_0x5c16('0x39')];if(_0x4f866c[_0x5c16('0x3a')][_0x5c16('0x49')]){_0x125c7f['include']=[{'all':!![]}];}_0x125c7f=_[_0x5c16('0x47')]({},_0x125c7f,_0x4f866c['options']);return db[_0x5c16('0x34')][_0x5c16('0x4e')](_0x125c7f)[_0x5c16('0x2a')](handleEntityNotFound(_0x3fad59,null))['then'](respondWithResult(_0x3fad59,null))['catch'](handleError(_0x3fad59,null));};exports['create']=function(_0x76bfdd,_0x3acfe6){return db[_0x5c16('0x34')][_0x5c16('0x4f')](_0x76bfdd[_0x5c16('0x50')],{})[_0x5c16('0x2a')](function(_0x7f6ed){var _0xebf61=_0x76bfdd['user'][_0x5c16('0x2c')]({'plain':!![]});if(!_0xebf61)throw new Error(_0x5c16('0x51'));if(_0xebf61['role']===_0x5c16('0x52')){var _0x854f45=_0x7f6ed['get']({'plain':!![]});var _0x52376a='FaxQueues';return db[_0x5c16('0x53')][_0x5c16('0x4e')]({'where':{'name':_0x52376a,'userProfileId':_0xebf61['userProfileId']},'raw':!![]})[_0x5c16('0x2a')](function(_0x4eadd5){if(_0x4eadd5&&_0x4eadd5[_0x5c16('0x54')]===0x0){return db[_0x5c16('0x55')][_0x5c16('0x4f')]({'name':_0x854f45['name'],'resourceId':_0x854f45['id'],'type':_0x4eadd5[_0x5c16('0x30')],'sectionId':_0x4eadd5['id']},{})[_0x5c16('0x2a')](function(){return _0x7f6ed;});}else{return _0x7f6ed;}})[_0x5c16('0x4b')](function(_0x19e6a3){logger[_0x5c16('0x2e')](_0x5c16('0x56'),_0x19e6a3);throw _0x19e6a3;});}return _0x7f6ed;})['then'](respondWithResult(_0x3acfe6,0xc9))[_0x5c16('0x4b')](handleError(_0x3acfe6,null));};exports[_0x5c16('0x29')]=function(_0x38a989,_0x504b46){if(_0x38a989[_0x5c16('0x50')]['id']){delete _0x38a989[_0x5c16('0x50')]['id'];}return db[_0x5c16('0x34')]['find']({'where':{'id':_0x38a989['params']['id']}})[_0x5c16('0x2a')](handleEntityNotFound(_0x504b46,null))[_0x5c16('0x2a')](saveUpdates(_0x38a989[_0x5c16('0x50')],null))[_0x5c16('0x2a')](respondWithResult(_0x504b46,null))[_0x5c16('0x4b')](handleError(_0x504b46,null));};exports[_0x5c16('0x2b')]=function(_0x5a9d4b,_0x5a1969){return db[_0x5c16('0x34')][_0x5c16('0x4e')]({'where':{'id':_0x5a9d4b[_0x5c16('0x4c')]['id']}})['then'](handleEntityNotFound(_0x5a1969,null))[_0x5c16('0x2a')](removeEntity(_0x5a1969,null))['catch'](handleError(_0x5a1969,null));};exports[_0x5c16('0x57')]=function(_0x4f50bb,_0x4062c9){return db['FaxQueue'][_0x5c16('0x57')]()[_0x5c16('0x2a')](respondWithResult(_0x4062c9,null))['catch'](handleError(_0x4062c9,null));};exports[_0x5c16('0x58')]=function(_0x50ba58,_0x1ab232,_0x971a2f){var _0x4ee8cc={'raw':!![],'where':{}},_0x3087ac={},_0x2fcb3b;return db[_0x5c16('0x34')][_0x5c16('0x59')]({'where':{'id':_0x50ba58[_0x5c16('0x4c')]['id']}})['then'](handleEntityNotFound(_0x1ab232,null))[_0x5c16('0x2a')](function(_0x41cf93){if(_0x41cf93){_0x2fcb3b=_0x41cf93[_0x5c16('0x2c')]({'plain':!![]});_0x3087ac[_0x5c16('0x39')]=_[_0x5c16('0x3b')](db[_0x5c16('0x5a')][_0x5c16('0x35')]);_0x3087ac[_0x5c16('0x3a')]=_[_0x5c16('0x3b')](_0x50ba58[_0x5c16('0x3a')]);_0x3087ac[_0x5c16('0x3c')]=_['intersection'](_0x3087ac['model'],_0x3087ac[_0x5c16('0x3a')]);_0x4ee8cc[_0x5c16('0x3e')]=_['intersection'](_0x3087ac['model'],qs['fields'](_0x50ba58[_0x5c16('0x3a')][_0x5c16('0x3f')]));_0x4ee8cc[_0x5c16('0x3e')]=_0x4ee8cc[_0x5c16('0x3e')][_0x5c16('0x4d')]?_0x4ee8cc[_0x5c16('0x3e')]:_0x3087ac['model'];if(!_0x50ba58[_0x5c16('0x3a')][_0x5c16('0x40')]('nolimit')){_0x4ee8cc[_0x5c16('0x24')]=qs[_0x5c16('0x24')](_0x50ba58[_0x5c16('0x3a')][_0x5c16('0x24')]);_0x4ee8cc[_0x5c16('0x21')]=qs[_0x5c16('0x21')](_0x50ba58[_0x5c16('0x3a')][_0x5c16('0x21')]);}_0x4ee8cc[_0x5c16('0x41')]=qs[_0x5c16('0x42')](_0x50ba58[_0x5c16('0x3a')][_0x5c16('0x42')]);_0x4ee8cc[_0x5c16('0x43')]=qs['filters'](_['pick'](_0x50ba58['query'],_0x3087ac['filters']));_0x4ee8cc[_0x5c16('0x43')][_0x5c16('0x5b')]=_0x41cf93['id'];if(_0x50ba58[_0x5c16('0x3a')][_0x5c16('0x45')]){_0x4ee8cc[_0x5c16('0x43')]=_[_0x5c16('0x47')](_0x4ee8cc[_0x5c16('0x43')],{'$or':_[_0x5c16('0x33')](_0x4ee8cc[_0x5c16('0x3e')],function(_0x1f4f6e){var _0x42b983={};_0x42b983[_0x1f4f6e]={'$like':'%'+_0x50ba58[_0x5c16('0x3a')][_0x5c16('0x45')]+'%'};return _0x42b983;})});}_0x4ee8cc=_[_0x5c16('0x47')]({},_0x4ee8cc,_0x50ba58['options']);return db[_0x5c16('0x5a')][_0x5c16('0x5c')](_0x4ee8cc);}})['then'](function(_0x5ac0ba){if(_0x5ac0ba){return db[_0x5c16('0x5d')][_0x5c16('0x5e')]({'where':{'id':_[_0x5c16('0x33')](_0x5ac0ba,_0x5c16('0x5f')),'role':_0x5c16('0x60')},'attributes':['id','name','faxPause','updatedAt',_0x5c16('0x61')]});}})[_0x5c16('0x2a')](function(_0x4fe42b){if(_0x4fe42b){return{'count':_0x4fe42b['count'],'rows':_[_0x5c16('0x33')](_0x4fe42b[_0x5c16('0x4a')],function(_0x6785d1){return{'membername':_0x6785d1[_0x5c16('0x30')],'UserId':_0x6785d1['id'],'queue_name':_0x2fcb3b[_0x5c16('0x30')],'FaxQueueId':_0x2fcb3b['id'],'interface':util[_0x5c16('0x62')]('%s/%s','SIP',_0x6785d1[_0x5c16('0x30')]),'penalty':0x0,'paused':_0x6785d1[_0x5c16('0x63')],'createdAt':_0x6785d1[_0x5c16('0x61')],'updatedAt':_0x6785d1[_0x5c16('0x64')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x5c16('0x2a')](respondWithFilteredResult(_0x1ab232,_0x4ee8cc))['catch'](handleError(_0x1ab232,null));};exports[_0x5c16('0x65')]=function(_0xa3051c,_0x479893,_0x59a91c){var _0x5ad2ec={};var _0x3f32e1={};var _0x4cb3d6;var _0x405f98;return db['FaxQueue'][_0x5c16('0x59')]({'where':{'id':_0xa3051c[_0x5c16('0x4c')]['id']}})[_0x5c16('0x2a')](handleEntityNotFound(_0x479893,null))[_0x5c16('0x2a')](function(_0x27faa6){if(_0x27faa6){_0x4cb3d6=_0x27faa6;_0x3f32e1[_0x5c16('0x39')]=_['keys'](db[_0x5c16('0x66')][_0x5c16('0x35')]);_0x3f32e1[_0x5c16('0x3a')]=_[_0x5c16('0x3b')](_0xa3051c[_0x5c16('0x3a')]);_0x3f32e1[_0x5c16('0x3c')]=_[_0x5c16('0x3d')](_0x3f32e1[_0x5c16('0x39')],_0x3f32e1[_0x5c16('0x3a')]);_0x5ad2ec[_0x5c16('0x3e')]=_[_0x5c16('0x3d')](_0x3f32e1['model'],qs[_0x5c16('0x3f')](_0xa3051c[_0x5c16('0x3a')][_0x5c16('0x3f')]));_0x5ad2ec[_0x5c16('0x3e')]=_0x5ad2ec[_0x5c16('0x3e')]['length']?_0x5ad2ec[_0x5c16('0x3e')]:_0x3f32e1[_0x5c16('0x39')];_0x5ad2ec[_0x5c16('0x41')]=qs[_0x5c16('0x42')](_0xa3051c['query'][_0x5c16('0x42')]);_0x5ad2ec[_0x5c16('0x43')]=qs[_0x5c16('0x3c')](_[_0x5c16('0x44')](_0xa3051c[_0x5c16('0x3a')],_0x3f32e1[_0x5c16('0x3c')]));if(_0xa3051c[_0x5c16('0x3a')][_0x5c16('0x45')]){_0x5ad2ec['where']=_['merge'](_0x5ad2ec[_0x5c16('0x43')],{'$or':_[_0x5c16('0x33')](_0x5ad2ec[_0x5c16('0x3e')],function(_0x47318c){var _0x55f356={};_0x55f356[_0x47318c]={'$like':'%'+_0xa3051c[_0x5c16('0x3a')][_0x5c16('0x45')]+'%'};return _0x55f356;})});}_0x5ad2ec=_[_0x5c16('0x47')]({},_0x5ad2ec,_0xa3051c[_0x5c16('0x48')]);return _0x4cb3d6[_0x5c16('0x65')](_0x5ad2ec);}})[_0x5c16('0x2a')](function(_0x900037){if(_0x900037){_0x405f98=_0x900037[_0x5c16('0x4d')];if(!_0xa3051c['query'][_0x5c16('0x40')]('nolimit')){_0x5ad2ec['limit']=qs['limit'](_0xa3051c['query'][_0x5c16('0x24')]);_0x5ad2ec['offset']=qs[_0x5c16('0x21')](_0xa3051c[_0x5c16('0x3a')][_0x5c16('0x21')]);}return _0x4cb3d6[_0x5c16('0x65')](_0x5ad2ec);}})[_0x5c16('0x2a')](function(_0x25f927){if(_0x25f927){return _0x25f927?{'count':_0x405f98,'rows':_0x25f927}:null;}})[_0x5c16('0x2a')](respondWithResult(_0x479893,null))['catch'](handleError(_0x479893,null));};exports[_0x5c16('0x67')]=function(_0x5c9a67,_0x28eb4b,_0x59e679){var _0x3edfde=_0x5c9a67[_0x5c16('0x50')][_0x5c16('0x68')];return db[_0x5c16('0x66')][_0x5c16('0x5c')]({'where':{'id':_0x3edfde},'attributes':['id'],'include':[{'model':db[_0x5c16('0x5d')],'as':'Agents','attributes':['id','name',_0x5c16('0x69'),_0x5c16('0x6a'),'interface'],'raw':!![]}]})[_0x5c16('0x2a')](function(_0xc0664a){if(_0xc0664a){var _0x4a50ce=_[_0x5c16('0x6b')](_0xc0664a,function(_0xb48eb1){var _0x272268=_0xb48eb1[_0x5c16('0x2c')]({'plain':!![]});return _0x272268[_0x5c16('0x6c')];});return db[_0x5c16('0x34')][_0x5c16('0x4e')]({'where':{'id':_0x5c9a67[_0x5c16('0x4c')]['id']}})['then'](function(_0xd37550){return db[_0x5c16('0x6d')][_0x5c16('0x6e')](function(_0x43090b){return _0xd37550[_0x5c16('0x67')](_0x3edfde,{'transaction':_0x43090b})[_0x5c16('0x2a')](function(){return BPromise[_0x5c16('0x6f')](_0x4a50ce,function(_0x12767b){return db[_0x5c16('0x5a')]['findOrCreate']({'where':{'UserId':_0x12767b['id'],'FaxQueueId':_0x5c9a67['params']['id']},'transaction':_0x43090b});});})[_0x5c16('0x2a')](function(){_0x4a50ce[_0x5c16('0x70')](function(_0x16536d){socket['emit'](_0x5c16('0x71'),{'UserId':_0x16536d['id'],'FaxQueueId':_0xd37550['id']});});});});});}})[_0x5c16('0x2a')](respondWithStatusCode(_0x28eb4b,null))['catch'](handleError(_0x28eb4b,null));};exports['removeTeams']=function(_0xb9b068,_0x193f6a,_0x55aa97){return db[_0x5c16('0x66')]['findAll']({'where':{'id':_0xb9b068[_0x5c16('0x3a')]['ids']},'attributes':['id'],'include':[{'model':db[_0x5c16('0x5d')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x5c16('0x2a')](handleEntityNotFound(_0x193f6a,null))[_0x5c16('0x2a')](function(_0x5490cf){var _0x359b05=_['map'](_0x5490cf,'id');var _0xb129f3=[];var _0x4059ea=[];var _0x4f805c=squel['select']();_0x4f805c[_0x5c16('0x72')](_0x5c16('0x73'))['from'](_0x5c16('0x74'),'tq')[_0x5c16('0x75')](_0x5c16('0x76'),'ut',_0x5c16('0x77'))['where'](_0x5c16('0x78'),_0xb9b068[_0x5c16('0x4c')]['id']);for(var _0x26cce9=0x0;_0x26cce9<_0x5490cf[_0x5c16('0x4d')];_0x26cce9+=0x1){let _0x394ce5=_0x5490cf[_0x26cce9];for(var _0x52ef9f=0x0;_0x52ef9f<_0x394ce5[_0x5c16('0x6c')][_0x5c16('0x4d')];_0x52ef9f+=0x1){let _0x10bf7f=_0x394ce5[_0x5c16('0x6c')][_0x52ef9f];var _0x16c9a3=_0x4f805c['clone']();_0x16c9a3[_0x5c16('0x43')]('ut.UserId\x20=\x20?',_0x10bf7f['id']);_0x4059ea[_0x5c16('0x79')](db[_0x5c16('0x6d')][_0x5c16('0x3a')](_0x16c9a3['toString'](),{'type':db[_0x5c16('0x6d')]['QueryTypes']['SELECT']})[_0x5c16('0x2a')](function(_0x37cefb){if(_0x37cefb[_0x5c16('0x4d')]===0x1){return _0x10bf7f['id'];}else{var _0x432580=_['every'](_[_0x5c16('0x33')](_0x37cefb,_0x5c16('0x7a')),function(_0x358e7c){return _[_0x5c16('0x7b')](_0x359b05,_0x358e7c);});if(_0x432580){return _0x10bf7f['id'];}}}));}}return BPromise[_0x5c16('0x7c')](_0x4059ea)[_0x5c16('0x2a')](function(_0x371050){_0xb129f3=_(_0xb129f3)['union'](_0x371050)[_0x5c16('0x7d')]()[_0x5c16('0x7e')]();return db[_0x5c16('0x34')]['find']({'where':{'id':_0xb9b068['params']['id']}})[_0x5c16('0x2a')](function(_0x2537f7){return db[_0x5c16('0x6d')][_0x5c16('0x6e')](function(_0x14b155){return _0x2537f7[_0x5c16('0x7f')](_0xb9b068[_0x5c16('0x3a')][_0x5c16('0x68')],{'transaction':_0x14b155})[_0x5c16('0x2a')](function(){if(!_['isEmpty'](_0xb129f3)){return _0x2537f7[_0x5c16('0x80')](_0xb129f3,{'transaction':_0x14b155});}})[_0x5c16('0x2a')](function(){_0xb129f3[_0x5c16('0x70')](function(_0x578106){socket[_0x5c16('0x81')]('userFaxQueue:remove',{'UserId':_0x578106,'FaxQueueId':_0x2537f7['id']});});});});});});})[_0x5c16('0x2a')](respondWithStatusCode(_0x193f6a,null))[_0x5c16('0x4b')](handleError(_0x193f6a,null));};exports[_0x5c16('0x82')]=function(_0x511ca9,_0x4c83a2,_0x270eb2){return db[_0x5c16('0x34')]['find']({'where':{'id':_0x511ca9[_0x5c16('0x4c')]['id']}})[_0x5c16('0x2a')](handleEntityNotFound(_0x4c83a2,null))['then'](function(_0x4a4a7d){if(_0x4a4a7d){return _0x4a4a7d[_0x5c16('0x82')](_0x511ca9[_0x5c16('0x50')][_0x5c16('0x68')],_[_0x5c16('0x83')](_0x511ca9[_0x5c16('0x50')],['ids','id'])||{})[_0x5c16('0x84')](function(_0x172991){for(var _0x194094=0x0;_0x194094<_0x511ca9['body'][_0x5c16('0x68')][_0x5c16('0x4d')];_0x194094+=0x1){socket[_0x5c16('0x81')](_0x5c16('0x71'),{'UserId':_0x511ca9[_0x5c16('0x50')][_0x5c16('0x68')][_0x194094],'FaxQueueId':_0x511ca9[_0x5c16('0x4c')]['id']});}return _0x172991;});}})[_0x5c16('0x2a')](respondWithResult(_0x4c83a2,null))[_0x5c16('0x4b')](handleError(_0x4c83a2,null));};exports[_0x5c16('0x80')]=function(_0x3d5a72,_0x5b526f,_0x2f660d){return db[_0x5c16('0x34')]['find']({'where':{'id':_0x3d5a72['params']['id']}})[_0x5c16('0x2a')](handleEntityNotFound(_0x5b526f,null))[_0x5c16('0x2a')](function(_0x610a09){if(_0x610a09){return _0x610a09[_0x5c16('0x80')](_0x3d5a72[_0x5c16('0x3a')][_0x5c16('0x68')])[_0x5c16('0x2a')](function(){if(_[_0x5c16('0x85')](_0x3d5a72['query']['ids'])){for(var _0x2031ba=0x0;_0x2031ba<_0x3d5a72[_0x5c16('0x3a')]['ids']['length'];_0x2031ba+=0x1){socket['emit'](_0x5c16('0x86'),{'UserId':Number(_0x3d5a72[_0x5c16('0x3a')][_0x5c16('0x68')][_0x2031ba]),'FaxQueueId':Number(_0x3d5a72[_0x5c16('0x4c')]['id'])});}}else{socket[_0x5c16('0x81')](_0x5c16('0x86'),{'UserId':Number(_0x3d5a72[_0x5c16('0x3a')]['ids']),'FaxQueueId':Number(_0x3d5a72['params']['id'])});}});}})[_0x5c16('0x2a')](respondWithStatusCode(_0x5b526f,null))['catch'](handleError(_0x5b526f,null));};exports['getAgents']=function(_0x29cba2,_0x5a3ce8,_0x2297a7){var _0x592cf7={};var _0x35dc74={};var _0xe7b72d;var _0x3ce3ee;return db[_0x5c16('0x34')][_0x5c16('0x59')]({'where':{'id':_0x29cba2[_0x5c16('0x4c')]['id']}})[_0x5c16('0x2a')](handleEntityNotFound(_0x5a3ce8,null))['then'](function(_0x3702f7){if(_0x3702f7){_0xe7b72d=_0x3702f7;_0x35dc74[_0x5c16('0x39')]=_['keys'](db[_0x5c16('0x5d')][_0x5c16('0x35')]);_0x35dc74[_0x5c16('0x3a')]=_[_0x5c16('0x3b')](_0x29cba2['query']);_0x35dc74['filters']=_[_0x5c16('0x3d')](_0x35dc74[_0x5c16('0x39')],_0x35dc74['query']);_0x592cf7[_0x5c16('0x3e')]=_['intersection'](_0x35dc74['model'],qs[_0x5c16('0x3f')](_0x29cba2['query'][_0x5c16('0x3f')]));_0x592cf7[_0x5c16('0x3e')]=_0x592cf7[_0x5c16('0x3e')][_0x5c16('0x4d')]?_0x592cf7[_0x5c16('0x3e')]:_0x35dc74[_0x5c16('0x39')];_0x592cf7[_0x5c16('0x41')]=qs[_0x5c16('0x42')](_0x29cba2[_0x5c16('0x3a')][_0x5c16('0x42')]);_0x592cf7['where']=qs[_0x5c16('0x3c')](_[_0x5c16('0x44')](_0x29cba2[_0x5c16('0x3a')],_0x35dc74[_0x5c16('0x3c')]));if(_0x29cba2[_0x5c16('0x3a')][_0x5c16('0x45')]){_0x592cf7[_0x5c16('0x43')]=_[_0x5c16('0x47')](_0x592cf7['where'],{'$or':_[_0x5c16('0x33')](_0x592cf7[_0x5c16('0x3e')],function(_0x2c2e1b){var _0x5ae3bc={};_0x5ae3bc[_0x2c2e1b]={'$like':'%'+_0x29cba2['query']['filter']+'%'};return _0x5ae3bc;})});}_0x592cf7=_[_0x5c16('0x47')]({},_0x592cf7,_0x29cba2[_0x5c16('0x48')]);return _0xe7b72d[_0x5c16('0x87')](_0x592cf7);}})[_0x5c16('0x2a')](function(_0x57ab33){if(_0x57ab33){_0x3ce3ee=_0x57ab33['length'];if(!_0x29cba2[_0x5c16('0x3a')][_0x5c16('0x40')](_0x5c16('0x88'))){_0x592cf7[_0x5c16('0x24')]=qs[_0x5c16('0x24')](_0x29cba2[_0x5c16('0x3a')]['limit']);_0x592cf7[_0x5c16('0x21')]=qs[_0x5c16('0x21')](_0x29cba2[_0x5c16('0x3a')][_0x5c16('0x21')]);}return _0xe7b72d['getAgents'](_0x592cf7);}})[_0x5c16('0x2a')](function(_0x48f180){if(_0x48f180){return _0x48f180?{'count':_0x3ce3ee,'rows':_0x48f180}:null;}})[_0x5c16('0x2a')](respondWithResult(_0x5a3ce8,null))[_0x5c16('0x4b')](handleError(_0x5a3ce8,null));};
\ No newline at end of file
+var _0x31f0=['merge','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','error','describe','findOne','UserFaxQueue','nolimit','order','sort','pick','FaxQueueId','filter','findAndCountAll','UserId','agent','faxPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','ids','User','Agents','online','interface','flatMap','sequelize','each','findOrCreate','forEach','userFaxQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','QueryTypes','every','TeamId','includes','union','transaction','removeAgents','userFaxQueue:remove','addAgents','omit','emit','getAgents','bluebird','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','redis','socket.io-emitter','./faxQueue.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','then','destroy','get','FaxQueues','UserProfileResource','name','send','index','map','rawAttributes','type','key','getOptions','where','FaxQueue','include','query','findAll','rows','catch','show','params','model','keys','filters','intersection','attributes','fields','length','includeAll'];(function(_0x147656,_0x205a15){var _0x37e1e9=function(_0xea78b){while(--_0xea78b){_0x147656['push'](_0x147656['shift']());}};_0x37e1e9(++_0x205a15);}(_0x31f0,0xb7));var _0x031f=function(_0x33f6db,_0x277e76){_0x33f6db=_0x33f6db-0x0;var _0x3bc6d0=_0x31f0[_0x33f6db];return _0x3bc6d0;};'use strict';var BPromise=require(_0x031f('0x0'));var util=require('util');var _=require(_0x031f('0x1'));var squel=require('squel');var Redis=require(_0x031f('0x2'));var qs=require(_0x031f('0x3'));var logger=require(_0x031f('0x4'))(_0x031f('0x5'));var config=require('../../config/environment');var db=require(_0x031f('0x6'))['db'];config[_0x031f('0x7')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x031f('0x8'))(new Redis(config['redis']));require(_0x031f('0x9'))[_0x031f('0xa')](socket);function respondWithStatusCode(_0x2569b6,_0x3e41ed){_0x3e41ed=_0x3e41ed||0xcc;return function(_0x4d47c5){if(_0x4d47c5){return _0x2569b6[_0x031f('0xb')](_0x3e41ed);}return _0x2569b6[_0x031f('0xc')](_0x3e41ed)[_0x031f('0xd')]();};}function respondWithResult(_0x439940,_0x3dd729){_0x3dd729=_0x3dd729||0xc8;return function(_0x3b0a17){if(_0x3b0a17){return _0x439940[_0x031f('0xc')](_0x3dd729)[_0x031f('0xe')](_0x3b0a17);}};}function respondWithFilteredResult(_0x4df318,_0x5c3657){return function(_0x353744){if(_0x353744){var _0x28da6e=typeof _0x5c3657[_0x031f('0xf')]===_0x031f('0x10')&&typeof _0x5c3657[_0x031f('0x11')]===_0x031f('0x10');var _0x5d0457=_0x353744[_0x031f('0x12')];var _0x23b40c=_0x28da6e?0x0:_0x5c3657[_0x031f('0xf')];var _0x2e3dfe=_0x28da6e?_0x353744[_0x031f('0x12')]:_0x5c3657['offset']+_0x5c3657['limit'];var _0x1f08db;if(_0x2e3dfe>=_0x5d0457){_0x2e3dfe=_0x5d0457;_0x1f08db=0xc8;}else{_0x1f08db=0xce;}_0x4df318[_0x031f('0xc')](_0x1f08db);return _0x4df318[_0x031f('0x13')](_0x031f('0x14'),_0x23b40c+'-'+_0x2e3dfe+'/'+_0x5d0457)['json'](_0x353744);}return null;};}function saveUpdates(_0x1dc4a7){return function(_0x1d8ac2){if(_0x1d8ac2){return _0x1d8ac2['update'](_0x1dc4a7)[_0x031f('0x15')](function(_0x535e70){return _0x535e70;});}return null;};}function removeEntity(_0x421f75){return function(_0x5f2199){if(_0x5f2199){return _0x5f2199[_0x031f('0x16')]()[_0x031f('0x15')](function(){var _0x1ceddc=_0x5f2199[_0x031f('0x17')]({'plain':!![]});var _0x1b76d6=_0x031f('0x18');return db[_0x031f('0x19')][_0x031f('0x16')]({'where':{'type':_0x1b76d6,'resourceId':_0x1ceddc['id']}})[_0x031f('0x15')](function(){return _0x5f2199;});})['then'](function(){_0x421f75[_0x031f('0xc')](0xcc)[_0x031f('0xd')]();});}};}function handleEntityNotFound(_0x451328){return function(_0x4d6706){if(!_0x4d6706){_0x451328['sendStatus'](0x194);}return _0x4d6706;};}function handleError(_0xa11a2b,_0x4d0f92){_0x4d0f92=_0x4d0f92||0x1f4;return function(_0x3472a2){logger['error'](_0x3472a2['stack']);if(_0x3472a2['name']){delete _0x3472a2[_0x031f('0x1a')];}_0xa11a2b[_0x031f('0xc')](_0x4d0f92)[_0x031f('0x1b')](_0x3472a2);};}exports[_0x031f('0x1c')]=function(_0x494568,_0x374b65){var _0x5a64c0={};var _0x40cb1c={'count':0x0,'rows':[]};var _0x1f5a14=_[_0x031f('0x1d')](db['FaxQueue'][_0x031f('0x1e')],function(_0x3b2a51){return{'name':_0x3b2a51['fieldName'],'type':_0x3b2a51[_0x031f('0x1f')][_0x031f('0x20')]};});_0x5a64c0=qs[_0x031f('0x21')](_0x1f5a14,_0x494568);var _0x5395ea={'where':_0x5a64c0[_0x031f('0x22')]};return db[_0x031f('0x23')][_0x031f('0x12')](_0x5395ea)[_0x031f('0x15')](function(_0xfaa36){_0x40cb1c[_0x031f('0x12')]=_0xfaa36;_0x5a64c0['include']=qs[_0x031f('0x24')](_0x494568[_0x031f('0x25')]);return db[_0x031f('0x23')][_0x031f('0x26')](_0x5a64c0);})[_0x031f('0x15')](function(_0x2d24f0){_0x40cb1c[_0x031f('0x27')]=_0x2d24f0;return _0x40cb1c;})[_0x031f('0x15')](respondWithFilteredResult(_0x374b65,_0x5a64c0))[_0x031f('0x28')](handleError(_0x374b65,null));};exports[_0x031f('0x29')]=function(_0x2cf3a8,_0x5ec564){var _0xced6ff={'raw':!![],'where':{'id':_0x2cf3a8[_0x031f('0x2a')]['id']}},_0xe5f11c={};_0xe5f11c[_0x031f('0x2b')]=_[_0x031f('0x2c')](db[_0x031f('0x23')][_0x031f('0x1e')]);_0xe5f11c[_0x031f('0x25')]=_[_0x031f('0x2c')](_0x2cf3a8[_0x031f('0x25')]);_0xe5f11c[_0x031f('0x2d')]=_[_0x031f('0x2e')](_0xe5f11c[_0x031f('0x2b')],_0xe5f11c['query']);_0xced6ff[_0x031f('0x2f')]=_[_0x031f('0x2e')](_0xe5f11c['model'],qs[_0x031f('0x30')](_0x2cf3a8[_0x031f('0x25')]['fields']));_0xced6ff[_0x031f('0x2f')]=_0xced6ff[_0x031f('0x2f')][_0x031f('0x31')]?_0xced6ff[_0x031f('0x2f')]:_0xe5f11c['model'];if(_0x2cf3a8['query'][_0x031f('0x32')]){_0xced6ff['include']=[{'all':!![]}];}_0xced6ff=_[_0x031f('0x33')]({},_0xced6ff,_0x2cf3a8[_0x031f('0x34')]);return db[_0x031f('0x23')]['find'](_0xced6ff)['then'](handleEntityNotFound(_0x5ec564,null))[_0x031f('0x15')](respondWithResult(_0x5ec564,null))['catch'](handleError(_0x5ec564,null));};exports['create']=function(_0x2d489a,_0x45e3a4){return db[_0x031f('0x23')][_0x031f('0x35')](_0x2d489a[_0x031f('0x36')],{})[_0x031f('0x15')](function(_0x1ffd03){var _0x55c85f=_0x2d489a[_0x031f('0x37')][_0x031f('0x17')]({'plain':!![]});if(!_0x55c85f)throw new Error(_0x031f('0x38'));if(_0x55c85f[_0x031f('0x39')]==='user'){var _0x2be5d1=_0x1ffd03[_0x031f('0x17')]({'plain':!![]});var _0x2dba8b='FaxQueues';return db[_0x031f('0x3a')][_0x031f('0x3b')]({'where':{'name':_0x2dba8b,'userProfileId':_0x55c85f['userProfileId']},'raw':!![]})[_0x031f('0x15')](function(_0x268dc7){if(_0x268dc7&&_0x268dc7['autoAssociation']===0x0){return db['UserProfileResource'][_0x031f('0x35')]({'name':_0x2be5d1[_0x031f('0x1a')],'resourceId':_0x2be5d1['id'],'type':_0x268dc7[_0x031f('0x1a')],'sectionId':_0x268dc7['id']},{})[_0x031f('0x15')](function(){return _0x1ffd03;});}else{return _0x1ffd03;}})[_0x031f('0x28')](function(_0xf0fb95){logger[_0x031f('0x3c')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xf0fb95);throw _0xf0fb95;});}return _0x1ffd03;})[_0x031f('0x15')](respondWithResult(_0x45e3a4,0xc9))[_0x031f('0x28')](handleError(_0x45e3a4,null));};exports['update']=function(_0x12279a,_0x505e93){if(_0x12279a[_0x031f('0x36')]['id']){delete _0x12279a[_0x031f('0x36')]['id'];}return db['FaxQueue'][_0x031f('0x3b')]({'where':{'id':_0x12279a[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](handleEntityNotFound(_0x505e93,null))['then'](saveUpdates(_0x12279a[_0x031f('0x36')],null))[_0x031f('0x15')](respondWithResult(_0x505e93,null))[_0x031f('0x28')](handleError(_0x505e93,null));};exports[_0x031f('0x16')]=function(_0x177306,_0x193b8f){return db[_0x031f('0x23')][_0x031f('0x3b')]({'where':{'id':_0x177306[_0x031f('0x2a')]['id']}})['then'](handleEntityNotFound(_0x193b8f,null))[_0x031f('0x15')](removeEntity(_0x193b8f,null))[_0x031f('0x28')](handleError(_0x193b8f,null));};exports[_0x031f('0x3d')]=function(_0x3205ce,_0xcf2072){return db[_0x031f('0x23')][_0x031f('0x3d')]()[_0x031f('0x15')](respondWithResult(_0xcf2072,null))[_0x031f('0x28')](handleError(_0xcf2072,null));};exports['getMembers']=function(_0x38539a,_0x5ec593){var _0x512937={'raw':!![],'where':{}},_0x434849={},_0x2359d1;return db[_0x031f('0x23')][_0x031f('0x3e')]({'where':{'id':_0x38539a[_0x031f('0x2a')]['id']}})['then'](handleEntityNotFound(_0x5ec593,null))[_0x031f('0x15')](function(_0x365f8c){if(_0x365f8c){_0x2359d1=_0x365f8c[_0x031f('0x17')]({'plain':!![]});_0x434849['model']=_[_0x031f('0x2c')](db[_0x031f('0x3f')][_0x031f('0x1e')]);_0x434849[_0x031f('0x25')]=_[_0x031f('0x2c')](_0x38539a[_0x031f('0x25')]);_0x434849['filters']=_['intersection'](_0x434849[_0x031f('0x2b')],_0x434849['query']);_0x512937[_0x031f('0x2f')]=_[_0x031f('0x2e')](_0x434849['model'],qs[_0x031f('0x30')](_0x38539a['query']['fields']));_0x512937[_0x031f('0x2f')]=_0x512937['attributes'][_0x031f('0x31')]?_0x512937['attributes']:_0x434849[_0x031f('0x2b')];if(!_0x38539a[_0x031f('0x25')]['hasOwnProperty'](_0x031f('0x40'))){_0x512937[_0x031f('0x11')]=qs['limit'](_0x38539a[_0x031f('0x25')]['limit']);_0x512937[_0x031f('0xf')]=qs['offset'](_0x38539a[_0x031f('0x25')][_0x031f('0xf')]);}_0x512937[_0x031f('0x41')]=qs[_0x031f('0x42')](_0x38539a[_0x031f('0x25')]['sort']);_0x512937[_0x031f('0x22')]=qs['filters'](_[_0x031f('0x43')](_0x38539a[_0x031f('0x25')],_0x434849['filters']));_0x512937[_0x031f('0x22')][_0x031f('0x44')]=_0x365f8c['id'];if(_0x38539a['query'][_0x031f('0x45')]){_0x512937[_0x031f('0x22')]=_[_0x031f('0x33')](_0x512937['where'],{'$or':_[_0x031f('0x1d')](_0x512937['attributes'],function(_0x254604){var _0x5a4aa4={};_0x5a4aa4[_0x254604]={'$like':'%'+_0x38539a[_0x031f('0x25')]['filter']+'%'};return _0x5a4aa4;})});}_0x512937=_[_0x031f('0x33')]({},_0x512937,_0x38539a[_0x031f('0x34')]);return db['UserFaxQueue']['findAll'](_0x512937);}})[_0x031f('0x15')](function(_0x10fa4c){if(_0x10fa4c){return db['User'][_0x031f('0x46')]({'where':{'id':_[_0x031f('0x1d')](_0x10fa4c,_0x031f('0x47')),'role':_0x031f('0x48')},'attributes':['id',_0x031f('0x1a'),_0x031f('0x49'),_0x031f('0x4a'),_0x031f('0x4b')]});}})['then'](function(_0xe452c2){if(_0xe452c2){return{'count':_0xe452c2[_0x031f('0x12')],'rows':_[_0x031f('0x1d')](_0xe452c2['rows'],function(_0x3937b7){return{'membername':_0x3937b7[_0x031f('0x1a')],'UserId':_0x3937b7['id'],'queue_name':_0x2359d1['name'],'FaxQueueId':_0x2359d1['id'],'interface':util[_0x031f('0x4c')](_0x031f('0x4d'),_0x031f('0x4e'),_0x3937b7[_0x031f('0x1a')]),'penalty':0x0,'paused':_0x3937b7['faxPause'],'createdAt':_0x3937b7['createdAt'],'updatedAt':_0x3937b7['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x5ec593,_0x512937))[_0x031f('0x28')](handleError(_0x5ec593,null));};exports[_0x031f('0x4f')]=function(_0x4a7fbb,_0x10531d){var _0x28f026={};var _0x508c4c={};var _0x110495;var _0x26ecb0;return db[_0x031f('0x23')][_0x031f('0x3e')]({'where':{'id':_0x4a7fbb[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](handleEntityNotFound(_0x10531d,null))[_0x031f('0x15')](function(_0x4527e5){if(_0x4527e5){_0x110495=_0x4527e5;_0x508c4c[_0x031f('0x2b')]=_['keys'](db[_0x031f('0x50')]['rawAttributes']);_0x508c4c[_0x031f('0x25')]=_[_0x031f('0x2c')](_0x4a7fbb[_0x031f('0x25')]);_0x508c4c['filters']=_['intersection'](_0x508c4c[_0x031f('0x2b')],_0x508c4c[_0x031f('0x25')]);_0x28f026[_0x031f('0x2f')]=_[_0x031f('0x2e')](_0x508c4c['model'],qs[_0x031f('0x30')](_0x4a7fbb['query']['fields']));_0x28f026[_0x031f('0x2f')]=_0x28f026['attributes']['length']?_0x28f026[_0x031f('0x2f')]:_0x508c4c[_0x031f('0x2b')];_0x28f026[_0x031f('0x41')]=qs[_0x031f('0x42')](_0x4a7fbb[_0x031f('0x25')]['sort']);_0x28f026['where']=qs[_0x031f('0x2d')](_['pick'](_0x4a7fbb[_0x031f('0x25')],_0x508c4c[_0x031f('0x2d')]));if(_0x4a7fbb['query'][_0x031f('0x45')]){_0x28f026[_0x031f('0x22')]=_[_0x031f('0x33')](_0x28f026[_0x031f('0x22')],{'$or':_[_0x031f('0x1d')](_0x28f026[_0x031f('0x2f')],function(_0x5bea08){var _0x58f012={};_0x58f012[_0x5bea08]={'$like':'%'+_0x4a7fbb[_0x031f('0x25')][_0x031f('0x45')]+'%'};return _0x58f012;})});}_0x28f026=_[_0x031f('0x33')]({},_0x28f026,_0x4a7fbb[_0x031f('0x34')]);return _0x110495[_0x031f('0x4f')](_0x28f026);}})[_0x031f('0x15')](function(_0x3cfb21){if(_0x3cfb21){_0x26ecb0=_0x3cfb21['length'];if(!_0x4a7fbb['query']['hasOwnProperty']('nolimit')){_0x28f026[_0x031f('0x11')]=qs[_0x031f('0x11')](_0x4a7fbb[_0x031f('0x25')]['limit']);_0x28f026[_0x031f('0xf')]=qs[_0x031f('0xf')](_0x4a7fbb['query'][_0x031f('0xf')]);}return _0x110495[_0x031f('0x4f')](_0x28f026);}})[_0x031f('0x15')](function(_0x140ccd){if(_0x140ccd){return _0x140ccd?{'count':_0x26ecb0,'rows':_0x140ccd}:null;}})[_0x031f('0x15')](respondWithResult(_0x10531d,null))[_0x031f('0x28')](handleError(_0x10531d,null));};exports[_0x031f('0x51')]=function(_0x5ecbd6,_0x571d15){var _0x8a448f=_0x5ecbd6['body'][_0x031f('0x52')];return db['Team'][_0x031f('0x26')]({'where':{'id':_0x8a448f},'attributes':['id'],'include':[{'model':db[_0x031f('0x53')],'as':_0x031f('0x54'),'attributes':['id','name',_0x031f('0x55'),'voicePause',_0x031f('0x56')],'raw':!![]}]})[_0x031f('0x15')](function(_0x3efa82){if(_0x3efa82){var _0x4e7251=_[_0x031f('0x57')](_0x3efa82,function(_0x398e7c){var _0x3c4b09=_0x398e7c[_0x031f('0x17')]({'plain':!![]});return _0x3c4b09[_0x031f('0x54')];});return db['FaxQueue']['find']({'where':{'id':_0x5ecbd6[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](function(_0x4bc4c7){return db[_0x031f('0x58')]['transaction'](function(_0x2dfff2){return _0x4bc4c7[_0x031f('0x51')](_0x8a448f,{'transaction':_0x2dfff2})[_0x031f('0x15')](function(){return BPromise[_0x031f('0x59')](_0x4e7251,function(_0x52bb92){return db[_0x031f('0x3f')][_0x031f('0x5a')]({'where':{'UserId':_0x52bb92['id'],'FaxQueueId':_0x5ecbd6[_0x031f('0x2a')]['id']},'transaction':_0x2dfff2});});})['then'](function(){_0x4e7251[_0x031f('0x5b')](function(_0xfda893){socket['emit'](_0x031f('0x5c'),{'UserId':_0xfda893['id'],'FaxQueueId':_0x4bc4c7['id']});});});});});}})[_0x031f('0x15')](respondWithStatusCode(_0x571d15,null))[_0x031f('0x28')](handleError(_0x571d15,null));};exports[_0x031f('0x5d')]=function(_0x104025,_0x38a8a4){return db[_0x031f('0x50')]['findAll']({'where':{'id':_0x104025[_0x031f('0x25')][_0x031f('0x52')]},'attributes':['id'],'include':[{'model':db[_0x031f('0x53')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x38a8a4,null))[_0x031f('0x15')](function(_0x5bd344){var _0x54f02d=_[_0x031f('0x1d')](_0x5bd344,'id');var _0x184bbd=[];var _0x1c8055=[];var _0x1d6aca=squel[_0x031f('0x5e')]();_0x1d6aca[_0x031f('0x5f')](_0x031f('0x60'))[_0x031f('0x61')](_0x031f('0x62'),'tq')[_0x031f('0x63')](_0x031f('0x64'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x031f('0x22')](_0x031f('0x65'),_0x104025[_0x031f('0x2a')]['id']);for(var _0x8290bf=0x0;_0x8290bf<_0x5bd344['length'];_0x8290bf+=0x1){let _0x6970f5=_0x5bd344[_0x8290bf];for(var _0x5329c2=0x0;_0x5329c2<_0x6970f5['Agents'][_0x031f('0x31')];_0x5329c2+=0x1){let _0x2f4d09=_0x6970f5['Agents'][_0x5329c2];var _0x510bb6=_0x1d6aca[_0x031f('0x66')]();_0x510bb6[_0x031f('0x22')](_0x031f('0x67'),_0x2f4d09['id']);_0x1c8055[_0x031f('0x68')](db[_0x031f('0x58')][_0x031f('0x25')](_0x510bb6['toString'](),{'type':db[_0x031f('0x58')][_0x031f('0x69')]['SELECT']})[_0x031f('0x15')](function(_0x2f2e96){if(_0x2f2e96[_0x031f('0x31')]===0x1){return _0x2f4d09['id'];}else{var _0x14fc7e=_[_0x031f('0x6a')](_[_0x031f('0x1d')](_0x2f2e96,_0x031f('0x6b')),function(_0x4e9157){return _[_0x031f('0x6c')](_0x54f02d,_0x4e9157);});if(_0x14fc7e){return _0x2f4d09['id'];}}}));}}return BPromise['all'](_0x1c8055)[_0x031f('0x15')](function(_0x1d5d61){_0x184bbd=_(_0x184bbd)[_0x031f('0x6d')](_0x1d5d61)['compact']()['value']();return db['FaxQueue'][_0x031f('0x3b')]({'where':{'id':_0x104025[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](function(_0x2985fe){return db[_0x031f('0x58')][_0x031f('0x6e')](function(_0x232aa0){return _0x2985fe['removeTeams'](_0x104025['query'][_0x031f('0x52')],{'transaction':_0x232aa0})[_0x031f('0x15')](function(){if(!_['isEmpty'](_0x184bbd)){return _0x2985fe[_0x031f('0x6f')](_0x184bbd,{'transaction':_0x232aa0});}})['then'](function(){_0x184bbd[_0x031f('0x5b')](function(_0x20d85a){socket['emit'](_0x031f('0x70'),{'UserId':_0x20d85a,'FaxQueueId':_0x2985fe['id']});});});});});});})[_0x031f('0x15')](respondWithStatusCode(_0x38a8a4,null))['catch'](handleError(_0x38a8a4,null));};exports[_0x031f('0x71')]=function(_0x3c7dee,_0x1b588e){return db['FaxQueue'][_0x031f('0x3b')]({'where':{'id':_0x3c7dee[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](handleEntityNotFound(_0x1b588e,null))[_0x031f('0x15')](function(_0x11165b){if(_0x11165b){return _0x11165b[_0x031f('0x71')](_0x3c7dee['body'][_0x031f('0x52')],_[_0x031f('0x72')](_0x3c7dee[_0x031f('0x36')],[_0x031f('0x52'),'id'])||{})['spread'](function(_0x33bf51){for(var _0x467a76=0x0;_0x467a76<_0x3c7dee['body'][_0x031f('0x52')][_0x031f('0x31')];_0x467a76+=0x1){socket[_0x031f('0x73')](_0x031f('0x5c'),{'UserId':Number(_0x3c7dee[_0x031f('0x36')][_0x031f('0x52')][_0x467a76]),'FaxQueueId':Number(_0x3c7dee[_0x031f('0x2a')]['id'])});}return _0x33bf51;});}})[_0x031f('0x15')](respondWithResult(_0x1b588e,null))[_0x031f('0x28')](handleError(_0x1b588e,null));};exports[_0x031f('0x6f')]=function(_0x16f7a0,_0x2b7347){return db[_0x031f('0x23')][_0x031f('0x3b')]({'where':{'id':_0x16f7a0[_0x031f('0x2a')]['id']}})['then'](handleEntityNotFound(_0x2b7347,null))[_0x031f('0x15')](function(_0x4368d6){if(_0x4368d6){return _0x4368d6[_0x031f('0x6f')](_0x16f7a0[_0x031f('0x25')][_0x031f('0x52')])[_0x031f('0x15')](function(){if(_['isArray'](_0x16f7a0['query']['ids'])){for(var _0x343acc=0x0;_0x343acc<_0x16f7a0[_0x031f('0x25')]['ids'][_0x031f('0x31')];_0x343acc+=0x1){socket[_0x031f('0x73')](_0x031f('0x70'),{'UserId':Number(_0x16f7a0[_0x031f('0x25')]['ids'][_0x343acc]),'FaxQueueId':Number(_0x16f7a0[_0x031f('0x2a')]['id'])});}}else{socket[_0x031f('0x73')](_0x031f('0x70'),{'UserId':Number(_0x16f7a0[_0x031f('0x25')][_0x031f('0x52')]),'FaxQueueId':Number(_0x16f7a0[_0x031f('0x2a')]['id'])});}});}})[_0x031f('0x15')](respondWithStatusCode(_0x2b7347,null))[_0x031f('0x28')](handleError(_0x2b7347,null));};exports[_0x031f('0x74')]=function(_0x3a798a,_0x3e3467){var _0x3eec5b={};var _0x4bd749={};var _0x2541fd;var _0x1f1f0e;return db['FaxQueue'][_0x031f('0x3e')]({'where':{'id':_0x3a798a[_0x031f('0x2a')]['id']}})['then'](handleEntityNotFound(_0x3e3467,null))[_0x031f('0x15')](function(_0x3bc88c){if(_0x3bc88c){_0x2541fd=_0x3bc88c;_0x4bd749[_0x031f('0x2b')]=_[_0x031f('0x2c')](db[_0x031f('0x53')][_0x031f('0x1e')]);_0x4bd749[_0x031f('0x25')]=_[_0x031f('0x2c')](_0x3a798a[_0x031f('0x25')]);_0x4bd749['filters']=_[_0x031f('0x2e')](_0x4bd749[_0x031f('0x2b')],_0x4bd749[_0x031f('0x25')]);_0x3eec5b['attributes']=_['intersection'](_0x4bd749[_0x031f('0x2b')],qs['fields'](_0x3a798a[_0x031f('0x25')][_0x031f('0x30')]));_0x3eec5b['attributes']=_0x3eec5b[_0x031f('0x2f')][_0x031f('0x31')]?_0x3eec5b[_0x031f('0x2f')]:_0x4bd749[_0x031f('0x2b')];_0x3eec5b[_0x031f('0x41')]=qs[_0x031f('0x42')](_0x3a798a[_0x031f('0x25')][_0x031f('0x42')]);_0x3eec5b[_0x031f('0x22')]=qs[_0x031f('0x2d')](_[_0x031f('0x43')](_0x3a798a[_0x031f('0x25')],_0x4bd749[_0x031f('0x2d')]));if(_0x3a798a['query']['filter']){_0x3eec5b[_0x031f('0x22')]=_['merge'](_0x3eec5b[_0x031f('0x22')],{'$or':_[_0x031f('0x1d')](_0x3eec5b[_0x031f('0x2f')],function(_0x513dfc){var _0x21f647={};_0x21f647[_0x513dfc]={'$like':'%'+_0x3a798a[_0x031f('0x25')]['filter']+'%'};return _0x21f647;})});}_0x3eec5b=_[_0x031f('0x33')]({},_0x3eec5b,_0x3a798a[_0x031f('0x34')]);return _0x2541fd[_0x031f('0x74')](_0x3eec5b);}})[_0x031f('0x15')](function(_0x348909){if(_0x348909){_0x1f1f0e=_0x348909[_0x031f('0x31')];if(!_0x3a798a[_0x031f('0x25')]['hasOwnProperty'](_0x031f('0x40'))){_0x3eec5b[_0x031f('0x11')]=qs[_0x031f('0x11')](_0x3a798a[_0x031f('0x25')]['limit']);_0x3eec5b['offset']=qs[_0x031f('0xf')](_0x3a798a['query']['offset']);}return _0x2541fd[_0x031f('0x74')](_0x3eec5b);}})['then'](function(_0x579ade){if(_0x579ade){return _0x579ade?{'count':_0x1f1f0e,'rows':_0x579ade}:null;}})[_0x031f('0x15')](respondWithResult(_0x3e3467,null))[_0x031f('0x28')](handleError(_0x3e3467,null));};
\ No newline at end of file