Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index cd25828..1daa7df 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3f10=['FaxQueues','UserProfileResource','then','error','stack','name','send','index','FaxQueue','rawAttributes','fieldName','type','model','map','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filter','merge','includeAll','include','findAll','rows','catch','show','params','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','getMembers','findOne','UserFaxQueue','pick','FaxQueueId','User','UserId','agent','faxPause','createdAt','format','%s/%s','SIP','updatedAt','getTeams','Team','length','addTeams','ids','Agents','flatMap','sequelize','transaction','each','emit','userFaxQueue:save','removeTeams','select','field','from','user_has_teams','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','TeamId','includes','union','compact','value','removeAgents','forEach','userFaxQueue:remove','addAgents','omit','spread','isArray','getAgents','html-pdf','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','defaults','localhost','socket.io-emitter','redis','./faxQueue.socket','register','sendStatus','status','end','json','count','offset','limit','apply','reject','save','destroy','get'];(function(_0x55821d,_0x27a22e){var _0x58ea8a=function(_0x5bdd3d){while(--_0x5bdd3d){_0x55821d['push'](_0x55821d['shift']());}};_0x58ea8a(++_0x27a22e);}(_0x3f10,0xe9));var _0x03f1=function(_0x21e9ed,_0x4ab24b){_0x21e9ed=_0x21e9ed-0x0;var _0x4db455=_0x3f10[_0x21e9ed];return _0x4db455;};'use strict';var pdf=require(_0x03f1('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x03f1('0x1'));var zipdir=require(_0x03f1('0x2'));var jsonpatch=require(_0x03f1('0x3'));var rp=require('request-promise');var moment=require(_0x03f1('0x4'));var BPromise=require(_0x03f1('0x5'));var Mustache=require(_0x03f1('0x6'));var util=require(_0x03f1('0x7'));var path=require(_0x03f1('0x8'));var sox=require(_0x03f1('0x9'));var csv=require(_0x03f1('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x03f1('0xb'));var crypto=require('crypto');var jsforce=require(_0x03f1('0xc'));var deskjs=require(_0x03f1('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x03f1('0xe'));var Redis=require(_0x03f1('0xf'));var authService=require(_0x03f1('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x03f1('0x11'));var hardwareService=require(_0x03f1('0x12'));var logger=require(_0x03f1('0x13'))('api');var utils=require('../../config/utils');var config=require(_0x03f1('0x14'));var licenseUtil=require(_0x03f1('0x15'));var db=require(_0x03f1('0x16'))['db'];config['redis']=_[_0x03f1('0x17')](config['redis'],{'host':_0x03f1('0x18'),'port':0x18eb});var socket=require(_0x03f1('0x19'))(new Redis(config[_0x03f1('0x1a')]));require(_0x03f1('0x1b'))[_0x03f1('0x1c')](socket);function respondWithStatusCode(_0x5d9f06,_0xecef6c){_0xecef6c=_0xecef6c||0xcc;return function(_0x547743){if(_0x547743){return _0x5d9f06[_0x03f1('0x1d')](_0xecef6c);}return _0x5d9f06[_0x03f1('0x1e')](_0xecef6c)[_0x03f1('0x1f')]();};}function respondWithResult(_0x533656,_0x34e5ff){_0x34e5ff=_0x34e5ff||0xc8;return function(_0xd10941){if(_0xd10941){return _0x533656[_0x03f1('0x1e')](_0x34e5ff)[_0x03f1('0x20')](_0xd10941);}};}function respondWithFilteredResult(_0x2452ca,_0x45516f){return function(_0x4cb10b){if(_0x4cb10b){var _0x32bfcb=_0x4cb10b[_0x03f1('0x21')],_0x3b1148=_0x45516f['offset'],_0x5a5516=_0x45516f[_0x03f1('0x22')]+_0x45516f[_0x03f1('0x23')],_0xbe9f1b;if(_0x5a5516>=_0x32bfcb){_0x5a5516=_0x32bfcb;_0xbe9f1b=0xc8;}else{_0xbe9f1b=0xce;}_0x2452ca['status'](_0xbe9f1b);return _0x2452ca['set']('Content-Range',_0x3b1148+'-'+_0x5a5516+'/'+_0x32bfcb)[_0x03f1('0x20')](_0x4cb10b);}return null;};}function patchUpdates(_0xe7c7d7){return function(_0x342d55){try{jsonpatch[_0x03f1('0x24')](_0x342d55,_0xe7c7d7,!![]);}catch(_0x45f0f6){return BPromise[_0x03f1('0x25')](_0x45f0f6);}return _0x342d55[_0x03f1('0x26')]();};}function saveUpdates(_0x1090d4,_0x285c81){return function(_0x38828a){if(_0x38828a){return _0x38828a['update'](_0x1090d4)['then'](function(_0xfcaaef){return _0xfcaaef;});}return null;};}function removeEntity(_0x38558e,_0x36a5bb){return function(_0x54b149){if(_0x54b149){return _0x54b149[_0x03f1('0x27')]()['then'](function(){var _0x3d48c5=_0x54b149[_0x03f1('0x28')]({'plain':!![]});var _0xa32312=_0x03f1('0x29');return db[_0x03f1('0x2a')][_0x03f1('0x27')]({'where':{'type':_0xa32312,'resourceId':_0x3d48c5['id']}})['then'](function(){return _0x54b149;});})[_0x03f1('0x2b')](function(){_0x38558e[_0x03f1('0x1e')](0xcc)[_0x03f1('0x1f')]();});}};}function handleEntityNotFound(_0x13b415,_0x59452e){return function(_0x257932){if(!_0x257932){_0x13b415['sendStatus'](0x194);}return _0x257932;};}function handleError(_0x3e3bd1,_0x10847e){_0x10847e=_0x10847e||0x1f4;return function(_0x4475bc){logger[_0x03f1('0x2c')](_0x4475bc[_0x03f1('0x2d')]);if(_0x4475bc[_0x03f1('0x2e')]){delete _0x4475bc[_0x03f1('0x2e')];}_0x3e3bd1[_0x03f1('0x1e')](_0x10847e)[_0x03f1('0x2f')](_0x4475bc);};}exports[_0x03f1('0x30')]=function(_0xea325b,_0x4545a7){var _0x3e0df6={},_0x16c5bb={},_0x4873e8={'count':0x0,'rows':[]};var _0x1998b3=_['map'](db[_0x03f1('0x31')][_0x03f1('0x32')],function(_0x552d8f){return{'name':_0x552d8f[_0x03f1('0x33')],'type':_0x552d8f[_0x03f1('0x34')]['key']};});_0x16c5bb[_0x03f1('0x35')]=_[_0x03f1('0x36')](_0x1998b3,_0x03f1('0x2e'));_0x16c5bb[_0x03f1('0x37')]=_[_0x03f1('0x38')](_0xea325b['query']);_0x16c5bb[_0x03f1('0x39')]=_[_0x03f1('0x3a')](_0x16c5bb[_0x03f1('0x35')],_0x16c5bb['query']);_0x3e0df6[_0x03f1('0x3b')]=_[_0x03f1('0x3a')](_0x16c5bb[_0x03f1('0x35')],qs[_0x03f1('0x3c')](_0xea325b[_0x03f1('0x37')]['fields']));_0x3e0df6[_0x03f1('0x3b')]=_0x3e0df6[_0x03f1('0x3b')]['length']?_0x3e0df6[_0x03f1('0x3b')]:_0x16c5bb['model'];if(!_0xea325b['query'][_0x03f1('0x3d')](_0x03f1('0x3e'))){_0x3e0df6['limit']=qs[_0x03f1('0x23')](_0xea325b[_0x03f1('0x37')]['limit']);_0x3e0df6[_0x03f1('0x22')]=qs['offset'](_0xea325b['query'][_0x03f1('0x22')]);}_0x3e0df6[_0x03f1('0x3f')]=qs[_0x03f1('0x40')](_0xea325b[_0x03f1('0x37')]['sort']);_0x3e0df6[_0x03f1('0x41')]=qs[_0x03f1('0x39')](_['pick'](_0xea325b[_0x03f1('0x37')],_0x16c5bb[_0x03f1('0x39')]),_0x1998b3);if(_0xea325b['query'][_0x03f1('0x42')]){_0x3e0df6[_0x03f1('0x41')]=_[_0x03f1('0x43')](_0x3e0df6[_0x03f1('0x41')],{'$or':_[_0x03f1('0x36')](_0x1998b3,function(_0x7cf1de){if(_0x7cf1de[_0x03f1('0x34')]!=='VIRTUAL'){var _0x2d8b54={};_0x2d8b54[_0x7cf1de['name']]={'$like':'%'+_0xea325b[_0x03f1('0x37')][_0x03f1('0x42')]+'%'};return _0x2d8b54;}})});}_0x3e0df6=_['merge']({},_0x3e0df6,_0xea325b['options']);var _0x20b8cd={'where':_0x3e0df6[_0x03f1('0x41')]};return db[_0x03f1('0x31')][_0x03f1('0x21')](_0x20b8cd)[_0x03f1('0x2b')](function(_0x26226c){_0x4873e8[_0x03f1('0x21')]=_0x26226c;if(_0xea325b[_0x03f1('0x37')][_0x03f1('0x44')]){_0x3e0df6[_0x03f1('0x45')]=[{'all':!![]}];}return db[_0x03f1('0x31')][_0x03f1('0x46')](_0x3e0df6);})[_0x03f1('0x2b')](function(_0xd6edd8){_0x4873e8[_0x03f1('0x47')]=_0xd6edd8;return _0x4873e8;})[_0x03f1('0x2b')](respondWithFilteredResult(_0x4545a7,_0x3e0df6))[_0x03f1('0x48')](handleError(_0x4545a7,null));};exports[_0x03f1('0x49')]=function(_0x172cb4,_0x151282){var _0x840fd1={'raw':!![],'where':{'id':_0x172cb4[_0x03f1('0x4a')]['id']}},_0x3b4858={};_0x3b4858[_0x03f1('0x35')]=_[_0x03f1('0x38')](db[_0x03f1('0x31')][_0x03f1('0x32')]);_0x3b4858[_0x03f1('0x37')]=_['keys'](_0x172cb4[_0x03f1('0x37')]);_0x3b4858[_0x03f1('0x39')]=_[_0x03f1('0x3a')](_0x3b4858[_0x03f1('0x35')],_0x3b4858[_0x03f1('0x37')]);_0x840fd1['attributes']=_[_0x03f1('0x3a')](_0x3b4858['model'],qs[_0x03f1('0x3c')](_0x172cb4[_0x03f1('0x37')][_0x03f1('0x3c')]));_0x840fd1[_0x03f1('0x3b')]=_0x840fd1[_0x03f1('0x3b')]['length']?_0x840fd1[_0x03f1('0x3b')]:_0x3b4858[_0x03f1('0x35')];if(_0x172cb4['query'][_0x03f1('0x44')]){_0x840fd1[_0x03f1('0x45')]=[{'all':!![]}];}_0x840fd1=_[_0x03f1('0x43')]({},_0x840fd1,_0x172cb4[_0x03f1('0x4b')]);return db['FaxQueue']['find'](_0x840fd1)[_0x03f1('0x2b')](handleEntityNotFound(_0x151282,null))['then'](respondWithResult(_0x151282,null))[_0x03f1('0x48')](handleError(_0x151282,null));};exports[_0x03f1('0x4c')]=function(_0x31101f,_0x15a775){return db[_0x03f1('0x31')][_0x03f1('0x4c')](_0x31101f[_0x03f1('0x4d')],{})[_0x03f1('0x2b')](function(_0x41955a){var _0x47b293=_0x31101f[_0x03f1('0x4e')]['get']({'plain':!![]});if(!_0x47b293)throw new Error(_0x03f1('0x4f'));if(_0x47b293[_0x03f1('0x50')]===_0x03f1('0x4e')){var _0x2541d9=_0x41955a[_0x03f1('0x28')]({'plain':!![]});var _0x465411=_0x03f1('0x29');return db[_0x03f1('0x51')][_0x03f1('0x52')]({'where':{'name':_0x465411,'userProfileId':_0x47b293[_0x03f1('0x53')]},'raw':!![]})[_0x03f1('0x2b')](function(_0x1801e5){if(_0x1801e5&&_0x1801e5[_0x03f1('0x54')]===0x0){return db['UserProfileResource']['create']({'name':_0x2541d9[_0x03f1('0x2e')],'resourceId':_0x2541d9['id'],'type':_0x1801e5['name'],'sectionId':_0x1801e5['id']},{})[_0x03f1('0x2b')](function(){return _0x41955a;});}else{return _0x41955a;}})[_0x03f1('0x48')](function(_0x15a6a7){logger['error'](_0x03f1('0x55'),_0x15a6a7);throw _0x15a6a7;});}return _0x41955a;})[_0x03f1('0x2b')](respondWithResult(_0x15a775,0xc9))[_0x03f1('0x48')](handleError(_0x15a775,null));};exports[_0x03f1('0x56')]=function(_0x43ece0,_0x4275bf){if(_0x43ece0[_0x03f1('0x4d')]['id']){delete _0x43ece0[_0x03f1('0x4d')]['id'];}return db[_0x03f1('0x31')][_0x03f1('0x52')]({'where':{'id':_0x43ece0[_0x03f1('0x4a')]['id']}})[_0x03f1('0x2b')](handleEntityNotFound(_0x4275bf,null))['then'](saveUpdates(_0x43ece0[_0x03f1('0x4d')],null))[_0x03f1('0x2b')](respondWithResult(_0x4275bf,null))['catch'](handleError(_0x4275bf,null));};exports[_0x03f1('0x27')]=function(_0x2d861c,_0x555946){return db[_0x03f1('0x31')]['find']({'where':{'id':_0x2d861c[_0x03f1('0x4a')]['id']}})[_0x03f1('0x2b')](handleEntityNotFound(_0x555946,null))[_0x03f1('0x2b')](removeEntity(_0x555946,null))[_0x03f1('0x48')](handleError(_0x555946,null));};exports[_0x03f1('0x57')]=function(_0x593ade,_0x5ec193){return db['FaxQueue'][_0x03f1('0x57')]()[_0x03f1('0x2b')](respondWithResult(_0x5ec193,null))[_0x03f1('0x48')](handleError(_0x5ec193,null));};exports[_0x03f1('0x58')]=function(_0x3dc957,_0xcb1048,_0x4e616d){var _0x449f79={'raw':!![],'where':{}},_0x3ac692={},_0x1e323e;return db['FaxQueue'][_0x03f1('0x59')]({'where':{'id':_0x3dc957[_0x03f1('0x4a')]['id']}})['then'](handleEntityNotFound(_0xcb1048,null))[_0x03f1('0x2b')](function(_0x1894d7){if(_0x1894d7){_0x1e323e=_0x1894d7[_0x03f1('0x28')]({'plain':!![]});_0x3ac692[_0x03f1('0x35')]=_[_0x03f1('0x38')](db[_0x03f1('0x5a')][_0x03f1('0x32')]);_0x3ac692[_0x03f1('0x37')]=_[_0x03f1('0x38')](_0x3dc957['query']);_0x3ac692[_0x03f1('0x39')]=_[_0x03f1('0x3a')](_0x3ac692[_0x03f1('0x35')],_0x3ac692['query']);_0x449f79['attributes']=_[_0x03f1('0x3a')](_0x3ac692[_0x03f1('0x35')],qs[_0x03f1('0x3c')](_0x3dc957[_0x03f1('0x37')]['fields']));_0x449f79['attributes']=_0x449f79[_0x03f1('0x3b')]['length']?_0x449f79[_0x03f1('0x3b')]:_0x3ac692[_0x03f1('0x35')];if(!_0x3dc957[_0x03f1('0x37')][_0x03f1('0x3d')](_0x03f1('0x3e'))){_0x449f79[_0x03f1('0x23')]=qs[_0x03f1('0x23')](_0x3dc957[_0x03f1('0x37')][_0x03f1('0x23')]);_0x449f79[_0x03f1('0x22')]=qs[_0x03f1('0x22')](_0x3dc957[_0x03f1('0x37')][_0x03f1('0x22')]);}_0x449f79[_0x03f1('0x3f')]=qs[_0x03f1('0x40')](_0x3dc957[_0x03f1('0x37')][_0x03f1('0x40')]);_0x449f79['where']=qs[_0x03f1('0x39')](_[_0x03f1('0x5b')](_0x3dc957[_0x03f1('0x37')],_0x3ac692[_0x03f1('0x39')]));_0x449f79['where'][_0x03f1('0x5c')]=_0x1894d7['id'];if(_0x3dc957[_0x03f1('0x37')][_0x03f1('0x42')]){_0x449f79[_0x03f1('0x41')]=_[_0x03f1('0x43')](_0x449f79[_0x03f1('0x41')],{'$or':_['map'](_0x449f79[_0x03f1('0x3b')],function(_0x20ddd1){var _0x5593f6={};_0x5593f6[_0x20ddd1]={'$like':'%'+_0x3dc957[_0x03f1('0x37')][_0x03f1('0x42')]+'%'};return _0x5593f6;})});}_0x449f79=_['merge']({},_0x449f79,_0x3dc957[_0x03f1('0x4b')]);return db['UserFaxQueue'][_0x03f1('0x46')](_0x449f79);}})[_0x03f1('0x2b')](function(_0x4ea796){if(_0x4ea796){return db[_0x03f1('0x5d')]['findAndCountAll']({'where':{'id':_[_0x03f1('0x36')](_0x4ea796,_0x03f1('0x5e')),'role':_0x03f1('0x5f')},'attributes':['id',_0x03f1('0x2e'),_0x03f1('0x60'),'updatedAt',_0x03f1('0x61')]});}})[_0x03f1('0x2b')](function(_0x40d51a){if(_0x40d51a){return{'count':_0x40d51a[_0x03f1('0x21')],'rows':_['map'](_0x40d51a[_0x03f1('0x47')],function(_0xd2470e){return{'membername':_0xd2470e[_0x03f1('0x2e')],'UserId':_0xd2470e['id'],'queue_name':_0x1e323e[_0x03f1('0x2e')],'FaxQueueId':_0x1e323e['id'],'interface':util[_0x03f1('0x62')](_0x03f1('0x63'),_0x03f1('0x64'),_0xd2470e[_0x03f1('0x2e')]),'penalty':0x0,'paused':_0xd2470e[_0x03f1('0x60')],'createdAt':_0xd2470e[_0x03f1('0x61')],'updatedAt':_0xd2470e[_0x03f1('0x65')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x03f1('0x2b')](respondWithFilteredResult(_0xcb1048,_0x449f79))[_0x03f1('0x48')](handleError(_0xcb1048,null));};exports[_0x03f1('0x66')]=function(_0x4af697,_0x478015,_0x2f4457){var _0x36218a={};var _0x42a98c={};var _0x4728e6;var _0x1b4da2;return db[_0x03f1('0x31')][_0x03f1('0x59')]({'where':{'id':_0x4af697['params']['id']}})['then'](handleEntityNotFound(_0x478015,null))[_0x03f1('0x2b')](function(_0x511c85){if(_0x511c85){_0x4728e6=_0x511c85;_0x42a98c[_0x03f1('0x35')]=_['keys'](db[_0x03f1('0x67')]['rawAttributes']);_0x42a98c[_0x03f1('0x37')]=_['keys'](_0x4af697[_0x03f1('0x37')]);_0x42a98c[_0x03f1('0x39')]=_[_0x03f1('0x3a')](_0x42a98c['model'],_0x42a98c['query']);_0x36218a[_0x03f1('0x3b')]=_[_0x03f1('0x3a')](_0x42a98c[_0x03f1('0x35')],qs[_0x03f1('0x3c')](_0x4af697[_0x03f1('0x37')][_0x03f1('0x3c')]));_0x36218a[_0x03f1('0x3b')]=_0x36218a['attributes'][_0x03f1('0x68')]?_0x36218a['attributes']:_0x42a98c[_0x03f1('0x35')];_0x36218a['order']=qs[_0x03f1('0x40')](_0x4af697[_0x03f1('0x37')][_0x03f1('0x40')]);_0x36218a[_0x03f1('0x41')]=qs[_0x03f1('0x39')](_[_0x03f1('0x5b')](_0x4af697[_0x03f1('0x37')],_0x42a98c[_0x03f1('0x39')]));if(_0x4af697[_0x03f1('0x37')][_0x03f1('0x42')]){_0x36218a['where']=_[_0x03f1('0x43')](_0x36218a[_0x03f1('0x41')],{'$or':_[_0x03f1('0x36')](_0x36218a[_0x03f1('0x3b')],function(_0x5c639f){var _0xb18273={};_0xb18273[_0x5c639f]={'$like':'%'+_0x4af697['query']['filter']+'%'};return _0xb18273;})});}_0x36218a=_['merge']({},_0x36218a,_0x4af697[_0x03f1('0x4b')]);return _0x4728e6[_0x03f1('0x66')](_0x36218a);}})['then'](function(_0x1538a5){if(_0x1538a5){_0x1b4da2=_0x1538a5[_0x03f1('0x68')];if(!_0x4af697['query'][_0x03f1('0x3d')](_0x03f1('0x3e'))){_0x36218a[_0x03f1('0x23')]=qs['limit'](_0x4af697[_0x03f1('0x37')][_0x03f1('0x23')]);_0x36218a['offset']=qs[_0x03f1('0x22')](_0x4af697[_0x03f1('0x37')]['offset']);}return _0x4728e6[_0x03f1('0x66')](_0x36218a);}})['then'](function(_0x414b92){if(_0x414b92){return _0x414b92?{'count':_0x1b4da2,'rows':_0x414b92}:null;}})[_0x03f1('0x2b')](respondWithResult(_0x478015,null))[_0x03f1('0x48')](handleError(_0x478015,null));};exports[_0x03f1('0x69')]=function(_0x2ecd80,_0x5a91a1,_0x57336f){var _0x21237a=_0x2ecd80[_0x03f1('0x4d')][_0x03f1('0x6a')];return db['Team'][_0x03f1('0x46')]({'where':{'id':_0x21237a},'attributes':['id'],'include':[{'model':db[_0x03f1('0x5d')],'as':_0x03f1('0x6b'),'attributes':['id',_0x03f1('0x2e'),'online','voicePause','interface'],'raw':!![]}]})[_0x03f1('0x2b')](function(_0x5bd29c){if(_0x5bd29c){var _0x179822=_[_0x03f1('0x6c')](_0x5bd29c,function(_0x4a249a){var _0x3bcb3c=_0x4a249a[_0x03f1('0x28')]({'plain':!![]});return _0x3bcb3c[_0x03f1('0x6b')];});return db[_0x03f1('0x31')][_0x03f1('0x52')]({'where':{'id':_0x2ecd80[_0x03f1('0x4a')]['id']}})[_0x03f1('0x2b')](function(_0x3a50b2){return db[_0x03f1('0x6d')][_0x03f1('0x6e')](function(_0x503061){return _0x3a50b2[_0x03f1('0x69')](_0x21237a,{'transaction':_0x503061})['then'](function(){return BPromise[_0x03f1('0x6f')](_0x179822,function(_0x21c41f){return db[_0x03f1('0x5a')]['findOrCreate']({'where':{'UserId':_0x21c41f['id'],'FaxQueueId':_0x2ecd80[_0x03f1('0x4a')]['id']},'transaction':_0x503061});});})[_0x03f1('0x2b')](function(){_0x179822['forEach'](function(_0xaa00d7){socket[_0x03f1('0x70')](_0x03f1('0x71'),{'UserId':_0xaa00d7['id'],'FaxQueueId':_0x3a50b2['id']});});});});});}})[_0x03f1('0x2b')](respondWithStatusCode(_0x5a91a1,null))[_0x03f1('0x48')](handleError(_0x5a91a1,null));};exports[_0x03f1('0x72')]=function(_0x454941,_0x2007a4,_0x48a45b){return db[_0x03f1('0x67')][_0x03f1('0x46')]({'where':{'id':_0x454941[_0x03f1('0x37')]['ids']},'attributes':['id'],'include':[{'model':db[_0x03f1('0x5d')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x2007a4,null))[_0x03f1('0x2b')](function(_0x1d43de){var _0x2f99b9=_['map'](_0x1d43de,'id');var _0x37e346=[];var _0x5d527a=[];var _0x3ff495=squel[_0x03f1('0x73')]();_0x3ff495[_0x03f1('0x74')]('tq.TeamId')[_0x03f1('0x75')]('team_has_fax_queues','tq')['join'](_0x03f1('0x76'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x03f1('0x41')]('FaxQueueId\x20=\x20?',_0x454941[_0x03f1('0x4a')]['id']);for(var _0x5d86c8=0x0;_0x5d86c8<_0x1d43de[_0x03f1('0x68')];_0x5d86c8+=0x1){let _0x27eef3=_0x1d43de[_0x5d86c8];for(var _0x9485b1=0x0;_0x9485b1<_0x27eef3[_0x03f1('0x6b')][_0x03f1('0x68')];_0x9485b1+=0x1){let _0x174e80=_0x27eef3[_0x03f1('0x6b')][_0x9485b1];var _0x2bcba7=_0x3ff495['clone']();_0x2bcba7[_0x03f1('0x41')](_0x03f1('0x77'),_0x174e80['id']);_0x5d527a[_0x03f1('0x78')](db[_0x03f1('0x6d')][_0x03f1('0x37')](_0x2bcba7[_0x03f1('0x79')](),{'type':db[_0x03f1('0x6d')][_0x03f1('0x7a')][_0x03f1('0x7b')]})['then'](function(_0x528907){if(_0x528907[_0x03f1('0x68')]===0x1){return _0x174e80['id'];}else{var _0x4ff46b=_['every'](_[_0x03f1('0x36')](_0x528907,_0x03f1('0x7c')),function(_0x20ef34){return _[_0x03f1('0x7d')](_0x2f99b9,_0x20ef34);});if(_0x4ff46b){return _0x174e80['id'];}}}));}}return BPromise['all'](_0x5d527a)[_0x03f1('0x2b')](function(_0x41bab4){_0x37e346=_(_0x37e346)[_0x03f1('0x7e')](_0x41bab4)[_0x03f1('0x7f')]()[_0x03f1('0x80')]();return db[_0x03f1('0x31')][_0x03f1('0x52')]({'where':{'id':_0x454941['params']['id']}})[_0x03f1('0x2b')](function(_0x3f3607){return db[_0x03f1('0x6d')]['transaction'](function(_0x275068){return _0x3f3607['removeTeams'](_0x454941[_0x03f1('0x37')][_0x03f1('0x6a')],{'transaction':_0x275068})[_0x03f1('0x2b')](function(){if(!_['isEmpty'](_0x37e346)){return _0x3f3607[_0x03f1('0x81')](_0x37e346,{'transaction':_0x275068});}})['then'](function(){_0x37e346[_0x03f1('0x82')](function(_0x107346){socket[_0x03f1('0x70')](_0x03f1('0x83'),{'UserId':_0x107346,'FaxQueueId':_0x3f3607['id']});});});});});});})['then'](respondWithStatusCode(_0x2007a4,null))['catch'](handleError(_0x2007a4,null));};exports['addAgents']=function(_0x312046,_0x4e2363,_0x4feecf){return db['FaxQueue'][_0x03f1('0x52')]({'where':{'id':_0x312046['params']['id']}})[_0x03f1('0x2b')](handleEntityNotFound(_0x4e2363,null))[_0x03f1('0x2b')](function(_0x531ffe){if(_0x531ffe){return _0x531ffe[_0x03f1('0x84')](_0x312046[_0x03f1('0x4d')][_0x03f1('0x6a')],_[_0x03f1('0x85')](_0x312046[_0x03f1('0x4d')],['ids','id'])||{})[_0x03f1('0x86')](function(_0x2c619b){for(var _0x331867=0x0;_0x331867<_0x312046[_0x03f1('0x4d')][_0x03f1('0x6a')][_0x03f1('0x68')];_0x331867+=0x1){socket[_0x03f1('0x70')](_0x03f1('0x71'),{'UserId':_0x312046[_0x03f1('0x4d')][_0x03f1('0x6a')][_0x331867],'FaxQueueId':_0x312046[_0x03f1('0x4a')]['id']});}return _0x2c619b;});}})['then'](respondWithResult(_0x4e2363,null))[_0x03f1('0x48')](handleError(_0x4e2363,null));};exports[_0x03f1('0x81')]=function(_0x54ec2d,_0x1e14a5,_0x45d219){return db[_0x03f1('0x31')][_0x03f1('0x52')]({'where':{'id':_0x54ec2d[_0x03f1('0x4a')]['id']}})[_0x03f1('0x2b')](handleEntityNotFound(_0x1e14a5,null))[_0x03f1('0x2b')](function(_0x351ea3){if(_0x351ea3){return _0x351ea3[_0x03f1('0x81')](_0x54ec2d[_0x03f1('0x37')][_0x03f1('0x6a')])[_0x03f1('0x2b')](function(){if(_[_0x03f1('0x87')](_0x54ec2d['query'][_0x03f1('0x6a')])){for(var _0x28732e=0x0;_0x28732e<_0x54ec2d[_0x03f1('0x37')]['ids'][_0x03f1('0x68')];_0x28732e+=0x1){socket['emit'](_0x03f1('0x83'),{'UserId':Number(_0x54ec2d[_0x03f1('0x37')][_0x03f1('0x6a')][_0x28732e]),'FaxQueueId':Number(_0x54ec2d[_0x03f1('0x4a')]['id'])});}}else{socket[_0x03f1('0x70')](_0x03f1('0x83'),{'UserId':Number(_0x54ec2d[_0x03f1('0x37')][_0x03f1('0x6a')]),'FaxQueueId':Number(_0x54ec2d[_0x03f1('0x4a')]['id'])});}});}})[_0x03f1('0x2b')](respondWithStatusCode(_0x1e14a5,null))[_0x03f1('0x48')](handleError(_0x1e14a5,null));};exports['getAgents']=function(_0x287ea8,_0x2d1b16,_0x23c54c){var _0x4b9467={};var _0x18f902={};var _0x314c22;var _0x4d13fd;return db[_0x03f1('0x31')]['findOne']({'where':{'id':_0x287ea8['params']['id']}})[_0x03f1('0x2b')](handleEntityNotFound(_0x2d1b16,null))[_0x03f1('0x2b')](function(_0x416610){if(_0x416610){_0x314c22=_0x416610;_0x18f902['model']=_[_0x03f1('0x38')](db[_0x03f1('0x5d')]['rawAttributes']);_0x18f902[_0x03f1('0x37')]=_[_0x03f1('0x38')](_0x287ea8[_0x03f1('0x37')]);_0x18f902['filters']=_[_0x03f1('0x3a')](_0x18f902[_0x03f1('0x35')],_0x18f902[_0x03f1('0x37')]);_0x4b9467['attributes']=_[_0x03f1('0x3a')](_0x18f902[_0x03f1('0x35')],qs['fields'](_0x287ea8[_0x03f1('0x37')]['fields']));_0x4b9467[_0x03f1('0x3b')]=_0x4b9467[_0x03f1('0x3b')][_0x03f1('0x68')]?_0x4b9467['attributes']:_0x18f902['model'];_0x4b9467[_0x03f1('0x3f')]=qs[_0x03f1('0x40')](_0x287ea8[_0x03f1('0x37')][_0x03f1('0x40')]);_0x4b9467[_0x03f1('0x41')]=qs['filters'](_[_0x03f1('0x5b')](_0x287ea8[_0x03f1('0x37')],_0x18f902[_0x03f1('0x39')]));if(_0x287ea8['query']['filter']){_0x4b9467[_0x03f1('0x41')]=_[_0x03f1('0x43')](_0x4b9467[_0x03f1('0x41')],{'$or':_[_0x03f1('0x36')](_0x4b9467['attributes'],function(_0x1c3d93){var _0x45bed2={};_0x45bed2[_0x1c3d93]={'$like':'%'+_0x287ea8['query'][_0x03f1('0x42')]+'%'};return _0x45bed2;})});}_0x4b9467=_[_0x03f1('0x43')]({},_0x4b9467,_0x287ea8[_0x03f1('0x4b')]);return _0x314c22[_0x03f1('0x88')](_0x4b9467);}})[_0x03f1('0x2b')](function(_0x3fa405){if(_0x3fa405){_0x4d13fd=_0x3fa405[_0x03f1('0x68')];if(!_0x287ea8[_0x03f1('0x37')][_0x03f1('0x3d')](_0x03f1('0x3e'))){_0x4b9467['limit']=qs[_0x03f1('0x23')](_0x287ea8['query'][_0x03f1('0x23')]);_0x4b9467[_0x03f1('0x22')]=qs[_0x03f1('0x22')](_0x287ea8[_0x03f1('0x37')]['offset']);}return _0x314c22['getAgents'](_0x4b9467);}})[_0x03f1('0x2b')](function(_0xc98a51){if(_0xc98a51){return _0xc98a51?{'count':_0x4d13fd,'rows':_0xc98a51}:null;}})[_0x03f1('0x2b')](respondWithResult(_0x2d1b16,null))[_0x03f1('0x48')](handleError(_0x2d1b16,null));};
\ No newline at end of file
+var _0xb194=['findOne','rawAttributes','hasOwnProperty','nolimit','order','sort','pick','FaxQueueId','filter','merge','User','findAndCountAll','map','agent','faxPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','ids','online','flatMap','Agents','sequelize','UserFaxQueue','findOrCreate','forEach','emit','removeTeams','select','field','from','team_has_fax_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','every','includes','union','value','transaction','isEmpty','addAgents','omit','spread','userFaxQueue:save','removeAgents','isArray','userFaxQueue:remove','getAgents','bluebird','lodash','squel','ioredis','../../components/parsers/qs','../../config/logger','../../config/environment','../../mysqldb','defaults','localhost','redis','./faxQueue.socket','register','status','end','json','offset','undefined','count','limit','set','Content-Range','update','then','destroy','get','FaxQueues','UserProfileResource','sendStatus','error','name','send','index','FaxQueue','fieldName','type','key','where','include','query','findAll','rows','catch','show','params','model','keys','filters','attributes','intersection','fields','length','includeAll','options','find','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','getMembers'];(function(_0x454312,_0x3721d4){var _0x4348ca=function(_0x5386f4){while(--_0x5386f4){_0x454312['push'](_0x454312['shift']());}};_0x4348ca(++_0x3721d4);}(_0xb194,0x1b2));var _0x4b19=function(_0x251b4f,_0x4ffab4){_0x251b4f=_0x251b4f-0x0;var _0xac541e=_0xb194[_0x251b4f];return _0xac541e;};'use strict';var BPromise=require(_0x4b19('0x0'));var util=require('util');var _=require(_0x4b19('0x1'));var squel=require(_0x4b19('0x2'));var Redis=require(_0x4b19('0x3'));var qs=require(_0x4b19('0x4'));var logger=require(_0x4b19('0x5'))('api');var config=require(_0x4b19('0x6'));var db=require(_0x4b19('0x7'))['db'];config['redis']=_[_0x4b19('0x8')](config['redis'],{'host':_0x4b19('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4b19('0xa')]));require(_0x4b19('0xb'))[_0x4b19('0xc')](socket);function respondWithStatusCode(_0x528ad4,_0x5d2ce4){_0x5d2ce4=_0x5d2ce4||0xcc;return function(_0x28c5d4){if(_0x28c5d4){return _0x528ad4['sendStatus'](_0x5d2ce4);}return _0x528ad4[_0x4b19('0xd')](_0x5d2ce4)[_0x4b19('0xe')]();};}function respondWithResult(_0xac7611,_0x211f44){_0x211f44=_0x211f44||0xc8;return function(_0x3b74ad){if(_0x3b74ad){return _0xac7611[_0x4b19('0xd')](_0x211f44)[_0x4b19('0xf')](_0x3b74ad);}};}function respondWithFilteredResult(_0x32f16e,_0x4e37af){return function(_0xbcfb9d){if(_0xbcfb9d){var _0x5354f1=typeof _0x4e37af[_0x4b19('0x10')]===_0x4b19('0x11')&&typeof _0x4e37af['limit']===_0x4b19('0x11');var _0x4bb9c5=_0xbcfb9d[_0x4b19('0x12')];var _0x820063=_0x5354f1?0x0:_0x4e37af[_0x4b19('0x10')];var _0x3a3af4=_0x5354f1?_0xbcfb9d[_0x4b19('0x12')]:_0x4e37af['offset']+_0x4e37af[_0x4b19('0x13')];var _0xffedd7;if(_0x3a3af4>=_0x4bb9c5){_0x3a3af4=_0x4bb9c5;_0xffedd7=0xc8;}else{_0xffedd7=0xce;}_0x32f16e[_0x4b19('0xd')](_0xffedd7);return _0x32f16e[_0x4b19('0x14')](_0x4b19('0x15'),_0x820063+'-'+_0x3a3af4+'/'+_0x4bb9c5)[_0x4b19('0xf')](_0xbcfb9d);}return null;};}function saveUpdates(_0x5d8335){return function(_0xb01cb6){if(_0xb01cb6){return _0xb01cb6[_0x4b19('0x16')](_0x5d8335)[_0x4b19('0x17')](function(_0xe7696a){return _0xe7696a;});}return null;};}function removeEntity(_0x2d17b5){return function(_0x17c7da){if(_0x17c7da){return _0x17c7da[_0x4b19('0x18')]()[_0x4b19('0x17')](function(){var _0x4c9841=_0x17c7da[_0x4b19('0x19')]({'plain':!![]});var _0x5ed26d=_0x4b19('0x1a');return db[_0x4b19('0x1b')][_0x4b19('0x18')]({'where':{'type':_0x5ed26d,'resourceId':_0x4c9841['id']}})[_0x4b19('0x17')](function(){return _0x17c7da;});})[_0x4b19('0x17')](function(){_0x2d17b5[_0x4b19('0xd')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2095f0){return function(_0x49338e){if(!_0x49338e){_0x2095f0[_0x4b19('0x1c')](0x194);}return _0x49338e;};}function handleError(_0x10d407,_0x234632){_0x234632=_0x234632||0x1f4;return function(_0x5c2fd6){logger[_0x4b19('0x1d')](_0x5c2fd6['stack']);if(_0x5c2fd6[_0x4b19('0x1e')]){delete _0x5c2fd6[_0x4b19('0x1e')];}_0x10d407['status'](_0x234632)[_0x4b19('0x1f')](_0x5c2fd6);};}exports[_0x4b19('0x20')]=function(_0x569946,_0x821fae){var _0x4c5f27={};var _0x12c4ac={'count':0x0,'rows':[]};var _0x4ceba3=_['map'](db[_0x4b19('0x21')]['rawAttributes'],function(_0x294372){return{'name':_0x294372[_0x4b19('0x22')],'type':_0x294372[_0x4b19('0x23')][_0x4b19('0x24')]};});_0x4c5f27=qs['getOptions'](_0x4ceba3,_0x569946);var _0x4149f1={'where':_0x4c5f27[_0x4b19('0x25')]};return db['FaxQueue'][_0x4b19('0x12')](_0x4149f1)[_0x4b19('0x17')](function(_0x37d99b){_0x12c4ac['count']=_0x37d99b;_0x4c5f27['include']=qs[_0x4b19('0x26')](_0x569946[_0x4b19('0x27')]);return db[_0x4b19('0x21')][_0x4b19('0x28')](_0x4c5f27);})[_0x4b19('0x17')](function(_0x4b4463){_0x12c4ac[_0x4b19('0x29')]=_0x4b4463;return _0x12c4ac;})[_0x4b19('0x17')](respondWithFilteredResult(_0x821fae,_0x4c5f27))[_0x4b19('0x2a')](handleError(_0x821fae,null));};exports[_0x4b19('0x2b')]=function(_0x24fac2,_0x16b9c5){var _0x2549e5={'raw':!![],'where':{'id':_0x24fac2[_0x4b19('0x2c')]['id']}},_0x32ee93={};_0x32ee93[_0x4b19('0x2d')]=_[_0x4b19('0x2e')](db[_0x4b19('0x21')]['rawAttributes']);_0x32ee93[_0x4b19('0x27')]=_['keys'](_0x24fac2[_0x4b19('0x27')]);_0x32ee93[_0x4b19('0x2f')]=_['intersection'](_0x32ee93[_0x4b19('0x2d')],_0x32ee93[_0x4b19('0x27')]);_0x2549e5[_0x4b19('0x30')]=_[_0x4b19('0x31')](_0x32ee93[_0x4b19('0x2d')],qs[_0x4b19('0x32')](_0x24fac2[_0x4b19('0x27')][_0x4b19('0x32')]));_0x2549e5[_0x4b19('0x30')]=_0x2549e5[_0x4b19('0x30')][_0x4b19('0x33')]?_0x2549e5[_0x4b19('0x30')]:_0x32ee93[_0x4b19('0x2d')];if(_0x24fac2['query'][_0x4b19('0x34')]){_0x2549e5['include']=[{'all':!![]}];}_0x2549e5=_['merge']({},_0x2549e5,_0x24fac2[_0x4b19('0x35')]);return db[_0x4b19('0x21')][_0x4b19('0x36')](_0x2549e5)[_0x4b19('0x17')](handleEntityNotFound(_0x16b9c5,null))[_0x4b19('0x17')](respondWithResult(_0x16b9c5,null))[_0x4b19('0x2a')](handleError(_0x16b9c5,null));};exports[_0x4b19('0x37')]=function(_0x2c8bfa,_0x418a24){return db[_0x4b19('0x21')][_0x4b19('0x37')](_0x2c8bfa['body'],{})[_0x4b19('0x17')](function(_0x35f572){var _0x4c770a=_0x2c8bfa['user'][_0x4b19('0x19')]({'plain':!![]});if(!_0x4c770a)throw new Error(_0x4b19('0x38'));if(_0x4c770a[_0x4b19('0x39')]===_0x4b19('0x3a')){var _0x1b31c3=_0x35f572['get']({'plain':!![]});var _0x5171c0=_0x4b19('0x1a');return db[_0x4b19('0x3b')][_0x4b19('0x36')]({'where':{'name':_0x5171c0,'userProfileId':_0x4c770a[_0x4b19('0x3c')]},'raw':!![]})[_0x4b19('0x17')](function(_0x277a54){if(_0x277a54&&_0x277a54[_0x4b19('0x3d')]===0x0){return db[_0x4b19('0x1b')][_0x4b19('0x37')]({'name':_0x1b31c3[_0x4b19('0x1e')],'resourceId':_0x1b31c3['id'],'type':_0x277a54[_0x4b19('0x1e')],'sectionId':_0x277a54['id']},{})[_0x4b19('0x17')](function(){return _0x35f572;});}else{return _0x35f572;}})[_0x4b19('0x2a')](function(_0x516999){logger[_0x4b19('0x1d')](_0x4b19('0x3e'),_0x516999);throw _0x516999;});}return _0x35f572;})[_0x4b19('0x17')](respondWithResult(_0x418a24,0xc9))['catch'](handleError(_0x418a24,null));};exports[_0x4b19('0x16')]=function(_0x372fdc,_0x5fab72){if(_0x372fdc[_0x4b19('0x3f')]['id']){delete _0x372fdc[_0x4b19('0x3f')]['id'];}return db['FaxQueue'][_0x4b19('0x36')]({'where':{'id':_0x372fdc['params']['id']}})[_0x4b19('0x17')](handleEntityNotFound(_0x5fab72,null))[_0x4b19('0x17')](saveUpdates(_0x372fdc[_0x4b19('0x3f')],null))['then'](respondWithResult(_0x5fab72,null))[_0x4b19('0x2a')](handleError(_0x5fab72,null));};exports[_0x4b19('0x18')]=function(_0x2c4a8a,_0x24d370){return db['FaxQueue']['find']({'where':{'id':_0x2c4a8a['params']['id']}})[_0x4b19('0x17')](handleEntityNotFound(_0x24d370,null))[_0x4b19('0x17')](removeEntity(_0x24d370,null))[_0x4b19('0x2a')](handleError(_0x24d370,null));};exports['describe']=function(_0x45fed4,_0x4d8aa8){return db[_0x4b19('0x21')][_0x4b19('0x40')]()[_0x4b19('0x17')](respondWithResult(_0x4d8aa8,null))[_0x4b19('0x2a')](handleError(_0x4d8aa8,null));};exports[_0x4b19('0x41')]=function(_0xf48771,_0x4f30d4){var _0x468e82={'raw':!![],'where':{}},_0x2743f1={},_0x2ddfd8;return db[_0x4b19('0x21')][_0x4b19('0x42')]({'where':{'id':_0xf48771['params']['id']}})['then'](handleEntityNotFound(_0x4f30d4,null))[_0x4b19('0x17')](function(_0x1ae695){if(_0x1ae695){_0x2ddfd8=_0x1ae695[_0x4b19('0x19')]({'plain':!![]});_0x2743f1[_0x4b19('0x2d')]=_['keys'](db['UserFaxQueue'][_0x4b19('0x43')]);_0x2743f1[_0x4b19('0x27')]=_['keys'](_0xf48771['query']);_0x2743f1[_0x4b19('0x2f')]=_[_0x4b19('0x31')](_0x2743f1[_0x4b19('0x2d')],_0x2743f1[_0x4b19('0x27')]);_0x468e82[_0x4b19('0x30')]=_['intersection'](_0x2743f1[_0x4b19('0x2d')],qs[_0x4b19('0x32')](_0xf48771['query'][_0x4b19('0x32')]));_0x468e82[_0x4b19('0x30')]=_0x468e82['attributes'][_0x4b19('0x33')]?_0x468e82[_0x4b19('0x30')]:_0x2743f1[_0x4b19('0x2d')];if(!_0xf48771[_0x4b19('0x27')][_0x4b19('0x44')](_0x4b19('0x45'))){_0x468e82[_0x4b19('0x13')]=qs[_0x4b19('0x13')](_0xf48771[_0x4b19('0x27')][_0x4b19('0x13')]);_0x468e82[_0x4b19('0x10')]=qs[_0x4b19('0x10')](_0xf48771['query'][_0x4b19('0x10')]);}_0x468e82[_0x4b19('0x46')]=qs[_0x4b19('0x47')](_0xf48771[_0x4b19('0x27')][_0x4b19('0x47')]);_0x468e82[_0x4b19('0x25')]=qs['filters'](_[_0x4b19('0x48')](_0xf48771['query'],_0x2743f1[_0x4b19('0x2f')]));_0x468e82[_0x4b19('0x25')][_0x4b19('0x49')]=_0x1ae695['id'];if(_0xf48771['query'][_0x4b19('0x4a')]){_0x468e82[_0x4b19('0x25')]=_[_0x4b19('0x4b')](_0x468e82['where'],{'$or':_['map'](_0x468e82[_0x4b19('0x30')],function(_0x3547f6){var _0x3b700b={};_0x3b700b[_0x3547f6]={'$like':'%'+_0xf48771[_0x4b19('0x27')]['filter']+'%'};return _0x3b700b;})});}_0x468e82=_[_0x4b19('0x4b')]({},_0x468e82,_0xf48771[_0x4b19('0x35')]);return db['UserFaxQueue'][_0x4b19('0x28')](_0x468e82);}})['then'](function(_0x3dce54){if(_0x3dce54){return db[_0x4b19('0x4c')][_0x4b19('0x4d')]({'where':{'id':_[_0x4b19('0x4e')](_0x3dce54,'UserId'),'role':_0x4b19('0x4f')},'attributes':['id',_0x4b19('0x1e'),_0x4b19('0x50'),_0x4b19('0x51'),_0x4b19('0x52')]});}})['then'](function(_0xeaa367){if(_0xeaa367){return{'count':_0xeaa367[_0x4b19('0x12')],'rows':_[_0x4b19('0x4e')](_0xeaa367[_0x4b19('0x29')],function(_0x62df26){return{'membername':_0x62df26[_0x4b19('0x1e')],'UserId':_0x62df26['id'],'queue_name':_0x2ddfd8['name'],'FaxQueueId':_0x2ddfd8['id'],'interface':util[_0x4b19('0x53')](_0x4b19('0x54'),_0x4b19('0x55'),_0x62df26['name']),'penalty':0x0,'paused':_0x62df26['faxPause'],'createdAt':_0x62df26['createdAt'],'updatedAt':_0x62df26['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x4f30d4,_0x468e82))[_0x4b19('0x2a')](handleError(_0x4f30d4,null));};exports[_0x4b19('0x56')]=function(_0x56f7a1,_0x4f06ec){var _0x576d05={};var _0x77a529={};var _0x3e875c;var _0x3c55a0;return db['FaxQueue'][_0x4b19('0x42')]({'where':{'id':_0x56f7a1[_0x4b19('0x2c')]['id']}})[_0x4b19('0x17')](handleEntityNotFound(_0x4f06ec,null))[_0x4b19('0x17')](function(_0x2b3f18){if(_0x2b3f18){_0x3e875c=_0x2b3f18;_0x77a529['model']=_['keys'](db[_0x4b19('0x57')][_0x4b19('0x43')]);_0x77a529[_0x4b19('0x27')]=_['keys'](_0x56f7a1[_0x4b19('0x27')]);_0x77a529['filters']=_[_0x4b19('0x31')](_0x77a529[_0x4b19('0x2d')],_0x77a529[_0x4b19('0x27')]);_0x576d05[_0x4b19('0x30')]=_[_0x4b19('0x31')](_0x77a529[_0x4b19('0x2d')],qs['fields'](_0x56f7a1[_0x4b19('0x27')]['fields']));_0x576d05[_0x4b19('0x30')]=_0x576d05[_0x4b19('0x30')][_0x4b19('0x33')]?_0x576d05['attributes']:_0x77a529[_0x4b19('0x2d')];_0x576d05['order']=qs[_0x4b19('0x47')](_0x56f7a1[_0x4b19('0x27')][_0x4b19('0x47')]);_0x576d05[_0x4b19('0x25')]=qs[_0x4b19('0x2f')](_[_0x4b19('0x48')](_0x56f7a1['query'],_0x77a529[_0x4b19('0x2f')]));if(_0x56f7a1[_0x4b19('0x27')]['filter']){_0x576d05['where']=_[_0x4b19('0x4b')](_0x576d05['where'],{'$or':_[_0x4b19('0x4e')](_0x576d05[_0x4b19('0x30')],function(_0xe97023){var _0x3e406c={};_0x3e406c[_0xe97023]={'$like':'%'+_0x56f7a1[_0x4b19('0x27')][_0x4b19('0x4a')]+'%'};return _0x3e406c;})});}_0x576d05=_[_0x4b19('0x4b')]({},_0x576d05,_0x56f7a1['options']);return _0x3e875c[_0x4b19('0x56')](_0x576d05);}})[_0x4b19('0x17')](function(_0x1725e5){if(_0x1725e5){_0x3c55a0=_0x1725e5['length'];if(!_0x56f7a1['query']['hasOwnProperty'](_0x4b19('0x45'))){_0x576d05[_0x4b19('0x13')]=qs[_0x4b19('0x13')](_0x56f7a1['query']['limit']);_0x576d05[_0x4b19('0x10')]=qs['offset'](_0x56f7a1['query'][_0x4b19('0x10')]);}return _0x3e875c[_0x4b19('0x56')](_0x576d05);}})[_0x4b19('0x17')](function(_0x3aa670){if(_0x3aa670){return _0x3aa670?{'count':_0x3c55a0,'rows':_0x3aa670}:null;}})[_0x4b19('0x17')](respondWithResult(_0x4f06ec,null))[_0x4b19('0x2a')](handleError(_0x4f06ec,null));};exports[_0x4b19('0x58')]=function(_0x36c5b3,_0x4878c3){var _0x5e9a93=_0x36c5b3['body'][_0x4b19('0x59')];return db[_0x4b19('0x57')][_0x4b19('0x28')]({'where':{'id':_0x5e9a93},'attributes':['id'],'include':[{'model':db['User'],'as':'Agents','attributes':['id','name',_0x4b19('0x5a'),'voicePause','interface'],'raw':!![]}]})[_0x4b19('0x17')](function(_0x367a63){if(_0x367a63){var _0x4fdf6c=_[_0x4b19('0x5b')](_0x367a63,function(_0x546913){var _0x426282=_0x546913[_0x4b19('0x19')]({'plain':!![]});return _0x426282[_0x4b19('0x5c')];});return db[_0x4b19('0x21')][_0x4b19('0x36')]({'where':{'id':_0x36c5b3[_0x4b19('0x2c')]['id']}})[_0x4b19('0x17')](function(_0x1ae295){return db[_0x4b19('0x5d')]['transaction'](function(_0x21b526){return _0x1ae295[_0x4b19('0x58')](_0x5e9a93,{'transaction':_0x21b526})['then'](function(){return BPromise['each'](_0x4fdf6c,function(_0x538d6a){return db[_0x4b19('0x5e')][_0x4b19('0x5f')]({'where':{'UserId':_0x538d6a['id'],'FaxQueueId':_0x36c5b3[_0x4b19('0x2c')]['id']},'transaction':_0x21b526});});})[_0x4b19('0x17')](function(){_0x4fdf6c[_0x4b19('0x60')](function(_0xf1225e){socket[_0x4b19('0x61')]('userFaxQueue:save',{'UserId':_0xf1225e['id'],'FaxQueueId':_0x1ae295['id']});});});});});}})[_0x4b19('0x17')](respondWithStatusCode(_0x4878c3,null))[_0x4b19('0x2a')](handleError(_0x4878c3,null));};exports[_0x4b19('0x62')]=function(_0xf74948,_0x5e34ad){return db[_0x4b19('0x57')][_0x4b19('0x28')]({'where':{'id':_0xf74948[_0x4b19('0x27')][_0x4b19('0x59')]},'attributes':['id'],'include':[{'model':db[_0x4b19('0x4c')],'as':'Agents','attributes':['id'],'raw':!![]}]})[_0x4b19('0x17')](handleEntityNotFound(_0x5e34ad,null))['then'](function(_0x1bc924){var _0x3298ed=_[_0x4b19('0x4e')](_0x1bc924,'id');var _0x5977a1=[];var _0xed7354=[];var _0x33d9c0=squel[_0x4b19('0x63')]();_0x33d9c0[_0x4b19('0x64')]('tq.TeamId')[_0x4b19('0x65')](_0x4b19('0x66'),'tq')[_0x4b19('0x67')](_0x4b19('0x68'),'ut',_0x4b19('0x69'))[_0x4b19('0x25')](_0x4b19('0x6a'),_0xf74948[_0x4b19('0x2c')]['id']);for(var _0xdd0077=0x0;_0xdd0077<_0x1bc924[_0x4b19('0x33')];_0xdd0077+=0x1){let _0x640807=_0x1bc924[_0xdd0077];for(var _0x3f9428=0x0;_0x3f9428<_0x640807['Agents']['length'];_0x3f9428+=0x1){let _0xb4cf85=_0x640807[_0x4b19('0x5c')][_0x3f9428];var _0x35494a=_0x33d9c0[_0x4b19('0x6b')]();_0x35494a[_0x4b19('0x25')](_0x4b19('0x6c'),_0xb4cf85['id']);_0xed7354['push'](db[_0x4b19('0x5d')][_0x4b19('0x27')](_0x35494a[_0x4b19('0x6d')](),{'type':db[_0x4b19('0x5d')][_0x4b19('0x6e')]['SELECT']})[_0x4b19('0x17')](function(_0x12348c){if(_0x12348c[_0x4b19('0x33')]===0x1){return _0xb4cf85['id'];}else{var _0x3e13d6=_[_0x4b19('0x6f')](_[_0x4b19('0x4e')](_0x12348c,'TeamId'),function(_0xe5c335){return _[_0x4b19('0x70')](_0x3298ed,_0xe5c335);});if(_0x3e13d6){return _0xb4cf85['id'];}}}));}}return BPromise['all'](_0xed7354)['then'](function(_0xad4ef4){_0x5977a1=_(_0x5977a1)[_0x4b19('0x71')](_0xad4ef4)['compact']()[_0x4b19('0x72')]();return db[_0x4b19('0x21')][_0x4b19('0x36')]({'where':{'id':_0xf74948['params']['id']}})[_0x4b19('0x17')](function(_0x3740f0){return db[_0x4b19('0x5d')][_0x4b19('0x73')](function(_0x247c85){return _0x3740f0[_0x4b19('0x62')](_0xf74948['query'][_0x4b19('0x59')],{'transaction':_0x247c85})['then'](function(){if(!_[_0x4b19('0x74')](_0x5977a1)){return _0x3740f0['removeAgents'](_0x5977a1,{'transaction':_0x247c85});}})[_0x4b19('0x17')](function(){_0x5977a1['forEach'](function(_0x5066c4){socket[_0x4b19('0x61')]('userFaxQueue:remove',{'UserId':_0x5066c4,'FaxQueueId':_0x3740f0['id']});});});});});});})[_0x4b19('0x17')](respondWithStatusCode(_0x5e34ad,null))[_0x4b19('0x2a')](handleError(_0x5e34ad,null));};exports[_0x4b19('0x75')]=function(_0x49fd9f,_0x54ae7c){return db[_0x4b19('0x21')][_0x4b19('0x36')]({'where':{'id':_0x49fd9f['params']['id']}})[_0x4b19('0x17')](handleEntityNotFound(_0x54ae7c,null))[_0x4b19('0x17')](function(_0x34a0b6){if(_0x34a0b6){return _0x34a0b6['addAgents'](_0x49fd9f[_0x4b19('0x3f')]['ids'],_[_0x4b19('0x76')](_0x49fd9f[_0x4b19('0x3f')],[_0x4b19('0x59'),'id'])||{})[_0x4b19('0x77')](function(_0x5bfbe4){for(var _0x4a265b=0x0;_0x4a265b<_0x49fd9f['body']['ids'][_0x4b19('0x33')];_0x4a265b+=0x1){socket[_0x4b19('0x61')](_0x4b19('0x78'),{'UserId':Number(_0x49fd9f[_0x4b19('0x3f')][_0x4b19('0x59')][_0x4a265b]),'FaxQueueId':Number(_0x49fd9f[_0x4b19('0x2c')]['id'])});}return _0x5bfbe4;});}})[_0x4b19('0x17')](respondWithResult(_0x54ae7c,null))['catch'](handleError(_0x54ae7c,null));};exports[_0x4b19('0x79')]=function(_0x17f878,_0x11bbe3){return db[_0x4b19('0x21')]['find']({'where':{'id':_0x17f878[_0x4b19('0x2c')]['id']}})[_0x4b19('0x17')](handleEntityNotFound(_0x11bbe3,null))['then'](function(_0x44a106){if(_0x44a106){return _0x44a106[_0x4b19('0x79')](_0x17f878[_0x4b19('0x27')][_0x4b19('0x59')])[_0x4b19('0x17')](function(){if(_[_0x4b19('0x7a')](_0x17f878[_0x4b19('0x27')][_0x4b19('0x59')])){for(var _0x534a3c=0x0;_0x534a3c<_0x17f878[_0x4b19('0x27')]['ids']['length'];_0x534a3c+=0x1){socket[_0x4b19('0x61')](_0x4b19('0x7b'),{'UserId':Number(_0x17f878[_0x4b19('0x27')][_0x4b19('0x59')][_0x534a3c]),'FaxQueueId':Number(_0x17f878[_0x4b19('0x2c')]['id'])});}}else{socket['emit']('userFaxQueue:remove',{'UserId':Number(_0x17f878[_0x4b19('0x27')][_0x4b19('0x59')]),'FaxQueueId':Number(_0x17f878['params']['id'])});}});}})[_0x4b19('0x17')](respondWithStatusCode(_0x11bbe3,null))[_0x4b19('0x2a')](handleError(_0x11bbe3,null));};exports[_0x4b19('0x7c')]=function(_0xeea4d2,_0x2e7e6f){var _0x2c59dc={};var _0x335a80={};var _0x50e6fe;var _0x3cd679;return db[_0x4b19('0x21')][_0x4b19('0x42')]({'where':{'id':_0xeea4d2[_0x4b19('0x2c')]['id']}})[_0x4b19('0x17')](handleEntityNotFound(_0x2e7e6f,null))['then'](function(_0x14ccd8){if(_0x14ccd8){_0x50e6fe=_0x14ccd8;_0x335a80['model']=_[_0x4b19('0x2e')](db[_0x4b19('0x4c')]['rawAttributes']);_0x335a80[_0x4b19('0x27')]=_[_0x4b19('0x2e')](_0xeea4d2['query']);_0x335a80[_0x4b19('0x2f')]=_['intersection'](_0x335a80['model'],_0x335a80[_0x4b19('0x27')]);_0x2c59dc[_0x4b19('0x30')]=_['intersection'](_0x335a80[_0x4b19('0x2d')],qs[_0x4b19('0x32')](_0xeea4d2[_0x4b19('0x27')][_0x4b19('0x32')]));_0x2c59dc['attributes']=_0x2c59dc[_0x4b19('0x30')][_0x4b19('0x33')]?_0x2c59dc['attributes']:_0x335a80[_0x4b19('0x2d')];_0x2c59dc['order']=qs[_0x4b19('0x47')](_0xeea4d2[_0x4b19('0x27')][_0x4b19('0x47')]);_0x2c59dc[_0x4b19('0x25')]=qs[_0x4b19('0x2f')](_[_0x4b19('0x48')](_0xeea4d2['query'],_0x335a80[_0x4b19('0x2f')]));if(_0xeea4d2[_0x4b19('0x27')]['filter']){_0x2c59dc[_0x4b19('0x25')]=_[_0x4b19('0x4b')](_0x2c59dc[_0x4b19('0x25')],{'$or':_['map'](_0x2c59dc[_0x4b19('0x30')],function(_0x3a643f){var _0x22dcb5={};_0x22dcb5[_0x3a643f]={'$like':'%'+_0xeea4d2['query'][_0x4b19('0x4a')]+'%'};return _0x22dcb5;})});}_0x2c59dc=_[_0x4b19('0x4b')]({},_0x2c59dc,_0xeea4d2['options']);return _0x50e6fe[_0x4b19('0x7c')](_0x2c59dc);}})[_0x4b19('0x17')](function(_0xa9fed8){if(_0xa9fed8){_0x3cd679=_0xa9fed8[_0x4b19('0x33')];if(!_0xeea4d2[_0x4b19('0x27')]['hasOwnProperty'](_0x4b19('0x45'))){_0x2c59dc['limit']=qs['limit'](_0xeea4d2['query'][_0x4b19('0x13')]);_0x2c59dc['offset']=qs[_0x4b19('0x10')](_0xeea4d2[_0x4b19('0x27')][_0x4b19('0x10')]);}return _0x50e6fe[_0x4b19('0x7c')](_0x2c59dc);}})['then'](function(_0xf9da18){if(_0xf9da18){return _0xf9da18?{'count':_0x3cd679,'rows':_0xf9da18}:null;}})[_0x4b19('0x17')](respondWithResult(_0x2e7e6f,null))[_0x4b19('0x2a')](handleError(_0x2e7e6f,null));};
\ No newline at end of file