Built motion from commit (unavailable).|2.5.17
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 43ddd90..47c8fcd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd52d=['flatMap','transaction','addTeams','each','findOrCreate','forEach','ids','select','tq.TeamId','team_has_fax_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','sequelize','toString','QueryTypes','SELECT','TeamId','compact','removeTeams','isEmpty','removeAgents','emit','userFaxQueue:remove','addAgents','omit','spread','userFaxQueue:save','getAgents','eml-format','rimraf','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./faxQueue.socket','sendStatus','status','end','count','offset','limit','set','json','apply','reject','update','then','destroy','get','FaxQueues','UserProfileResource','stack','name','index','map','FaxQueue','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','show','params','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','FaxQueueId','UserFaxQueue','User','findAndCountAll','UserId','faxPause','updatedAt','createdAt','rows','%s/%s','SIP','getTeams','Team','Agents','online','voicePause','interface'];(function(_0x1acca6,_0x1cf198){var _0xa3710f=function(_0x155531){while(--_0x155531){_0x1acca6['push'](_0x1acca6['shift']());}};_0xa3710f(++_0x1cf198);}(_0xd52d,0x1c7));var _0xdd52=function(_0xd60b3b,_0x45895a){_0xd60b3b=_0xd60b3b-0x0;var _0x655041=_0xd52d[_0xd60b3b];return _0x655041;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xdd52('0x0'));var rimraf=require(_0xdd52('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xdd52('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xdd52('0x3'));var Mustache=require(_0xdd52('0x4'));var util=require(_0xdd52('0x5'));var path=require(_0xdd52('0x6'));var sox=require(_0xdd52('0x7'));var csv=require(_0xdd52('0x8'));var ejs=require(_0xdd52('0x9'));var fs=require('fs');var _=require(_0xdd52('0xa'));var squel=require('squel');var crypto=require(_0xdd52('0xb'));var jsforce=require(_0xdd52('0xc'));var deskjs=require(_0xdd52('0xd'));var toCsv=require(_0xdd52('0x8'));var querystring=require(_0xdd52('0xe'));var Papa=require(_0xdd52('0xf'));var Redis=require(_0xdd52('0x10'));var authService=require(_0xdd52('0x11'));var qs=require(_0xdd52('0x12'));var as=require(_0xdd52('0x13'));var hardwareService=require(_0xdd52('0x14'));var logger=require(_0xdd52('0x15'))(_0xdd52('0x16'));var utils=require('../../config/utils');var config=require(_0xdd52('0x17'));var licenseUtil=require(_0xdd52('0x18'));var db=require(_0xdd52('0x19'))['db'];config[_0xdd52('0x1a')]=_[_0xdd52('0x1b')](config[_0xdd52('0x1a')],{'host':'localhost','port':0x18eb});var socket=require(_0xdd52('0x1c'))(new Redis(config[_0xdd52('0x1a')]));require(_0xdd52('0x1d'))['register'](socket);function respondWithStatusCode(_0x3f6585,_0x194b7a){_0x194b7a=_0x194b7a||0xcc;return function(_0x32f6b6){if(_0x32f6b6){return _0x3f6585[_0xdd52('0x1e')](_0x194b7a);}return _0x3f6585[_0xdd52('0x1f')](_0x194b7a)[_0xdd52('0x20')]();};}function respondWithResult(_0x25a2b7,_0xdfed5c){_0xdfed5c=_0xdfed5c||0xc8;return function(_0x5da34c){if(_0x5da34c){return _0x25a2b7[_0xdd52('0x1f')](_0xdfed5c)['json'](_0x5da34c);}};}function respondWithFilteredResult(_0x2822be,_0x11d80a){return function(_0x4568dc){if(_0x4568dc){var _0x45062e=_0x4568dc[_0xdd52('0x21')],_0x4dc017=_0x11d80a[_0xdd52('0x22')],_0x46803a=_0x11d80a['offset']+_0x11d80a[_0xdd52('0x23')],_0x2bf6ff;if(_0x46803a>=_0x45062e){_0x46803a=_0x45062e;_0x2bf6ff=0xc8;}else{_0x2bf6ff=0xce;}_0x2822be['status'](_0x2bf6ff);return _0x2822be[_0xdd52('0x24')]('Content-Range',_0x4dc017+'-'+_0x46803a+'/'+_0x45062e)[_0xdd52('0x25')](_0x4568dc);}return null;};}function patchUpdates(_0x40c8d2){return function(_0x5a671a){try{jsonpatch[_0xdd52('0x26')](_0x5a671a,_0x40c8d2,!![]);}catch(_0x5ed39b){return BPromise[_0xdd52('0x27')](_0x5ed39b);}return _0x5a671a['save']();};}function saveUpdates(_0x14cd54,_0xfa872c){return function(_0x39731d){if(_0x39731d){return _0x39731d[_0xdd52('0x28')](_0x14cd54)[_0xdd52('0x29')](function(_0x455e74){return _0x455e74;});}return null;};}function removeEntity(_0x3ce226,_0x248c27){return function(_0x5029e5){if(_0x5029e5){return _0x5029e5[_0xdd52('0x2a')]()[_0xdd52('0x29')](function(){var _0x592f15=_0x5029e5[_0xdd52('0x2b')]({'plain':!![]});var _0x353fde=_0xdd52('0x2c');return db[_0xdd52('0x2d')]['destroy']({'where':{'type':_0x353fde,'resourceId':_0x592f15['id']}})[_0xdd52('0x29')](function(){return _0x5029e5;});})[_0xdd52('0x29')](function(){_0x3ce226[_0xdd52('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x515e78,_0x1a5bf4){return function(_0x4e8290){if(!_0x4e8290){_0x515e78[_0xdd52('0x1e')](0x194);}return _0x4e8290;};}function handleError(_0x3f96bd,_0xeb81a0){_0xeb81a0=_0xeb81a0||0x1f4;return function(_0x539418){logger['error'](_0x539418[_0xdd52('0x2e')]);if(_0x539418[_0xdd52('0x2f')]){delete _0x539418[_0xdd52('0x2f')];}_0x3f96bd['status'](_0xeb81a0)['send'](_0x539418);};}exports[_0xdd52('0x30')]=function(_0x566658,_0x29c940){var _0x271353={},_0x1e1b3e={},_0x388ef0={'count':0x0,'rows':[]};var _0x3126f0=_[_0xdd52('0x31')](db[_0xdd52('0x32')][_0xdd52('0x33')],function(_0x294f84){return{'name':_0x294f84[_0xdd52('0x34')],'type':_0x294f84[_0xdd52('0x35')][_0xdd52('0x36')]};});_0x1e1b3e[_0xdd52('0x37')]=_[_0xdd52('0x31')](_0x3126f0,_0xdd52('0x2f'));_0x1e1b3e[_0xdd52('0x38')]=_[_0xdd52('0x39')](_0x566658[_0xdd52('0x38')]);_0x1e1b3e[_0xdd52('0x3a')]=_[_0xdd52('0x3b')](_0x1e1b3e[_0xdd52('0x37')],_0x1e1b3e['query']);_0x271353[_0xdd52('0x3c')]=_[_0xdd52('0x3b')](_0x1e1b3e['model'],qs['fields'](_0x566658['query'][_0xdd52('0x3d')]));_0x271353[_0xdd52('0x3c')]=_0x271353[_0xdd52('0x3c')][_0xdd52('0x3e')]?_0x271353[_0xdd52('0x3c')]:_0x1e1b3e[_0xdd52('0x37')];if(!_0x566658[_0xdd52('0x38')][_0xdd52('0x3f')](_0xdd52('0x40'))){_0x271353[_0xdd52('0x23')]=qs['limit'](_0x566658[_0xdd52('0x38')][_0xdd52('0x23')]);_0x271353[_0xdd52('0x22')]=qs[_0xdd52('0x22')](_0x566658[_0xdd52('0x38')][_0xdd52('0x22')]);}_0x271353[_0xdd52('0x41')]=qs[_0xdd52('0x42')](_0x566658[_0xdd52('0x38')][_0xdd52('0x42')]);_0x271353[_0xdd52('0x43')]=qs[_0xdd52('0x3a')](_[_0xdd52('0x44')](_0x566658[_0xdd52('0x38')],_0x1e1b3e[_0xdd52('0x3a')]),_0x3126f0);if(_0x566658[_0xdd52('0x38')][_0xdd52('0x45')]){_0x271353[_0xdd52('0x43')]=_[_0xdd52('0x46')](_0x271353[_0xdd52('0x43')],{'$or':_[_0xdd52('0x31')](_0x3126f0,function(_0x506b7a){if(_0x506b7a['type']!==_0xdd52('0x47')){var _0x30b258={};_0x30b258[_0x506b7a[_0xdd52('0x2f')]]={'$like':'%'+_0x566658[_0xdd52('0x38')][_0xdd52('0x45')]+'%'};return _0x30b258;}})});}_0x271353=_[_0xdd52('0x46')]({},_0x271353,_0x566658[_0xdd52('0x48')]);var _0x37ac51={'where':_0x271353[_0xdd52('0x43')]};return db[_0xdd52('0x32')]['count'](_0x37ac51)[_0xdd52('0x29')](function(_0x35d964){_0x388ef0[_0xdd52('0x21')]=_0x35d964;if(_0x566658['query'][_0xdd52('0x49')]){_0x271353[_0xdd52('0x4a')]=[{'all':!![]}];}return db[_0xdd52('0x32')][_0xdd52('0x4b')](_0x271353);})[_0xdd52('0x29')](function(_0x23d3af){_0x388ef0['rows']=_0x23d3af;return _0x388ef0;})[_0xdd52('0x29')](respondWithFilteredResult(_0x29c940,_0x271353))[_0xdd52('0x4c')](handleError(_0x29c940,null));};exports[_0xdd52('0x4d')]=function(_0x4cac5c,_0x9fd63f){var _0x88fadc={'raw':!![],'where':{'id':_0x4cac5c[_0xdd52('0x4e')]['id']}},_0x4a0301={};_0x4a0301['model']=_[_0xdd52('0x39')](db['FaxQueue']['rawAttributes']);_0x4a0301['query']=_[_0xdd52('0x39')](_0x4cac5c[_0xdd52('0x38')]);_0x4a0301[_0xdd52('0x3a')]=_[_0xdd52('0x3b')](_0x4a0301[_0xdd52('0x37')],_0x4a0301[_0xdd52('0x38')]);_0x88fadc['attributes']=_[_0xdd52('0x3b')](_0x4a0301[_0xdd52('0x37')],qs[_0xdd52('0x3d')](_0x4cac5c['query'][_0xdd52('0x3d')]));_0x88fadc[_0xdd52('0x3c')]=_0x88fadc[_0xdd52('0x3c')][_0xdd52('0x3e')]?_0x88fadc['attributes']:_0x4a0301[_0xdd52('0x37')];if(_0x4cac5c[_0xdd52('0x38')]['includeAll']){_0x88fadc[_0xdd52('0x4a')]=[{'all':!![]}];}_0x88fadc=_[_0xdd52('0x46')]({},_0x88fadc,_0x4cac5c[_0xdd52('0x48')]);return db['FaxQueue']['find'](_0x88fadc)[_0xdd52('0x29')](handleEntityNotFound(_0x9fd63f,null))[_0xdd52('0x29')](respondWithResult(_0x9fd63f,null))[_0xdd52('0x4c')](handleError(_0x9fd63f,null));};exports['create']=function(_0x267646,_0x529964){return db[_0xdd52('0x32')][_0xdd52('0x4f')](_0x267646[_0xdd52('0x50')],{})['then'](function(_0x56da47){var _0x43a354=_0x267646['user'][_0xdd52('0x2b')]({'plain':!![]});if(!_0x43a354)throw new Error(_0xdd52('0x51'));if(_0x43a354[_0xdd52('0x52')]===_0xdd52('0x53')){var _0x2387ed=_0x56da47[_0xdd52('0x2b')]({'plain':!![]});var _0x5c2555=_0xdd52('0x2c');return db[_0xdd52('0x54')][_0xdd52('0x55')]({'where':{'name':_0x5c2555,'userProfileId':_0x43a354[_0xdd52('0x56')]},'raw':!![]})['then'](function(_0x2ca606){if(_0x2ca606&&_0x2ca606[_0xdd52('0x57')]===0x0){return db[_0xdd52('0x2d')]['create']({'name':_0x2387ed[_0xdd52('0x2f')],'resourceId':_0x2387ed['id'],'type':_0x2ca606[_0xdd52('0x2f')],'sectionId':_0x2ca606['id']},{})[_0xdd52('0x29')](function(){return _0x56da47;});}else{return _0x56da47;}})[_0xdd52('0x4c')](function(_0x2c5e92){logger['error'](_0xdd52('0x58'),_0x2c5e92);throw _0x2c5e92;});}return _0x56da47;})[_0xdd52('0x29')](respondWithResult(_0x529964,0xc9))[_0xdd52('0x4c')](handleError(_0x529964,null));};exports[_0xdd52('0x28')]=function(_0x3e0ab1,_0x5510e4){if(_0x3e0ab1[_0xdd52('0x50')]['id']){delete _0x3e0ab1[_0xdd52('0x50')]['id'];}return db['FaxQueue']['find']({'where':{'id':_0x3e0ab1[_0xdd52('0x4e')]['id']}})['then'](handleEntityNotFound(_0x5510e4,null))[_0xdd52('0x29')](saveUpdates(_0x3e0ab1[_0xdd52('0x50')],null))['then'](respondWithResult(_0x5510e4,null))[_0xdd52('0x4c')](handleError(_0x5510e4,null));};exports['destroy']=function(_0x540591,_0x5b2992){return db[_0xdd52('0x32')][_0xdd52('0x55')]({'where':{'id':_0x540591[_0xdd52('0x4e')]['id']}})[_0xdd52('0x29')](handleEntityNotFound(_0x5b2992,null))[_0xdd52('0x29')](removeEntity(_0x5b2992,null))['catch'](handleError(_0x5b2992,null));};exports[_0xdd52('0x59')]=function(_0x331394,_0x1bf35e){return db[_0xdd52('0x32')][_0xdd52('0x59')]()[_0xdd52('0x29')](respondWithResult(_0x1bf35e,null))[_0xdd52('0x4c')](handleError(_0x1bf35e,null));};exports[_0xdd52('0x5a')]=function(_0x4d5f44,_0x707eb7,_0x1100a4){var _0x17d294={'raw':!![],'where':{}},_0x205856={},_0x16974f;return db[_0xdd52('0x32')][_0xdd52('0x5b')]({'where':{'id':_0x4d5f44[_0xdd52('0x4e')]['id']}})[_0xdd52('0x29')](handleEntityNotFound(_0x707eb7,null))[_0xdd52('0x29')](function(_0x4891e9){if(_0x4891e9){_0x16974f=_0x4891e9[_0xdd52('0x2b')]({'plain':!![]});_0x205856['model']=_['keys'](db['UserFaxQueue'][_0xdd52('0x33')]);_0x205856[_0xdd52('0x38')]=_['keys'](_0x4d5f44['query']);_0x205856[_0xdd52('0x3a')]=_[_0xdd52('0x3b')](_0x205856[_0xdd52('0x37')],_0x205856[_0xdd52('0x38')]);_0x17d294[_0xdd52('0x3c')]=_[_0xdd52('0x3b')](_0x205856[_0xdd52('0x37')],qs[_0xdd52('0x3d')](_0x4d5f44[_0xdd52('0x38')][_0xdd52('0x3d')]));_0x17d294['attributes']=_0x17d294['attributes']['length']?_0x17d294[_0xdd52('0x3c')]:_0x205856[_0xdd52('0x37')];if(!_0x4d5f44[_0xdd52('0x38')][_0xdd52('0x3f')]('nolimit')){_0x17d294[_0xdd52('0x23')]=qs['limit'](_0x4d5f44[_0xdd52('0x38')][_0xdd52('0x23')]);_0x17d294[_0xdd52('0x22')]=qs[_0xdd52('0x22')](_0x4d5f44[_0xdd52('0x38')][_0xdd52('0x22')]);}_0x17d294[_0xdd52('0x41')]=qs[_0xdd52('0x42')](_0x4d5f44[_0xdd52('0x38')][_0xdd52('0x42')]);_0x17d294['where']=qs[_0xdd52('0x3a')](_[_0xdd52('0x44')](_0x4d5f44[_0xdd52('0x38')],_0x205856[_0xdd52('0x3a')]));_0x17d294[_0xdd52('0x43')][_0xdd52('0x5c')]=_0x4891e9['id'];if(_0x4d5f44[_0xdd52('0x38')][_0xdd52('0x45')]){_0x17d294[_0xdd52('0x43')]=_['merge'](_0x17d294[_0xdd52('0x43')],{'$or':_[_0xdd52('0x31')](_0x17d294[_0xdd52('0x3c')],function(_0x3d6d27){var _0x4e9bd6={};_0x4e9bd6[_0x3d6d27]={'$like':'%'+_0x4d5f44[_0xdd52('0x38')]['filter']+'%'};return _0x4e9bd6;})});}_0x17d294=_[_0xdd52('0x46')]({},_0x17d294,_0x4d5f44[_0xdd52('0x48')]);return db[_0xdd52('0x5d')]['findAll'](_0x17d294);}})[_0xdd52('0x29')](function(_0x1eb45b){if(_0x1eb45b){return db[_0xdd52('0x5e')][_0xdd52('0x5f')]({'where':{'id':_[_0xdd52('0x31')](_0x1eb45b,_0xdd52('0x60')),'role':'agent'},'attributes':['id',_0xdd52('0x2f'),_0xdd52('0x61'),_0xdd52('0x62'),_0xdd52('0x63')]});}})['then'](function(_0x36c321){if(_0x36c321){return{'count':_0x36c321[_0xdd52('0x21')],'rows':_[_0xdd52('0x31')](_0x36c321[_0xdd52('0x64')],function(_0x1971da){return{'membername':_0x1971da[_0xdd52('0x2f')],'UserId':_0x1971da['id'],'queue_name':_0x16974f[_0xdd52('0x2f')],'FaxQueueId':_0x16974f['id'],'interface':util['format'](_0xdd52('0x65'),_0xdd52('0x66'),_0x1971da['name']),'penalty':0x0,'paused':_0x1971da['faxPause'],'createdAt':_0x1971da['createdAt'],'updatedAt':_0x1971da[_0xdd52('0x62')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xdd52('0x29')](respondWithFilteredResult(_0x707eb7,_0x17d294))[_0xdd52('0x4c')](handleError(_0x707eb7,null));};exports[_0xdd52('0x67')]=function(_0x1679ea,_0x157dfa,_0x2ca18c){var _0x5a8032={};var _0x27f986={};var _0x4c5560;var _0x396f70;return db[_0xdd52('0x32')]['findOne']({'where':{'id':_0x1679ea['params']['id']}})[_0xdd52('0x29')](handleEntityNotFound(_0x157dfa,null))['then'](function(_0x379b62){if(_0x379b62){_0x4c5560=_0x379b62;_0x27f986[_0xdd52('0x37')]=_[_0xdd52('0x39')](db['Team'][_0xdd52('0x33')]);_0x27f986[_0xdd52('0x38')]=_['keys'](_0x1679ea[_0xdd52('0x38')]);_0x27f986[_0xdd52('0x3a')]=_[_0xdd52('0x3b')](_0x27f986[_0xdd52('0x37')],_0x27f986[_0xdd52('0x38')]);_0x5a8032[_0xdd52('0x3c')]=_['intersection'](_0x27f986['model'],qs[_0xdd52('0x3d')](_0x1679ea['query'][_0xdd52('0x3d')]));_0x5a8032[_0xdd52('0x3c')]=_0x5a8032[_0xdd52('0x3c')][_0xdd52('0x3e')]?_0x5a8032['attributes']:_0x27f986['model'];_0x5a8032[_0xdd52('0x41')]=qs['sort'](_0x1679ea[_0xdd52('0x38')][_0xdd52('0x42')]);_0x5a8032['where']=qs[_0xdd52('0x3a')](_[_0xdd52('0x44')](_0x1679ea[_0xdd52('0x38')],_0x27f986['filters']));if(_0x1679ea[_0xdd52('0x38')][_0xdd52('0x45')]){_0x5a8032[_0xdd52('0x43')]=_[_0xdd52('0x46')](_0x5a8032[_0xdd52('0x43')],{'$or':_[_0xdd52('0x31')](_0x5a8032[_0xdd52('0x3c')],function(_0x7d0ec1){var _0x458866={};_0x458866[_0x7d0ec1]={'$like':'%'+_0x1679ea[_0xdd52('0x38')][_0xdd52('0x45')]+'%'};return _0x458866;})});}_0x5a8032=_['merge']({},_0x5a8032,_0x1679ea[_0xdd52('0x48')]);return _0x4c5560[_0xdd52('0x67')](_0x5a8032);}})[_0xdd52('0x29')](function(_0x362484){if(_0x362484){_0x396f70=_0x362484[_0xdd52('0x3e')];if(!_0x1679ea[_0xdd52('0x38')][_0xdd52('0x3f')](_0xdd52('0x40'))){_0x5a8032[_0xdd52('0x23')]=qs[_0xdd52('0x23')](_0x1679ea[_0xdd52('0x38')]['limit']);_0x5a8032[_0xdd52('0x22')]=qs[_0xdd52('0x22')](_0x1679ea[_0xdd52('0x38')][_0xdd52('0x22')]);}return _0x4c5560[_0xdd52('0x67')](_0x5a8032);}})[_0xdd52('0x29')](function(_0x38f9c0){if(_0x38f9c0){return _0x38f9c0?{'count':_0x396f70,'rows':_0x38f9c0}:null;}})[_0xdd52('0x29')](respondWithResult(_0x157dfa,null))[_0xdd52('0x4c')](handleError(_0x157dfa,null));};exports['addTeams']=function(_0x5d1f12,_0x1d803f,_0x4ea21d){var _0x199857=_0x5d1f12[_0xdd52('0x50')]['ids'];return db[_0xdd52('0x68')]['findAll']({'where':{'id':_0x199857},'attributes':['id'],'include':[{'model':db['User'],'as':_0xdd52('0x69'),'attributes':['id',_0xdd52('0x2f'),_0xdd52('0x6a'),_0xdd52('0x6b'),_0xdd52('0x6c')],'raw':!![]}]})[_0xdd52('0x29')](function(_0x1e41b1){if(_0x1e41b1){var _0x369a37=_[_0xdd52('0x6d')](_0x1e41b1,function(_0x39f0d7){var _0x40f36b=_0x39f0d7['get']({'plain':!![]});return _0x40f36b['Agents'];});return db[_0xdd52('0x32')]['find']({'where':{'id':_0x5d1f12['params']['id']}})['then'](function(_0x361869){return db['sequelize'][_0xdd52('0x6e')](function(_0x5e6e7b){return _0x361869[_0xdd52('0x6f')](_0x199857,{'transaction':_0x5e6e7b})['then'](function(){return BPromise[_0xdd52('0x70')](_0x369a37,function(_0x387065){return db[_0xdd52('0x5d')][_0xdd52('0x71')]({'where':{'UserId':_0x387065['id'],'FaxQueueId':_0x5d1f12[_0xdd52('0x4e')]['id']},'transaction':_0x5e6e7b});});})['then'](function(){_0x369a37[_0xdd52('0x72')](function(_0x296395){socket['emit']('userFaxQueue:save',{'UserId':_0x296395['id'],'FaxQueueId':_0x361869['id']});});});});});}})[_0xdd52('0x29')](respondWithStatusCode(_0x1d803f,null))[_0xdd52('0x4c')](handleError(_0x1d803f,null));};exports['removeTeams']=function(_0x574314,_0x196a58,_0x93cfde){return db[_0xdd52('0x68')]['findAll']({'where':{'id':_0x574314[_0xdd52('0x38')][_0xdd52('0x73')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0xdd52('0x69'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x196a58,null))[_0xdd52('0x29')](function(_0x468fba){var _0x498e7c=_[_0xdd52('0x31')](_0x468fba,'id');var _0x12e7ea=[];var _0xad7510=[];var _0x2ec76c=squel[_0xdd52('0x74')]();_0x2ec76c['field'](_0xdd52('0x75'))['from'](_0xdd52('0x76'),'tq')[_0xdd52('0x77')](_0xdd52('0x78'),'ut',_0xdd52('0x79'))['where'](_0xdd52('0x7a'),_0x574314[_0xdd52('0x4e')]['id']);for(var _0x287af4=0x0;_0x287af4<_0x468fba[_0xdd52('0x3e')];_0x287af4+=0x1){let _0xf18f63=_0x468fba[_0x287af4];for(var _0x245155=0x0;_0x245155<_0xf18f63[_0xdd52('0x69')][_0xdd52('0x3e')];_0x245155+=0x1){let _0x5c8d15=_0xf18f63[_0xdd52('0x69')][_0x245155];var _0x25132d=_0x2ec76c['clone']();_0x25132d[_0xdd52('0x43')](_0xdd52('0x7b'),_0x5c8d15['id']);_0xad7510[_0xdd52('0x7c')](db[_0xdd52('0x7d')][_0xdd52('0x38')](_0x25132d[_0xdd52('0x7e')](),{'type':db[_0xdd52('0x7d')][_0xdd52('0x7f')][_0xdd52('0x80')]})['then'](function(_0xa3ac52){if(_0xa3ac52['length']===0x1){return _0x5c8d15['id'];}else{var _0x58f832=_['every'](_[_0xdd52('0x31')](_0xa3ac52,_0xdd52('0x81')),function(_0x4a10cd){return _['includes'](_0x498e7c,_0x4a10cd);});if(_0x58f832){return _0x5c8d15['id'];}}}));}}return BPromise['all'](_0xad7510)[_0xdd52('0x29')](function(_0x301c2b){_0x12e7ea=_(_0x12e7ea)['union'](_0x301c2b)[_0xdd52('0x82')]()['value']();return db[_0xdd52('0x32')][_0xdd52('0x55')]({'where':{'id':_0x574314[_0xdd52('0x4e')]['id']}})['then'](function(_0x1c1651){return db['sequelize'][_0xdd52('0x6e')](function(_0x71bccc){return _0x1c1651[_0xdd52('0x83')](_0x574314[_0xdd52('0x38')][_0xdd52('0x73')],{'transaction':_0x71bccc})[_0xdd52('0x29')](function(){if(!_[_0xdd52('0x84')](_0x12e7ea)){return _0x1c1651[_0xdd52('0x85')](_0x12e7ea,{'transaction':_0x71bccc});}})[_0xdd52('0x29')](function(){_0x12e7ea[_0xdd52('0x72')](function(_0x1e245e){socket[_0xdd52('0x86')](_0xdd52('0x87'),{'UserId':_0x1e245e,'FaxQueueId':_0x1c1651['id']});});});});});});})[_0xdd52('0x29')](respondWithStatusCode(_0x196a58,null))[_0xdd52('0x4c')](handleError(_0x196a58,null));};exports[_0xdd52('0x88')]=function(_0x2029cc,_0x417b61,_0x868689){return db[_0xdd52('0x32')][_0xdd52('0x55')]({'where':{'id':_0x2029cc[_0xdd52('0x4e')]['id']}})[_0xdd52('0x29')](handleEntityNotFound(_0x417b61,null))[_0xdd52('0x29')](function(_0x1c2581){if(_0x1c2581){return _0x1c2581[_0xdd52('0x88')](_0x2029cc[_0xdd52('0x50')]['ids'],_[_0xdd52('0x89')](_0x2029cc[_0xdd52('0x50')],['ids','id'])||{})[_0xdd52('0x8a')](function(_0x2866dc){for(var _0x136fa7=0x0;_0x136fa7<_0x2029cc[_0xdd52('0x50')][_0xdd52('0x73')][_0xdd52('0x3e')];_0x136fa7+=0x1){socket[_0xdd52('0x86')](_0xdd52('0x8b'),{'UserId':_0x2029cc[_0xdd52('0x50')][_0xdd52('0x73')][_0x136fa7],'FaxQueueId':_0x2029cc['params']['id']});}return _0x2866dc;});}})[_0xdd52('0x29')](respondWithResult(_0x417b61,null))[_0xdd52('0x4c')](handleError(_0x417b61,null));};exports[_0xdd52('0x85')]=function(_0x167229,_0x2a908a,_0x367ea1){return db['FaxQueue'][_0xdd52('0x55')]({'where':{'id':_0x167229['params']['id']}})[_0xdd52('0x29')](handleEntityNotFound(_0x2a908a,null))['then'](function(_0x5d5623){if(_0x5d5623){return _0x5d5623[_0xdd52('0x85')](_0x167229[_0xdd52('0x38')][_0xdd52('0x73')])[_0xdd52('0x29')](function(){if(_['isArray'](_0x167229[_0xdd52('0x38')][_0xdd52('0x73')])){for(var _0x268512=0x0;_0x268512<_0x167229[_0xdd52('0x38')][_0xdd52('0x73')]['length'];_0x268512+=0x1){socket[_0xdd52('0x86')]('userFaxQueue:remove',{'UserId':Number(_0x167229[_0xdd52('0x38')][_0xdd52('0x73')][_0x268512]),'FaxQueueId':Number(_0x167229[_0xdd52('0x4e')]['id'])});}}else{socket[_0xdd52('0x86')](_0xdd52('0x87'),{'UserId':Number(_0x167229[_0xdd52('0x38')][_0xdd52('0x73')]),'FaxQueueId':Number(_0x167229[_0xdd52('0x4e')]['id'])});}});}})['then'](respondWithStatusCode(_0x2a908a,null))[_0xdd52('0x4c')](handleError(_0x2a908a,null));};exports['getAgents']=function(_0x305290,_0x436169,_0x59c41e){var _0x17c541={};var _0x5656aa={};var _0x12957c;var _0x12cffd;return db['FaxQueue'][_0xdd52('0x5b')]({'where':{'id':_0x305290['params']['id']}})['then'](handleEntityNotFound(_0x436169,null))[_0xdd52('0x29')](function(_0x3373df){if(_0x3373df){_0x12957c=_0x3373df;_0x5656aa[_0xdd52('0x37')]=_['keys'](db[_0xdd52('0x5e')][_0xdd52('0x33')]);_0x5656aa[_0xdd52('0x38')]=_['keys'](_0x305290[_0xdd52('0x38')]);_0x5656aa['filters']=_['intersection'](_0x5656aa[_0xdd52('0x37')],_0x5656aa[_0xdd52('0x38')]);_0x17c541[_0xdd52('0x3c')]=_['intersection'](_0x5656aa[_0xdd52('0x37')],qs[_0xdd52('0x3d')](_0x305290['query'][_0xdd52('0x3d')]));_0x17c541[_0xdd52('0x3c')]=_0x17c541[_0xdd52('0x3c')][_0xdd52('0x3e')]?_0x17c541[_0xdd52('0x3c')]:_0x5656aa[_0xdd52('0x37')];_0x17c541[_0xdd52('0x41')]=qs[_0xdd52('0x42')](_0x305290[_0xdd52('0x38')]['sort']);_0x17c541[_0xdd52('0x43')]=qs[_0xdd52('0x3a')](_['pick'](_0x305290[_0xdd52('0x38')],_0x5656aa[_0xdd52('0x3a')]));if(_0x305290[_0xdd52('0x38')][_0xdd52('0x45')]){_0x17c541[_0xdd52('0x43')]=_[_0xdd52('0x46')](_0x17c541[_0xdd52('0x43')],{'$or':_['map'](_0x17c541[_0xdd52('0x3c')],function(_0x3716aa){var _0x534b29={};_0x534b29[_0x3716aa]={'$like':'%'+_0x305290['query']['filter']+'%'};return _0x534b29;})});}_0x17c541=_[_0xdd52('0x46')]({},_0x17c541,_0x305290[_0xdd52('0x48')]);return _0x12957c['getAgents'](_0x17c541);}})['then'](function(_0xe5338a){if(_0xe5338a){_0x12cffd=_0xe5338a[_0xdd52('0x3e')];if(!_0x305290[_0xdd52('0x38')]['hasOwnProperty'](_0xdd52('0x40'))){_0x17c541[_0xdd52('0x23')]=qs[_0xdd52('0x23')](_0x305290['query'][_0xdd52('0x23')]);_0x17c541[_0xdd52('0x22')]=qs[_0xdd52('0x22')](_0x305290[_0xdd52('0x38')][_0xdd52('0x22')]);}return _0x12957c[_0xdd52('0x8c')](_0x17c541);}})[_0xdd52('0x29')](function(_0x561f26){if(_0x561f26){return _0x561f26?{'count':_0x12cffd,'rows':_0x561f26}:null;}})[_0xdd52('0x29')](respondWithResult(_0x436169,null))['catch'](handleError(_0x436169,null));};
\ No newline at end of file
+var _0xb7ee=['agent','faxPause','createdAt','format','SIP','Team','getTeams','addTeams','User','online','flatMap','Agents','each','forEach','emit','userFaxQueue:save','removeTeams','ids','select','field','tq.TeamId','team_has_fax_queues','user_has_teams','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','userFaxQueue:remove','addAgents','omit','spread','removeAgents','isArray','getAgents','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxQueue.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','then','get','UserProfileResource','error','stack','name','send','index','map','fieldName','type','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','merge','VIRTUAL','options','where','FaxQueue','includeAll','include','rows','show','params','rawAttributes','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','FaxQueues','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','catch','describe','getMembers','findOne','UserFaxQueue','findAll','findAndCountAll','UserId'];(function(_0x3b380d,_0x4bf247){var _0x54502b=function(_0x35d207){while(--_0x35d207){_0x3b380d['push'](_0x3b380d['shift']());}};_0x54502b(++_0x4bf247);}(_0xb7ee,0xba));var _0xeb7e=function(_0x106777,_0x50cf24){_0x106777=_0x106777-0x0;var _0x1168c3=_0xb7ee[_0x106777];return _0x1168c3;};'use strict';var pdf=require(_0xeb7e('0x0'));var emlformat=require(_0xeb7e('0x1'));var rimraf=require(_0xeb7e('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xeb7e('0x3'));var rp=require(_0xeb7e('0x4'));var moment=require(_0xeb7e('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xeb7e('0x6'));var util=require(_0xeb7e('0x7'));var path=require(_0xeb7e('0x8'));var sox=require(_0xeb7e('0x9'));var csv=require(_0xeb7e('0xa'));var ejs=require(_0xeb7e('0xb'));var fs=require('fs');var _=require(_0xeb7e('0xc'));var squel=require(_0xeb7e('0xd'));var crypto=require(_0xeb7e('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xeb7e('0xf'));var toCsv=require('to-csv');var querystring=require(_0xeb7e('0x10'));var Papa=require(_0xeb7e('0x11'));var Redis=require(_0xeb7e('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xeb7e('0x13'));var logger=require(_0xeb7e('0x14'))('api');var utils=require('../../config/utils');var config=require(_0xeb7e('0x15'));var licenseUtil=require(_0xeb7e('0x16'));var db=require(_0xeb7e('0x17'))['db'];config[_0xeb7e('0x18')]=_['defaults'](config['redis'],{'host':_0xeb7e('0x19'),'port':0x18eb});var socket=require(_0xeb7e('0x1a'))(new Redis(config[_0xeb7e('0x18')]));require(_0xeb7e('0x1b'))[_0xeb7e('0x1c')](socket);function respondWithStatusCode(_0x50df8b,_0x3c67d6){_0x3c67d6=_0x3c67d6||0xcc;return function(_0x3d3c08){if(_0x3d3c08){return _0x50df8b[_0xeb7e('0x1d')](_0x3c67d6);}return _0x50df8b[_0xeb7e('0x1e')](_0x3c67d6)[_0xeb7e('0x1f')]();};}function respondWithResult(_0x120008,_0x49e32e){_0x49e32e=_0x49e32e||0xc8;return function(_0x5e9fa7){if(_0x5e9fa7){return _0x120008[_0xeb7e('0x1e')](_0x49e32e)[_0xeb7e('0x20')](_0x5e9fa7);}};}function respondWithFilteredResult(_0xc9f651,_0x25bdf6){return function(_0x49c60f){if(_0x49c60f){var _0x1699ca=_0x49c60f[_0xeb7e('0x21')],_0x3cfc4a=_0x25bdf6[_0xeb7e('0x22')],_0x4e81f4=_0x25bdf6[_0xeb7e('0x22')]+_0x25bdf6[_0xeb7e('0x23')],_0x4df811;if(_0x4e81f4>=_0x1699ca){_0x4e81f4=_0x1699ca;_0x4df811=0xc8;}else{_0x4df811=0xce;}_0xc9f651[_0xeb7e('0x1e')](_0x4df811);return _0xc9f651[_0xeb7e('0x24')](_0xeb7e('0x25'),_0x3cfc4a+'-'+_0x4e81f4+'/'+_0x1699ca)['json'](_0x49c60f);}return null;};}function patchUpdates(_0x1dbad4){return function(_0x33ac95){try{jsonpatch[_0xeb7e('0x26')](_0x33ac95,_0x1dbad4,!![]);}catch(_0x182f98){return BPromise[_0xeb7e('0x27')](_0x182f98);}return _0x33ac95[_0xeb7e('0x28')]();};}function saveUpdates(_0x5b7138,_0x3701c7){return function(_0x5301bb){if(_0x5301bb){return _0x5301bb[_0xeb7e('0x29')](_0x5b7138)['then'](function(_0x14349b){return _0x14349b;});}return null;};}function removeEntity(_0x4a98fc,_0x1802d2){return function(_0x34fc45){if(_0x34fc45){return _0x34fc45[_0xeb7e('0x2a')]()[_0xeb7e('0x2b')](function(){var _0x51485d=_0x34fc45[_0xeb7e('0x2c')]({'plain':!![]});var _0x36b26d='FaxQueues';return db[_0xeb7e('0x2d')][_0xeb7e('0x2a')]({'where':{'type':_0x36b26d,'resourceId':_0x51485d['id']}})[_0xeb7e('0x2b')](function(){return _0x34fc45;});})[_0xeb7e('0x2b')](function(){_0x4a98fc['status'](0xcc)[_0xeb7e('0x1f')]();});}};}function handleEntityNotFound(_0x243835,_0x3cd7e3){return function(_0x5e9d1a){if(!_0x5e9d1a){_0x243835[_0xeb7e('0x1d')](0x194);}return _0x5e9d1a;};}function handleError(_0x1334bd,_0xdc8d55){_0xdc8d55=_0xdc8d55||0x1f4;return function(_0x190c08){logger[_0xeb7e('0x2e')](_0x190c08[_0xeb7e('0x2f')]);if(_0x190c08[_0xeb7e('0x30')]){delete _0x190c08[_0xeb7e('0x30')];}_0x1334bd[_0xeb7e('0x1e')](_0xdc8d55)[_0xeb7e('0x31')](_0x190c08);};}exports[_0xeb7e('0x32')]=function(_0x4f1034,_0x5992b3){var _0x53b281={},_0x466840={},_0x338a77={'count':0x0,'rows':[]};var _0x4ab889=_[_0xeb7e('0x33')](db['FaxQueue']['rawAttributes'],function(_0x4d2c20){return{'name':_0x4d2c20[_0xeb7e('0x34')],'type':_0x4d2c20[_0xeb7e('0x35')]['key']};});_0x466840[_0xeb7e('0x36')]=_[_0xeb7e('0x33')](_0x4ab889,_0xeb7e('0x30'));_0x466840['query']=_[_0xeb7e('0x37')](_0x4f1034[_0xeb7e('0x38')]);_0x466840[_0xeb7e('0x39')]=_[_0xeb7e('0x3a')](_0x466840['model'],_0x466840[_0xeb7e('0x38')]);_0x53b281['attributes']=_[_0xeb7e('0x3a')](_0x466840[_0xeb7e('0x36')],qs[_0xeb7e('0x3b')](_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x3b')]));_0x53b281[_0xeb7e('0x3c')]=_0x53b281[_0xeb7e('0x3c')][_0xeb7e('0x3d')]?_0x53b281[_0xeb7e('0x3c')]:_0x466840[_0xeb7e('0x36')];if(!_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x3e')](_0xeb7e('0x3f'))){_0x53b281[_0xeb7e('0x23')]=qs[_0xeb7e('0x23')](_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x23')]);_0x53b281[_0xeb7e('0x22')]=qs[_0xeb7e('0x22')](_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x22')]);}_0x53b281[_0xeb7e('0x40')]=qs[_0xeb7e('0x41')](_0x4f1034[_0xeb7e('0x38')]['sort']);_0x53b281['where']=qs[_0xeb7e('0x39')](_[_0xeb7e('0x42')](_0x4f1034[_0xeb7e('0x38')],_0x466840['filters']),_0x4ab889);if(_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x43')]){_0x53b281['where']=_[_0xeb7e('0x44')](_0x53b281['where'],{'$or':_[_0xeb7e('0x33')](_0x4ab889,function(_0x360446){if(_0x360446['type']!==_0xeb7e('0x45')){var _0x11efbd={};_0x11efbd[_0x360446[_0xeb7e('0x30')]]={'$like':'%'+_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x43')]+'%'};return _0x11efbd;}})});}_0x53b281=_[_0xeb7e('0x44')]({},_0x53b281,_0x4f1034[_0xeb7e('0x46')]);var _0x248869={'where':_0x53b281[_0xeb7e('0x47')]};return db[_0xeb7e('0x48')][_0xeb7e('0x21')](_0x248869)[_0xeb7e('0x2b')](function(_0x436ede){_0x338a77[_0xeb7e('0x21')]=_0x436ede;if(_0x4f1034[_0xeb7e('0x38')][_0xeb7e('0x49')]){_0x53b281[_0xeb7e('0x4a')]=[{'all':!![]}];}return db[_0xeb7e('0x48')]['findAll'](_0x53b281);})['then'](function(_0x558330){_0x338a77[_0xeb7e('0x4b')]=_0x558330;return _0x338a77;})[_0xeb7e('0x2b')](respondWithFilteredResult(_0x5992b3,_0x53b281))['catch'](handleError(_0x5992b3,null));};exports[_0xeb7e('0x4c')]=function(_0x2798f6,_0x720da2){var _0x363aa0={'raw':!![],'where':{'id':_0x2798f6[_0xeb7e('0x4d')]['id']}},_0xcbedaa={};_0xcbedaa[_0xeb7e('0x36')]=_['keys'](db[_0xeb7e('0x48')][_0xeb7e('0x4e')]);_0xcbedaa['query']=_[_0xeb7e('0x37')](_0x2798f6[_0xeb7e('0x38')]);_0xcbedaa['filters']=_[_0xeb7e('0x3a')](_0xcbedaa[_0xeb7e('0x36')],_0xcbedaa['query']);_0x363aa0[_0xeb7e('0x3c')]=_[_0xeb7e('0x3a')](_0xcbedaa[_0xeb7e('0x36')],qs[_0xeb7e('0x3b')](_0x2798f6[_0xeb7e('0x38')][_0xeb7e('0x3b')]));_0x363aa0['attributes']=_0x363aa0[_0xeb7e('0x3c')]['length']?_0x363aa0['attributes']:_0xcbedaa[_0xeb7e('0x36')];if(_0x2798f6[_0xeb7e('0x38')]['includeAll']){_0x363aa0['include']=[{'all':!![]}];}_0x363aa0=_[_0xeb7e('0x44')]({},_0x363aa0,_0x2798f6['options']);return db[_0xeb7e('0x48')][_0xeb7e('0x4f')](_0x363aa0)['then'](handleEntityNotFound(_0x720da2,null))['then'](respondWithResult(_0x720da2,null))['catch'](handleError(_0x720da2,null));};exports[_0xeb7e('0x50')]=function(_0x1c4742,_0x1125b6){return db[_0xeb7e('0x48')]['create'](_0x1c4742[_0xeb7e('0x51')],{})['then'](function(_0x542aed){var _0x1598f4=_0x1c4742['user'][_0xeb7e('0x2c')]({'plain':!![]});if(!_0x1598f4)throw new Error(_0xeb7e('0x52'));if(_0x1598f4[_0xeb7e('0x53')]===_0xeb7e('0x54')){var _0x6719f6=_0x542aed[_0xeb7e('0x2c')]({'plain':!![]});var _0x291201=_0xeb7e('0x55');return db[_0xeb7e('0x56')][_0xeb7e('0x4f')]({'where':{'name':_0x291201,'userProfileId':_0x1598f4[_0xeb7e('0x57')]},'raw':!![]})[_0xeb7e('0x2b')](function(_0x270010){if(_0x270010&&_0x270010[_0xeb7e('0x58')]===0x0){return db[_0xeb7e('0x2d')]['create']({'name':_0x6719f6[_0xeb7e('0x30')],'resourceId':_0x6719f6['id'],'type':_0x270010['name'],'sectionId':_0x270010['id']},{})[_0xeb7e('0x2b')](function(){return _0x542aed;});}else{return _0x542aed;}})['catch'](function(_0x449c41){logger[_0xeb7e('0x2e')](_0xeb7e('0x59'),_0x449c41);throw _0x449c41;});}return _0x542aed;})[_0xeb7e('0x2b')](respondWithResult(_0x1125b6,0xc9))['catch'](handleError(_0x1125b6,null));};exports[_0xeb7e('0x29')]=function(_0x278437,_0x3ff698){if(_0x278437[_0xeb7e('0x51')]['id']){delete _0x278437[_0xeb7e('0x51')]['id'];}return db['FaxQueue'][_0xeb7e('0x4f')]({'where':{'id':_0x278437['params']['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x3ff698,null))[_0xeb7e('0x2b')](saveUpdates(_0x278437[_0xeb7e('0x51')],null))[_0xeb7e('0x2b')](respondWithResult(_0x3ff698,null))['catch'](handleError(_0x3ff698,null));};exports['destroy']=function(_0x51419c,_0x3a6cb7){return db[_0xeb7e('0x48')][_0xeb7e('0x4f')]({'where':{'id':_0x51419c['params']['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x3a6cb7,null))[_0xeb7e('0x2b')](removeEntity(_0x3a6cb7,null))[_0xeb7e('0x5a')](handleError(_0x3a6cb7,null));};exports[_0xeb7e('0x5b')]=function(_0x5ed3ff,_0x6fe130){return db[_0xeb7e('0x48')][_0xeb7e('0x5b')]()[_0xeb7e('0x2b')](respondWithResult(_0x6fe130,null))[_0xeb7e('0x5a')](handleError(_0x6fe130,null));};exports[_0xeb7e('0x5c')]=function(_0x5b765d,_0x7fbaee,_0x4d4800){var _0x5df357={'raw':!![],'where':{}},_0x4628f0={},_0x476bee;return db['FaxQueue'][_0xeb7e('0x5d')]({'where':{'id':_0x5b765d[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x7fbaee,null))[_0xeb7e('0x2b')](function(_0x22ef5d){if(_0x22ef5d){_0x476bee=_0x22ef5d[_0xeb7e('0x2c')]({'plain':!![]});_0x4628f0[_0xeb7e('0x36')]=_[_0xeb7e('0x37')](db[_0xeb7e('0x5e')][_0xeb7e('0x4e')]);_0x4628f0[_0xeb7e('0x38')]=_[_0xeb7e('0x37')](_0x5b765d[_0xeb7e('0x38')]);_0x4628f0[_0xeb7e('0x39')]=_[_0xeb7e('0x3a')](_0x4628f0[_0xeb7e('0x36')],_0x4628f0[_0xeb7e('0x38')]);_0x5df357[_0xeb7e('0x3c')]=_[_0xeb7e('0x3a')](_0x4628f0[_0xeb7e('0x36')],qs[_0xeb7e('0x3b')](_0x5b765d[_0xeb7e('0x38')][_0xeb7e('0x3b')]));_0x5df357[_0xeb7e('0x3c')]=_0x5df357[_0xeb7e('0x3c')][_0xeb7e('0x3d')]?_0x5df357[_0xeb7e('0x3c')]:_0x4628f0[_0xeb7e('0x36')];if(!_0x5b765d[_0xeb7e('0x38')][_0xeb7e('0x3e')](_0xeb7e('0x3f'))){_0x5df357['limit']=qs[_0xeb7e('0x23')](_0x5b765d[_0xeb7e('0x38')]['limit']);_0x5df357[_0xeb7e('0x22')]=qs[_0xeb7e('0x22')](_0x5b765d[_0xeb7e('0x38')][_0xeb7e('0x22')]);}_0x5df357[_0xeb7e('0x40')]=qs[_0xeb7e('0x41')](_0x5b765d['query'][_0xeb7e('0x41')]);_0x5df357[_0xeb7e('0x47')]=qs[_0xeb7e('0x39')](_['pick'](_0x5b765d['query'],_0x4628f0[_0xeb7e('0x39')]));_0x5df357[_0xeb7e('0x47')]['FaxQueueId']=_0x22ef5d['id'];if(_0x5b765d[_0xeb7e('0x38')][_0xeb7e('0x43')]){_0x5df357['where']=_[_0xeb7e('0x44')](_0x5df357[_0xeb7e('0x47')],{'$or':_[_0xeb7e('0x33')](_0x5df357['attributes'],function(_0x121a62){var _0x300704={};_0x300704[_0x121a62]={'$like':'%'+_0x5b765d['query'][_0xeb7e('0x43')]+'%'};return _0x300704;})});}_0x5df357=_['merge']({},_0x5df357,_0x5b765d[_0xeb7e('0x46')]);return db[_0xeb7e('0x5e')][_0xeb7e('0x5f')](_0x5df357);}})[_0xeb7e('0x2b')](function(_0x488aa0){if(_0x488aa0){return db['User'][_0xeb7e('0x60')]({'where':{'id':_[_0xeb7e('0x33')](_0x488aa0,_0xeb7e('0x61')),'role':_0xeb7e('0x62')},'attributes':['id','name',_0xeb7e('0x63'),'updatedAt',_0xeb7e('0x64')]});}})[_0xeb7e('0x2b')](function(_0x144b64){if(_0x144b64){return{'count':_0x144b64[_0xeb7e('0x21')],'rows':_[_0xeb7e('0x33')](_0x144b64[_0xeb7e('0x4b')],function(_0x4fb12b){return{'membername':_0x4fb12b[_0xeb7e('0x30')],'UserId':_0x4fb12b['id'],'queue_name':_0x476bee['name'],'FaxQueueId':_0x476bee['id'],'interface':util[_0xeb7e('0x65')]('%s/%s',_0xeb7e('0x66'),_0x4fb12b[_0xeb7e('0x30')]),'penalty':0x0,'paused':_0x4fb12b[_0xeb7e('0x63')],'createdAt':_0x4fb12b['createdAt'],'updatedAt':_0x4fb12b['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})[_0xeb7e('0x2b')](respondWithFilteredResult(_0x7fbaee,_0x5df357))[_0xeb7e('0x5a')](handleError(_0x7fbaee,null));};exports['getTeams']=function(_0x2feed8,_0x476781,_0x56b73b){var _0x6fb807={};var _0x221479={};var _0x3adc91;var _0x5f59c5;return db[_0xeb7e('0x48')][_0xeb7e('0x5d')]({'where':{'id':_0x2feed8[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x476781,null))[_0xeb7e('0x2b')](function(_0x55702b){if(_0x55702b){_0x3adc91=_0x55702b;_0x221479[_0xeb7e('0x36')]=_[_0xeb7e('0x37')](db[_0xeb7e('0x67')][_0xeb7e('0x4e')]);_0x221479[_0xeb7e('0x38')]=_[_0xeb7e('0x37')](_0x2feed8[_0xeb7e('0x38')]);_0x221479[_0xeb7e('0x39')]=_['intersection'](_0x221479[_0xeb7e('0x36')],_0x221479[_0xeb7e('0x38')]);_0x6fb807[_0xeb7e('0x3c')]=_[_0xeb7e('0x3a')](_0x221479['model'],qs['fields'](_0x2feed8[_0xeb7e('0x38')]['fields']));_0x6fb807['attributes']=_0x6fb807['attributes'][_0xeb7e('0x3d')]?_0x6fb807[_0xeb7e('0x3c')]:_0x221479[_0xeb7e('0x36')];_0x6fb807[_0xeb7e('0x40')]=qs[_0xeb7e('0x41')](_0x2feed8[_0xeb7e('0x38')]['sort']);_0x6fb807['where']=qs[_0xeb7e('0x39')](_['pick'](_0x2feed8[_0xeb7e('0x38')],_0x221479[_0xeb7e('0x39')]));if(_0x2feed8['query'][_0xeb7e('0x43')]){_0x6fb807['where']=_[_0xeb7e('0x44')](_0x6fb807['where'],{'$or':_[_0xeb7e('0x33')](_0x6fb807['attributes'],function(_0x531552){var _0x342e87={};_0x342e87[_0x531552]={'$like':'%'+_0x2feed8['query']['filter']+'%'};return _0x342e87;})});}_0x6fb807=_[_0xeb7e('0x44')]({},_0x6fb807,_0x2feed8[_0xeb7e('0x46')]);return _0x3adc91[_0xeb7e('0x68')](_0x6fb807);}})[_0xeb7e('0x2b')](function(_0x58e945){if(_0x58e945){_0x5f59c5=_0x58e945[_0xeb7e('0x3d')];if(!_0x2feed8[_0xeb7e('0x38')][_0xeb7e('0x3e')](_0xeb7e('0x3f'))){_0x6fb807[_0xeb7e('0x23')]=qs['limit'](_0x2feed8[_0xeb7e('0x38')][_0xeb7e('0x23')]);_0x6fb807['offset']=qs[_0xeb7e('0x22')](_0x2feed8[_0xeb7e('0x38')][_0xeb7e('0x22')]);}return _0x3adc91[_0xeb7e('0x68')](_0x6fb807);}})[_0xeb7e('0x2b')](function(_0x2da8b9){if(_0x2da8b9){return _0x2da8b9?{'count':_0x5f59c5,'rows':_0x2da8b9}:null;}})[_0xeb7e('0x2b')](respondWithResult(_0x476781,null))[_0xeb7e('0x5a')](handleError(_0x476781,null));};exports[_0xeb7e('0x69')]=function(_0x3fa0c3,_0x3c60b6,_0x43ed14){var _0x5538ad=_0x3fa0c3[_0xeb7e('0x51')]['ids'];return db[_0xeb7e('0x67')][_0xeb7e('0x5f')]({'where':{'id':_0x5538ad},'attributes':['id'],'include':[{'model':db[_0xeb7e('0x6a')],'as':'Agents','attributes':['id',_0xeb7e('0x30'),_0xeb7e('0x6b'),'voicePause','interface'],'raw':!![]}]})['then'](function(_0x49e46a){if(_0x49e46a){var _0x10e383=_[_0xeb7e('0x6c')](_0x49e46a,function(_0x4ac21b){var _0x584ee8=_0x4ac21b[_0xeb7e('0x2c')]({'plain':!![]});return _0x584ee8[_0xeb7e('0x6d')];});return db['FaxQueue'][_0xeb7e('0x4f')]({'where':{'id':_0x3fa0c3['params']['id']}})['then'](function(_0x22bcc0){return db['sequelize']['transaction'](function(_0x1eb327){return _0x22bcc0[_0xeb7e('0x69')](_0x5538ad,{'transaction':_0x1eb327})[_0xeb7e('0x2b')](function(){return BPromise[_0xeb7e('0x6e')](_0x10e383,function(_0x2f503d){return db[_0xeb7e('0x5e')]['findOrCreate']({'where':{'UserId':_0x2f503d['id'],'FaxQueueId':_0x3fa0c3[_0xeb7e('0x4d')]['id']},'transaction':_0x1eb327});});})[_0xeb7e('0x2b')](function(){_0x10e383[_0xeb7e('0x6f')](function(_0x30ca5d){socket[_0xeb7e('0x70')](_0xeb7e('0x71'),{'UserId':_0x30ca5d['id'],'FaxQueueId':_0x22bcc0['id']});});});});});}})['then'](respondWithStatusCode(_0x3c60b6,null))['catch'](handleError(_0x3c60b6,null));};exports[_0xeb7e('0x72')]=function(_0x94a945,_0x1fedad,_0x6da153){return db['Team'][_0xeb7e('0x5f')]({'where':{'id':_0x94a945['query'][_0xeb7e('0x73')]},'attributes':['id'],'include':[{'model':db[_0xeb7e('0x6a')],'as':_0xeb7e('0x6d'),'attributes':['id'],'raw':!![]}]})[_0xeb7e('0x2b')](handleEntityNotFound(_0x1fedad,null))[_0xeb7e('0x2b')](function(_0x5a0758){var _0x1ea6da=_[_0xeb7e('0x33')](_0x5a0758,'id');var _0x317734=[];var _0x4372e1=[];var _0x2f0dcb=squel[_0xeb7e('0x74')]();_0x2f0dcb[_0xeb7e('0x75')](_0xeb7e('0x76'))['from'](_0xeb7e('0x77'),'tq')['join'](_0xeb7e('0x78'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0xeb7e('0x47')](_0xeb7e('0x79'),_0x94a945[_0xeb7e('0x4d')]['id']);for(var _0x59f680=0x0;_0x59f680<_0x5a0758['length'];_0x59f680+=0x1){let _0x18e673=_0x5a0758[_0x59f680];for(var _0x2e92b1=0x0;_0x2e92b1<_0x18e673['Agents'][_0xeb7e('0x3d')];_0x2e92b1+=0x1){let _0xbb3d60=_0x18e673[_0xeb7e('0x6d')][_0x2e92b1];var _0x147542=_0x2f0dcb[_0xeb7e('0x7a')]();_0x147542[_0xeb7e('0x47')](_0xeb7e('0x7b'),_0xbb3d60['id']);_0x4372e1[_0xeb7e('0x7c')](db[_0xeb7e('0x7d')]['query'](_0x147542['toString'](),{'type':db[_0xeb7e('0x7d')][_0xeb7e('0x7e')][_0xeb7e('0x7f')]})[_0xeb7e('0x2b')](function(_0x51cdd6){if(_0x51cdd6['length']===0x1){return _0xbb3d60['id'];}else{var _0x2451f2=_[_0xeb7e('0x80')](_['map'](_0x51cdd6,_0xeb7e('0x81')),function(_0x3af9e6){return _[_0xeb7e('0x82')](_0x1ea6da,_0x3af9e6);});if(_0x2451f2){return _0xbb3d60['id'];}}}));}}return BPromise[_0xeb7e('0x83')](_0x4372e1)[_0xeb7e('0x2b')](function(_0x585451){_0x317734=_(_0x317734)[_0xeb7e('0x84')](_0x585451)[_0xeb7e('0x85')]()[_0xeb7e('0x86')]();return db[_0xeb7e('0x48')][_0xeb7e('0x4f')]({'where':{'id':_0x94a945[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](function(_0x1b5e06){return db[_0xeb7e('0x7d')]['transaction'](function(_0x4fc251){return _0x1b5e06[_0xeb7e('0x72')](_0x94a945['query']['ids'],{'transaction':_0x4fc251})['then'](function(){if(!_['isEmpty'](_0x317734)){return _0x1b5e06['removeAgents'](_0x317734,{'transaction':_0x4fc251});}})[_0xeb7e('0x2b')](function(){_0x317734[_0xeb7e('0x6f')](function(_0x139474){socket[_0xeb7e('0x70')](_0xeb7e('0x87'),{'UserId':_0x139474,'FaxQueueId':_0x1b5e06['id']});});});});});});})[_0xeb7e('0x2b')](respondWithStatusCode(_0x1fedad,null))[_0xeb7e('0x5a')](handleError(_0x1fedad,null));};exports[_0xeb7e('0x88')]=function(_0x2250f0,_0x3497a1,_0xc9986b){return db[_0xeb7e('0x48')]['find']({'where':{'id':_0x2250f0[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x3497a1,null))[_0xeb7e('0x2b')](function(_0x594975){if(_0x594975){return _0x594975[_0xeb7e('0x88')](_0x2250f0[_0xeb7e('0x51')][_0xeb7e('0x73')],_[_0xeb7e('0x89')](_0x2250f0[_0xeb7e('0x51')],['ids','id'])||{})[_0xeb7e('0x8a')](function(_0x1c21f0){for(var _0x324b5c=0x0;_0x324b5c<_0x2250f0[_0xeb7e('0x51')][_0xeb7e('0x73')][_0xeb7e('0x3d')];_0x324b5c+=0x1){socket['emit'](_0xeb7e('0x71'),{'UserId':_0x2250f0['body']['ids'][_0x324b5c],'FaxQueueId':_0x2250f0[_0xeb7e('0x4d')]['id']});}return _0x1c21f0;});}})[_0xeb7e('0x2b')](respondWithResult(_0x3497a1,null))[_0xeb7e('0x5a')](handleError(_0x3497a1,null));};exports[_0xeb7e('0x8b')]=function(_0x5d0300,_0x2d1cff,_0x1729fe){return db[_0xeb7e('0x48')][_0xeb7e('0x4f')]({'where':{'id':_0x5d0300['params']['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0x2d1cff,null))[_0xeb7e('0x2b')](function(_0x2480cc){if(_0x2480cc){return _0x2480cc['removeAgents'](_0x5d0300[_0xeb7e('0x38')][_0xeb7e('0x73')])[_0xeb7e('0x2b')](function(){if(_[_0xeb7e('0x8c')](_0x5d0300[_0xeb7e('0x38')][_0xeb7e('0x73')])){for(var _0x5a62f9=0x0;_0x5a62f9<_0x5d0300[_0xeb7e('0x38')]['ids']['length'];_0x5a62f9+=0x1){socket[_0xeb7e('0x70')](_0xeb7e('0x87'),{'UserId':Number(_0x5d0300[_0xeb7e('0x38')]['ids'][_0x5a62f9]),'FaxQueueId':Number(_0x5d0300[_0xeb7e('0x4d')]['id'])});}}else{socket['emit'](_0xeb7e('0x87'),{'UserId':Number(_0x5d0300['query']['ids']),'FaxQueueId':Number(_0x5d0300[_0xeb7e('0x4d')]['id'])});}});}})[_0xeb7e('0x2b')](respondWithStatusCode(_0x2d1cff,null))['catch'](handleError(_0x2d1cff,null));};exports[_0xeb7e('0x8d')]=function(_0x5f1c3c,_0xff2dab,_0x2eb904){var _0x5b9535={};var _0x9642fd={};var _0x32c4a7;var _0x4cdc14;return db[_0xeb7e('0x48')][_0xeb7e('0x5d')]({'where':{'id':_0x5f1c3c[_0xeb7e('0x4d')]['id']}})[_0xeb7e('0x2b')](handleEntityNotFound(_0xff2dab,null))[_0xeb7e('0x2b')](function(_0x32a25c){if(_0x32a25c){_0x32c4a7=_0x32a25c;_0x9642fd[_0xeb7e('0x36')]=_[_0xeb7e('0x37')](db[_0xeb7e('0x6a')][_0xeb7e('0x4e')]);_0x9642fd['query']=_[_0xeb7e('0x37')](_0x5f1c3c[_0xeb7e('0x38')]);_0x9642fd[_0xeb7e('0x39')]=_['intersection'](_0x9642fd[_0xeb7e('0x36')],_0x9642fd['query']);_0x5b9535['attributes']=_[_0xeb7e('0x3a')](_0x9642fd['model'],qs['fields'](_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x3b')]));_0x5b9535[_0xeb7e('0x3c')]=_0x5b9535['attributes']['length']?_0x5b9535[_0xeb7e('0x3c')]:_0x9642fd['model'];_0x5b9535['order']=qs[_0xeb7e('0x41')](_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x41')]);_0x5b9535[_0xeb7e('0x47')]=qs[_0xeb7e('0x39')](_[_0xeb7e('0x42')](_0x5f1c3c[_0xeb7e('0x38')],_0x9642fd['filters']));if(_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x43')]){_0x5b9535[_0xeb7e('0x47')]=_[_0xeb7e('0x44')](_0x5b9535['where'],{'$or':_[_0xeb7e('0x33')](_0x5b9535['attributes'],function(_0x1fbf03){var _0x24daa3={};_0x24daa3[_0x1fbf03]={'$like':'%'+_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x43')]+'%'};return _0x24daa3;})});}_0x5b9535=_['merge']({},_0x5b9535,_0x5f1c3c[_0xeb7e('0x46')]);return _0x32c4a7[_0xeb7e('0x8d')](_0x5b9535);}})['then'](function(_0x3f3488){if(_0x3f3488){_0x4cdc14=_0x3f3488[_0xeb7e('0x3d')];if(!_0x5f1c3c['query'][_0xeb7e('0x3e')](_0xeb7e('0x3f'))){_0x5b9535[_0xeb7e('0x23')]=qs[_0xeb7e('0x23')](_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x23')]);_0x5b9535[_0xeb7e('0x22')]=qs[_0xeb7e('0x22')](_0x5f1c3c[_0xeb7e('0x38')][_0xeb7e('0x22')]);}return _0x32c4a7[_0xeb7e('0x8d')](_0x5b9535);}})[_0xeb7e('0x2b')](function(_0x414961){if(_0x414961){return _0x414961?{'count':_0x4cdc14,'rows':_0x414961}:null;}})[_0xeb7e('0x2b')](respondWithResult(_0xff2dab,null))[_0xeb7e('0x5a')](handleError(_0xff2dab,null));};
\ No newline at end of file