Built motion from commit cb845558.|2.6.34
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index ec34bc9..8dfd6ba 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4ccb=['createdAt','format','%s/%s','SIP','updatedAt','getTeams','findOne','options','addTeams','ids','online','voicePause','interface','flatMap','Agents','sequelize','transaction','each','findOrCreate','forEach','emit','removeTeams','Team','select','tq.TeamId','from','team_has_fax_queues','join','ut.TeamId\x20=\x20tq.TeamId','ut.UserId\x20=\x20?','push','toString','SELECT','every','TeamId','includes','all','union','compact','isEmpty','userFaxQueue:remove','addAgents','omit','spread','removeAgents','getAgents','bluebird','util','lodash','ioredis','../../components/parsers/qs','api','../../config/environment','../../mysqldb','defaults','redis','localhost','./faxQueue.socket','register','sendStatus','status','end','json','limit','count','offset','set','Content-Range','update','then','destroy','FaxQueues','UserProfileResource','error','stack','send','rawAttributes','fieldName','type','key','getOptions','where','FaxQueue','include','query','rows','show','model','keys','filters','intersection','attributes','fields','length','includeAll','merge','find','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','name','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','catch','params','getMembers','UserFaxQueue','hasOwnProperty','nolimit','order','sort','pick','filter','map','findAll','User','agent','faxPause'];(function(_0x57d9d9,_0x40b94c){var _0xa4a00c=function(_0x435b6e){while(--_0x435b6e){_0x57d9d9['push'](_0x57d9d9['shift']());}};_0xa4a00c(++_0x40b94c);}(_0x4ccb,0x196));var _0xb4cc=function(_0x10bc30,_0x2c5ff1){_0x10bc30=_0x10bc30-0x0;var _0x19f32b=_0x4ccb[_0x10bc30];return _0x19f32b;};'use strict';var BPromise=require(_0xb4cc('0x0'));var util=require(_0xb4cc('0x1'));var _=require(_0xb4cc('0x2'));var squel=require('squel');var Redis=require(_0xb4cc('0x3'));var qs=require(_0xb4cc('0x4'));var logger=require('../../config/logger')(_0xb4cc('0x5'));var config=require(_0xb4cc('0x6'));var db=require(_0xb4cc('0x7'))['db'];config['redis']=_[_0xb4cc('0x8')](config[_0xb4cc('0x9')],{'host':_0xb4cc('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb4cc('0x9')]));require(_0xb4cc('0xb'))[_0xb4cc('0xc')](socket);function respondWithStatusCode(_0x5327a4,_0x7e4460){_0x7e4460=_0x7e4460||0xcc;return function(_0x475478){if(_0x475478){return _0x5327a4[_0xb4cc('0xd')](_0x7e4460);}return _0x5327a4[_0xb4cc('0xe')](_0x7e4460)[_0xb4cc('0xf')]();};}function respondWithResult(_0x55224b,_0x507d38){_0x507d38=_0x507d38||0xc8;return function(_0x19d43e){if(_0x19d43e){return _0x55224b['status'](_0x507d38)[_0xb4cc('0x10')](_0x19d43e);}};}function respondWithFilteredResult(_0x4a54a5,_0x1d7063){return function(_0x1e5a83){if(_0x1e5a83){var _0x277c2a=typeof _0x1d7063['offset']==='undefined'&&typeof _0x1d7063[_0xb4cc('0x11')]==='undefined';var _0x5cf92a=_0x1e5a83[_0xb4cc('0x12')];var _0x58b1c2=_0x277c2a?0x0:_0x1d7063['offset'];var _0xcfdeb9=_0x277c2a?_0x1e5a83[_0xb4cc('0x12')]:_0x1d7063[_0xb4cc('0x13')]+_0x1d7063['limit'];var _0x4096db;if(_0xcfdeb9>=_0x5cf92a){_0xcfdeb9=_0x5cf92a;_0x4096db=0xc8;}else{_0x4096db=0xce;}_0x4a54a5[_0xb4cc('0xe')](_0x4096db);return _0x4a54a5[_0xb4cc('0x14')](_0xb4cc('0x15'),_0x58b1c2+'-'+_0xcfdeb9+'/'+_0x5cf92a)[_0xb4cc('0x10')](_0x1e5a83);}return null;};}function saveUpdates(_0x506ef9){return function(_0x4d4546){if(_0x4d4546){return _0x4d4546[_0xb4cc('0x16')](_0x506ef9)[_0xb4cc('0x17')](function(_0x5b56b2){return _0x5b56b2;});}return null;};}function removeEntity(_0x490b1a){return function(_0x14d8b6){if(_0x14d8b6){return _0x14d8b6[_0xb4cc('0x18')]()[_0xb4cc('0x17')](function(){var _0xa99916=_0x14d8b6['get']({'plain':!![]});var _0x242272=_0xb4cc('0x19');return db[_0xb4cc('0x1a')][_0xb4cc('0x18')]({'where':{'type':_0x242272,'resourceId':_0xa99916['id']}})[_0xb4cc('0x17')](function(){return _0x14d8b6;});})['then'](function(){_0x490b1a[_0xb4cc('0xe')](0xcc)[_0xb4cc('0xf')]();});}};}function handleEntityNotFound(_0x442d86){return function(_0x1a9c91){if(!_0x1a9c91){_0x442d86[_0xb4cc('0xd')](0x194);}return _0x1a9c91;};}function handleError(_0x571793,_0xc9d835){_0xc9d835=_0xc9d835||0x1f4;return function(_0x2289f6){logger[_0xb4cc('0x1b')](_0x2289f6[_0xb4cc('0x1c')]);if(_0x2289f6['name']){delete _0x2289f6['name'];}_0x571793[_0xb4cc('0xe')](_0xc9d835)[_0xb4cc('0x1d')](_0x2289f6);};}exports['index']=function(_0x5b4a17,_0x1f1809){var _0xeb25e1={};var _0x2ee2d3={'count':0x0,'rows':[]};var _0x154002=_['map'](db['FaxQueue'][_0xb4cc('0x1e')],function(_0x4f47ed){return{'name':_0x4f47ed[_0xb4cc('0x1f')],'type':_0x4f47ed[_0xb4cc('0x20')][_0xb4cc('0x21')]};});_0xeb25e1=qs[_0xb4cc('0x22')](_0x154002,_0x5b4a17);var _0x6fb0fb={'where':_0xeb25e1[_0xb4cc('0x23')]};return db[_0xb4cc('0x24')][_0xb4cc('0x12')](_0x6fb0fb)[_0xb4cc('0x17')](function(_0x5baab6){_0x2ee2d3[_0xb4cc('0x12')]=_0x5baab6;_0xeb25e1[_0xb4cc('0x25')]=qs[_0xb4cc('0x25')](_0x5b4a17[_0xb4cc('0x26')]);return db[_0xb4cc('0x24')]['findAll'](_0xeb25e1);})[_0xb4cc('0x17')](function(_0x2957ee){_0x2ee2d3[_0xb4cc('0x27')]=_0x2957ee;return _0x2ee2d3;})[_0xb4cc('0x17')](respondWithFilteredResult(_0x1f1809,_0xeb25e1))['catch'](handleError(_0x1f1809,null));};exports[_0xb4cc('0x28')]=function(_0x3641d5,_0x4e8e5f){var _0x3a78ef={'raw':!![],'where':{'id':_0x3641d5['params']['id']}},_0x418c2d={};_0x418c2d[_0xb4cc('0x29')]=_[_0xb4cc('0x2a')](db[_0xb4cc('0x24')][_0xb4cc('0x1e')]);_0x418c2d[_0xb4cc('0x26')]=_[_0xb4cc('0x2a')](_0x3641d5[_0xb4cc('0x26')]);_0x418c2d[_0xb4cc('0x2b')]=_[_0xb4cc('0x2c')](_0x418c2d['model'],_0x418c2d['query']);_0x3a78ef[_0xb4cc('0x2d')]=_[_0xb4cc('0x2c')](_0x418c2d[_0xb4cc('0x29')],qs[_0xb4cc('0x2e')](_0x3641d5[_0xb4cc('0x26')]['fields']));_0x3a78ef[_0xb4cc('0x2d')]=_0x3a78ef[_0xb4cc('0x2d')][_0xb4cc('0x2f')]?_0x3a78ef['attributes']:_0x418c2d[_0xb4cc('0x29')];if(_0x3641d5[_0xb4cc('0x26')][_0xb4cc('0x30')]){_0x3a78ef['include']=[{'all':!![]}];}_0x3a78ef=_[_0xb4cc('0x31')]({},_0x3a78ef,_0x3641d5['options']);return db[_0xb4cc('0x24')][_0xb4cc('0x32')](_0x3a78ef)[_0xb4cc('0x17')](handleEntityNotFound(_0x4e8e5f,null))[_0xb4cc('0x17')](respondWithResult(_0x4e8e5f,null))['catch'](handleError(_0x4e8e5f,null));};exports[_0xb4cc('0x33')]=function(_0x5e7fd1,_0x8d6f09){return db[_0xb4cc('0x24')][_0xb4cc('0x33')](_0x5e7fd1[_0xb4cc('0x34')],{})[_0xb4cc('0x17')](function(_0x3f9b37){var _0x4214e5=_0x5e7fd1['user'][_0xb4cc('0x35')]({'plain':!![]});if(!_0x4214e5)throw new Error(_0xb4cc('0x36'));if(_0x4214e5[_0xb4cc('0x37')]==='user'){var _0x5f05fa=_0x3f9b37[_0xb4cc('0x35')]({'plain':!![]});var _0xc257a=_0xb4cc('0x19');return db[_0xb4cc('0x38')][_0xb4cc('0x32')]({'where':{'name':_0xc257a,'userProfileId':_0x4214e5['userProfileId']},'raw':!![]})[_0xb4cc('0x17')](function(_0x5d55fe){if(_0x5d55fe&&_0x5d55fe['autoAssociation']===0x0){return db[_0xb4cc('0x1a')][_0xb4cc('0x33')]({'name':_0x5f05fa[_0xb4cc('0x39')],'resourceId':_0x5f05fa['id'],'type':_0x5d55fe[_0xb4cc('0x39')],'sectionId':_0x5d55fe['id']},{})[_0xb4cc('0x17')](function(){return _0x3f9b37;});}else{return _0x3f9b37;}})['catch'](function(_0xda87d5){logger['error'](_0xb4cc('0x3a'),_0xda87d5);throw _0xda87d5;});}return _0x3f9b37;})[_0xb4cc('0x17')](respondWithResult(_0x8d6f09,0xc9))[_0xb4cc('0x3b')](handleError(_0x8d6f09,null));};exports[_0xb4cc('0x16')]=function(_0x428ef1,_0x35a6c8){if(_0x428ef1[_0xb4cc('0x34')]['id']){delete _0x428ef1[_0xb4cc('0x34')]['id'];}return db[_0xb4cc('0x24')][_0xb4cc('0x32')]({'where':{'id':_0x428ef1[_0xb4cc('0x3c')]['id']}})['then'](handleEntityNotFound(_0x35a6c8,null))[_0xb4cc('0x17')](saveUpdates(_0x428ef1[_0xb4cc('0x34')],null))[_0xb4cc('0x17')](respondWithResult(_0x35a6c8,null))[_0xb4cc('0x3b')](handleError(_0x35a6c8,null));};exports['destroy']=function(_0x5be726,_0x2fe47b){return db[_0xb4cc('0x24')]['find']({'where':{'id':_0x5be726[_0xb4cc('0x3c')]['id']}})[_0xb4cc('0x17')](handleEntityNotFound(_0x2fe47b,null))[_0xb4cc('0x17')](removeEntity(_0x2fe47b,null))[_0xb4cc('0x3b')](handleError(_0x2fe47b,null));};exports['describe']=function(_0x1093bc,_0x94476f){return db[_0xb4cc('0x24')]['describe']()[_0xb4cc('0x17')](respondWithResult(_0x94476f,null))[_0xb4cc('0x3b')](handleError(_0x94476f,null));};exports[_0xb4cc('0x3d')]=function(_0x1490b6,_0xdbba1){var _0x439aa6={'raw':!![],'where':{}},_0x26caae={},_0x303efa;return db[_0xb4cc('0x24')]['findOne']({'where':{'id':_0x1490b6[_0xb4cc('0x3c')]['id']}})['then'](handleEntityNotFound(_0xdbba1,null))[_0xb4cc('0x17')](function(_0x31a76a){if(_0x31a76a){_0x303efa=_0x31a76a[_0xb4cc('0x35')]({'plain':!![]});_0x26caae['model']=_[_0xb4cc('0x2a')](db[_0xb4cc('0x3e')][_0xb4cc('0x1e')]);_0x26caae[_0xb4cc('0x26')]=_[_0xb4cc('0x2a')](_0x1490b6[_0xb4cc('0x26')]);_0x26caae[_0xb4cc('0x2b')]=_[_0xb4cc('0x2c')](_0x26caae['model'],_0x26caae[_0xb4cc('0x26')]);_0x439aa6[_0xb4cc('0x2d')]=_[_0xb4cc('0x2c')](_0x26caae[_0xb4cc('0x29')],qs[_0xb4cc('0x2e')](_0x1490b6[_0xb4cc('0x26')][_0xb4cc('0x2e')]));_0x439aa6['attributes']=_0x439aa6[_0xb4cc('0x2d')][_0xb4cc('0x2f')]?_0x439aa6['attributes']:_0x26caae[_0xb4cc('0x29')];if(!_0x1490b6[_0xb4cc('0x26')][_0xb4cc('0x3f')](_0xb4cc('0x40'))){_0x439aa6['limit']=qs[_0xb4cc('0x11')](_0x1490b6['query'][_0xb4cc('0x11')]);_0x439aa6['offset']=qs['offset'](_0x1490b6[_0xb4cc('0x26')][_0xb4cc('0x13')]);}_0x439aa6[_0xb4cc('0x41')]=qs['sort'](_0x1490b6[_0xb4cc('0x26')][_0xb4cc('0x42')]);_0x439aa6[_0xb4cc('0x23')]=qs[_0xb4cc('0x2b')](_[_0xb4cc('0x43')](_0x1490b6['query'],_0x26caae[_0xb4cc('0x2b')]));_0x439aa6[_0xb4cc('0x23')]['FaxQueueId']=_0x31a76a['id'];if(_0x1490b6[_0xb4cc('0x26')][_0xb4cc('0x44')]){_0x439aa6[_0xb4cc('0x23')]=_['merge'](_0x439aa6[_0xb4cc('0x23')],{'$or':_[_0xb4cc('0x45')](_0x439aa6['attributes'],function(_0x5c5a3e){var _0x6c1e81={};_0x6c1e81[_0x5c5a3e]={'$like':'%'+_0x1490b6['query'][_0xb4cc('0x44')]+'%'};return _0x6c1e81;})});}_0x439aa6=_[_0xb4cc('0x31')]({},_0x439aa6,_0x1490b6['options']);return db[_0xb4cc('0x3e')][_0xb4cc('0x46')](_0x439aa6);}})[_0xb4cc('0x17')](function(_0x191ca4){if(_0x191ca4){return db[_0xb4cc('0x47')]['findAndCountAll']({'where':{'id':_[_0xb4cc('0x45')](_0x191ca4,'UserId'),'role':_0xb4cc('0x48')},'attributes':['id',_0xb4cc('0x39'),_0xb4cc('0x49'),'updatedAt',_0xb4cc('0x4a')]});}})[_0xb4cc('0x17')](function(_0x3b4f28){if(_0x3b4f28){return{'count':_0x3b4f28['count'],'rows':_[_0xb4cc('0x45')](_0x3b4f28[_0xb4cc('0x27')],function(_0x290b4f){return{'membername':_0x290b4f['name'],'UserId':_0x290b4f['id'],'queue_name':_0x303efa[_0xb4cc('0x39')],'FaxQueueId':_0x303efa['id'],'interface':util[_0xb4cc('0x4b')](_0xb4cc('0x4c'),_0xb4cc('0x4d'),_0x290b4f[_0xb4cc('0x39')]),'penalty':0x0,'paused':_0x290b4f['faxPause'],'createdAt':_0x290b4f[_0xb4cc('0x4a')],'updatedAt':_0x290b4f[_0xb4cc('0x4e')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xb4cc('0x17')](respondWithFilteredResult(_0xdbba1,_0x439aa6))[_0xb4cc('0x3b')](handleError(_0xdbba1,null));};exports[_0xb4cc('0x4f')]=function(_0x1e7798,_0xc2a99c){var _0x31d28c={};var _0x36537a={};var _0x491aaa;var _0x23bb10;return db['FaxQueue'][_0xb4cc('0x50')]({'where':{'id':_0x1e7798[_0xb4cc('0x3c')]['id']}})['then'](handleEntityNotFound(_0xc2a99c,null))[_0xb4cc('0x17')](function(_0x4c02ba){if(_0x4c02ba){_0x491aaa=_0x4c02ba;_0x36537a[_0xb4cc('0x29')]=_[_0xb4cc('0x2a')](db['Team'][_0xb4cc('0x1e')]);_0x36537a[_0xb4cc('0x26')]=_[_0xb4cc('0x2a')](_0x1e7798[_0xb4cc('0x26')]);_0x36537a[_0xb4cc('0x2b')]=_['intersection'](_0x36537a[_0xb4cc('0x29')],_0x36537a['query']);_0x31d28c[_0xb4cc('0x2d')]=_[_0xb4cc('0x2c')](_0x36537a[_0xb4cc('0x29')],qs[_0xb4cc('0x2e')](_0x1e7798[_0xb4cc('0x26')][_0xb4cc('0x2e')]));_0x31d28c[_0xb4cc('0x2d')]=_0x31d28c[_0xb4cc('0x2d')][_0xb4cc('0x2f')]?_0x31d28c[_0xb4cc('0x2d')]:_0x36537a['model'];_0x31d28c['order']=qs[_0xb4cc('0x42')](_0x1e7798[_0xb4cc('0x26')][_0xb4cc('0x42')]);_0x31d28c['where']=qs[_0xb4cc('0x2b')](_[_0xb4cc('0x43')](_0x1e7798[_0xb4cc('0x26')],_0x36537a[_0xb4cc('0x2b')]));if(_0x1e7798[_0xb4cc('0x26')][_0xb4cc('0x44')]){_0x31d28c[_0xb4cc('0x23')]=_[_0xb4cc('0x31')](_0x31d28c[_0xb4cc('0x23')],{'$or':_['map'](_0x31d28c[_0xb4cc('0x2d')],function(_0x5c1d89){var _0xd335f={};_0xd335f[_0x5c1d89]={'$like':'%'+_0x1e7798[_0xb4cc('0x26')]['filter']+'%'};return _0xd335f;})});}_0x31d28c=_[_0xb4cc('0x31')]({},_0x31d28c,_0x1e7798[_0xb4cc('0x51')]);return _0x491aaa['getTeams'](_0x31d28c);}})[_0xb4cc('0x17')](function(_0x196409){if(_0x196409){_0x23bb10=_0x196409['length'];if(!_0x1e7798[_0xb4cc('0x26')][_0xb4cc('0x3f')](_0xb4cc('0x40'))){_0x31d28c[_0xb4cc('0x11')]=qs[_0xb4cc('0x11')](_0x1e7798[_0xb4cc('0x26')][_0xb4cc('0x11')]);_0x31d28c[_0xb4cc('0x13')]=qs[_0xb4cc('0x13')](_0x1e7798[_0xb4cc('0x26')][_0xb4cc('0x13')]);}return _0x491aaa[_0xb4cc('0x4f')](_0x31d28c);}})[_0xb4cc('0x17')](function(_0x1ba8c0){if(_0x1ba8c0){return _0x1ba8c0?{'count':_0x23bb10,'rows':_0x1ba8c0}:null;}})[_0xb4cc('0x17')](respondWithResult(_0xc2a99c,null))['catch'](handleError(_0xc2a99c,null));};exports[_0xb4cc('0x52')]=function(_0x15fb52,_0x3632f3){var _0x17ea2e=_0x15fb52[_0xb4cc('0x34')][_0xb4cc('0x53')];return db['Team'][_0xb4cc('0x46')]({'where':{'id':_0x17ea2e},'attributes':['id'],'include':[{'model':db[_0xb4cc('0x47')],'as':'Agents','attributes':['id',_0xb4cc('0x39'),_0xb4cc('0x54'),_0xb4cc('0x55'),_0xb4cc('0x56')],'raw':!![]}]})[_0xb4cc('0x17')](function(_0x35fcca){if(_0x35fcca){var _0x405dd2=_[_0xb4cc('0x57')](_0x35fcca,function(_0x5592d3){var _0xfa6816=_0x5592d3[_0xb4cc('0x35')]({'plain':!![]});return _0xfa6816[_0xb4cc('0x58')];});return db[_0xb4cc('0x24')][_0xb4cc('0x32')]({'where':{'id':_0x15fb52['params']['id']}})[_0xb4cc('0x17')](function(_0x27b9b){return db[_0xb4cc('0x59')][_0xb4cc('0x5a')](function(_0x46fd76){return _0x27b9b[_0xb4cc('0x52')](_0x17ea2e,{'transaction':_0x46fd76})[_0xb4cc('0x17')](function(){return BPromise[_0xb4cc('0x5b')](_0x405dd2,function(_0x51a63f){return db['UserFaxQueue'][_0xb4cc('0x5c')]({'where':{'UserId':_0x51a63f['id'],'FaxQueueId':_0x15fb52['params']['id']},'transaction':_0x46fd76});});})[_0xb4cc('0x17')](function(){_0x405dd2[_0xb4cc('0x5d')](function(_0x5e47a2){socket[_0xb4cc('0x5e')]('userFaxQueue:save',{'UserId':_0x5e47a2['id'],'FaxQueueId':_0x27b9b['id']});});});});});}})[_0xb4cc('0x17')](respondWithStatusCode(_0x3632f3,null))['catch'](handleError(_0x3632f3,null));};exports[_0xb4cc('0x5f')]=function(_0x5138c2,_0x1ce412){return db[_0xb4cc('0x60')][_0xb4cc('0x46')]({'where':{'id':_0x5138c2[_0xb4cc('0x26')]['ids']},'attributes':['id'],'include':[{'model':db[_0xb4cc('0x47')],'as':_0xb4cc('0x58'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x1ce412,null))[_0xb4cc('0x17')](function(_0x3edef8){var _0x4d5531=_['map'](_0x3edef8,'id');var _0x5bdbab=[];var _0x5c6323=[];var _0x42b62d=squel[_0xb4cc('0x61')]();_0x42b62d['field'](_0xb4cc('0x62'))[_0xb4cc('0x63')](_0xb4cc('0x64'),'tq')[_0xb4cc('0x65')]('user_has_teams','ut',_0xb4cc('0x66'))[_0xb4cc('0x23')]('FaxQueueId\x20=\x20?',_0x5138c2[_0xb4cc('0x3c')]['id']);for(var _0x154f7a=0x0;_0x154f7a<_0x3edef8[_0xb4cc('0x2f')];_0x154f7a+=0x1){let _0x482de7=_0x3edef8[_0x154f7a];for(var _0x19f329=0x0;_0x19f329<_0x482de7[_0xb4cc('0x58')][_0xb4cc('0x2f')];_0x19f329+=0x1){let _0x403716=_0x482de7['Agents'][_0x19f329];var _0x44e9d0=_0x42b62d['clone']();_0x44e9d0[_0xb4cc('0x23')](_0xb4cc('0x67'),_0x403716['id']);_0x5c6323[_0xb4cc('0x68')](db[_0xb4cc('0x59')][_0xb4cc('0x26')](_0x44e9d0[_0xb4cc('0x69')](),{'type':db[_0xb4cc('0x59')]['QueryTypes'][_0xb4cc('0x6a')]})['then'](function(_0x23e30c){if(_0x23e30c[_0xb4cc('0x2f')]===0x1){return _0x403716['id'];}else{var _0x402743=_[_0xb4cc('0x6b')](_[_0xb4cc('0x45')](_0x23e30c,_0xb4cc('0x6c')),function(_0x3d2326){return _[_0xb4cc('0x6d')](_0x4d5531,_0x3d2326);});if(_0x402743){return _0x403716['id'];}}}));}}return BPromise[_0xb4cc('0x6e')](_0x5c6323)[_0xb4cc('0x17')](function(_0x4f2bc6){_0x5bdbab=_(_0x5bdbab)[_0xb4cc('0x6f')](_0x4f2bc6)[_0xb4cc('0x70')]()['value']();return db['FaxQueue'][_0xb4cc('0x32')]({'where':{'id':_0x5138c2[_0xb4cc('0x3c')]['id']}})[_0xb4cc('0x17')](function(_0x363e75){return db[_0xb4cc('0x59')][_0xb4cc('0x5a')](function(_0x221307){return _0x363e75[_0xb4cc('0x5f')](_0x5138c2[_0xb4cc('0x26')][_0xb4cc('0x53')],{'transaction':_0x221307})[_0xb4cc('0x17')](function(){if(!_[_0xb4cc('0x71')](_0x5bdbab)){return _0x363e75['removeAgents'](_0x5bdbab,{'transaction':_0x221307});}})['then'](function(){_0x5bdbab[_0xb4cc('0x5d')](function(_0x31eda6){socket['emit'](_0xb4cc('0x72'),{'UserId':_0x31eda6,'FaxQueueId':_0x363e75['id']});});});});});});})['then'](respondWithStatusCode(_0x1ce412,null))[_0xb4cc('0x3b')](handleError(_0x1ce412,null));};exports[_0xb4cc('0x73')]=function(_0x1a211e,_0x3fadaf){return db[_0xb4cc('0x24')][_0xb4cc('0x32')]({'where':{'id':_0x1a211e[_0xb4cc('0x3c')]['id']}})[_0xb4cc('0x17')](handleEntityNotFound(_0x3fadaf,null))[_0xb4cc('0x17')](function(_0x281118){if(_0x281118){return _0x281118[_0xb4cc('0x73')](_0x1a211e['body'][_0xb4cc('0x53')],_[_0xb4cc('0x74')](_0x1a211e[_0xb4cc('0x34')],[_0xb4cc('0x53'),'id'])||{})[_0xb4cc('0x75')](function(_0xa4abb8){for(var _0x36863e=0x0;_0x36863e<_0x1a211e[_0xb4cc('0x34')][_0xb4cc('0x53')][_0xb4cc('0x2f')];_0x36863e+=0x1){socket[_0xb4cc('0x5e')]('userFaxQueue:save',{'UserId':Number(_0x1a211e[_0xb4cc('0x34')][_0xb4cc('0x53')][_0x36863e]),'FaxQueueId':Number(_0x1a211e[_0xb4cc('0x3c')]['id'])});}return _0xa4abb8;});}})[_0xb4cc('0x17')](respondWithResult(_0x3fadaf,null))[_0xb4cc('0x3b')](handleError(_0x3fadaf,null));};exports[_0xb4cc('0x76')]=function(_0x598ac6,_0x236bc3){return db['FaxQueue']['find']({'where':{'id':_0x598ac6[_0xb4cc('0x3c')]['id']}})['then'](handleEntityNotFound(_0x236bc3,null))['then'](function(_0x486a1d){if(_0x486a1d){return _0x486a1d['removeAgents'](_0x598ac6[_0xb4cc('0x26')][_0xb4cc('0x53')])[_0xb4cc('0x17')](function(){if(_['isArray'](_0x598ac6[_0xb4cc('0x26')]['ids'])){for(var _0x4d6c67=0x0;_0x4d6c67<_0x598ac6[_0xb4cc('0x26')]['ids'][_0xb4cc('0x2f')];_0x4d6c67+=0x1){socket[_0xb4cc('0x5e')]('userFaxQueue:remove',{'UserId':Number(_0x598ac6[_0xb4cc('0x26')][_0xb4cc('0x53')][_0x4d6c67]),'FaxQueueId':Number(_0x598ac6[_0xb4cc('0x3c')]['id'])});}}else{socket[_0xb4cc('0x5e')](_0xb4cc('0x72'),{'UserId':Number(_0x598ac6[_0xb4cc('0x26')][_0xb4cc('0x53')]),'FaxQueueId':Number(_0x598ac6[_0xb4cc('0x3c')]['id'])});}});}})[_0xb4cc('0x17')](respondWithStatusCode(_0x236bc3,null))['catch'](handleError(_0x236bc3,null));};exports[_0xb4cc('0x77')]=function(_0x11c9dc,_0x11e57b){var _0x2092b3={};var _0x5cbdf8={};var _0x51061b;var _0x2c49f3;return db[_0xb4cc('0x24')]['findOne']({'where':{'id':_0x11c9dc['params']['id']}})[_0xb4cc('0x17')](handleEntityNotFound(_0x11e57b,null))[_0xb4cc('0x17')](function(_0x2894e1){if(_0x2894e1){_0x51061b=_0x2894e1;_0x5cbdf8[_0xb4cc('0x29')]=_['keys'](db[_0xb4cc('0x47')]['rawAttributes']);_0x5cbdf8[_0xb4cc('0x26')]=_[_0xb4cc('0x2a')](_0x11c9dc[_0xb4cc('0x26')]);_0x5cbdf8[_0xb4cc('0x2b')]=_['intersection'](_0x5cbdf8[_0xb4cc('0x29')],_0x5cbdf8[_0xb4cc('0x26')]);_0x2092b3['attributes']=_['intersection'](_0x5cbdf8[_0xb4cc('0x29')],qs[_0xb4cc('0x2e')](_0x11c9dc['query'][_0xb4cc('0x2e')]));_0x2092b3[_0xb4cc('0x2d')]=_0x2092b3[_0xb4cc('0x2d')][_0xb4cc('0x2f')]?_0x2092b3[_0xb4cc('0x2d')]:_0x5cbdf8[_0xb4cc('0x29')];_0x2092b3[_0xb4cc('0x41')]=qs[_0xb4cc('0x42')](_0x11c9dc[_0xb4cc('0x26')][_0xb4cc('0x42')]);_0x2092b3[_0xb4cc('0x23')]=qs[_0xb4cc('0x2b')](_[_0xb4cc('0x43')](_0x11c9dc[_0xb4cc('0x26')],_0x5cbdf8[_0xb4cc('0x2b')]));if(_0x11c9dc[_0xb4cc('0x26')][_0xb4cc('0x44')]){_0x2092b3['where']=_[_0xb4cc('0x31')](_0x2092b3[_0xb4cc('0x23')],{'$or':_['map'](_0x2092b3[_0xb4cc('0x2d')],function(_0x1fb015){var _0x55ee58={};_0x55ee58[_0x1fb015]={'$like':'%'+_0x11c9dc[_0xb4cc('0x26')]['filter']+'%'};return _0x55ee58;})});}_0x2092b3=_[_0xb4cc('0x31')]({},_0x2092b3,_0x11c9dc[_0xb4cc('0x51')]);return _0x51061b['getAgents'](_0x2092b3);}})[_0xb4cc('0x17')](function(_0x4121da){if(_0x4121da){_0x2c49f3=_0x4121da[_0xb4cc('0x2f')];if(!_0x11c9dc['query'][_0xb4cc('0x3f')]('nolimit')){_0x2092b3['limit']=qs['limit'](_0x11c9dc[_0xb4cc('0x26')]['limit']);_0x2092b3['offset']=qs['offset'](_0x11c9dc[_0xb4cc('0x26')][_0xb4cc('0x13')]);}return _0x51061b['getAgents'](_0x2092b3);}})['then'](function(_0x1ab8c2){if(_0x1ab8c2){return _0x1ab8c2?{'count':_0x2c49f3,'rows':_0x1ab8c2}:null;}})[_0xb4cc('0x17')](respondWithResult(_0x11e57b,null))['catch'](handleError(_0x11e57b,null));};
\ No newline at end of file
+var _0x90b5=['user','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','getMembers','findOne','hasOwnProperty','order','sort','FaxQueueId','filter','merge','UserFaxQueue','User','findAndCountAll','UserId','agent','faxPause','updatedAt','createdAt','rows','%s/%s','SIP','getTeams','Team','pick','nolimit','ids','Agents','voicePause','interface','flatMap','sequelize','addTeams','findOrCreate','emit','removeTeams','field','tq.TeamId','from','team_has_fax_queues','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','clone','toString','QueryTypes','every','TeamId','includes','all','compact','value','transaction','removeAgents','forEach','userFaxQueue:remove','addAgents','omit','spread','userFaxQueue:save','isArray','getAgents','bluebird','lodash','squel','ioredis','../../components/parsers/qs','../../config/environment','../../mysqldb','defaults','redis','localhost','./faxQueue.socket','register','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','then','get','FaxQueues','destroy','error','stack','name','map','FaxQueue','fieldName','type','key','getOptions','where','include','findAll','show','model','keys','rawAttributes','query','filters','intersection','fields','attributes','length','includeAll','options','find','create','role'];(function(_0x94b286,_0x47f8c2){var _0x49148b=function(_0x1c2766){while(--_0x1c2766){_0x94b286['push'](_0x94b286['shift']());}};_0x49148b(++_0x47f8c2);}(_0x90b5,0x139));var _0x590b=function(_0xf9e6c1,_0x350daa){_0xf9e6c1=_0xf9e6c1-0x0;var _0x20ba02=_0x90b5[_0xf9e6c1];return _0x20ba02;};'use strict';var BPromise=require(_0x590b('0x0'));var util=require('util');var _=require(_0x590b('0x1'));var squel=require(_0x590b('0x2'));var Redis=require(_0x590b('0x3'));var qs=require(_0x590b('0x4'));var logger=require('../../config/logger')('api');var config=require(_0x590b('0x5'));var db=require(_0x590b('0x6'))['db'];config['redis']=_[_0x590b('0x7')](config[_0x590b('0x8')],{'host':_0x590b('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x590b('0x8')]));require(_0x590b('0xa'))[_0x590b('0xb')](socket);function respondWithStatusCode(_0x9c408b,_0x450969){_0x450969=_0x450969||0xcc;return function(_0x268b0a){if(_0x268b0a){return _0x9c408b[_0x590b('0xc')](_0x450969);}return _0x9c408b[_0x590b('0xd')](_0x450969)[_0x590b('0xe')]();};}function respondWithResult(_0x50a7b8,_0x5e567){_0x5e567=_0x5e567||0xc8;return function(_0x381bfe){if(_0x381bfe){return _0x50a7b8['status'](_0x5e567)[_0x590b('0xf')](_0x381bfe);}};}function respondWithFilteredResult(_0x4a5939,_0x392467){return function(_0x311c9d){if(_0x311c9d){var _0x8173c2=typeof _0x392467[_0x590b('0x10')]==='undefined'&&typeof _0x392467[_0x590b('0x11')]===_0x590b('0x12');var _0x88865c=_0x311c9d[_0x590b('0x13')];var _0x2e85b1=_0x8173c2?0x0:_0x392467[_0x590b('0x10')];var _0x45ac04=_0x8173c2?_0x311c9d[_0x590b('0x13')]:_0x392467[_0x590b('0x10')]+_0x392467[_0x590b('0x11')];var _0x3fc5ca;if(_0x45ac04>=_0x88865c){_0x45ac04=_0x88865c;_0x3fc5ca=0xc8;}else{_0x3fc5ca=0xce;}_0x4a5939[_0x590b('0xd')](_0x3fc5ca);return _0x4a5939[_0x590b('0x14')](_0x590b('0x15'),_0x2e85b1+'-'+_0x45ac04+'/'+_0x88865c)[_0x590b('0xf')](_0x311c9d);}return null;};}function saveUpdates(_0x4f2512){return function(_0x1ec65a){if(_0x1ec65a){return _0x1ec65a['update'](_0x4f2512)[_0x590b('0x16')](function(_0x115309){return _0x115309;});}return null;};}function removeEntity(_0xf05b00){return function(_0x53337c){if(_0x53337c){return _0x53337c['destroy']()[_0x590b('0x16')](function(){var _0x4f39e8=_0x53337c[_0x590b('0x17')]({'plain':!![]});var _0x4e4cc6=_0x590b('0x18');return db['UserProfileResource'][_0x590b('0x19')]({'where':{'type':_0x4e4cc6,'resourceId':_0x4f39e8['id']}})[_0x590b('0x16')](function(){return _0x53337c;});})[_0x590b('0x16')](function(){_0xf05b00[_0x590b('0xd')](0xcc)['end']();});}};}function handleEntityNotFound(_0x7c94ee){return function(_0x5839b7){if(!_0x5839b7){_0x7c94ee[_0x590b('0xc')](0x194);}return _0x5839b7;};}function handleError(_0x30dc9f,_0x5bdaba){_0x5bdaba=_0x5bdaba||0x1f4;return function(_0x5d47a6){logger[_0x590b('0x1a')](_0x5d47a6[_0x590b('0x1b')]);if(_0x5d47a6['name']){delete _0x5d47a6[_0x590b('0x1c')];}_0x30dc9f[_0x590b('0xd')](_0x5bdaba)['send'](_0x5d47a6);};}exports['index']=function(_0x26f073,_0x49c3f5){var _0x39fead={};var _0x520095={'count':0x0,'rows':[]};var _0x4d3ff9=_[_0x590b('0x1d')](db[_0x590b('0x1e')]['rawAttributes'],function(_0x1febcd){return{'name':_0x1febcd[_0x590b('0x1f')],'type':_0x1febcd[_0x590b('0x20')][_0x590b('0x21')]};});_0x39fead=qs[_0x590b('0x22')](_0x4d3ff9,_0x26f073);var _0x5c5903={'where':_0x39fead[_0x590b('0x23')]};return db[_0x590b('0x1e')][_0x590b('0x13')](_0x5c5903)[_0x590b('0x16')](function(_0x1ee769){_0x520095[_0x590b('0x13')]=_0x1ee769;_0x39fead['include']=qs[_0x590b('0x24')](_0x26f073['query']);return db[_0x590b('0x1e')][_0x590b('0x25')](_0x39fead);})[_0x590b('0x16')](function(_0x33931e){_0x520095['rows']=_0x33931e;return _0x520095;})[_0x590b('0x16')](respondWithFilteredResult(_0x49c3f5,_0x39fead))['catch'](handleError(_0x49c3f5,null));};exports[_0x590b('0x26')]=function(_0x369e63,_0x2ea853){var _0x1da455={'raw':!![],'where':{'id':_0x369e63['params']['id']}},_0x46aebb={};_0x46aebb[_0x590b('0x27')]=_[_0x590b('0x28')](db[_0x590b('0x1e')][_0x590b('0x29')]);_0x46aebb['query']=_['keys'](_0x369e63[_0x590b('0x2a')]);_0x46aebb[_0x590b('0x2b')]=_[_0x590b('0x2c')](_0x46aebb[_0x590b('0x27')],_0x46aebb['query']);_0x1da455['attributes']=_[_0x590b('0x2c')](_0x46aebb['model'],qs[_0x590b('0x2d')](_0x369e63[_0x590b('0x2a')][_0x590b('0x2d')]));_0x1da455[_0x590b('0x2e')]=_0x1da455[_0x590b('0x2e')][_0x590b('0x2f')]?_0x1da455[_0x590b('0x2e')]:_0x46aebb[_0x590b('0x27')];if(_0x369e63[_0x590b('0x2a')][_0x590b('0x30')]){_0x1da455['include']=[{'all':!![]}];}_0x1da455=_['merge']({},_0x1da455,_0x369e63[_0x590b('0x31')]);return db[_0x590b('0x1e')][_0x590b('0x32')](_0x1da455)[_0x590b('0x16')](handleEntityNotFound(_0x2ea853,null))[_0x590b('0x16')](respondWithResult(_0x2ea853,null))['catch'](handleError(_0x2ea853,null));};exports[_0x590b('0x33')]=function(_0x69be0a,_0x3e5ca5){return db[_0x590b('0x1e')][_0x590b('0x33')](_0x69be0a['body'],{})[_0x590b('0x16')](function(_0x2fd86b){var _0x4e3f84=_0x69be0a['user'][_0x590b('0x17')]({'plain':!![]});if(!_0x4e3f84)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x4e3f84[_0x590b('0x34')]===_0x590b('0x35')){var _0x3e83da=_0x2fd86b[_0x590b('0x17')]({'plain':!![]});var _0x210af8=_0x590b('0x18');return db[_0x590b('0x36')][_0x590b('0x32')]({'where':{'name':_0x210af8,'userProfileId':_0x4e3f84[_0x590b('0x37')]},'raw':!![]})[_0x590b('0x16')](function(_0x593b35){if(_0x593b35&&_0x593b35[_0x590b('0x38')]===0x0){return db[_0x590b('0x39')][_0x590b('0x33')]({'name':_0x3e83da['name'],'resourceId':_0x3e83da['id'],'type':_0x593b35[_0x590b('0x1c')],'sectionId':_0x593b35['id']},{})[_0x590b('0x16')](function(){return _0x2fd86b;});}else{return _0x2fd86b;}})[_0x590b('0x3a')](function(_0x114bbe){logger[_0x590b('0x1a')](_0x590b('0x3b'),_0x114bbe);throw _0x114bbe;});}return _0x2fd86b;})[_0x590b('0x16')](respondWithResult(_0x3e5ca5,0xc9))[_0x590b('0x3a')](handleError(_0x3e5ca5,null));};exports['update']=function(_0x7da2e3,_0x5984c0){if(_0x7da2e3[_0x590b('0x3c')]['id']){delete _0x7da2e3[_0x590b('0x3c')]['id'];}return db[_0x590b('0x1e')]['find']({'where':{'id':_0x7da2e3[_0x590b('0x3d')]['id']}})[_0x590b('0x16')](handleEntityNotFound(_0x5984c0,null))[_0x590b('0x16')](saveUpdates(_0x7da2e3[_0x590b('0x3c')],null))['then'](respondWithResult(_0x5984c0,null))[_0x590b('0x3a')](handleError(_0x5984c0,null));};exports[_0x590b('0x19')]=function(_0x4f9d8e,_0x48c7da){return db['FaxQueue'][_0x590b('0x32')]({'where':{'id':_0x4f9d8e[_0x590b('0x3d')]['id']}})[_0x590b('0x16')](handleEntityNotFound(_0x48c7da,null))['then'](removeEntity(_0x48c7da,null))['catch'](handleError(_0x48c7da,null));};exports[_0x590b('0x3e')]=function(_0x187db5,_0x53a19b){return db[_0x590b('0x1e')][_0x590b('0x3e')]()[_0x590b('0x16')](respondWithResult(_0x53a19b,null))[_0x590b('0x3a')](handleError(_0x53a19b,null));};exports[_0x590b('0x3f')]=function(_0x25ae14,_0x2050f3){var _0x67f695={'raw':!![],'where':{}},_0x2e92e7={},_0x30570;return db[_0x590b('0x1e')][_0x590b('0x40')]({'where':{'id':_0x25ae14[_0x590b('0x3d')]['id']}})['then'](handleEntityNotFound(_0x2050f3,null))['then'](function(_0x1a92fb){if(_0x1a92fb){_0x30570=_0x1a92fb[_0x590b('0x17')]({'plain':!![]});_0x2e92e7[_0x590b('0x27')]=_[_0x590b('0x28')](db['UserFaxQueue'][_0x590b('0x29')]);_0x2e92e7[_0x590b('0x2a')]=_[_0x590b('0x28')](_0x25ae14['query']);_0x2e92e7[_0x590b('0x2b')]=_[_0x590b('0x2c')](_0x2e92e7['model'],_0x2e92e7['query']);_0x67f695[_0x590b('0x2e')]=_[_0x590b('0x2c')](_0x2e92e7['model'],qs[_0x590b('0x2d')](_0x25ae14[_0x590b('0x2a')]['fields']));_0x67f695[_0x590b('0x2e')]=_0x67f695[_0x590b('0x2e')][_0x590b('0x2f')]?_0x67f695['attributes']:_0x2e92e7['model'];if(!_0x25ae14[_0x590b('0x2a')][_0x590b('0x41')]('nolimit')){_0x67f695[_0x590b('0x11')]=qs[_0x590b('0x11')](_0x25ae14[_0x590b('0x2a')][_0x590b('0x11')]);_0x67f695[_0x590b('0x10')]=qs[_0x590b('0x10')](_0x25ae14[_0x590b('0x2a')]['offset']);}_0x67f695[_0x590b('0x42')]=qs['sort'](_0x25ae14[_0x590b('0x2a')][_0x590b('0x43')]);_0x67f695[_0x590b('0x23')]=qs['filters'](_['pick'](_0x25ae14[_0x590b('0x2a')],_0x2e92e7[_0x590b('0x2b')]));_0x67f695[_0x590b('0x23')][_0x590b('0x44')]=_0x1a92fb['id'];if(_0x25ae14['query'][_0x590b('0x45')]){_0x67f695['where']=_['merge'](_0x67f695[_0x590b('0x23')],{'$or':_['map'](_0x67f695[_0x590b('0x2e')],function(_0x5663ef){var _0x153aca={};_0x153aca[_0x5663ef]={'$like':'%'+_0x25ae14['query'][_0x590b('0x45')]+'%'};return _0x153aca;})});}_0x67f695=_[_0x590b('0x46')]({},_0x67f695,_0x25ae14[_0x590b('0x31')]);return db[_0x590b('0x47')][_0x590b('0x25')](_0x67f695);}})[_0x590b('0x16')](function(_0x2d9f0d){if(_0x2d9f0d){return db[_0x590b('0x48')][_0x590b('0x49')]({'where':{'id':_['map'](_0x2d9f0d,_0x590b('0x4a')),'role':_0x590b('0x4b')},'attributes':['id','name',_0x590b('0x4c'),_0x590b('0x4d'),_0x590b('0x4e')]});}})[_0x590b('0x16')](function(_0x57e442){if(_0x57e442){return{'count':_0x57e442[_0x590b('0x13')],'rows':_[_0x590b('0x1d')](_0x57e442[_0x590b('0x4f')],function(_0x20eaf6){return{'membername':_0x20eaf6['name'],'UserId':_0x20eaf6['id'],'queue_name':_0x30570[_0x590b('0x1c')],'FaxQueueId':_0x30570['id'],'interface':util['format'](_0x590b('0x50'),_0x590b('0x51'),_0x20eaf6[_0x590b('0x1c')]),'penalty':0x0,'paused':_0x20eaf6[_0x590b('0x4c')],'createdAt':_0x20eaf6['createdAt'],'updatedAt':_0x20eaf6[_0x590b('0x4d')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x2050f3,_0x67f695))[_0x590b('0x3a')](handleError(_0x2050f3,null));};exports[_0x590b('0x52')]=function(_0x3ef6d3,_0x556276){var _0x2dff4f={};var _0x48f49a={};var _0x1b0cbb;var _0x4f22da;return db[_0x590b('0x1e')][_0x590b('0x40')]({'where':{'id':_0x3ef6d3[_0x590b('0x3d')]['id']}})['then'](handleEntityNotFound(_0x556276,null))['then'](function(_0x38bdde){if(_0x38bdde){_0x1b0cbb=_0x38bdde;_0x48f49a[_0x590b('0x27')]=_[_0x590b('0x28')](db[_0x590b('0x53')]['rawAttributes']);_0x48f49a[_0x590b('0x2a')]=_['keys'](_0x3ef6d3[_0x590b('0x2a')]);_0x48f49a[_0x590b('0x2b')]=_[_0x590b('0x2c')](_0x48f49a[_0x590b('0x27')],_0x48f49a[_0x590b('0x2a')]);_0x2dff4f['attributes']=_['intersection'](_0x48f49a[_0x590b('0x27')],qs['fields'](_0x3ef6d3['query'][_0x590b('0x2d')]));_0x2dff4f[_0x590b('0x2e')]=_0x2dff4f['attributes'][_0x590b('0x2f')]?_0x2dff4f[_0x590b('0x2e')]:_0x48f49a['model'];_0x2dff4f[_0x590b('0x42')]=qs[_0x590b('0x43')](_0x3ef6d3['query'][_0x590b('0x43')]);_0x2dff4f['where']=qs[_0x590b('0x2b')](_[_0x590b('0x54')](_0x3ef6d3[_0x590b('0x2a')],_0x48f49a['filters']));if(_0x3ef6d3[_0x590b('0x2a')][_0x590b('0x45')]){_0x2dff4f[_0x590b('0x23')]=_[_0x590b('0x46')](_0x2dff4f['where'],{'$or':_[_0x590b('0x1d')](_0x2dff4f[_0x590b('0x2e')],function(_0x4aa511){var _0x151e6={};_0x151e6[_0x4aa511]={'$like':'%'+_0x3ef6d3['query'][_0x590b('0x45')]+'%'};return _0x151e6;})});}_0x2dff4f=_[_0x590b('0x46')]({},_0x2dff4f,_0x3ef6d3[_0x590b('0x31')]);return _0x1b0cbb[_0x590b('0x52')](_0x2dff4f);}})[_0x590b('0x16')](function(_0x2fc424){if(_0x2fc424){_0x4f22da=_0x2fc424[_0x590b('0x2f')];if(!_0x3ef6d3[_0x590b('0x2a')]['hasOwnProperty'](_0x590b('0x55'))){_0x2dff4f[_0x590b('0x11')]=qs[_0x590b('0x11')](_0x3ef6d3[_0x590b('0x2a')]['limit']);_0x2dff4f['offset']=qs[_0x590b('0x10')](_0x3ef6d3[_0x590b('0x2a')]['offset']);}return _0x1b0cbb[_0x590b('0x52')](_0x2dff4f);}})[_0x590b('0x16')](function(_0x2bbfff){if(_0x2bbfff){return _0x2bbfff?{'count':_0x4f22da,'rows':_0x2bbfff}:null;}})['then'](respondWithResult(_0x556276,null))[_0x590b('0x3a')](handleError(_0x556276,null));};exports['addTeams']=function(_0x43dedf,_0x4b7d4b){var _0x4a46fc=_0x43dedf[_0x590b('0x3c')][_0x590b('0x56')];return db['Team'][_0x590b('0x25')]({'where':{'id':_0x4a46fc},'attributes':['id'],'include':[{'model':db[_0x590b('0x48')],'as':_0x590b('0x57'),'attributes':['id',_0x590b('0x1c'),'online',_0x590b('0x58'),_0x590b('0x59')],'raw':!![]}]})[_0x590b('0x16')](function(_0x5e158b){if(_0x5e158b){var _0x1be3fc=_[_0x590b('0x5a')](_0x5e158b,function(_0x251272){var _0xfa8e7d=_0x251272[_0x590b('0x17')]({'plain':!![]});return _0xfa8e7d['Agents'];});return db[_0x590b('0x1e')]['find']({'where':{'id':_0x43dedf[_0x590b('0x3d')]['id']}})[_0x590b('0x16')](function(_0x24b0cd){return db[_0x590b('0x5b')]['transaction'](function(_0x2d1709){return _0x24b0cd[_0x590b('0x5c')](_0x4a46fc,{'transaction':_0x2d1709})[_0x590b('0x16')](function(){return BPromise['each'](_0x1be3fc,function(_0x384382){return db[_0x590b('0x47')][_0x590b('0x5d')]({'where':{'UserId':_0x384382['id'],'FaxQueueId':_0x43dedf[_0x590b('0x3d')]['id']},'transaction':_0x2d1709});});})[_0x590b('0x16')](function(){_0x1be3fc['forEach'](function(_0x31db81){socket[_0x590b('0x5e')]('userFaxQueue:save',{'UserId':_0x31db81['id'],'FaxQueueId':_0x24b0cd['id']});});});});});}})['then'](respondWithStatusCode(_0x4b7d4b,null))['catch'](handleError(_0x4b7d4b,null));};exports[_0x590b('0x5f')]=function(_0x1e6e11,_0x5dfe32){return db['Team'][_0x590b('0x25')]({'where':{'id':_0x1e6e11['query'][_0x590b('0x56')]},'attributes':['id'],'include':[{'model':db[_0x590b('0x48')],'as':_0x590b('0x57'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x5dfe32,null))[_0x590b('0x16')](function(_0x19c313){var _0x2b84e3=_['map'](_0x19c313,'id');var _0x18b10f=[];var _0x3d1617=[];var _0x437755=squel['select']();_0x437755[_0x590b('0x60')](_0x590b('0x61'))[_0x590b('0x62')](_0x590b('0x63'),'tq')['join'](_0x590b('0x64'),'ut',_0x590b('0x65'))[_0x590b('0x23')](_0x590b('0x66'),_0x1e6e11[_0x590b('0x3d')]['id']);for(var _0x6519b=0x0;_0x6519b<_0x19c313['length'];_0x6519b+=0x1){let _0x20baa9=_0x19c313[_0x6519b];for(var _0x44f649=0x0;_0x44f649<_0x20baa9[_0x590b('0x57')][_0x590b('0x2f')];_0x44f649+=0x1){let _0x15b162=_0x20baa9['Agents'][_0x44f649];var _0x1da0af=_0x437755[_0x590b('0x67')]();_0x1da0af[_0x590b('0x23')]('ut.UserId\x20=\x20?',_0x15b162['id']);_0x3d1617['push'](db[_0x590b('0x5b')][_0x590b('0x2a')](_0x1da0af[_0x590b('0x68')](),{'type':db[_0x590b('0x5b')][_0x590b('0x69')]['SELECT']})[_0x590b('0x16')](function(_0x616cdf){if(_0x616cdf['length']===0x1){return _0x15b162['id'];}else{var _0xa3f06f=_[_0x590b('0x6a')](_['map'](_0x616cdf,_0x590b('0x6b')),function(_0x2cf317){return _[_0x590b('0x6c')](_0x2b84e3,_0x2cf317);});if(_0xa3f06f){return _0x15b162['id'];}}}));}}return BPromise[_0x590b('0x6d')](_0x3d1617)[_0x590b('0x16')](function(_0x6281dc){_0x18b10f=_(_0x18b10f)['union'](_0x6281dc)[_0x590b('0x6e')]()[_0x590b('0x6f')]();return db['FaxQueue'][_0x590b('0x32')]({'where':{'id':_0x1e6e11[_0x590b('0x3d')]['id']}})[_0x590b('0x16')](function(_0x5357f1){return db[_0x590b('0x5b')][_0x590b('0x70')](function(_0x524a65){return _0x5357f1['removeTeams'](_0x1e6e11['query'][_0x590b('0x56')],{'transaction':_0x524a65})[_0x590b('0x16')](function(){if(!_['isEmpty'](_0x18b10f)){return _0x5357f1[_0x590b('0x71')](_0x18b10f,{'transaction':_0x524a65});}})[_0x590b('0x16')](function(){_0x18b10f[_0x590b('0x72')](function(_0x1ef93c){socket[_0x590b('0x5e')](_0x590b('0x73'),{'UserId':_0x1ef93c,'FaxQueueId':_0x5357f1['id']});});});});});});})[_0x590b('0x16')](respondWithStatusCode(_0x5dfe32,null))[_0x590b('0x3a')](handleError(_0x5dfe32,null));};exports[_0x590b('0x74')]=function(_0x303f7c,_0x5efc21){return db[_0x590b('0x1e')][_0x590b('0x32')]({'where':{'id':_0x303f7c[_0x590b('0x3d')]['id']}})[_0x590b('0x16')](handleEntityNotFound(_0x5efc21,null))[_0x590b('0x16')](function(_0x2a01ec){if(_0x2a01ec){return _0x2a01ec[_0x590b('0x74')](_0x303f7c[_0x590b('0x3c')][_0x590b('0x56')],_[_0x590b('0x75')](_0x303f7c[_0x590b('0x3c')],['ids','id'])||{})[_0x590b('0x76')](function(_0x2981bf){for(var _0x265b75=0x0;_0x265b75<_0x303f7c[_0x590b('0x3c')][_0x590b('0x56')][_0x590b('0x2f')];_0x265b75+=0x1){socket[_0x590b('0x5e')](_0x590b('0x77'),{'UserId':Number(_0x303f7c[_0x590b('0x3c')]['ids'][_0x265b75]),'FaxQueueId':Number(_0x303f7c[_0x590b('0x3d')]['id'])});}return _0x2981bf;});}})[_0x590b('0x16')](respondWithResult(_0x5efc21,null))[_0x590b('0x3a')](handleError(_0x5efc21,null));};exports[_0x590b('0x71')]=function(_0x388b80,_0x54f273){return db[_0x590b('0x1e')][_0x590b('0x32')]({'where':{'id':_0x388b80[_0x590b('0x3d')]['id']}})['then'](handleEntityNotFound(_0x54f273,null))['then'](function(_0x3c1365){if(_0x3c1365){return _0x3c1365[_0x590b('0x71')](_0x388b80[_0x590b('0x2a')][_0x590b('0x56')])[_0x590b('0x16')](function(){if(_[_0x590b('0x78')](_0x388b80[_0x590b('0x2a')][_0x590b('0x56')])){for(var _0x3baa48=0x0;_0x3baa48<_0x388b80['query']['ids'][_0x590b('0x2f')];_0x3baa48+=0x1){socket['emit'](_0x590b('0x73'),{'UserId':Number(_0x388b80[_0x590b('0x2a')][_0x590b('0x56')][_0x3baa48]),'FaxQueueId':Number(_0x388b80['params']['id'])});}}else{socket[_0x590b('0x5e')](_0x590b('0x73'),{'UserId':Number(_0x388b80[_0x590b('0x2a')]['ids']),'FaxQueueId':Number(_0x388b80[_0x590b('0x3d')]['id'])});}});}})[_0x590b('0x16')](respondWithStatusCode(_0x54f273,null))[_0x590b('0x3a')](handleError(_0x54f273,null));};exports['getAgents']=function(_0x182ab4,_0x316ca2){var _0x608ff6={};var _0x253e8e={};var _0x373582;var _0x567f33;return db['FaxQueue'][_0x590b('0x40')]({'where':{'id':_0x182ab4[_0x590b('0x3d')]['id']}})['then'](handleEntityNotFound(_0x316ca2,null))[_0x590b('0x16')](function(_0x36562e){if(_0x36562e){_0x373582=_0x36562e;_0x253e8e[_0x590b('0x27')]=_[_0x590b('0x28')](db[_0x590b('0x48')][_0x590b('0x29')]);_0x253e8e[_0x590b('0x2a')]=_[_0x590b('0x28')](_0x182ab4[_0x590b('0x2a')]);_0x253e8e[_0x590b('0x2b')]=_[_0x590b('0x2c')](_0x253e8e[_0x590b('0x27')],_0x253e8e[_0x590b('0x2a')]);_0x608ff6[_0x590b('0x2e')]=_[_0x590b('0x2c')](_0x253e8e[_0x590b('0x27')],qs['fields'](_0x182ab4['query'][_0x590b('0x2d')]));_0x608ff6['attributes']=_0x608ff6[_0x590b('0x2e')][_0x590b('0x2f')]?_0x608ff6[_0x590b('0x2e')]:_0x253e8e[_0x590b('0x27')];_0x608ff6[_0x590b('0x42')]=qs['sort'](_0x182ab4[_0x590b('0x2a')][_0x590b('0x43')]);_0x608ff6[_0x590b('0x23')]=qs[_0x590b('0x2b')](_[_0x590b('0x54')](_0x182ab4[_0x590b('0x2a')],_0x253e8e[_0x590b('0x2b')]));if(_0x182ab4[_0x590b('0x2a')][_0x590b('0x45')]){_0x608ff6[_0x590b('0x23')]=_[_0x590b('0x46')](_0x608ff6['where'],{'$or':_[_0x590b('0x1d')](_0x608ff6[_0x590b('0x2e')],function(_0xc3374c){var _0x4d8d39={};_0x4d8d39[_0xc3374c]={'$like':'%'+_0x182ab4[_0x590b('0x2a')][_0x590b('0x45')]+'%'};return _0x4d8d39;})});}_0x608ff6=_[_0x590b('0x46')]({},_0x608ff6,_0x182ab4[_0x590b('0x31')]);return _0x373582[_0x590b('0x79')](_0x608ff6);}})[_0x590b('0x16')](function(_0x196ce6){if(_0x196ce6){_0x567f33=_0x196ce6[_0x590b('0x2f')];if(!_0x182ab4[_0x590b('0x2a')]['hasOwnProperty'](_0x590b('0x55'))){_0x608ff6[_0x590b('0x11')]=qs[_0x590b('0x11')](_0x182ab4[_0x590b('0x2a')][_0x590b('0x11')]);_0x608ff6[_0x590b('0x10')]=qs[_0x590b('0x10')](_0x182ab4[_0x590b('0x2a')]['offset']);}return _0x373582['getAgents'](_0x608ff6);}})[_0x590b('0x16')](function(_0x49a273){if(_0x49a273){return _0x49a273?{'count':_0x567f33,'rows':_0x49a273}:null;}})[_0x590b('0x16')](respondWithResult(_0x316ca2,null))[_0x590b('0x3a')](handleError(_0x316ca2,null));};
\ No newline at end of file