Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 48d94c3..7595f6a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x04c7=['eml-format','rimraf','zip-dir','fast-json-patch','request-promise','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','localhost','./faxQueue.socket','register','end','json','count','offset','limit','status','set','apply','reject','save','update','then','destroy','get','FaxQueues','error','stack','name','send','index','FaxQueue','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','merge','map','VIRTUAL','includeAll','include','findAll','rows','catch','params','length','options','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','UserFaxQueue','filter','User','findAndCountAll','agent','faxPause','updatedAt','format','%s/%s','SIP','createdAt','getTeams','findOne','pick','addTeams','ids','Team','Agents','online','interface','flatMap','sequelize','transaction','each','select','field','user_has_teams','FaxQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','removeAgents','forEach','userFaxQueue:remove','addAgents','omit','spread','emit','userFaxQueue:save','isArray','getAgents','html-pdf'];(function(_0x24f31b,_0x44b8f3){var _0x488401=function(_0x204caf){while(--_0x204caf){_0x24f31b['push'](_0x24f31b['shift']());}};_0x488401(++_0x44b8f3);}(_0x04c7,0x8b));var _0x704c=function(_0x400b6c,_0x4a6139){_0x400b6c=_0x400b6c-0x0;var _0x4c4e3e=_0x04c7[_0x400b6c];return _0x4c4e3e;};'use strict';var pdf=require(_0x704c('0x0'));var emlformat=require(_0x704c('0x1'));var rimraf=require(_0x704c('0x2'));var zipdir=require(_0x704c('0x3'));var jsonpatch=require(_0x704c('0x4'));var rp=require(_0x704c('0x5'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x704c('0x6'));var path=require(_0x704c('0x7'));var sox=require(_0x704c('0x8'));var csv=require(_0x704c('0x9'));var ejs=require(_0x704c('0xa'));var fs=require('fs');var _=require(_0x704c('0xb'));var squel=require(_0x704c('0xc'));var crypto=require(_0x704c('0xd'));var jsforce=require(_0x704c('0xe'));var deskjs=require(_0x704c('0xf'));var toCsv=require(_0x704c('0x9'));var querystring=require(_0x704c('0x10'));var Papa=require('papaparse');var Redis=require(_0x704c('0x11'));var authService=require(_0x704c('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x704c('0x13'));var hardwareService=require(_0x704c('0x14'));var logger=require(_0x704c('0x15'))('api');var utils=require(_0x704c('0x16'));var config=require(_0x704c('0x17'));var licenseUtil=require(_0x704c('0x18'));var db=require(_0x704c('0x19'))['db'];config['redis']=_[_0x704c('0x1a')](config['redis'],{'host':_0x704c('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x704c('0x1c'))[_0x704c('0x1d')](socket);function respondWithStatusCode(_0x5c6157,_0x52815b){_0x52815b=_0x52815b||0xcc;return function(_0x506948){if(_0x506948){return _0x5c6157['sendStatus'](_0x52815b);}return _0x5c6157['status'](_0x52815b)[_0x704c('0x1e')]();};}function respondWithResult(_0xd21861,_0x367d9c){_0x367d9c=_0x367d9c||0xc8;return function(_0x228717){if(_0x228717){return _0xd21861['status'](_0x367d9c)[_0x704c('0x1f')](_0x228717);}};}function respondWithFilteredResult(_0xf002b,_0xe1f6c1){return function(_0x53b737){if(_0x53b737){var _0x11ff15=_0x53b737[_0x704c('0x20')],_0x573ffe=_0xe1f6c1[_0x704c('0x21')],_0x2451c3=_0xe1f6c1['offset']+_0xe1f6c1[_0x704c('0x22')],_0x1041c4;if(_0x2451c3>=_0x11ff15){_0x2451c3=_0x11ff15;_0x1041c4=0xc8;}else{_0x1041c4=0xce;}_0xf002b[_0x704c('0x23')](_0x1041c4);return _0xf002b[_0x704c('0x24')]('Content-Range',_0x573ffe+'-'+_0x2451c3+'/'+_0x11ff15)['json'](_0x53b737);}return null;};}function patchUpdates(_0x5eef5c){return function(_0x2be879){try{jsonpatch[_0x704c('0x25')](_0x2be879,_0x5eef5c,!![]);}catch(_0x128823){return BPromise[_0x704c('0x26')](_0x128823);}return _0x2be879[_0x704c('0x27')]();};}function saveUpdates(_0x5a8181,_0x1e90e8){return function(_0x312b91){if(_0x312b91){return _0x312b91[_0x704c('0x28')](_0x5a8181)[_0x704c('0x29')](function(_0x22c13b){return _0x22c13b;});}return null;};}function removeEntity(_0x3ae027,_0x4c45ff){return function(_0xa9a9fc){if(_0xa9a9fc){return _0xa9a9fc[_0x704c('0x2a')]()['then'](function(){var _0x7cbdcd=_0xa9a9fc[_0x704c('0x2b')]({'plain':!![]});var _0x234586=_0x704c('0x2c');return db['UserProfileResource'][_0x704c('0x2a')]({'where':{'type':_0x234586,'resourceId':_0x7cbdcd['id']}})[_0x704c('0x29')](function(){return _0xa9a9fc;});})[_0x704c('0x29')](function(){_0x3ae027[_0x704c('0x23')](0xcc)[_0x704c('0x1e')]();});}};}function handleEntityNotFound(_0x31f363,_0x1018c8){return function(_0x428c5c){if(!_0x428c5c){_0x31f363['sendStatus'](0x194);}return _0x428c5c;};}function handleError(_0xd7a0c2,_0x4eee79){_0x4eee79=_0x4eee79||0x1f4;return function(_0x5a779a){logger[_0x704c('0x2d')](_0x5a779a[_0x704c('0x2e')]);if(_0x5a779a['name']){delete _0x5a779a[_0x704c('0x2f')];}_0xd7a0c2[_0x704c('0x23')](_0x4eee79)[_0x704c('0x30')](_0x5a779a);};}exports[_0x704c('0x31')]=function(_0x44c7ab,_0x3d4ead){var _0x2b9673={},_0x42de48={},_0x18cb33={'count':0x0,'rows':[]};var _0x4db536=_['map'](db[_0x704c('0x32')][_0x704c('0x33')],function(_0x55675e){return{'name':_0x55675e[_0x704c('0x34')],'type':_0x55675e[_0x704c('0x35')][_0x704c('0x36')]};});_0x42de48[_0x704c('0x37')]=_['map'](_0x4db536,'name');_0x42de48['query']=_[_0x704c('0x38')](_0x44c7ab[_0x704c('0x39')]);_0x42de48[_0x704c('0x3a')]=_['intersection'](_0x42de48[_0x704c('0x37')],_0x42de48[_0x704c('0x39')]);_0x2b9673[_0x704c('0x3b')]=_[_0x704c('0x3c')](_0x42de48[_0x704c('0x37')],qs[_0x704c('0x3d')](_0x44c7ab[_0x704c('0x39')][_0x704c('0x3d')]));_0x2b9673[_0x704c('0x3b')]=_0x2b9673[_0x704c('0x3b')]['length']?_0x2b9673[_0x704c('0x3b')]:_0x42de48[_0x704c('0x37')];if(!_0x44c7ab[_0x704c('0x39')][_0x704c('0x3e')](_0x704c('0x3f'))){_0x2b9673[_0x704c('0x22')]=qs[_0x704c('0x22')](_0x44c7ab['query'][_0x704c('0x22')]);_0x2b9673[_0x704c('0x21')]=qs[_0x704c('0x21')](_0x44c7ab['query'][_0x704c('0x21')]);}_0x2b9673[_0x704c('0x40')]=qs[_0x704c('0x41')](_0x44c7ab[_0x704c('0x39')][_0x704c('0x41')]);_0x2b9673[_0x704c('0x42')]=qs[_0x704c('0x3a')](_['pick'](_0x44c7ab[_0x704c('0x39')],_0x42de48[_0x704c('0x3a')]),_0x4db536);if(_0x44c7ab['query']['filter']){_0x2b9673['where']=_[_0x704c('0x43')](_0x2b9673['where'],{'$or':_[_0x704c('0x44')](_0x4db536,function(_0xf2e64c){if(_0xf2e64c[_0x704c('0x35')]!==_0x704c('0x45')){var _0x3a51db={};_0x3a51db[_0xf2e64c['name']]={'$like':'%'+_0x44c7ab[_0x704c('0x39')]['filter']+'%'};return _0x3a51db;}})});}_0x2b9673=_['merge']({},_0x2b9673,_0x44c7ab['options']);var _0x287faa={'where':_0x2b9673[_0x704c('0x42')]};return db[_0x704c('0x32')][_0x704c('0x20')](_0x287faa)['then'](function(_0x34e046){_0x18cb33[_0x704c('0x20')]=_0x34e046;if(_0x44c7ab[_0x704c('0x39')][_0x704c('0x46')]){_0x2b9673[_0x704c('0x47')]=[{'all':!![]}];}return db[_0x704c('0x32')][_0x704c('0x48')](_0x2b9673);})[_0x704c('0x29')](function(_0x3e9443){_0x18cb33[_0x704c('0x49')]=_0x3e9443;return _0x18cb33;})[_0x704c('0x29')](respondWithFilteredResult(_0x3d4ead,_0x2b9673))[_0x704c('0x4a')](handleError(_0x3d4ead,null));};exports['show']=function(_0x157b14,_0xa544f2){var _0x18ac73={'raw':!![],'where':{'id':_0x157b14[_0x704c('0x4b')]['id']}},_0x1bd516={};_0x1bd516[_0x704c('0x37')]=_[_0x704c('0x38')](db['FaxQueue'][_0x704c('0x33')]);_0x1bd516[_0x704c('0x39')]=_[_0x704c('0x38')](_0x157b14[_0x704c('0x39')]);_0x1bd516[_0x704c('0x3a')]=_[_0x704c('0x3c')](_0x1bd516['model'],_0x1bd516[_0x704c('0x39')]);_0x18ac73['attributes']=_[_0x704c('0x3c')](_0x1bd516[_0x704c('0x37')],qs[_0x704c('0x3d')](_0x157b14[_0x704c('0x39')][_0x704c('0x3d')]));_0x18ac73[_0x704c('0x3b')]=_0x18ac73[_0x704c('0x3b')][_0x704c('0x4c')]?_0x18ac73['attributes']:_0x1bd516[_0x704c('0x37')];if(_0x157b14[_0x704c('0x39')][_0x704c('0x46')]){_0x18ac73[_0x704c('0x47')]=[{'all':!![]}];}_0x18ac73=_[_0x704c('0x43')]({},_0x18ac73,_0x157b14[_0x704c('0x4d')]);return db['FaxQueue'][_0x704c('0x4e')](_0x18ac73)['then'](handleEntityNotFound(_0xa544f2,null))[_0x704c('0x29')](respondWithResult(_0xa544f2,null))[_0x704c('0x4a')](handleError(_0xa544f2,null));};exports[_0x704c('0x4f')]=function(_0x5b03c1,_0x39c15b){return db[_0x704c('0x32')][_0x704c('0x4f')](_0x5b03c1[_0x704c('0x50')],{})[_0x704c('0x29')](function(_0x25f5d1){var _0x5eb881=_0x5b03c1[_0x704c('0x51')]['get']({'plain':!![]});if(!_0x5eb881)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5eb881[_0x704c('0x52')]==='user'){var _0x1c1055=_0x25f5d1[_0x704c('0x2b')]({'plain':!![]});var _0x32fb7f=_0x704c('0x2c');return db[_0x704c('0x53')][_0x704c('0x4e')]({'where':{'name':_0x32fb7f,'userProfileId':_0x5eb881[_0x704c('0x54')]},'raw':!![]})['then'](function(_0x9c0452){if(_0x9c0452&&_0x9c0452[_0x704c('0x55')]===0x0){return db['UserProfileResource'][_0x704c('0x4f')]({'name':_0x1c1055[_0x704c('0x2f')],'resourceId':_0x1c1055['id'],'type':_0x9c0452[_0x704c('0x2f')],'sectionId':_0x9c0452['id']},{})[_0x704c('0x29')](function(){return _0x25f5d1;});}else{return _0x25f5d1;}})[_0x704c('0x4a')](function(_0x3dcc18){logger[_0x704c('0x2d')](_0x704c('0x56'),_0x3dcc18);throw _0x3dcc18;});}return _0x25f5d1;})[_0x704c('0x29')](respondWithResult(_0x39c15b,0xc9))[_0x704c('0x4a')](handleError(_0x39c15b,null));};exports['update']=function(_0x3ad891,_0x4229a9){if(_0x3ad891['body']['id']){delete _0x3ad891[_0x704c('0x50')]['id'];}return db[_0x704c('0x32')][_0x704c('0x4e')]({'where':{'id':_0x3ad891[_0x704c('0x4b')]['id']}})['then'](handleEntityNotFound(_0x4229a9,null))[_0x704c('0x29')](saveUpdates(_0x3ad891[_0x704c('0x50')],null))[_0x704c('0x29')](respondWithResult(_0x4229a9,null))[_0x704c('0x4a')](handleError(_0x4229a9,null));};exports[_0x704c('0x2a')]=function(_0x4a8448,_0x36e52d){return db['FaxQueue'][_0x704c('0x4e')]({'where':{'id':_0x4a8448[_0x704c('0x4b')]['id']}})['then'](handleEntityNotFound(_0x36e52d,null))[_0x704c('0x29')](removeEntity(_0x36e52d,null))['catch'](handleError(_0x36e52d,null));};exports['describe']=function(_0x55a450,_0x144c35){return db['FaxQueue'][_0x704c('0x57')]()[_0x704c('0x29')](respondWithResult(_0x144c35,null))[_0x704c('0x4a')](handleError(_0x144c35,null));};exports[_0x704c('0x58')]=function(_0x463027,_0x3c5263,_0x374676){var _0x2ae6bf={'raw':!![],'where':{}},_0x3d893b={},_0x48d16e;return db[_0x704c('0x32')]['findOne']({'where':{'id':_0x463027['params']['id']}})[_0x704c('0x29')](handleEntityNotFound(_0x3c5263,null))[_0x704c('0x29')](function(_0x358888){if(_0x358888){_0x48d16e=_0x358888[_0x704c('0x2b')]({'plain':!![]});_0x3d893b[_0x704c('0x37')]=_[_0x704c('0x38')](db[_0x704c('0x59')]['rawAttributes']);_0x3d893b[_0x704c('0x39')]=_[_0x704c('0x38')](_0x463027[_0x704c('0x39')]);_0x3d893b[_0x704c('0x3a')]=_[_0x704c('0x3c')](_0x3d893b[_0x704c('0x37')],_0x3d893b['query']);_0x2ae6bf[_0x704c('0x3b')]=_[_0x704c('0x3c')](_0x3d893b[_0x704c('0x37')],qs[_0x704c('0x3d')](_0x463027[_0x704c('0x39')]['fields']));_0x2ae6bf['attributes']=_0x2ae6bf[_0x704c('0x3b')][_0x704c('0x4c')]?_0x2ae6bf[_0x704c('0x3b')]:_0x3d893b[_0x704c('0x37')];if(!_0x463027[_0x704c('0x39')]['hasOwnProperty']('nolimit')){_0x2ae6bf[_0x704c('0x22')]=qs['limit'](_0x463027[_0x704c('0x39')][_0x704c('0x22')]);_0x2ae6bf[_0x704c('0x21')]=qs[_0x704c('0x21')](_0x463027[_0x704c('0x39')][_0x704c('0x21')]);}_0x2ae6bf[_0x704c('0x40')]=qs[_0x704c('0x41')](_0x463027[_0x704c('0x39')][_0x704c('0x41')]);_0x2ae6bf[_0x704c('0x42')]=qs[_0x704c('0x3a')](_['pick'](_0x463027[_0x704c('0x39')],_0x3d893b[_0x704c('0x3a')]));_0x2ae6bf[_0x704c('0x42')]['FaxQueueId']=_0x358888['id'];if(_0x463027[_0x704c('0x39')]['filter']){_0x2ae6bf['where']=_['merge'](_0x2ae6bf[_0x704c('0x42')],{'$or':_['map'](_0x2ae6bf[_0x704c('0x3b')],function(_0x32759a){var _0x3b9dcd={};_0x3b9dcd[_0x32759a]={'$like':'%'+_0x463027['query'][_0x704c('0x5a')]+'%'};return _0x3b9dcd;})});}_0x2ae6bf=_[_0x704c('0x43')]({},_0x2ae6bf,_0x463027[_0x704c('0x4d')]);return db['UserFaxQueue'][_0x704c('0x48')](_0x2ae6bf);}})[_0x704c('0x29')](function(_0x56bc46){if(_0x56bc46){return db[_0x704c('0x5b')][_0x704c('0x5c')]({'where':{'id':_[_0x704c('0x44')](_0x56bc46,'UserId'),'role':_0x704c('0x5d')},'attributes':['id',_0x704c('0x2f'),_0x704c('0x5e'),_0x704c('0x5f'),'createdAt']});}})['then'](function(_0xc209fe){if(_0xc209fe){return{'count':_0xc209fe[_0x704c('0x20')],'rows':_[_0x704c('0x44')](_0xc209fe[_0x704c('0x49')],function(_0xaf8d44){return{'membername':_0xaf8d44['name'],'UserId':_0xaf8d44['id'],'queue_name':_0x48d16e[_0x704c('0x2f')],'FaxQueueId':_0x48d16e['id'],'interface':util[_0x704c('0x60')](_0x704c('0x61'),_0x704c('0x62'),_0xaf8d44['name']),'penalty':0x0,'paused':_0xaf8d44[_0x704c('0x5e')],'createdAt':_0xaf8d44[_0x704c('0x63')],'updatedAt':_0xaf8d44['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x3c5263,_0x2ae6bf))[_0x704c('0x4a')](handleError(_0x3c5263,null));};exports[_0x704c('0x64')]=function(_0x1f5778,_0x5a5a77,_0x38a2fb){var _0x1280d4={};var _0x4aac89={};var _0x3950d4;var _0x4e88d9;return db[_0x704c('0x32')][_0x704c('0x65')]({'where':{'id':_0x1f5778[_0x704c('0x4b')]['id']}})[_0x704c('0x29')](handleEntityNotFound(_0x5a5a77,null))['then'](function(_0x5901c9){if(_0x5901c9){_0x3950d4=_0x5901c9;_0x4aac89['model']=_[_0x704c('0x38')](db['Team'][_0x704c('0x33')]);_0x4aac89[_0x704c('0x39')]=_['keys'](_0x1f5778['query']);_0x4aac89['filters']=_['intersection'](_0x4aac89['model'],_0x4aac89[_0x704c('0x39')]);_0x1280d4[_0x704c('0x3b')]=_[_0x704c('0x3c')](_0x4aac89[_0x704c('0x37')],qs['fields'](_0x1f5778[_0x704c('0x39')][_0x704c('0x3d')]));_0x1280d4[_0x704c('0x3b')]=_0x1280d4[_0x704c('0x3b')][_0x704c('0x4c')]?_0x1280d4[_0x704c('0x3b')]:_0x4aac89[_0x704c('0x37')];_0x1280d4[_0x704c('0x40')]=qs[_0x704c('0x41')](_0x1f5778[_0x704c('0x39')][_0x704c('0x41')]);_0x1280d4[_0x704c('0x42')]=qs[_0x704c('0x3a')](_[_0x704c('0x66')](_0x1f5778[_0x704c('0x39')],_0x4aac89['filters']));if(_0x1f5778[_0x704c('0x39')]['filter']){_0x1280d4[_0x704c('0x42')]=_[_0x704c('0x43')](_0x1280d4[_0x704c('0x42')],{'$or':_[_0x704c('0x44')](_0x1280d4['attributes'],function(_0x542145){var _0x251ac3={};_0x251ac3[_0x542145]={'$like':'%'+_0x1f5778[_0x704c('0x39')][_0x704c('0x5a')]+'%'};return _0x251ac3;})});}_0x1280d4=_[_0x704c('0x43')]({},_0x1280d4,_0x1f5778[_0x704c('0x4d')]);return _0x3950d4[_0x704c('0x64')](_0x1280d4);}})[_0x704c('0x29')](function(_0x5000d1){if(_0x5000d1){_0x4e88d9=_0x5000d1[_0x704c('0x4c')];if(!_0x1f5778[_0x704c('0x39')][_0x704c('0x3e')]('nolimit')){_0x1280d4[_0x704c('0x22')]=qs[_0x704c('0x22')](_0x1f5778[_0x704c('0x39')][_0x704c('0x22')]);_0x1280d4[_0x704c('0x21')]=qs[_0x704c('0x21')](_0x1f5778[_0x704c('0x39')][_0x704c('0x21')]);}return _0x3950d4[_0x704c('0x64')](_0x1280d4);}})['then'](function(_0xda5651){if(_0xda5651){return _0xda5651?{'count':_0x4e88d9,'rows':_0xda5651}:null;}})['then'](respondWithResult(_0x5a5a77,null))[_0x704c('0x4a')](handleError(_0x5a5a77,null));};exports[_0x704c('0x67')]=function(_0x3dab1f,_0x6574a0,_0x779eec){var _0x20d127=_0x3dab1f[_0x704c('0x50')][_0x704c('0x68')];return db[_0x704c('0x69')][_0x704c('0x48')]({'where':{'id':_0x20d127},'attributes':['id'],'include':[{'model':db['User'],'as':_0x704c('0x6a'),'attributes':['id','name',_0x704c('0x6b'),'voicePause',_0x704c('0x6c')],'raw':!![]}]})[_0x704c('0x29')](function(_0x2f8d15){if(_0x2f8d15){var _0x1cab04=_[_0x704c('0x6d')](_0x2f8d15,function(_0x59eab3){var _0x3796d8=_0x59eab3[_0x704c('0x2b')]({'plain':!![]});return _0x3796d8[_0x704c('0x6a')];});return db[_0x704c('0x32')]['find']({'where':{'id':_0x3dab1f[_0x704c('0x4b')]['id']}})[_0x704c('0x29')](function(_0x44f5d1){return db[_0x704c('0x6e')][_0x704c('0x6f')](function(_0x38fb08){return _0x44f5d1['addTeams'](_0x20d127,{'transaction':_0x38fb08})[_0x704c('0x29')](function(){return BPromise[_0x704c('0x70')](_0x1cab04,function(_0x2062a0){return db[_0x704c('0x59')]['findOrCreate']({'where':{'UserId':_0x2062a0['id'],'FaxQueueId':_0x3dab1f[_0x704c('0x4b')]['id']},'transaction':_0x38fb08});});})[_0x704c('0x29')](function(){_0x1cab04['forEach'](function(_0x20ab09){socket['emit']('userFaxQueue:save',{'UserId':_0x20ab09['id'],'FaxQueueId':_0x44f5d1['id']});});});});});}})[_0x704c('0x29')](respondWithStatusCode(_0x6574a0,null))[_0x704c('0x4a')](handleError(_0x6574a0,null));};exports['removeTeams']=function(_0x38ed79,_0x4360c2,_0x3d4f63){return db[_0x704c('0x69')][_0x704c('0x48')]({'where':{'id':_0x38ed79['query'][_0x704c('0x68')]},'attributes':['id'],'include':[{'model':db[_0x704c('0x5b')],'as':_0x704c('0x6a'),'attributes':['id'],'raw':!![]}]})[_0x704c('0x29')](handleEntityNotFound(_0x4360c2,null))['then'](function(_0x9cde7b){var _0x1b7de1=_[_0x704c('0x44')](_0x9cde7b,'id');var _0x49f6e8=[];var _0xca7edc=[];var _0x5ed385=squel[_0x704c('0x71')]();_0x5ed385[_0x704c('0x72')]('tq.TeamId')['from']('team_has_fax_queues','tq')['join'](_0x704c('0x73'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x704c('0x42')](_0x704c('0x74'),_0x38ed79[_0x704c('0x4b')]['id']);for(var _0x422e8a=0x0;_0x422e8a<_0x9cde7b[_0x704c('0x4c')];_0x422e8a+=0x1){let _0x42f5f0=_0x9cde7b[_0x422e8a];for(var _0x16326b=0x0;_0x16326b<_0x42f5f0[_0x704c('0x6a')][_0x704c('0x4c')];_0x16326b+=0x1){let _0x5f25d8=_0x42f5f0['Agents'][_0x16326b];var _0x17a398=_0x5ed385['clone']();_0x17a398[_0x704c('0x42')](_0x704c('0x75'),_0x5f25d8['id']);_0xca7edc[_0x704c('0x76')](db['sequelize'][_0x704c('0x39')](_0x17a398[_0x704c('0x77')](),{'type':db[_0x704c('0x6e')][_0x704c('0x78')][_0x704c('0x79')]})[_0x704c('0x29')](function(_0x3d2584){if(_0x3d2584[_0x704c('0x4c')]===0x1){return _0x5f25d8['id'];}else{var _0xbe470e=_[_0x704c('0x7a')](_[_0x704c('0x44')](_0x3d2584,_0x704c('0x7b')),function(_0x52aead){return _[_0x704c('0x7c')](_0x1b7de1,_0x52aead);});if(_0xbe470e){return _0x5f25d8['id'];}}}));}}return BPromise[_0x704c('0x7d')](_0xca7edc)[_0x704c('0x29')](function(_0x4a65f0){_0x49f6e8=_(_0x49f6e8)[_0x704c('0x7e')](_0x4a65f0)[_0x704c('0x7f')]()[_0x704c('0x80')]();return db[_0x704c('0x32')][_0x704c('0x4e')]({'where':{'id':_0x38ed79['params']['id']}})[_0x704c('0x29')](function(_0x42d56b){return db[_0x704c('0x6e')][_0x704c('0x6f')](function(_0x430001){return _0x42d56b['removeTeams'](_0x38ed79[_0x704c('0x39')][_0x704c('0x68')],{'transaction':_0x430001})[_0x704c('0x29')](function(){if(!_[_0x704c('0x81')](_0x49f6e8)){return _0x42d56b[_0x704c('0x82')](_0x49f6e8,{'transaction':_0x430001});}})[_0x704c('0x29')](function(){_0x49f6e8[_0x704c('0x83')](function(_0x5390dd){socket['emit'](_0x704c('0x84'),{'UserId':_0x5390dd,'FaxQueueId':_0x42d56b['id']});});});});});});})[_0x704c('0x29')](respondWithStatusCode(_0x4360c2,null))[_0x704c('0x4a')](handleError(_0x4360c2,null));};exports[_0x704c('0x85')]=function(_0x4711de,_0x1c44fe,_0x25ee90){return db[_0x704c('0x32')][_0x704c('0x4e')]({'where':{'id':_0x4711de[_0x704c('0x4b')]['id']}})[_0x704c('0x29')](handleEntityNotFound(_0x1c44fe,null))[_0x704c('0x29')](function(_0x532ef8){if(_0x532ef8){return _0x532ef8[_0x704c('0x85')](_0x4711de[_0x704c('0x50')]['ids'],_[_0x704c('0x86')](_0x4711de[_0x704c('0x50')],[_0x704c('0x68'),'id'])||{})[_0x704c('0x87')](function(_0x45d8cf){for(var _0x279793=0x0;_0x279793<_0x4711de[_0x704c('0x50')]['ids'][_0x704c('0x4c')];_0x279793+=0x1){socket[_0x704c('0x88')](_0x704c('0x89'),{'UserId':_0x4711de['body'][_0x704c('0x68')][_0x279793],'FaxQueueId':_0x4711de[_0x704c('0x4b')]['id']});}return _0x45d8cf;});}})[_0x704c('0x29')](respondWithResult(_0x1c44fe,null))['catch'](handleError(_0x1c44fe,null));};exports['removeAgents']=function(_0x22cef7,_0x311cbb,_0x3c4fed){return db[_0x704c('0x32')]['find']({'where':{'id':_0x22cef7[_0x704c('0x4b')]['id']}})[_0x704c('0x29')](handleEntityNotFound(_0x311cbb,null))[_0x704c('0x29')](function(_0x283021){if(_0x283021){return _0x283021['removeAgents'](_0x22cef7[_0x704c('0x39')]['ids'])['then'](function(){if(_[_0x704c('0x8a')](_0x22cef7[_0x704c('0x39')][_0x704c('0x68')])){for(var _0x26b3c3=0x0;_0x26b3c3<_0x22cef7['query'][_0x704c('0x68')]['length'];_0x26b3c3+=0x1){socket[_0x704c('0x88')](_0x704c('0x84'),{'UserId':Number(_0x22cef7[_0x704c('0x39')]['ids'][_0x26b3c3]),'FaxQueueId':Number(_0x22cef7['params']['id'])});}}else{socket[_0x704c('0x88')](_0x704c('0x84'),{'UserId':Number(_0x22cef7[_0x704c('0x39')][_0x704c('0x68')]),'FaxQueueId':Number(_0x22cef7[_0x704c('0x4b')]['id'])});}});}})[_0x704c('0x29')](respondWithStatusCode(_0x311cbb,null))[_0x704c('0x4a')](handleError(_0x311cbb,null));};exports[_0x704c('0x8b')]=function(_0x10a566,_0x105e4f,_0x2e7b56){var _0x197cb6={};var _0x333397={};var _0xd4df16;var _0x41cb78;return db[_0x704c('0x32')][_0x704c('0x65')]({'where':{'id':_0x10a566['params']['id']}})[_0x704c('0x29')](handleEntityNotFound(_0x105e4f,null))['then'](function(_0x17ee06){if(_0x17ee06){_0xd4df16=_0x17ee06;_0x333397['model']=_[_0x704c('0x38')](db[_0x704c('0x5b')][_0x704c('0x33')]);_0x333397[_0x704c('0x39')]=_['keys'](_0x10a566[_0x704c('0x39')]);_0x333397['filters']=_[_0x704c('0x3c')](_0x333397['model'],_0x333397[_0x704c('0x39')]);_0x197cb6[_0x704c('0x3b')]=_[_0x704c('0x3c')](_0x333397[_0x704c('0x37')],qs[_0x704c('0x3d')](_0x10a566[_0x704c('0x39')]['fields']));_0x197cb6[_0x704c('0x3b')]=_0x197cb6[_0x704c('0x3b')][_0x704c('0x4c')]?_0x197cb6[_0x704c('0x3b')]:_0x333397[_0x704c('0x37')];_0x197cb6[_0x704c('0x40')]=qs[_0x704c('0x41')](_0x10a566['query'][_0x704c('0x41')]);_0x197cb6['where']=qs['filters'](_[_0x704c('0x66')](_0x10a566[_0x704c('0x39')],_0x333397['filters']));if(_0x10a566['query'][_0x704c('0x5a')]){_0x197cb6[_0x704c('0x42')]=_[_0x704c('0x43')](_0x197cb6[_0x704c('0x42')],{'$or':_[_0x704c('0x44')](_0x197cb6['attributes'],function(_0x84d441){var _0x2ac0e6={};_0x2ac0e6[_0x84d441]={'$like':'%'+_0x10a566['query'][_0x704c('0x5a')]+'%'};return _0x2ac0e6;})});}_0x197cb6=_[_0x704c('0x43')]({},_0x197cb6,_0x10a566['options']);return _0xd4df16['getAgents'](_0x197cb6);}})[_0x704c('0x29')](function(_0x19e20c){if(_0x19e20c){_0x41cb78=_0x19e20c[_0x704c('0x4c')];if(!_0x10a566['query'][_0x704c('0x3e')](_0x704c('0x3f'))){_0x197cb6[_0x704c('0x22')]=qs['limit'](_0x10a566[_0x704c('0x39')][_0x704c('0x22')]);_0x197cb6[_0x704c('0x21')]=qs['offset'](_0x10a566['query'][_0x704c('0x21')]);}return _0xd4df16[_0x704c('0x8b')](_0x197cb6);}})[_0x704c('0x29')](function(_0x31044a){if(_0x31044a){return _0x31044a?{'count':_0x41cb78,'rows':_0x31044a}:null;}})[_0x704c('0x29')](respondWithResult(_0x105e4f,null))[_0x704c('0x4a')](handleError(_0x105e4f,null));};
\ No newline at end of file
+var _0x8921=['transaction','each','findOrCreate','forEach','userFaxQueue:save','ids','select','tq.TeamId','team_has_fax_queues','join','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','removeTeams','isEmpty','emit','userFaxQueue:remove','addAgents','omit','spread','removeAgents','isArray','getAgents','bluebird','lodash','squel','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','./faxQueue.socket','register','status','end','json','undefined','limit','count','offset','Content-Range','update','destroy','get','FaxQueues','UserProfileResource','then','error','name','send','map','FaxQueue','rawAttributes','fieldName','type','getOptions','include','findAll','rows','catch','show','params','model','query','filters','intersection','attributes','fields','includeAll','merge','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','describe','findOne','keys','hasOwnProperty','nolimit','order','sort','pick','where','FaxQueueId','filter','UserFaxQueue','User','findAndCountAll','UserId','agent','faxPause','%s/%s','SIP','createdAt','updatedAt','Team','length','getTeams','addTeams','Agents','online','interface','sequelize'];(function(_0x2ffef7,_0x1359f3){var _0x12f19c=function(_0x133945){while(--_0x133945){_0x2ffef7['push'](_0x2ffef7['shift']());}};_0x12f19c(++_0x1359f3);}(_0x8921,0x9a));var _0x1892=function(_0x4998a0,_0x21bb70){_0x4998a0=_0x4998a0-0x0;var _0x1931ad=_0x8921[_0x4998a0];return _0x1931ad;};'use strict';var BPromise=require(_0x1892('0x0'));var util=require('util');var _=require(_0x1892('0x1'));var squel=require(_0x1892('0x2'));var Redis=require(_0x1892('0x3'));var qs=require(_0x1892('0x4'));var logger=require(_0x1892('0x5'))(_0x1892('0x6'));var config=require(_0x1892('0x7'));var db=require(_0x1892('0x8'))['db'];config[_0x1892('0x9')]=_[_0x1892('0xa')](config[_0x1892('0x9')],{'host':_0x1892('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x1892('0x9')]));require(_0x1892('0xc'))[_0x1892('0xd')](socket);function respondWithStatusCode(_0x18d62f,_0x1e8c17){_0x1e8c17=_0x1e8c17||0xcc;return function(_0xb50f8a){if(_0xb50f8a){return _0x18d62f['sendStatus'](_0x1e8c17);}return _0x18d62f[_0x1892('0xe')](_0x1e8c17)[_0x1892('0xf')]();};}function respondWithResult(_0x7435c2,_0x25683b){_0x25683b=_0x25683b||0xc8;return function(_0x1efeed){if(_0x1efeed){return _0x7435c2[_0x1892('0xe')](_0x25683b)[_0x1892('0x10')](_0x1efeed);}};}function respondWithFilteredResult(_0x531383,_0x3b2927){return function(_0x22baab){if(_0x22baab){var _0xe5ef78=typeof _0x3b2927['offset']===_0x1892('0x11')&&typeof _0x3b2927[_0x1892('0x12')]===_0x1892('0x11');var _0x53c709=_0x22baab[_0x1892('0x13')];var _0xeb57f7=_0xe5ef78?0x0:_0x3b2927[_0x1892('0x14')];var _0xf11b26=_0xe5ef78?_0x22baab['count']:_0x3b2927['offset']+_0x3b2927[_0x1892('0x12')];var _0x4b15ec;if(_0xf11b26>=_0x53c709){_0xf11b26=_0x53c709;_0x4b15ec=0xc8;}else{_0x4b15ec=0xce;}_0x531383[_0x1892('0xe')](_0x4b15ec);return _0x531383['set'](_0x1892('0x15'),_0xeb57f7+'-'+_0xf11b26+'/'+_0x53c709)[_0x1892('0x10')](_0x22baab);}return null;};}function saveUpdates(_0x237451){return function(_0x3dc9a4){if(_0x3dc9a4){return _0x3dc9a4[_0x1892('0x16')](_0x237451)['then'](function(_0x5d28fc){return _0x5d28fc;});}return null;};}function removeEntity(_0x349b58){return function(_0x49937d){if(_0x49937d){return _0x49937d[_0x1892('0x17')]()['then'](function(){var _0x11c2e6=_0x49937d[_0x1892('0x18')]({'plain':!![]});var _0x4c2e74=_0x1892('0x19');return db[_0x1892('0x1a')][_0x1892('0x17')]({'where':{'type':_0x4c2e74,'resourceId':_0x11c2e6['id']}})[_0x1892('0x1b')](function(){return _0x49937d;});})['then'](function(){_0x349b58['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3f5759){return function(_0x1fd123){if(!_0x1fd123){_0x3f5759['sendStatus'](0x194);}return _0x1fd123;};}function handleError(_0xa9a3e0,_0x8fd69a){_0x8fd69a=_0x8fd69a||0x1f4;return function(_0x27a514){logger[_0x1892('0x1c')](_0x27a514['stack']);if(_0x27a514[_0x1892('0x1d')]){delete _0x27a514[_0x1892('0x1d')];}_0xa9a3e0[_0x1892('0xe')](_0x8fd69a)[_0x1892('0x1e')](_0x27a514);};}exports['index']=function(_0x8e9dd4,_0x17ed21){var _0x25cd30={};var _0x38aac3={'count':0x0,'rows':[]};var _0x296c45=_[_0x1892('0x1f')](db[_0x1892('0x20')][_0x1892('0x21')],function(_0x3b6628){return{'name':_0x3b6628[_0x1892('0x22')],'type':_0x3b6628[_0x1892('0x23')]['key']};});_0x25cd30=qs[_0x1892('0x24')](_0x296c45,_0x8e9dd4);var _0x280a18={'where':_0x25cd30['where']};return db[_0x1892('0x20')]['count'](_0x280a18)[_0x1892('0x1b')](function(_0x1ca4db){_0x38aac3[_0x1892('0x13')]=_0x1ca4db;_0x25cd30[_0x1892('0x25')]=qs[_0x1892('0x25')](_0x8e9dd4['query']);return db[_0x1892('0x20')][_0x1892('0x26')](_0x25cd30);})[_0x1892('0x1b')](function(_0x1e3e4c){_0x38aac3[_0x1892('0x27')]=_0x1e3e4c;return _0x38aac3;})[_0x1892('0x1b')](respondWithFilteredResult(_0x17ed21,_0x25cd30))[_0x1892('0x28')](handleError(_0x17ed21,null));};exports[_0x1892('0x29')]=function(_0x6dda79,_0x504ba1){var _0x5f2b7b={'raw':!![],'where':{'id':_0x6dda79[_0x1892('0x2a')]['id']}},_0x49d5d4={};_0x49d5d4[_0x1892('0x2b')]=_['keys'](db['FaxQueue'][_0x1892('0x21')]);_0x49d5d4[_0x1892('0x2c')]=_['keys'](_0x6dda79[_0x1892('0x2c')]);_0x49d5d4[_0x1892('0x2d')]=_[_0x1892('0x2e')](_0x49d5d4[_0x1892('0x2b')],_0x49d5d4['query']);_0x5f2b7b[_0x1892('0x2f')]=_[_0x1892('0x2e')](_0x49d5d4['model'],qs[_0x1892('0x30')](_0x6dda79['query']['fields']));_0x5f2b7b[_0x1892('0x2f')]=_0x5f2b7b[_0x1892('0x2f')]['length']?_0x5f2b7b[_0x1892('0x2f')]:_0x49d5d4[_0x1892('0x2b')];if(_0x6dda79[_0x1892('0x2c')][_0x1892('0x31')]){_0x5f2b7b[_0x1892('0x25')]=[{'all':!![]}];}_0x5f2b7b=_[_0x1892('0x32')]({},_0x5f2b7b,_0x6dda79[_0x1892('0x33')]);return db[_0x1892('0x20')][_0x1892('0x34')](_0x5f2b7b)[_0x1892('0x1b')](handleEntityNotFound(_0x504ba1,null))['then'](respondWithResult(_0x504ba1,null))[_0x1892('0x28')](handleError(_0x504ba1,null));};exports[_0x1892('0x35')]=function(_0x1ac7bd,_0x532134){return db[_0x1892('0x20')][_0x1892('0x35')](_0x1ac7bd[_0x1892('0x36')],{})[_0x1892('0x1b')](function(_0x4b6e29){var _0x1f0f47=_0x1ac7bd[_0x1892('0x37')][_0x1892('0x18')]({'plain':!![]});if(!_0x1f0f47)throw new Error(_0x1892('0x38'));if(_0x1f0f47[_0x1892('0x39')]===_0x1892('0x37')){var _0x2e9b01=_0x4b6e29[_0x1892('0x18')]({'plain':!![]});var _0x13e72c=_0x1892('0x19');return db[_0x1892('0x3a')]['find']({'where':{'name':_0x13e72c,'userProfileId':_0x1f0f47[_0x1892('0x3b')]},'raw':!![]})[_0x1892('0x1b')](function(_0x118bfb){if(_0x118bfb&&_0x118bfb[_0x1892('0x3c')]===0x0){return db[_0x1892('0x1a')][_0x1892('0x35')]({'name':_0x2e9b01[_0x1892('0x1d')],'resourceId':_0x2e9b01['id'],'type':_0x118bfb[_0x1892('0x1d')],'sectionId':_0x118bfb['id']},{})[_0x1892('0x1b')](function(){return _0x4b6e29;});}else{return _0x4b6e29;}})[_0x1892('0x28')](function(_0x2ded54){logger[_0x1892('0x1c')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2ded54);throw _0x2ded54;});}return _0x4b6e29;})['then'](respondWithResult(_0x532134,0xc9))['catch'](handleError(_0x532134,null));};exports['update']=function(_0x53a7cc,_0x17b833){if(_0x53a7cc['body']['id']){delete _0x53a7cc[_0x1892('0x36')]['id'];}return db['FaxQueue'][_0x1892('0x34')]({'where':{'id':_0x53a7cc[_0x1892('0x2a')]['id']}})[_0x1892('0x1b')](handleEntityNotFound(_0x17b833,null))[_0x1892('0x1b')](saveUpdates(_0x53a7cc[_0x1892('0x36')],null))[_0x1892('0x1b')](respondWithResult(_0x17b833,null))[_0x1892('0x28')](handleError(_0x17b833,null));};exports[_0x1892('0x17')]=function(_0x170ebc,_0x1f5cbd){return db[_0x1892('0x20')][_0x1892('0x34')]({'where':{'id':_0x170ebc[_0x1892('0x2a')]['id']}})['then'](handleEntityNotFound(_0x1f5cbd,null))[_0x1892('0x1b')](removeEntity(_0x1f5cbd,null))['catch'](handleError(_0x1f5cbd,null));};exports['describe']=function(_0x49571,_0x5886cf){return db[_0x1892('0x20')][_0x1892('0x3d')]()[_0x1892('0x1b')](respondWithResult(_0x5886cf,null))[_0x1892('0x28')](handleError(_0x5886cf,null));};exports['getMembers']=function(_0x5f431f,_0x11ab70){var _0x68b91e={'raw':!![],'where':{}},_0x55d78f={},_0xd56892;return db['FaxQueue'][_0x1892('0x3e')]({'where':{'id':_0x5f431f[_0x1892('0x2a')]['id']}})[_0x1892('0x1b')](handleEntityNotFound(_0x11ab70,null))[_0x1892('0x1b')](function(_0x3f9135){if(_0x3f9135){_0xd56892=_0x3f9135['get']({'plain':!![]});_0x55d78f[_0x1892('0x2b')]=_['keys'](db['UserFaxQueue'][_0x1892('0x21')]);_0x55d78f[_0x1892('0x2c')]=_[_0x1892('0x3f')](_0x5f431f[_0x1892('0x2c')]);_0x55d78f[_0x1892('0x2d')]=_[_0x1892('0x2e')](_0x55d78f[_0x1892('0x2b')],_0x55d78f['query']);_0x68b91e[_0x1892('0x2f')]=_[_0x1892('0x2e')](_0x55d78f[_0x1892('0x2b')],qs[_0x1892('0x30')](_0x5f431f[_0x1892('0x2c')][_0x1892('0x30')]));_0x68b91e['attributes']=_0x68b91e[_0x1892('0x2f')]['length']?_0x68b91e[_0x1892('0x2f')]:_0x55d78f[_0x1892('0x2b')];if(!_0x5f431f['query'][_0x1892('0x40')](_0x1892('0x41'))){_0x68b91e['limit']=qs[_0x1892('0x12')](_0x5f431f[_0x1892('0x2c')]['limit']);_0x68b91e[_0x1892('0x14')]=qs[_0x1892('0x14')](_0x5f431f[_0x1892('0x2c')][_0x1892('0x14')]);}_0x68b91e[_0x1892('0x42')]=qs[_0x1892('0x43')](_0x5f431f[_0x1892('0x2c')][_0x1892('0x43')]);_0x68b91e['where']=qs[_0x1892('0x2d')](_[_0x1892('0x44')](_0x5f431f[_0x1892('0x2c')],_0x55d78f['filters']));_0x68b91e[_0x1892('0x45')][_0x1892('0x46')]=_0x3f9135['id'];if(_0x5f431f['query'][_0x1892('0x47')]){_0x68b91e[_0x1892('0x45')]=_[_0x1892('0x32')](_0x68b91e['where'],{'$or':_[_0x1892('0x1f')](_0x68b91e[_0x1892('0x2f')],function(_0x5c4305){var _0x448304={};_0x448304[_0x5c4305]={'$like':'%'+_0x5f431f['query'][_0x1892('0x47')]+'%'};return _0x448304;})});}_0x68b91e=_[_0x1892('0x32')]({},_0x68b91e,_0x5f431f['options']);return db[_0x1892('0x48')]['findAll'](_0x68b91e);}})[_0x1892('0x1b')](function(_0xc4139c){if(_0xc4139c){return db[_0x1892('0x49')][_0x1892('0x4a')]({'where':{'id':_['map'](_0xc4139c,_0x1892('0x4b')),'role':_0x1892('0x4c')},'attributes':['id',_0x1892('0x1d'),_0x1892('0x4d'),'updatedAt','createdAt']});}})['then'](function(_0x907913){if(_0x907913){return{'count':_0x907913[_0x1892('0x13')],'rows':_[_0x1892('0x1f')](_0x907913[_0x1892('0x27')],function(_0x2af629){return{'membername':_0x2af629[_0x1892('0x1d')],'UserId':_0x2af629['id'],'queue_name':_0xd56892[_0x1892('0x1d')],'FaxQueueId':_0xd56892['id'],'interface':util['format'](_0x1892('0x4e'),_0x1892('0x4f'),_0x2af629['name']),'penalty':0x0,'paused':_0x2af629[_0x1892('0x4d')],'createdAt':_0x2af629[_0x1892('0x50')],'updatedAt':_0x2af629[_0x1892('0x51')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x1892('0x1b')](respondWithFilteredResult(_0x11ab70,_0x68b91e))[_0x1892('0x28')](handleError(_0x11ab70,null));};exports['getTeams']=function(_0x155b54,_0x4d1e21){var _0x3ad2={};var _0x2e419c={};var _0x16aca4;var _0x56abd;return db['FaxQueue'][_0x1892('0x3e')]({'where':{'id':_0x155b54[_0x1892('0x2a')]['id']}})[_0x1892('0x1b')](handleEntityNotFound(_0x4d1e21,null))[_0x1892('0x1b')](function(_0x691aaf){if(_0x691aaf){_0x16aca4=_0x691aaf;_0x2e419c['model']=_['keys'](db[_0x1892('0x52')][_0x1892('0x21')]);_0x2e419c[_0x1892('0x2c')]=_[_0x1892('0x3f')](_0x155b54[_0x1892('0x2c')]);_0x2e419c[_0x1892('0x2d')]=_[_0x1892('0x2e')](_0x2e419c['model'],_0x2e419c[_0x1892('0x2c')]);_0x3ad2['attributes']=_['intersection'](_0x2e419c['model'],qs[_0x1892('0x30')](_0x155b54['query']['fields']));_0x3ad2[_0x1892('0x2f')]=_0x3ad2[_0x1892('0x2f')][_0x1892('0x53')]?_0x3ad2[_0x1892('0x2f')]:_0x2e419c[_0x1892('0x2b')];_0x3ad2['order']=qs['sort'](_0x155b54[_0x1892('0x2c')][_0x1892('0x43')]);_0x3ad2['where']=qs[_0x1892('0x2d')](_[_0x1892('0x44')](_0x155b54[_0x1892('0x2c')],_0x2e419c['filters']));if(_0x155b54[_0x1892('0x2c')][_0x1892('0x47')]){_0x3ad2[_0x1892('0x45')]=_[_0x1892('0x32')](_0x3ad2[_0x1892('0x45')],{'$or':_[_0x1892('0x1f')](_0x3ad2[_0x1892('0x2f')],function(_0x4bd538){var _0xa64578={};_0xa64578[_0x4bd538]={'$like':'%'+_0x155b54[_0x1892('0x2c')]['filter']+'%'};return _0xa64578;})});}_0x3ad2=_[_0x1892('0x32')]({},_0x3ad2,_0x155b54['options']);return _0x16aca4['getTeams'](_0x3ad2);}})['then'](function(_0x3be81b){if(_0x3be81b){_0x56abd=_0x3be81b[_0x1892('0x53')];if(!_0x155b54[_0x1892('0x2c')]['hasOwnProperty'](_0x1892('0x41'))){_0x3ad2['limit']=qs[_0x1892('0x12')](_0x155b54[_0x1892('0x2c')][_0x1892('0x12')]);_0x3ad2['offset']=qs['offset'](_0x155b54[_0x1892('0x2c')][_0x1892('0x14')]);}return _0x16aca4[_0x1892('0x54')](_0x3ad2);}})[_0x1892('0x1b')](function(_0x5c1693){if(_0x5c1693){return _0x5c1693?{'count':_0x56abd,'rows':_0x5c1693}:null;}})['then'](respondWithResult(_0x4d1e21,null))[_0x1892('0x28')](handleError(_0x4d1e21,null));};exports[_0x1892('0x55')]=function(_0x3e7b42,_0x4be458){var _0xf976d7=_0x3e7b42[_0x1892('0x36')]['ids'];return db[_0x1892('0x52')][_0x1892('0x26')]({'where':{'id':_0xf976d7},'attributes':['id'],'include':[{'model':db[_0x1892('0x49')],'as':_0x1892('0x56'),'attributes':['id',_0x1892('0x1d'),_0x1892('0x57'),'voicePause',_0x1892('0x58')],'raw':!![]}]})[_0x1892('0x1b')](function(_0x5f1b33){if(_0x5f1b33){var _0x554c2f=_['flatMap'](_0x5f1b33,function(_0x166fd8){var _0x44d0ce=_0x166fd8[_0x1892('0x18')]({'plain':!![]});return _0x44d0ce[_0x1892('0x56')];});return db[_0x1892('0x20')][_0x1892('0x34')]({'where':{'id':_0x3e7b42[_0x1892('0x2a')]['id']}})['then'](function(_0x5a9abe){return db[_0x1892('0x59')][_0x1892('0x5a')](function(_0x4234f2){return _0x5a9abe[_0x1892('0x55')](_0xf976d7,{'transaction':_0x4234f2})[_0x1892('0x1b')](function(){return BPromise[_0x1892('0x5b')](_0x554c2f,function(_0x41dd8d){return db['UserFaxQueue'][_0x1892('0x5c')]({'where':{'UserId':_0x41dd8d['id'],'FaxQueueId':_0x3e7b42['params']['id']},'transaction':_0x4234f2});});})[_0x1892('0x1b')](function(){_0x554c2f[_0x1892('0x5d')](function(_0x453f0d){socket['emit'](_0x1892('0x5e'),{'UserId':_0x453f0d['id'],'FaxQueueId':_0x5a9abe['id']});});});});});}})[_0x1892('0x1b')](respondWithStatusCode(_0x4be458,null))[_0x1892('0x28')](handleError(_0x4be458,null));};exports['removeTeams']=function(_0x572889,_0x4d3122){return db['Team']['findAll']({'where':{'id':_0x572889[_0x1892('0x2c')][_0x1892('0x5f')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x1892('0x56'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x4d3122,null))[_0x1892('0x1b')](function(_0x34c62e){var _0x452ab5=_['map'](_0x34c62e,'id');var _0x464a9a=[];var _0x2dfd9a=[];var _0x211c9c=squel[_0x1892('0x60')]();_0x211c9c['field'](_0x1892('0x61'))['from'](_0x1892('0x62'),'tq')[_0x1892('0x63')]('user_has_teams','ut',_0x1892('0x64'))[_0x1892('0x45')](_0x1892('0x65'),_0x572889[_0x1892('0x2a')]['id']);for(var _0x3059a9=0x0;_0x3059a9<_0x34c62e[_0x1892('0x53')];_0x3059a9+=0x1){let _0x3d7097=_0x34c62e[_0x3059a9];for(var _0x1bf24e=0x0;_0x1bf24e<_0x3d7097['Agents'][_0x1892('0x53')];_0x1bf24e+=0x1){let _0x405cd0=_0x3d7097[_0x1892('0x56')][_0x1bf24e];var _0x5812dc=_0x211c9c[_0x1892('0x66')]();_0x5812dc[_0x1892('0x45')](_0x1892('0x67'),_0x405cd0['id']);_0x2dfd9a[_0x1892('0x68')](db['sequelize'][_0x1892('0x2c')](_0x5812dc[_0x1892('0x69')](),{'type':db[_0x1892('0x59')][_0x1892('0x6a')][_0x1892('0x6b')]})[_0x1892('0x1b')](function(_0x233698){if(_0x233698[_0x1892('0x53')]===0x1){return _0x405cd0['id'];}else{var _0x45ab5d=_[_0x1892('0x6c')](_[_0x1892('0x1f')](_0x233698,_0x1892('0x6d')),function(_0x109e83){return _[_0x1892('0x6e')](_0x452ab5,_0x109e83);});if(_0x45ab5d){return _0x405cd0['id'];}}}));}}return BPromise[_0x1892('0x6f')](_0x2dfd9a)[_0x1892('0x1b')](function(_0x18dd0d){_0x464a9a=_(_0x464a9a)['union'](_0x18dd0d)['compact']()['value']();return db[_0x1892('0x20')][_0x1892('0x34')]({'where':{'id':_0x572889[_0x1892('0x2a')]['id']}})[_0x1892('0x1b')](function(_0x251c17){return db['sequelize'][_0x1892('0x5a')](function(_0x426e69){return _0x251c17[_0x1892('0x70')](_0x572889[_0x1892('0x2c')][_0x1892('0x5f')],{'transaction':_0x426e69})[_0x1892('0x1b')](function(){if(!_[_0x1892('0x71')](_0x464a9a)){return _0x251c17['removeAgents'](_0x464a9a,{'transaction':_0x426e69});}})[_0x1892('0x1b')](function(){_0x464a9a[_0x1892('0x5d')](function(_0x585018){socket[_0x1892('0x72')](_0x1892('0x73'),{'UserId':_0x585018,'FaxQueueId':_0x251c17['id']});});});});});});})['then'](respondWithStatusCode(_0x4d3122,null))[_0x1892('0x28')](handleError(_0x4d3122,null));};exports[_0x1892('0x74')]=function(_0x46eb60,_0x43e2fe){return db[_0x1892('0x20')][_0x1892('0x34')]({'where':{'id':_0x46eb60[_0x1892('0x2a')]['id']}})[_0x1892('0x1b')](handleEntityNotFound(_0x43e2fe,null))[_0x1892('0x1b')](function(_0x12d35d){if(_0x12d35d){return _0x12d35d[_0x1892('0x74')](_0x46eb60['body'][_0x1892('0x5f')],_[_0x1892('0x75')](_0x46eb60[_0x1892('0x36')],[_0x1892('0x5f'),'id'])||{})[_0x1892('0x76')](function(_0x15daa7){for(var _0x41f17f=0x0;_0x41f17f<_0x46eb60[_0x1892('0x36')][_0x1892('0x5f')][_0x1892('0x53')];_0x41f17f+=0x1){socket[_0x1892('0x72')](_0x1892('0x5e'),{'UserId':Number(_0x46eb60[_0x1892('0x36')][_0x1892('0x5f')][_0x41f17f]),'FaxQueueId':Number(_0x46eb60[_0x1892('0x2a')]['id'])});}return _0x15daa7;});}})[_0x1892('0x1b')](respondWithResult(_0x43e2fe,null))[_0x1892('0x28')](handleError(_0x43e2fe,null));};exports[_0x1892('0x77')]=function(_0x22a8ec,_0x1ca156){return db[_0x1892('0x20')][_0x1892('0x34')]({'where':{'id':_0x22a8ec[_0x1892('0x2a')]['id']}})[_0x1892('0x1b')](handleEntityNotFound(_0x1ca156,null))[_0x1892('0x1b')](function(_0x46221c){if(_0x46221c){return _0x46221c[_0x1892('0x77')](_0x22a8ec[_0x1892('0x2c')][_0x1892('0x5f')])[_0x1892('0x1b')](function(){if(_[_0x1892('0x78')](_0x22a8ec[_0x1892('0x2c')][_0x1892('0x5f')])){for(var _0x55f447=0x0;_0x55f447<_0x22a8ec['query']['ids'][_0x1892('0x53')];_0x55f447+=0x1){socket['emit'](_0x1892('0x73'),{'UserId':Number(_0x22a8ec[_0x1892('0x2c')][_0x1892('0x5f')][_0x55f447]),'FaxQueueId':Number(_0x22a8ec[_0x1892('0x2a')]['id'])});}}else{socket[_0x1892('0x72')](_0x1892('0x73'),{'UserId':Number(_0x22a8ec[_0x1892('0x2c')][_0x1892('0x5f')]),'FaxQueueId':Number(_0x22a8ec['params']['id'])});}});}})[_0x1892('0x1b')](respondWithStatusCode(_0x1ca156,null))[_0x1892('0x28')](handleError(_0x1ca156,null));};exports[_0x1892('0x79')]=function(_0x683898,_0x40feba){var _0x2868fe={};var _0xb1a1b4={};var _0x5485d6;var _0x105d88;return db['FaxQueue'][_0x1892('0x3e')]({'where':{'id':_0x683898['params']['id']}})[_0x1892('0x1b')](handleEntityNotFound(_0x40feba,null))[_0x1892('0x1b')](function(_0x4e68ff){if(_0x4e68ff){_0x5485d6=_0x4e68ff;_0xb1a1b4[_0x1892('0x2b')]=_[_0x1892('0x3f')](db[_0x1892('0x49')][_0x1892('0x21')]);_0xb1a1b4[_0x1892('0x2c')]=_[_0x1892('0x3f')](_0x683898['query']);_0xb1a1b4[_0x1892('0x2d')]=_[_0x1892('0x2e')](_0xb1a1b4['model'],_0xb1a1b4['query']);_0x2868fe['attributes']=_[_0x1892('0x2e')](_0xb1a1b4[_0x1892('0x2b')],qs[_0x1892('0x30')](_0x683898[_0x1892('0x2c')][_0x1892('0x30')]));_0x2868fe[_0x1892('0x2f')]=_0x2868fe[_0x1892('0x2f')][_0x1892('0x53')]?_0x2868fe[_0x1892('0x2f')]:_0xb1a1b4['model'];_0x2868fe[_0x1892('0x42')]=qs[_0x1892('0x43')](_0x683898['query'][_0x1892('0x43')]);_0x2868fe[_0x1892('0x45')]=qs[_0x1892('0x2d')](_['pick'](_0x683898[_0x1892('0x2c')],_0xb1a1b4[_0x1892('0x2d')]));if(_0x683898[_0x1892('0x2c')][_0x1892('0x47')]){_0x2868fe[_0x1892('0x45')]=_[_0x1892('0x32')](_0x2868fe[_0x1892('0x45')],{'$or':_[_0x1892('0x1f')](_0x2868fe['attributes'],function(_0x1c78e0){var _0x4d7f03={};_0x4d7f03[_0x1c78e0]={'$like':'%'+_0x683898[_0x1892('0x2c')][_0x1892('0x47')]+'%'};return _0x4d7f03;})});}_0x2868fe=_[_0x1892('0x32')]({},_0x2868fe,_0x683898[_0x1892('0x33')]);return _0x5485d6[_0x1892('0x79')](_0x2868fe);}})['then'](function(_0x301484){if(_0x301484){_0x105d88=_0x301484[_0x1892('0x53')];if(!_0x683898[_0x1892('0x2c')][_0x1892('0x40')](_0x1892('0x41'))){_0x2868fe[_0x1892('0x12')]=qs[_0x1892('0x12')](_0x683898[_0x1892('0x2c')][_0x1892('0x12')]);_0x2868fe[_0x1892('0x14')]=qs[_0x1892('0x14')](_0x683898[_0x1892('0x2c')][_0x1892('0x14')]);}return _0x5485d6[_0x1892('0x79')](_0x2868fe);}})[_0x1892('0x1b')](function(_0x60f292){if(_0x60f292){return _0x60f292?{'count':_0x105d88,'rows':_0x60f292}:null;}})[_0x1892('0x1b')](respondWithResult(_0x40feba,null))['catch'](handleError(_0x40feba,null));};
\ No newline at end of file