Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 4ed01f0..09d0cb3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x038d=['Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','findOne','UserFaxQueue','hasOwnProperty','order','sort','FaxQueueId','findAll','User','faxPause','updatedAt','createdAt','format','%s/%s','getTeams','Team','ids','Agents','online','voicePause','sequelize','transaction','addTeams','each','forEach','userFaxQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','clone','push','toString','SELECT','every','TeamId','includes','all','union','value','isEmpty','removeAgents','userFaxQueue:remove','addAgents','omit','spread','emit','isArray','getAgents','eml-format','fast-json-patch','request-promise','moment','mustache','util','sox','ejs','fs-extra','squel','crypto','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','redis','defaults','localhost','./faxQueue.socket','register','status','end','json','offset','undefined','limit','set','Content-Range','apply','save','update','destroy','then','get','FaxQueues','UserProfileResource','sendStatus','error','stack','name','send','index','map','FaxQueue','rawAttributes','fieldName','type','key','query','keys','intersection','model','attributes','fields','length','nolimit','where','filters','pick','filter','merge','count','includeAll','include','rows','catch','show','options','find','create','body','user'];(function(_0x1b8460,_0x2d308c){var _0x185c1d=function(_0xb3a4ef){while(--_0xb3a4ef){_0x1b8460['push'](_0x1b8460['shift']());}};_0x185c1d(++_0x2d308c);}(_0x038d,0x15b));var _0xd038=function(_0x29a400,_0x58cb23){_0x29a400=_0x29a400-0x0;var _0x6327b7=_0x038d[_0x29a400];return _0x6327b7;};'use strict';var emlformat=require(_0xd038('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xd038('0x1'));var rp=require(_0xd038('0x2'));var moment=require(_0xd038('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xd038('0x4'));var util=require(_0xd038('0x5'));var path=require('path');var sox=require(_0xd038('0x6'));var csv=require('to-csv');var ejs=require(_0xd038('0x7'));var fs=require('fs');var fs_extra=require(_0xd038('0x8'));var _=require('lodash');var squel=require(_0xd038('0x9'));var crypto=require(_0xd038('0xa'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xd038('0xb'));var querystring=require('querystring');var Papa=require(_0xd038('0xc'));var Redis=require(_0xd038('0xd'));var authService=require(_0xd038('0xe'));var qs=require(_0xd038('0xf'));var as=require(_0xd038('0x10'));var hardwareService=require(_0xd038('0x11'));var logger=require(_0xd038('0x12'))(_0xd038('0x13'));var utils=require(_0xd038('0x14'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xd038('0x15'))['db'];config[_0xd038('0x16')]=_[_0xd038('0x17')](config['redis'],{'host':_0xd038('0x18'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xd038('0x16')]));require(_0xd038('0x19'))[_0xd038('0x1a')](socket);function respondWithStatusCode(_0x2e94ab,_0x4a2e80){_0x4a2e80=_0x4a2e80||0xcc;return function(_0x30d2c1){if(_0x30d2c1){return _0x2e94ab['sendStatus'](_0x4a2e80);}return _0x2e94ab[_0xd038('0x1b')](_0x4a2e80)[_0xd038('0x1c')]();};}function respondWithResult(_0xba976d,_0x4d57e6){_0x4d57e6=_0x4d57e6||0xc8;return function(_0x4682d9){if(_0x4682d9){return _0xba976d['status'](_0x4d57e6)[_0xd038('0x1d')](_0x4682d9);}};}function respondWithFilteredResult(_0x23353c,_0x2b44da){return function(_0x5739d4){if(_0x5739d4){var _0x32aebe=typeof _0x2b44da[_0xd038('0x1e')]===_0xd038('0x1f')&&typeof _0x2b44da[_0xd038('0x20')]==='undefined';var _0x19e4de=_0x5739d4['count'];var _0x213d24=_0x32aebe?0x0:_0x2b44da['offset'];var _0x1d90aa=_0x32aebe?_0x5739d4['count']:_0x2b44da[_0xd038('0x1e')]+_0x2b44da[_0xd038('0x20')];var _0x5803d4;if(_0x1d90aa>=_0x19e4de){_0x1d90aa=_0x19e4de;_0x5803d4=0xc8;}else{_0x5803d4=0xce;}_0x23353c[_0xd038('0x1b')](_0x5803d4);return _0x23353c[_0xd038('0x21')](_0xd038('0x22'),_0x213d24+'-'+_0x1d90aa+'/'+_0x19e4de)[_0xd038('0x1d')](_0x5739d4);}return null;};}function patchUpdates(_0x385103){return function(_0x4b1dfc){try{jsonpatch[_0xd038('0x23')](_0x4b1dfc,_0x385103,!![]);}catch(_0x1df828){return BPromise['reject'](_0x1df828);}return _0x4b1dfc[_0xd038('0x24')]();};}function saveUpdates(_0x3df3a4,_0x583495){return function(_0x84f4c3){if(_0x84f4c3){return _0x84f4c3[_0xd038('0x25')](_0x3df3a4)['then'](function(_0x146583){return _0x146583;});}return null;};}function removeEntity(_0x12071e,_0x231324){return function(_0x24f724){if(_0x24f724){return _0x24f724[_0xd038('0x26')]()[_0xd038('0x27')](function(){var _0x12b1cd=_0x24f724[_0xd038('0x28')]({'plain':!![]});var _0x972e9d=_0xd038('0x29');return db[_0xd038('0x2a')][_0xd038('0x26')]({'where':{'type':_0x972e9d,'resourceId':_0x12b1cd['id']}})[_0xd038('0x27')](function(){return _0x24f724;});})['then'](function(){_0x12071e[_0xd038('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x25cd07,_0x20f296){return function(_0x3f84a1){if(!_0x3f84a1){_0x25cd07[_0xd038('0x2b')](0x194);}return _0x3f84a1;};}function handleError(_0x5f4a7b,_0x5af4d4){_0x5af4d4=_0x5af4d4||0x1f4;return function(_0x336169){logger[_0xd038('0x2c')](_0x336169[_0xd038('0x2d')]);if(_0x336169[_0xd038('0x2e')]){delete _0x336169['name'];}_0x5f4a7b[_0xd038('0x1b')](_0x5af4d4)[_0xd038('0x2f')](_0x336169);};}exports[_0xd038('0x30')]=function(_0x8e8cd8,_0x41733d){var _0x37fa8c={},_0xa55619={},_0x20f17f={'count':0x0,'rows':[]};var _0xb2a00a=_[_0xd038('0x31')](db[_0xd038('0x32')][_0xd038('0x33')],function(_0x452c07){return{'name':_0x452c07[_0xd038('0x34')],'type':_0x452c07[_0xd038('0x35')][_0xd038('0x36')]};});_0xa55619['model']=_[_0xd038('0x31')](_0xb2a00a,_0xd038('0x2e'));_0xa55619[_0xd038('0x37')]=_[_0xd038('0x38')](_0x8e8cd8[_0xd038('0x37')]);_0xa55619['filters']=_[_0xd038('0x39')](_0xa55619[_0xd038('0x3a')],_0xa55619[_0xd038('0x37')]);_0x37fa8c[_0xd038('0x3b')]=_['intersection'](_0xa55619[_0xd038('0x3a')],qs['fields'](_0x8e8cd8['query'][_0xd038('0x3c')]));_0x37fa8c[_0xd038('0x3b')]=_0x37fa8c[_0xd038('0x3b')][_0xd038('0x3d')]?_0x37fa8c[_0xd038('0x3b')]:_0xa55619[_0xd038('0x3a')];if(!_0x8e8cd8[_0xd038('0x37')]['hasOwnProperty'](_0xd038('0x3e'))){_0x37fa8c[_0xd038('0x20')]=qs[_0xd038('0x20')](_0x8e8cd8[_0xd038('0x37')][_0xd038('0x20')]);_0x37fa8c[_0xd038('0x1e')]=qs[_0xd038('0x1e')](_0x8e8cd8[_0xd038('0x37')][_0xd038('0x1e')]);}_0x37fa8c['order']=qs['sort'](_0x8e8cd8[_0xd038('0x37')]['sort']);_0x37fa8c[_0xd038('0x3f')]=qs[_0xd038('0x40')](_[_0xd038('0x41')](_0x8e8cd8[_0xd038('0x37')],_0xa55619[_0xd038('0x40')]),_0xb2a00a);if(_0x8e8cd8[_0xd038('0x37')][_0xd038('0x42')]){_0x37fa8c[_0xd038('0x3f')]=_[_0xd038('0x43')](_0x37fa8c['where'],{'$or':_[_0xd038('0x31')](_0xb2a00a,function(_0x383634){if(_0x383634[_0xd038('0x35')]!=='VIRTUAL'){var _0x4e750b={};_0x4e750b[_0x383634[_0xd038('0x2e')]]={'$like':'%'+_0x8e8cd8[_0xd038('0x37')][_0xd038('0x42')]+'%'};return _0x4e750b;}})});}_0x37fa8c=_[_0xd038('0x43')]({},_0x37fa8c,_0x8e8cd8['options']);var _0x4caf5f={'where':_0x37fa8c[_0xd038('0x3f')]};return db[_0xd038('0x32')][_0xd038('0x44')](_0x4caf5f)[_0xd038('0x27')](function(_0x54e9c4){_0x20f17f[_0xd038('0x44')]=_0x54e9c4;if(_0x8e8cd8['query'][_0xd038('0x45')]){_0x37fa8c[_0xd038('0x46')]=[{'all':!![]}];}return db[_0xd038('0x32')]['findAll'](_0x37fa8c);})[_0xd038('0x27')](function(_0x38087f){_0x20f17f[_0xd038('0x47')]=_0x38087f;return _0x20f17f;})[_0xd038('0x27')](respondWithFilteredResult(_0x41733d,_0x37fa8c))[_0xd038('0x48')](handleError(_0x41733d,null));};exports[_0xd038('0x49')]=function(_0x3c1192,_0x8e6319){var _0x13fb30={'raw':!![],'where':{'id':_0x3c1192['params']['id']}},_0xa925ab={};_0xa925ab['model']=_['keys'](db['FaxQueue'][_0xd038('0x33')]);_0xa925ab[_0xd038('0x37')]=_[_0xd038('0x38')](_0x3c1192[_0xd038('0x37')]);_0xa925ab[_0xd038('0x40')]=_['intersection'](_0xa925ab['model'],_0xa925ab['query']);_0x13fb30['attributes']=_[_0xd038('0x39')](_0xa925ab[_0xd038('0x3a')],qs[_0xd038('0x3c')](_0x3c1192[_0xd038('0x37')][_0xd038('0x3c')]));_0x13fb30[_0xd038('0x3b')]=_0x13fb30[_0xd038('0x3b')][_0xd038('0x3d')]?_0x13fb30[_0xd038('0x3b')]:_0xa925ab[_0xd038('0x3a')];if(_0x3c1192[_0xd038('0x37')][_0xd038('0x45')]){_0x13fb30[_0xd038('0x46')]=[{'all':!![]}];}_0x13fb30=_[_0xd038('0x43')]({},_0x13fb30,_0x3c1192[_0xd038('0x4a')]);return db[_0xd038('0x32')][_0xd038('0x4b')](_0x13fb30)[_0xd038('0x27')](handleEntityNotFound(_0x8e6319,null))[_0xd038('0x27')](respondWithResult(_0x8e6319,null))[_0xd038('0x48')](handleError(_0x8e6319,null));};exports[_0xd038('0x4c')]=function(_0x356da5,_0x594c6d){return db[_0xd038('0x32')]['create'](_0x356da5[_0xd038('0x4d')],{})['then'](function(_0x594610){var _0x16d809=_0x356da5[_0xd038('0x4e')][_0xd038('0x28')]({'plain':!![]});if(!_0x16d809)throw new Error(_0xd038('0x4f'));if(_0x16d809[_0xd038('0x50')]==='user'){var _0xc1b896=_0x594610['get']({'plain':!![]});var _0x1116a8='FaxQueues';return db[_0xd038('0x51')][_0xd038('0x4b')]({'where':{'name':_0x1116a8,'userProfileId':_0x16d809[_0xd038('0x52')]},'raw':!![]})['then'](function(_0x1fe7d6){if(_0x1fe7d6&&_0x1fe7d6[_0xd038('0x53')]===0x0){return db[_0xd038('0x2a')]['create']({'name':_0xc1b896[_0xd038('0x2e')],'resourceId':_0xc1b896['id'],'type':_0x1fe7d6[_0xd038('0x2e')],'sectionId':_0x1fe7d6['id']},{})[_0xd038('0x27')](function(){return _0x594610;});}else{return _0x594610;}})[_0xd038('0x48')](function(_0xa8b07c){logger[_0xd038('0x2c')](_0xd038('0x54'),_0xa8b07c);throw _0xa8b07c;});}return _0x594610;})[_0xd038('0x27')](respondWithResult(_0x594c6d,0xc9))[_0xd038('0x48')](handleError(_0x594c6d,null));};exports['update']=function(_0x14e14b,_0x55c277){if(_0x14e14b[_0xd038('0x4d')]['id']){delete _0x14e14b[_0xd038('0x4d')]['id'];}return db[_0xd038('0x32')]['find']({'where':{'id':_0x14e14b[_0xd038('0x55')]['id']}})[_0xd038('0x27')](handleEntityNotFound(_0x55c277,null))['then'](saveUpdates(_0x14e14b[_0xd038('0x4d')],null))[_0xd038('0x27')](respondWithResult(_0x55c277,null))[_0xd038('0x48')](handleError(_0x55c277,null));};exports[_0xd038('0x26')]=function(_0x452f3c,_0x314288){return db[_0xd038('0x32')][_0xd038('0x4b')]({'where':{'id':_0x452f3c[_0xd038('0x55')]['id']}})['then'](handleEntityNotFound(_0x314288,null))[_0xd038('0x27')](removeEntity(_0x314288,null))[_0xd038('0x48')](handleError(_0x314288,null));};exports[_0xd038('0x56')]=function(_0x6cc99d,_0x11fa3f){return db[_0xd038('0x32')]['describe']()[_0xd038('0x27')](respondWithResult(_0x11fa3f,null))['catch'](handleError(_0x11fa3f,null));};exports[_0xd038('0x57')]=function(_0x1b723f,_0x4cccfd,_0x50cf68){var _0x16208a={'raw':!![],'where':{}},_0x531caa={},_0x1c49bf;return db[_0xd038('0x32')][_0xd038('0x58')]({'where':{'id':_0x1b723f[_0xd038('0x55')]['id']}})[_0xd038('0x27')](handleEntityNotFound(_0x4cccfd,null))['then'](function(_0x35807e){if(_0x35807e){_0x1c49bf=_0x35807e['get']({'plain':!![]});_0x531caa[_0xd038('0x3a')]=_['keys'](db[_0xd038('0x59')]['rawAttributes']);_0x531caa[_0xd038('0x37')]=_[_0xd038('0x38')](_0x1b723f[_0xd038('0x37')]);_0x531caa[_0xd038('0x40')]=_[_0xd038('0x39')](_0x531caa[_0xd038('0x3a')],_0x531caa['query']);_0x16208a[_0xd038('0x3b')]=_[_0xd038('0x39')](_0x531caa[_0xd038('0x3a')],qs[_0xd038('0x3c')](_0x1b723f['query'][_0xd038('0x3c')]));_0x16208a['attributes']=_0x16208a[_0xd038('0x3b')][_0xd038('0x3d')]?_0x16208a['attributes']:_0x531caa[_0xd038('0x3a')];if(!_0x1b723f['query'][_0xd038('0x5a')](_0xd038('0x3e'))){_0x16208a[_0xd038('0x20')]=qs[_0xd038('0x20')](_0x1b723f['query'][_0xd038('0x20')]);_0x16208a[_0xd038('0x1e')]=qs[_0xd038('0x1e')](_0x1b723f[_0xd038('0x37')][_0xd038('0x1e')]);}_0x16208a[_0xd038('0x5b')]=qs['sort'](_0x1b723f[_0xd038('0x37')][_0xd038('0x5c')]);_0x16208a[_0xd038('0x3f')]=qs[_0xd038('0x40')](_[_0xd038('0x41')](_0x1b723f['query'],_0x531caa[_0xd038('0x40')]));_0x16208a[_0xd038('0x3f')][_0xd038('0x5d')]=_0x35807e['id'];if(_0x1b723f[_0xd038('0x37')][_0xd038('0x42')]){_0x16208a[_0xd038('0x3f')]=_[_0xd038('0x43')](_0x16208a[_0xd038('0x3f')],{'$or':_['map'](_0x16208a[_0xd038('0x3b')],function(_0x507307){var _0x2d29e5={};_0x2d29e5[_0x507307]={'$like':'%'+_0x1b723f['query'][_0xd038('0x42')]+'%'};return _0x2d29e5;})});}_0x16208a=_[_0xd038('0x43')]({},_0x16208a,_0x1b723f['options']);return db[_0xd038('0x59')][_0xd038('0x5e')](_0x16208a);}})['then'](function(_0x5e0c5e){if(_0x5e0c5e){return db[_0xd038('0x5f')]['findAndCountAll']({'where':{'id':_[_0xd038('0x31')](_0x5e0c5e,'UserId'),'role':'agent'},'attributes':['id',_0xd038('0x2e'),_0xd038('0x60'),_0xd038('0x61'),_0xd038('0x62')]});}})[_0xd038('0x27')](function(_0x440cfc){if(_0x440cfc){return{'count':_0x440cfc['count'],'rows':_[_0xd038('0x31')](_0x440cfc['rows'],function(_0x53c477){return{'membername':_0x53c477[_0xd038('0x2e')],'UserId':_0x53c477['id'],'queue_name':_0x1c49bf[_0xd038('0x2e')],'FaxQueueId':_0x1c49bf['id'],'interface':util[_0xd038('0x63')](_0xd038('0x64'),'SIP',_0x53c477[_0xd038('0x2e')]),'penalty':0x0,'paused':_0x53c477[_0xd038('0x60')],'createdAt':_0x53c477[_0xd038('0x62')],'updatedAt':_0x53c477[_0xd038('0x61')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xd038('0x27')](respondWithFilteredResult(_0x4cccfd,_0x16208a))['catch'](handleError(_0x4cccfd,null));};exports[_0xd038('0x65')]=function(_0x16434f,_0x3ea850,_0x4b9356){var _0x3561c9={};var _0x3184cb={};var _0x48b045;var _0x81532b;return db[_0xd038('0x32')][_0xd038('0x58')]({'where':{'id':_0x16434f['params']['id']}})['then'](handleEntityNotFound(_0x3ea850,null))[_0xd038('0x27')](function(_0xbdf21){if(_0xbdf21){_0x48b045=_0xbdf21;_0x3184cb[_0xd038('0x3a')]=_[_0xd038('0x38')](db[_0xd038('0x66')]['rawAttributes']);_0x3184cb['query']=_[_0xd038('0x38')](_0x16434f[_0xd038('0x37')]);_0x3184cb[_0xd038('0x40')]=_[_0xd038('0x39')](_0x3184cb[_0xd038('0x3a')],_0x3184cb[_0xd038('0x37')]);_0x3561c9['attributes']=_['intersection'](_0x3184cb[_0xd038('0x3a')],qs[_0xd038('0x3c')](_0x16434f[_0xd038('0x37')][_0xd038('0x3c')]));_0x3561c9['attributes']=_0x3561c9[_0xd038('0x3b')][_0xd038('0x3d')]?_0x3561c9['attributes']:_0x3184cb['model'];_0x3561c9[_0xd038('0x5b')]=qs[_0xd038('0x5c')](_0x16434f['query'][_0xd038('0x5c')]);_0x3561c9[_0xd038('0x3f')]=qs[_0xd038('0x40')](_['pick'](_0x16434f['query'],_0x3184cb[_0xd038('0x40')]));if(_0x16434f[_0xd038('0x37')]['filter']){_0x3561c9[_0xd038('0x3f')]=_[_0xd038('0x43')](_0x3561c9['where'],{'$or':_[_0xd038('0x31')](_0x3561c9['attributes'],function(_0x2d5f53){var _0x2f5baf={};_0x2f5baf[_0x2d5f53]={'$like':'%'+_0x16434f[_0xd038('0x37')][_0xd038('0x42')]+'%'};return _0x2f5baf;})});}_0x3561c9=_[_0xd038('0x43')]({},_0x3561c9,_0x16434f[_0xd038('0x4a')]);return _0x48b045[_0xd038('0x65')](_0x3561c9);}})['then'](function(_0x5dd0f9){if(_0x5dd0f9){_0x81532b=_0x5dd0f9[_0xd038('0x3d')];if(!_0x16434f['query'][_0xd038('0x5a')](_0xd038('0x3e'))){_0x3561c9[_0xd038('0x20')]=qs[_0xd038('0x20')](_0x16434f[_0xd038('0x37')][_0xd038('0x20')]);_0x3561c9['offset']=qs[_0xd038('0x1e')](_0x16434f['query'][_0xd038('0x1e')]);}return _0x48b045[_0xd038('0x65')](_0x3561c9);}})[_0xd038('0x27')](function(_0x26bd3e){if(_0x26bd3e){return _0x26bd3e?{'count':_0x81532b,'rows':_0x26bd3e}:null;}})['then'](respondWithResult(_0x3ea850,null))[_0xd038('0x48')](handleError(_0x3ea850,null));};exports['addTeams']=function(_0x595ef5,_0x32c8a5,_0x4b241f){var _0xe98657=_0x595ef5[_0xd038('0x4d')][_0xd038('0x67')];return db[_0xd038('0x66')]['findAll']({'where':{'id':_0xe98657},'attributes':['id'],'include':[{'model':db['User'],'as':_0xd038('0x68'),'attributes':['id',_0xd038('0x2e'),_0xd038('0x69'),_0xd038('0x6a'),'interface'],'raw':!![]}]})[_0xd038('0x27')](function(_0x3b1919){if(_0x3b1919){var _0x381e6c=_['flatMap'](_0x3b1919,function(_0x4a2094){var _0x369296=_0x4a2094[_0xd038('0x28')]({'plain':!![]});return _0x369296[_0xd038('0x68')];});return db[_0xd038('0x32')][_0xd038('0x4b')]({'where':{'id':_0x595ef5[_0xd038('0x55')]['id']}})['then'](function(_0x3028b4){return db[_0xd038('0x6b')][_0xd038('0x6c')](function(_0x4e3478){return _0x3028b4[_0xd038('0x6d')](_0xe98657,{'transaction':_0x4e3478})[_0xd038('0x27')](function(){return BPromise[_0xd038('0x6e')](_0x381e6c,function(_0x4d5573){return db['UserFaxQueue']['findOrCreate']({'where':{'UserId':_0x4d5573['id'],'FaxQueueId':_0x595ef5[_0xd038('0x55')]['id']},'transaction':_0x4e3478});});})[_0xd038('0x27')](function(){_0x381e6c[_0xd038('0x6f')](function(_0x56fb23){socket['emit'](_0xd038('0x70'),{'UserId':_0x56fb23['id'],'FaxQueueId':_0x3028b4['id']});});});});});}})[_0xd038('0x27')](respondWithStatusCode(_0x32c8a5,null))[_0xd038('0x48')](handleError(_0x32c8a5,null));};exports[_0xd038('0x71')]=function(_0x2e370d,_0x15c829,_0x17698a){return db[_0xd038('0x66')][_0xd038('0x5e')]({'where':{'id':_0x2e370d[_0xd038('0x37')][_0xd038('0x67')]},'attributes':['id'],'include':[{'model':db[_0xd038('0x5f')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0xd038('0x27')](handleEntityNotFound(_0x15c829,null))['then'](function(_0x1f6358){var _0x2384da=_[_0xd038('0x31')](_0x1f6358,'id');var _0x1f29f9=[];var _0xbf93d2=[];var _0x54abb3=squel[_0xd038('0x72')]();_0x54abb3[_0xd038('0x73')](_0xd038('0x74'))[_0xd038('0x75')](_0xd038('0x76'),'tq')[_0xd038('0x77')](_0xd038('0x78'),'ut',_0xd038('0x79'))[_0xd038('0x3f')](_0xd038('0x7a'),_0x2e370d[_0xd038('0x55')]['id']);for(var _0x22b860=0x0;_0x22b860<_0x1f6358[_0xd038('0x3d')];_0x22b860+=0x1){let _0x446cd3=_0x1f6358[_0x22b860];for(var _0x4eca94=0x0;_0x4eca94<_0x446cd3[_0xd038('0x68')]['length'];_0x4eca94+=0x1){let _0x4214e1=_0x446cd3['Agents'][_0x4eca94];var _0x6ab8bc=_0x54abb3[_0xd038('0x7b')]();_0x6ab8bc[_0xd038('0x3f')]('ut.UserId\x20=\x20?',_0x4214e1['id']);_0xbf93d2[_0xd038('0x7c')](db[_0xd038('0x6b')]['query'](_0x6ab8bc[_0xd038('0x7d')](),{'type':db[_0xd038('0x6b')]['QueryTypes'][_0xd038('0x7e')]})['then'](function(_0x10adac){if(_0x10adac[_0xd038('0x3d')]===0x1){return _0x4214e1['id'];}else{var _0x1b6ff5=_[_0xd038('0x7f')](_[_0xd038('0x31')](_0x10adac,_0xd038('0x80')),function(_0x366a43){return _[_0xd038('0x81')](_0x2384da,_0x366a43);});if(_0x1b6ff5){return _0x4214e1['id'];}}}));}}return BPromise[_0xd038('0x82')](_0xbf93d2)[_0xd038('0x27')](function(_0x29304c){_0x1f29f9=_(_0x1f29f9)[_0xd038('0x83')](_0x29304c)['compact']()[_0xd038('0x84')]();return db[_0xd038('0x32')]['find']({'where':{'id':_0x2e370d[_0xd038('0x55')]['id']}})['then'](function(_0x15efd8){return db[_0xd038('0x6b')][_0xd038('0x6c')](function(_0x5db420){return _0x15efd8[_0xd038('0x71')](_0x2e370d[_0xd038('0x37')][_0xd038('0x67')],{'transaction':_0x5db420})[_0xd038('0x27')](function(){if(!_[_0xd038('0x85')](_0x1f29f9)){return _0x15efd8[_0xd038('0x86')](_0x1f29f9,{'transaction':_0x5db420});}})[_0xd038('0x27')](function(){_0x1f29f9[_0xd038('0x6f')](function(_0x18f84b){socket['emit'](_0xd038('0x87'),{'UserId':_0x18f84b,'FaxQueueId':_0x15efd8['id']});});});});});});})[_0xd038('0x27')](respondWithStatusCode(_0x15c829,null))['catch'](handleError(_0x15c829,null));};exports[_0xd038('0x88')]=function(_0x497d4e,_0x29b971,_0x3de3c1){return db[_0xd038('0x32')][_0xd038('0x4b')]({'where':{'id':_0x497d4e[_0xd038('0x55')]['id']}})[_0xd038('0x27')](handleEntityNotFound(_0x29b971,null))[_0xd038('0x27')](function(_0x1426a9){if(_0x1426a9){return _0x1426a9[_0xd038('0x88')](_0x497d4e[_0xd038('0x4d')][_0xd038('0x67')],_[_0xd038('0x89')](_0x497d4e[_0xd038('0x4d')],['ids','id'])||{})[_0xd038('0x8a')](function(_0x26f87c){for(var _0x126ffa=0x0;_0x126ffa<_0x497d4e[_0xd038('0x4d')][_0xd038('0x67')][_0xd038('0x3d')];_0x126ffa+=0x1){socket[_0xd038('0x8b')](_0xd038('0x70'),{'UserId':Number(_0x497d4e[_0xd038('0x4d')][_0xd038('0x67')][_0x126ffa]),'FaxQueueId':Number(_0x497d4e[_0xd038('0x55')]['id'])});}return _0x26f87c;});}})[_0xd038('0x27')](respondWithResult(_0x29b971,null))[_0xd038('0x48')](handleError(_0x29b971,null));};exports['removeAgents']=function(_0x3cf3fd,_0x59f210,_0x385b42){return db[_0xd038('0x32')][_0xd038('0x4b')]({'where':{'id':_0x3cf3fd[_0xd038('0x55')]['id']}})[_0xd038('0x27')](handleEntityNotFound(_0x59f210,null))[_0xd038('0x27')](function(_0x19b6bc){if(_0x19b6bc){return _0x19b6bc[_0xd038('0x86')](_0x3cf3fd[_0xd038('0x37')][_0xd038('0x67')])[_0xd038('0x27')](function(){if(_[_0xd038('0x8c')](_0x3cf3fd[_0xd038('0x37')][_0xd038('0x67')])){for(var _0x208923=0x0;_0x208923<_0x3cf3fd[_0xd038('0x37')][_0xd038('0x67')][_0xd038('0x3d')];_0x208923+=0x1){socket[_0xd038('0x8b')](_0xd038('0x87'),{'UserId':Number(_0x3cf3fd[_0xd038('0x37')][_0xd038('0x67')][_0x208923]),'FaxQueueId':Number(_0x3cf3fd['params']['id'])});}}else{socket[_0xd038('0x8b')](_0xd038('0x87'),{'UserId':Number(_0x3cf3fd['query']['ids']),'FaxQueueId':Number(_0x3cf3fd[_0xd038('0x55')]['id'])});}});}})['then'](respondWithStatusCode(_0x59f210,null))['catch'](handleError(_0x59f210,null));};exports[_0xd038('0x8d')]=function(_0x36c343,_0x4c8ce7,_0x114165){var _0x5782bb={};var _0x592171={};var _0x1a6579;var _0x170252;return db[_0xd038('0x32')][_0xd038('0x58')]({'where':{'id':_0x36c343[_0xd038('0x55')]['id']}})[_0xd038('0x27')](handleEntityNotFound(_0x4c8ce7,null))[_0xd038('0x27')](function(_0xd96e17){if(_0xd96e17){_0x1a6579=_0xd96e17;_0x592171[_0xd038('0x3a')]=_['keys'](db[_0xd038('0x5f')][_0xd038('0x33')]);_0x592171['query']=_[_0xd038('0x38')](_0x36c343[_0xd038('0x37')]);_0x592171[_0xd038('0x40')]=_[_0xd038('0x39')](_0x592171[_0xd038('0x3a')],_0x592171[_0xd038('0x37')]);_0x5782bb['attributes']=_['intersection'](_0x592171[_0xd038('0x3a')],qs[_0xd038('0x3c')](_0x36c343[_0xd038('0x37')][_0xd038('0x3c')]));_0x5782bb['attributes']=_0x5782bb[_0xd038('0x3b')][_0xd038('0x3d')]?_0x5782bb[_0xd038('0x3b')]:_0x592171[_0xd038('0x3a')];_0x5782bb[_0xd038('0x5b')]=qs[_0xd038('0x5c')](_0x36c343[_0xd038('0x37')]['sort']);_0x5782bb[_0xd038('0x3f')]=qs[_0xd038('0x40')](_[_0xd038('0x41')](_0x36c343[_0xd038('0x37')],_0x592171[_0xd038('0x40')]));if(_0x36c343[_0xd038('0x37')]['filter']){_0x5782bb[_0xd038('0x3f')]=_[_0xd038('0x43')](_0x5782bb[_0xd038('0x3f')],{'$or':_[_0xd038('0x31')](_0x5782bb[_0xd038('0x3b')],function(_0x35bde1){var _0x22e30c={};_0x22e30c[_0x35bde1]={'$like':'%'+_0x36c343['query'][_0xd038('0x42')]+'%'};return _0x22e30c;})});}_0x5782bb=_[_0xd038('0x43')]({},_0x5782bb,_0x36c343[_0xd038('0x4a')]);return _0x1a6579[_0xd038('0x8d')](_0x5782bb);}})['then'](function(_0x27478b){if(_0x27478b){_0x170252=_0x27478b[_0xd038('0x3d')];if(!_0x36c343[_0xd038('0x37')][_0xd038('0x5a')](_0xd038('0x3e'))){_0x5782bb['limit']=qs['limit'](_0x36c343[_0xd038('0x37')][_0xd038('0x20')]);_0x5782bb[_0xd038('0x1e')]=qs[_0xd038('0x1e')](_0x36c343[_0xd038('0x37')][_0xd038('0x1e')]);}return _0x1a6579[_0xd038('0x8d')](_0x5782bb);}})[_0xd038('0x27')](function(_0x399a1b){if(_0x399a1b){return _0x399a1b?{'count':_0x170252,'rows':_0x399a1b}:null;}})['then'](respondWithResult(_0x4c8ce7,null))[_0xd038('0x48')](handleError(_0x4c8ce7,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