Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 6c39d0a..09d0cb3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x97c1=['where','pick','filter','merge','VIRTUAL','options','include','findAll','catch','show','params','includeAll','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','FaxQueues','userProfileId','autoAssociation','name','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','findOne','UserFaxQueue','FaxQueueId','User','findAndCountAll','UserId','agent','%s/%s','SIP','faxPause','createdAt','updatedAt','getTeams','Team','addTeams','ids','Agents','online','voicePause','interface','flatMap','sequelize','transaction','each','emit','userFaxQueue:save','removeTeams','select','field','tq.TeamId','from','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','union','compact','value','isEmpty','removeAgents','forEach','userFaxQueue:remove','addAgents','omit','isArray','getAgents','html-pdf','eml-format','zip-dir','moment','bluebird','mustache','util','path','ejs','lodash','squel','crypto','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','redis','defaults','localhost','./faxQueue.socket','register','end','status','json','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','get','UserProfileResource','sendStatus','error','stack','index','map','FaxQueue','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort'];(function(_0x22756e,_0x47120b){var _0xe56947=function(_0x125e35){while(--_0x125e35){_0x22756e['push'](_0x22756e['shift']());}};_0xe56947(++_0x47120b);}(_0x97c1,0xdf));var _0x197c=function(_0x4a9fb1,_0x273043){_0x4a9fb1=_0x4a9fb1-0x0;var _0x348672=_0x97c1[_0x4a9fb1];return _0x348672;};'use strict';var pdf=require(_0x197c('0x0'));var emlformat=require(_0x197c('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x197c('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x197c('0x3'));var BPromise=require(_0x197c('0x4'));var Mustache=require(_0x197c('0x5'));var util=require(_0x197c('0x6'));var path=require(_0x197c('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x197c('0x8'));var fs=require('fs');var _=require(_0x197c('0x9'));var squel=require(_0x197c('0xa'));var crypto=require(_0x197c('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x197c('0xc'));var querystring=require('querystring');var Papa=require(_0x197c('0xd'));var Redis=require(_0x197c('0xe'));var authService=require(_0x197c('0xf'));var qs=require(_0x197c('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x197c('0x11'));var logger=require(_0x197c('0x12'))(_0x197c('0x13'));var utils=require(_0x197c('0x14'));var config=require(_0x197c('0x15'));var db=require('../../mysqldb')['db'];config[_0x197c('0x16')]=_[_0x197c('0x17')](config[_0x197c('0x16')],{'host':_0x197c('0x18'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x197c('0x16')]));require(_0x197c('0x19'))[_0x197c('0x1a')](socket);function respondWithStatusCode(_0xf735ce,_0x188ff2){_0x188ff2=_0x188ff2||0xcc;return function(_0x109af2){if(_0x109af2){return _0xf735ce['sendStatus'](_0x188ff2);}return _0xf735ce['status'](_0x188ff2)[_0x197c('0x1b')]();};}function respondWithResult(_0x2bc612,_0x2083d4){_0x2083d4=_0x2083d4||0xc8;return function(_0x24901f){if(_0x24901f){return _0x2bc612[_0x197c('0x1c')](_0x2083d4)[_0x197c('0x1d')](_0x24901f);}};}function respondWithFilteredResult(_0x437050,_0x75beba){return function(_0x47f43b){if(_0x47f43b){var _0x372311=_0x47f43b[_0x197c('0x1e')],_0x47aaa9=_0x75beba[_0x197c('0x1f')],_0x50ac52=_0x75beba[_0x197c('0x1f')]+_0x75beba['limit'],_0x1725d9;if(_0x50ac52>=_0x372311){_0x50ac52=_0x372311;_0x1725d9=0xc8;}else{_0x1725d9=0xce;}_0x437050[_0x197c('0x1c')](_0x1725d9);return _0x437050[_0x197c('0x20')](_0x197c('0x21'),_0x47aaa9+'-'+_0x50ac52+'/'+_0x372311)['json'](_0x47f43b);}return null;};}function patchUpdates(_0x1adb43){return function(_0x27b3df){try{jsonpatch[_0x197c('0x22')](_0x27b3df,_0x1adb43,!![]);}catch(_0xf3aeda){return BPromise[_0x197c('0x23')](_0xf3aeda);}return _0x27b3df[_0x197c('0x24')]();};}function saveUpdates(_0x362bbf,_0x2092a0){return function(_0x8963fd){if(_0x8963fd){return _0x8963fd[_0x197c('0x25')](_0x362bbf)[_0x197c('0x26')](function(_0x177bc9){return _0x177bc9;});}return null;};}function removeEntity(_0x174942,_0x2a1310){return function(_0x37b040){if(_0x37b040){return _0x37b040[_0x197c('0x27')]()['then'](function(){var _0x112e27=_0x37b040[_0x197c('0x28')]({'plain':!![]});var _0x2b6319='FaxQueues';return db[_0x197c('0x29')][_0x197c('0x27')]({'where':{'type':_0x2b6319,'resourceId':_0x112e27['id']}})['then'](function(){return _0x37b040;});})['then'](function(){_0x174942[_0x197c('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0xfbca7a,_0x14b0aa){return function(_0x4e9a06){if(!_0x4e9a06){_0xfbca7a[_0x197c('0x2a')](0x194);}return _0x4e9a06;};}function handleError(_0x2f031c,_0x3cdcd8){_0x3cdcd8=_0x3cdcd8||0x1f4;return function(_0x2b6154){logger[_0x197c('0x2b')](_0x2b6154[_0x197c('0x2c')]);if(_0x2b6154['name']){delete _0x2b6154['name'];}_0x2f031c['status'](_0x3cdcd8)['send'](_0x2b6154);};}exports[_0x197c('0x2d')]=function(_0x4c9256,_0x252cde){var _0x35dbf3={},_0x58bc60={},_0x422ac6={'count':0x0,'rows':[]};var _0x4c7824=_[_0x197c('0x2e')](db[_0x197c('0x2f')][_0x197c('0x30')],function(_0x365f9f){return{'name':_0x365f9f[_0x197c('0x31')],'type':_0x365f9f[_0x197c('0x32')][_0x197c('0x33')]};});_0x58bc60[_0x197c('0x34')]=_[_0x197c('0x2e')](_0x4c7824,'name');_0x58bc60['query']=_[_0x197c('0x35')](_0x4c9256[_0x197c('0x36')]);_0x58bc60[_0x197c('0x37')]=_[_0x197c('0x38')](_0x58bc60[_0x197c('0x34')],_0x58bc60[_0x197c('0x36')]);_0x35dbf3[_0x197c('0x39')]=_['intersection'](_0x58bc60['model'],qs[_0x197c('0x3a')](_0x4c9256[_0x197c('0x36')]['fields']));_0x35dbf3['attributes']=_0x35dbf3[_0x197c('0x39')][_0x197c('0x3b')]?_0x35dbf3[_0x197c('0x39')]:_0x58bc60[_0x197c('0x34')];if(!_0x4c9256[_0x197c('0x36')][_0x197c('0x3c')](_0x197c('0x3d'))){_0x35dbf3[_0x197c('0x3e')]=qs[_0x197c('0x3e')](_0x4c9256['query'][_0x197c('0x3e')]);_0x35dbf3[_0x197c('0x1f')]=qs[_0x197c('0x1f')](_0x4c9256[_0x197c('0x36')][_0x197c('0x1f')]);}_0x35dbf3[_0x197c('0x3f')]=qs['sort'](_0x4c9256[_0x197c('0x36')][_0x197c('0x40')]);_0x35dbf3[_0x197c('0x41')]=qs['filters'](_[_0x197c('0x42')](_0x4c9256[_0x197c('0x36')],_0x58bc60[_0x197c('0x37')]));if(_0x4c9256[_0x197c('0x36')][_0x197c('0x43')]){_0x35dbf3[_0x197c('0x41')]=_[_0x197c('0x44')](_0x35dbf3[_0x197c('0x41')],{'$or':_[_0x197c('0x2e')](_0x4c7824,function(_0x1dc01b){if(_0x1dc01b['type']!==_0x197c('0x45')){var _0x38f9bd={};_0x38f9bd[_0x1dc01b['name']]={'$like':'%'+_0x4c9256['query'][_0x197c('0x43')]+'%'};return _0x38f9bd;}})});}_0x35dbf3=_[_0x197c('0x44')]({},_0x35dbf3,_0x4c9256[_0x197c('0x46')]);var _0x28f172={'where':_0x35dbf3[_0x197c('0x41')]};return db['FaxQueue'][_0x197c('0x1e')](_0x28f172)[_0x197c('0x26')](function(_0x7ed02b){_0x422ac6[_0x197c('0x1e')]=_0x7ed02b;if(_0x4c9256[_0x197c('0x36')]['includeAll']){_0x35dbf3[_0x197c('0x47')]=[{'all':!![]}];}return db[_0x197c('0x2f')][_0x197c('0x48')](_0x35dbf3);})[_0x197c('0x26')](function(_0x2f3c4b){_0x422ac6['rows']=_0x2f3c4b;return _0x422ac6;})[_0x197c('0x26')](respondWithFilteredResult(_0x252cde,_0x35dbf3))[_0x197c('0x49')](handleError(_0x252cde,null));};exports[_0x197c('0x4a')]=function(_0x35f36d,_0x3e6d6e){var _0x41eb51={'raw':!![],'where':{'id':_0x35f36d[_0x197c('0x4b')]['id']}},_0x2dc66d={};_0x2dc66d[_0x197c('0x34')]=_[_0x197c('0x35')](db[_0x197c('0x2f')]['rawAttributes']);_0x2dc66d['query']=_['keys'](_0x35f36d['query']);_0x2dc66d[_0x197c('0x37')]=_[_0x197c('0x38')](_0x2dc66d['model'],_0x2dc66d[_0x197c('0x36')]);_0x41eb51[_0x197c('0x39')]=_['intersection'](_0x2dc66d[_0x197c('0x34')],qs[_0x197c('0x3a')](_0x35f36d['query'][_0x197c('0x3a')]));_0x41eb51[_0x197c('0x39')]=_0x41eb51['attributes'][_0x197c('0x3b')]?_0x41eb51[_0x197c('0x39')]:_0x2dc66d[_0x197c('0x34')];if(_0x35f36d['query'][_0x197c('0x4c')]){_0x41eb51[_0x197c('0x47')]=[{'all':!![]}];}_0x41eb51=_[_0x197c('0x44')]({},_0x41eb51,_0x35f36d[_0x197c('0x46')]);return db['FaxQueue'][_0x197c('0x4d')](_0x41eb51)[_0x197c('0x26')](handleEntityNotFound(_0x3e6d6e,null))[_0x197c('0x26')](respondWithResult(_0x3e6d6e,null))['catch'](handleError(_0x3e6d6e,null));};exports['create']=function(_0x3a5089,_0x332c75){return db[_0x197c('0x2f')][_0x197c('0x4e')](_0x3a5089[_0x197c('0x4f')],{})[_0x197c('0x26')](function(_0x4c82d5){var _0x1e77da=_0x3a5089['user'][_0x197c('0x28')]({'plain':!![]});if(!_0x1e77da)throw new Error(_0x197c('0x50'));if(_0x1e77da[_0x197c('0x51')]===_0x197c('0x52')){var _0x34a211=_0x4c82d5[_0x197c('0x28')]({'plain':!![]});var _0x172720=_0x197c('0x53');return db['UserProfileSection'][_0x197c('0x4d')]({'where':{'name':_0x172720,'userProfileId':_0x1e77da[_0x197c('0x54')]},'raw':!![]})[_0x197c('0x26')](function(_0x4b0048){if(_0x4b0048&&_0x4b0048[_0x197c('0x55')]===0x0){return db['UserProfileResource'][_0x197c('0x4e')]({'name':_0x34a211[_0x197c('0x56')],'resourceId':_0x34a211['id'],'type':_0x4b0048[_0x197c('0x56')],'sectionId':_0x4b0048['id']},{})[_0x197c('0x26')](function(){return _0x4c82d5;});}else{return _0x4c82d5;}})[_0x197c('0x49')](function(_0x304537){logger[_0x197c('0x2b')](_0x197c('0x57'),_0x304537);throw _0x304537;});}return _0x4c82d5;})['then'](respondWithResult(_0x332c75,0xc9))[_0x197c('0x49')](handleError(_0x332c75,null));};exports[_0x197c('0x25')]=function(_0x275294,_0x5f3301){if(_0x275294[_0x197c('0x4f')]['id']){delete _0x275294[_0x197c('0x4f')]['id'];}return db[_0x197c('0x2f')][_0x197c('0x4d')]({'where':{'id':_0x275294[_0x197c('0x4b')]['id']}})['then'](handleEntityNotFound(_0x5f3301,null))['then'](saveUpdates(_0x275294[_0x197c('0x4f')],null))[_0x197c('0x26')](respondWithResult(_0x5f3301,null))[_0x197c('0x49')](handleError(_0x5f3301,null));};exports[_0x197c('0x27')]=function(_0x15e50f,_0x501ab3){return db['FaxQueue'][_0x197c('0x4d')]({'where':{'id':_0x15e50f[_0x197c('0x4b')]['id']}})['then'](handleEntityNotFound(_0x501ab3,null))[_0x197c('0x26')](removeEntity(_0x501ab3,null))[_0x197c('0x49')](handleError(_0x501ab3,null));};exports[_0x197c('0x58')]=function(_0x40867c,_0xc10419){return db[_0x197c('0x2f')]['describe']()[_0x197c('0x26')](respondWithResult(_0xc10419,null))[_0x197c('0x49')](handleError(_0xc10419,null));};exports['getMembers']=function(_0x480cab,_0x1b71cf,_0x5a70dd){var _0xfc9461={'raw':!![],'where':{}},_0x3c07bf={},_0x382602;return db['FaxQueue'][_0x197c('0x59')]({'where':{'id':_0x480cab[_0x197c('0x4b')]['id']}})['then'](handleEntityNotFound(_0x1b71cf,null))[_0x197c('0x26')](function(_0x30ac1e){if(_0x30ac1e){_0x382602=_0x30ac1e[_0x197c('0x28')]({'plain':!![]});_0x3c07bf['model']=_[_0x197c('0x35')](db[_0x197c('0x5a')]['rawAttributes']);_0x3c07bf['query']=_[_0x197c('0x35')](_0x480cab[_0x197c('0x36')]);_0x3c07bf[_0x197c('0x37')]=_['intersection'](_0x3c07bf[_0x197c('0x34')],_0x3c07bf[_0x197c('0x36')]);_0xfc9461[_0x197c('0x39')]=_['intersection'](_0x3c07bf[_0x197c('0x34')],qs[_0x197c('0x3a')](_0x480cab[_0x197c('0x36')][_0x197c('0x3a')]));_0xfc9461[_0x197c('0x39')]=_0xfc9461[_0x197c('0x39')][_0x197c('0x3b')]?_0xfc9461[_0x197c('0x39')]:_0x3c07bf[_0x197c('0x34')];if(!_0x480cab[_0x197c('0x36')]['hasOwnProperty'](_0x197c('0x3d'))){_0xfc9461['limit']=qs['limit'](_0x480cab['query']['limit']);_0xfc9461[_0x197c('0x1f')]=qs[_0x197c('0x1f')](_0x480cab[_0x197c('0x36')][_0x197c('0x1f')]);}_0xfc9461['order']=qs[_0x197c('0x40')](_0x480cab['query'][_0x197c('0x40')]);_0xfc9461['where']=qs[_0x197c('0x37')](_['pick'](_0x480cab[_0x197c('0x36')],_0x3c07bf[_0x197c('0x37')]));_0xfc9461[_0x197c('0x41')][_0x197c('0x5b')]=_0x30ac1e['id'];if(_0x480cab['query'][_0x197c('0x43')]){_0xfc9461[_0x197c('0x41')]=_[_0x197c('0x44')](_0xfc9461['where'],{'$or':_[_0x197c('0x2e')](_0xfc9461[_0x197c('0x39')],function(_0x110713){var _0x29b68f={};_0x29b68f[_0x110713]={'$like':'%'+_0x480cab[_0x197c('0x36')][_0x197c('0x43')]+'%'};return _0x29b68f;})});}_0xfc9461=_[_0x197c('0x44')]({},_0xfc9461,_0x480cab[_0x197c('0x46')]);return db[_0x197c('0x5a')][_0x197c('0x48')](_0xfc9461);}})[_0x197c('0x26')](function(_0x25d3c1){if(_0x25d3c1){return db[_0x197c('0x5c')][_0x197c('0x5d')]({'where':{'id':_[_0x197c('0x2e')](_0x25d3c1,_0x197c('0x5e')),'role':_0x197c('0x5f')},'attributes':['id',_0x197c('0x56'),'faxPause','updatedAt','createdAt']});}})[_0x197c('0x26')](function(_0x4b22f2){if(_0x4b22f2){return{'count':_0x4b22f2[_0x197c('0x1e')],'rows':_['map'](_0x4b22f2['rows'],function(_0x133ec9){return{'membername':_0x133ec9[_0x197c('0x56')],'UserId':_0x133ec9['id'],'queue_name':_0x382602[_0x197c('0x56')],'FaxQueueId':_0x382602['id'],'interface':util['format'](_0x197c('0x60'),_0x197c('0x61'),_0x133ec9['name']),'penalty':0x0,'paused':_0x133ec9[_0x197c('0x62')],'createdAt':_0x133ec9[_0x197c('0x63')],'updatedAt':_0x133ec9[_0x197c('0x64')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x197c('0x26')](respondWithFilteredResult(_0x1b71cf,_0xfc9461))['catch'](handleError(_0x1b71cf,null));};exports[_0x197c('0x65')]=function(_0x541dfa,_0x315bd3,_0x5c6894){var _0x9411e8={};var _0x290dd5={};var _0x272674;var _0x557b3c;return db[_0x197c('0x2f')][_0x197c('0x59')]({'where':{'id':_0x541dfa[_0x197c('0x4b')]['id']}})['then'](handleEntityNotFound(_0x315bd3,null))[_0x197c('0x26')](function(_0x3943a8){if(_0x3943a8){_0x272674=_0x3943a8;_0x290dd5[_0x197c('0x34')]=_[_0x197c('0x35')](db[_0x197c('0x66')][_0x197c('0x30')]);_0x290dd5['query']=_[_0x197c('0x35')](_0x541dfa['query']);_0x290dd5['filters']=_[_0x197c('0x38')](_0x290dd5[_0x197c('0x34')],_0x290dd5['query']);_0x9411e8[_0x197c('0x39')]=_[_0x197c('0x38')](_0x290dd5[_0x197c('0x34')],qs[_0x197c('0x3a')](_0x541dfa[_0x197c('0x36')]['fields']));_0x9411e8['attributes']=_0x9411e8['attributes']['length']?_0x9411e8[_0x197c('0x39')]:_0x290dd5[_0x197c('0x34')];_0x9411e8['order']=qs['sort'](_0x541dfa[_0x197c('0x36')]['sort']);_0x9411e8['where']=qs[_0x197c('0x37')](_[_0x197c('0x42')](_0x541dfa[_0x197c('0x36')],_0x290dd5[_0x197c('0x37')]));if(_0x541dfa[_0x197c('0x36')][_0x197c('0x43')]){_0x9411e8['where']=_[_0x197c('0x44')](_0x9411e8[_0x197c('0x41')],{'$or':_[_0x197c('0x2e')](_0x9411e8[_0x197c('0x39')],function(_0x2ab20f){var _0x3ba9a6={};_0x3ba9a6[_0x2ab20f]={'$like':'%'+_0x541dfa[_0x197c('0x36')]['filter']+'%'};return _0x3ba9a6;})});}_0x9411e8=_[_0x197c('0x44')]({},_0x9411e8,_0x541dfa[_0x197c('0x46')]);return _0x272674[_0x197c('0x65')](_0x9411e8);}})[_0x197c('0x26')](function(_0x3ef3a2){if(_0x3ef3a2){_0x557b3c=_0x3ef3a2[_0x197c('0x3b')];if(!_0x541dfa['query'][_0x197c('0x3c')](_0x197c('0x3d'))){_0x9411e8['limit']=qs[_0x197c('0x3e')](_0x541dfa[_0x197c('0x36')][_0x197c('0x3e')]);_0x9411e8[_0x197c('0x1f')]=qs[_0x197c('0x1f')](_0x541dfa['query']['offset']);}return _0x272674['getTeams'](_0x9411e8);}})[_0x197c('0x26')](function(_0x4aa465){if(_0x4aa465){return _0x4aa465?{'count':_0x557b3c,'rows':_0x4aa465}:null;}})['then'](respondWithResult(_0x315bd3,null))[_0x197c('0x49')](handleError(_0x315bd3,null));};exports[_0x197c('0x67')]=function(_0x3b9abb,_0x179af3,_0x652281){var _0x542db6=_0x3b9abb['body'][_0x197c('0x68')];return db[_0x197c('0x66')]['findAll']({'where':{'id':_0x542db6},'attributes':['id'],'include':[{'model':db[_0x197c('0x5c')],'as':_0x197c('0x69'),'attributes':['id',_0x197c('0x56'),_0x197c('0x6a'),_0x197c('0x6b'),_0x197c('0x6c')],'raw':!![]}]})['then'](function(_0x107d42){if(_0x107d42){var _0x45f2d0=_[_0x197c('0x6d')](_0x107d42,function(_0x26fe80){var _0x33e346=_0x26fe80['get']({'plain':!![]});return _0x33e346['Agents'];});return db[_0x197c('0x2f')]['find']({'where':{'id':_0x3b9abb[_0x197c('0x4b')]['id']}})[_0x197c('0x26')](function(_0x2483c2){return db[_0x197c('0x6e')][_0x197c('0x6f')](function(_0x5959b1){return _0x2483c2[_0x197c('0x67')](_0x542db6,{'transaction':_0x5959b1})[_0x197c('0x26')](function(){return BPromise[_0x197c('0x70')](_0x45f2d0,function(_0x2af0c1){return db['UserFaxQueue']['findOrCreate']({'where':{'UserId':_0x2af0c1['id'],'FaxQueueId':_0x3b9abb[_0x197c('0x4b')]['id']},'transaction':_0x5959b1});});})['then'](function(){_0x45f2d0['forEach'](function(_0x34b3d6){socket[_0x197c('0x71')](_0x197c('0x72'),{'UserId':_0x34b3d6['id'],'FaxQueueId':_0x2483c2['id']});});});});});}})['then'](respondWithStatusCode(_0x179af3,null))['catch'](handleError(_0x179af3,null));};exports[_0x197c('0x73')]=function(_0x36a69d,_0x545061,_0x17d82b){return db[_0x197c('0x66')]['findAll']({'where':{'id':_0x36a69d[_0x197c('0x36')][_0x197c('0x68')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x197c('0x69'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x545061,null))[_0x197c('0x26')](function(_0x18c722){var _0x3f078b=_[_0x197c('0x2e')](_0x18c722,'id');var _0x184623=[];var _0x56bdf5=[];var _0x2d1b23=squel[_0x197c('0x74')]();_0x2d1b23[_0x197c('0x75')](_0x197c('0x76'))[_0x197c('0x77')](_0x197c('0x78'),'tq')[_0x197c('0x79')]('user_has_teams','ut',_0x197c('0x7a'))['where'](_0x197c('0x7b'),_0x36a69d[_0x197c('0x4b')]['id']);for(var _0x154cb0=0x0;_0x154cb0<_0x18c722[_0x197c('0x3b')];_0x154cb0+=0x1){let _0x4edf13=_0x18c722[_0x154cb0];for(var _0x3a7ee0=0x0;_0x3a7ee0<_0x4edf13[_0x197c('0x69')][_0x197c('0x3b')];_0x3a7ee0+=0x1){let _0x4e45d9=_0x4edf13[_0x197c('0x69')][_0x3a7ee0];var _0x33224d=_0x2d1b23[_0x197c('0x7c')]();_0x33224d[_0x197c('0x41')](_0x197c('0x7d'),_0x4e45d9['id']);_0x56bdf5[_0x197c('0x7e')](db[_0x197c('0x6e')]['query'](_0x33224d[_0x197c('0x7f')](),{'type':db['sequelize'][_0x197c('0x80')][_0x197c('0x81')]})[_0x197c('0x26')](function(_0x3bbb37){if(_0x3bbb37[_0x197c('0x3b')]===0x1){return _0x4e45d9['id'];}else{var _0x5d78b6=_[_0x197c('0x82')](_[_0x197c('0x2e')](_0x3bbb37,_0x197c('0x83')),function(_0x54ada1){return _[_0x197c('0x84')](_0x3f078b,_0x54ada1);});if(_0x5d78b6){return _0x4e45d9['id'];}}}));}}return BPromise['all'](_0x56bdf5)['then'](function(_0x2abdfe){_0x184623=_(_0x184623)[_0x197c('0x85')](_0x2abdfe)[_0x197c('0x86')]()[_0x197c('0x87')]();return db[_0x197c('0x2f')][_0x197c('0x4d')]({'where':{'id':_0x36a69d[_0x197c('0x4b')]['id']}})[_0x197c('0x26')](function(_0x4f57d2){return db[_0x197c('0x6e')][_0x197c('0x6f')](function(_0x50d920){return _0x4f57d2[_0x197c('0x73')](_0x36a69d[_0x197c('0x36')]['ids'],{'transaction':_0x50d920})[_0x197c('0x26')](function(){if(!_[_0x197c('0x88')](_0x184623)){return _0x4f57d2[_0x197c('0x89')](_0x184623,{'transaction':_0x50d920});}})[_0x197c('0x26')](function(){_0x184623[_0x197c('0x8a')](function(_0x55e845){socket['emit'](_0x197c('0x8b'),{'UserId':_0x55e845,'FaxQueueId':_0x4f57d2['id']});});});});});});})[_0x197c('0x26')](respondWithStatusCode(_0x545061,null))[_0x197c('0x49')](handleError(_0x545061,null));};exports[_0x197c('0x8c')]=function(_0x40783c,_0x167f51,_0x23b759){return db[_0x197c('0x2f')]['find']({'where':{'id':_0x40783c[_0x197c('0x4b')]['id']}})[_0x197c('0x26')](handleEntityNotFound(_0x167f51,null))[_0x197c('0x26')](function(_0x1eb656){if(_0x1eb656){return _0x1eb656[_0x197c('0x8c')](_0x40783c[_0x197c('0x4f')]['ids'],_[_0x197c('0x8d')](_0x40783c[_0x197c('0x4f')],[_0x197c('0x68'),'id'])||{})['spread'](function(_0x317d88){for(var _0x4ee019=0x0;_0x4ee019<_0x40783c[_0x197c('0x4f')][_0x197c('0x68')][_0x197c('0x3b')];_0x4ee019+=0x1){socket[_0x197c('0x71')](_0x197c('0x72'),{'UserId':_0x40783c[_0x197c('0x4f')][_0x197c('0x68')][_0x4ee019],'FaxQueueId':_0x40783c['params']['id']});}return _0x317d88;});}})[_0x197c('0x26')](respondWithResult(_0x167f51,null))[_0x197c('0x49')](handleError(_0x167f51,null));};exports[_0x197c('0x89')]=function(_0x307edb,_0x59c96b,_0x254568){return db['FaxQueue'][_0x197c('0x4d')]({'where':{'id':_0x307edb[_0x197c('0x4b')]['id']}})[_0x197c('0x26')](handleEntityNotFound(_0x59c96b,null))[_0x197c('0x26')](function(_0x480380){if(_0x480380){return _0x480380[_0x197c('0x89')](_0x307edb[_0x197c('0x36')][_0x197c('0x68')])[_0x197c('0x26')](function(){if(_[_0x197c('0x8e')](_0x307edb['query'][_0x197c('0x68')])){for(var _0x1af79a=0x0;_0x1af79a<_0x307edb[_0x197c('0x36')][_0x197c('0x68')][_0x197c('0x3b')];_0x1af79a+=0x1){socket['emit']('userFaxQueue:remove',{'UserId':Number(_0x307edb[_0x197c('0x36')][_0x197c('0x68')][_0x1af79a]),'FaxQueueId':Number(_0x307edb[_0x197c('0x4b')]['id'])});}}else{socket[_0x197c('0x71')](_0x197c('0x8b'),{'UserId':Number(_0x307edb[_0x197c('0x36')]['ids']),'FaxQueueId':Number(_0x307edb[_0x197c('0x4b')]['id'])});}});}})['then'](respondWithStatusCode(_0x59c96b,null))['catch'](handleError(_0x59c96b,null));};exports[_0x197c('0x8f')]=function(_0x2e5db3,_0x3fbba7,_0x5e5a57){var _0x378a13={};var _0xb02205={};var _0x42be6b;var _0x194957;return db[_0x197c('0x2f')][_0x197c('0x59')]({'where':{'id':_0x2e5db3['params']['id']}})[_0x197c('0x26')](handleEntityNotFound(_0x3fbba7,null))['then'](function(_0x8b3237){if(_0x8b3237){_0x42be6b=_0x8b3237;_0xb02205['model']=_[_0x197c('0x35')](db[_0x197c('0x5c')]['rawAttributes']);_0xb02205[_0x197c('0x36')]=_[_0x197c('0x35')](_0x2e5db3[_0x197c('0x36')]);_0xb02205[_0x197c('0x37')]=_[_0x197c('0x38')](_0xb02205[_0x197c('0x34')],_0xb02205[_0x197c('0x36')]);_0x378a13[_0x197c('0x39')]=_[_0x197c('0x38')](_0xb02205[_0x197c('0x34')],qs[_0x197c('0x3a')](_0x2e5db3[_0x197c('0x36')]['fields']));_0x378a13['attributes']=_0x378a13[_0x197c('0x39')][_0x197c('0x3b')]?_0x378a13[_0x197c('0x39')]:_0xb02205[_0x197c('0x34')];_0x378a13[_0x197c('0x3f')]=qs['sort'](_0x2e5db3[_0x197c('0x36')][_0x197c('0x40')]);_0x378a13[_0x197c('0x41')]=qs[_0x197c('0x37')](_[_0x197c('0x42')](_0x2e5db3[_0x197c('0x36')],_0xb02205[_0x197c('0x37')]));if(_0x2e5db3[_0x197c('0x36')][_0x197c('0x43')]){_0x378a13[_0x197c('0x41')]=_[_0x197c('0x44')](_0x378a13[_0x197c('0x41')],{'$or':_['map'](_0x378a13['attributes'],function(_0x24da47){var _0x48b0c2={};_0x48b0c2[_0x24da47]={'$like':'%'+_0x2e5db3[_0x197c('0x36')][_0x197c('0x43')]+'%'};return _0x48b0c2;})});}_0x378a13=_[_0x197c('0x44')]({},_0x378a13,_0x2e5db3[_0x197c('0x46')]);return _0x42be6b[_0x197c('0x8f')](_0x378a13);}})[_0x197c('0x26')](function(_0x312212){if(_0x312212){_0x194957=_0x312212['length'];if(!_0x2e5db3[_0x197c('0x36')]['hasOwnProperty'](_0x197c('0x3d'))){_0x378a13[_0x197c('0x3e')]=qs[_0x197c('0x3e')](_0x2e5db3[_0x197c('0x36')][_0x197c('0x3e')]);_0x378a13[_0x197c('0x1f')]=qs['offset'](_0x2e5db3[_0x197c('0x36')][_0x197c('0x1f')]);}return _0x42be6b[_0x197c('0x8f')](_0x378a13);}})[_0x197c('0x26')](function(_0x2bc735){if(_0x2bc735){return _0x2bc735?{'count':_0x194957,'rows':_0x2bc735}:null;}})[_0x197c('0x26')](respondWithResult(_0x3fbba7,null))[_0x197c('0x49')](handleError(_0x3fbba7,null));};
\ No newline at end of file
+var _0x31f0=['merge','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','error','describe','findOne','UserFaxQueue','nolimit','order','sort','pick','FaxQueueId','filter','findAndCountAll','UserId','agent','faxPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','ids','User','Agents','online','interface','flatMap','sequelize','each','findOrCreate','forEach','userFaxQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','QueryTypes','every','TeamId','includes','union','transaction','removeAgents','userFaxQueue:remove','addAgents','omit','emit','getAgents','bluebird','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../mysqldb','redis','socket.io-emitter','./faxQueue.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','then','destroy','get','FaxQueues','UserProfileResource','name','send','index','map','rawAttributes','type','key','getOptions','where','FaxQueue','include','query','findAll','rows','catch','show','params','model','keys','filters','intersection','attributes','fields','length','includeAll'];(function(_0x147656,_0x205a15){var _0x37e1e9=function(_0xea78b){while(--_0xea78b){_0x147656['push'](_0x147656['shift']());}};_0x37e1e9(++_0x205a15);}(_0x31f0,0xb7));var _0x031f=function(_0x33f6db,_0x277e76){_0x33f6db=_0x33f6db-0x0;var _0x3bc6d0=_0x31f0[_0x33f6db];return _0x3bc6d0;};'use strict';var BPromise=require(_0x031f('0x0'));var util=require('util');var _=require(_0x031f('0x1'));var squel=require('squel');var Redis=require(_0x031f('0x2'));var qs=require(_0x031f('0x3'));var logger=require(_0x031f('0x4'))(_0x031f('0x5'));var config=require('../../config/environment');var db=require(_0x031f('0x6'))['db'];config[_0x031f('0x7')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x031f('0x8'))(new Redis(config['redis']));require(_0x031f('0x9'))[_0x031f('0xa')](socket);function respondWithStatusCode(_0x2569b6,_0x3e41ed){_0x3e41ed=_0x3e41ed||0xcc;return function(_0x4d47c5){if(_0x4d47c5){return _0x2569b6[_0x031f('0xb')](_0x3e41ed);}return _0x2569b6[_0x031f('0xc')](_0x3e41ed)[_0x031f('0xd')]();};}function respondWithResult(_0x439940,_0x3dd729){_0x3dd729=_0x3dd729||0xc8;return function(_0x3b0a17){if(_0x3b0a17){return _0x439940[_0x031f('0xc')](_0x3dd729)[_0x031f('0xe')](_0x3b0a17);}};}function respondWithFilteredResult(_0x4df318,_0x5c3657){return function(_0x353744){if(_0x353744){var _0x28da6e=typeof _0x5c3657[_0x031f('0xf')]===_0x031f('0x10')&&typeof _0x5c3657[_0x031f('0x11')]===_0x031f('0x10');var _0x5d0457=_0x353744[_0x031f('0x12')];var _0x23b40c=_0x28da6e?0x0:_0x5c3657[_0x031f('0xf')];var _0x2e3dfe=_0x28da6e?_0x353744[_0x031f('0x12')]:_0x5c3657['offset']+_0x5c3657['limit'];var _0x1f08db;if(_0x2e3dfe>=_0x5d0457){_0x2e3dfe=_0x5d0457;_0x1f08db=0xc8;}else{_0x1f08db=0xce;}_0x4df318[_0x031f('0xc')](_0x1f08db);return _0x4df318[_0x031f('0x13')](_0x031f('0x14'),_0x23b40c+'-'+_0x2e3dfe+'/'+_0x5d0457)['json'](_0x353744);}return null;};}function saveUpdates(_0x1dc4a7){return function(_0x1d8ac2){if(_0x1d8ac2){return _0x1d8ac2['update'](_0x1dc4a7)[_0x031f('0x15')](function(_0x535e70){return _0x535e70;});}return null;};}function removeEntity(_0x421f75){return function(_0x5f2199){if(_0x5f2199){return _0x5f2199[_0x031f('0x16')]()[_0x031f('0x15')](function(){var _0x1ceddc=_0x5f2199[_0x031f('0x17')]({'plain':!![]});var _0x1b76d6=_0x031f('0x18');return db[_0x031f('0x19')][_0x031f('0x16')]({'where':{'type':_0x1b76d6,'resourceId':_0x1ceddc['id']}})[_0x031f('0x15')](function(){return _0x5f2199;});})['then'](function(){_0x421f75[_0x031f('0xc')](0xcc)[_0x031f('0xd')]();});}};}function handleEntityNotFound(_0x451328){return function(_0x4d6706){if(!_0x4d6706){_0x451328['sendStatus'](0x194);}return _0x4d6706;};}function handleError(_0xa11a2b,_0x4d0f92){_0x4d0f92=_0x4d0f92||0x1f4;return function(_0x3472a2){logger['error'](_0x3472a2['stack']);if(_0x3472a2['name']){delete _0x3472a2[_0x031f('0x1a')];}_0xa11a2b[_0x031f('0xc')](_0x4d0f92)[_0x031f('0x1b')](_0x3472a2);};}exports[_0x031f('0x1c')]=function(_0x494568,_0x374b65){var _0x5a64c0={};var _0x40cb1c={'count':0x0,'rows':[]};var _0x1f5a14=_[_0x031f('0x1d')](db['FaxQueue'][_0x031f('0x1e')],function(_0x3b2a51){return{'name':_0x3b2a51['fieldName'],'type':_0x3b2a51[_0x031f('0x1f')][_0x031f('0x20')]};});_0x5a64c0=qs[_0x031f('0x21')](_0x1f5a14,_0x494568);var _0x5395ea={'where':_0x5a64c0[_0x031f('0x22')]};return db[_0x031f('0x23')][_0x031f('0x12')](_0x5395ea)[_0x031f('0x15')](function(_0xfaa36){_0x40cb1c[_0x031f('0x12')]=_0xfaa36;_0x5a64c0['include']=qs[_0x031f('0x24')](_0x494568[_0x031f('0x25')]);return db[_0x031f('0x23')][_0x031f('0x26')](_0x5a64c0);})[_0x031f('0x15')](function(_0x2d24f0){_0x40cb1c[_0x031f('0x27')]=_0x2d24f0;return _0x40cb1c;})[_0x031f('0x15')](respondWithFilteredResult(_0x374b65,_0x5a64c0))[_0x031f('0x28')](handleError(_0x374b65,null));};exports[_0x031f('0x29')]=function(_0x2cf3a8,_0x5ec564){var _0xced6ff={'raw':!![],'where':{'id':_0x2cf3a8[_0x031f('0x2a')]['id']}},_0xe5f11c={};_0xe5f11c[_0x031f('0x2b')]=_[_0x031f('0x2c')](db[_0x031f('0x23')][_0x031f('0x1e')]);_0xe5f11c[_0x031f('0x25')]=_[_0x031f('0x2c')](_0x2cf3a8[_0x031f('0x25')]);_0xe5f11c[_0x031f('0x2d')]=_[_0x031f('0x2e')](_0xe5f11c[_0x031f('0x2b')],_0xe5f11c['query']);_0xced6ff[_0x031f('0x2f')]=_[_0x031f('0x2e')](_0xe5f11c['model'],qs[_0x031f('0x30')](_0x2cf3a8[_0x031f('0x25')]['fields']));_0xced6ff[_0x031f('0x2f')]=_0xced6ff[_0x031f('0x2f')][_0x031f('0x31')]?_0xced6ff[_0x031f('0x2f')]:_0xe5f11c['model'];if(_0x2cf3a8['query'][_0x031f('0x32')]){_0xced6ff['include']=[{'all':!![]}];}_0xced6ff=_[_0x031f('0x33')]({},_0xced6ff,_0x2cf3a8[_0x031f('0x34')]);return db[_0x031f('0x23')]['find'](_0xced6ff)['then'](handleEntityNotFound(_0x5ec564,null))[_0x031f('0x15')](respondWithResult(_0x5ec564,null))['catch'](handleError(_0x5ec564,null));};exports['create']=function(_0x2d489a,_0x45e3a4){return db[_0x031f('0x23')][_0x031f('0x35')](_0x2d489a[_0x031f('0x36')],{})[_0x031f('0x15')](function(_0x1ffd03){var _0x55c85f=_0x2d489a[_0x031f('0x37')][_0x031f('0x17')]({'plain':!![]});if(!_0x55c85f)throw new Error(_0x031f('0x38'));if(_0x55c85f[_0x031f('0x39')]==='user'){var _0x2be5d1=_0x1ffd03[_0x031f('0x17')]({'plain':!![]});var _0x2dba8b='FaxQueues';return db[_0x031f('0x3a')][_0x031f('0x3b')]({'where':{'name':_0x2dba8b,'userProfileId':_0x55c85f['userProfileId']},'raw':!![]})[_0x031f('0x15')](function(_0x268dc7){if(_0x268dc7&&_0x268dc7['autoAssociation']===0x0){return db['UserProfileResource'][_0x031f('0x35')]({'name':_0x2be5d1[_0x031f('0x1a')],'resourceId':_0x2be5d1['id'],'type':_0x268dc7[_0x031f('0x1a')],'sectionId':_0x268dc7['id']},{})[_0x031f('0x15')](function(){return _0x1ffd03;});}else{return _0x1ffd03;}})[_0x031f('0x28')](function(_0xf0fb95){logger[_0x031f('0x3c')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xf0fb95);throw _0xf0fb95;});}return _0x1ffd03;})[_0x031f('0x15')](respondWithResult(_0x45e3a4,0xc9))[_0x031f('0x28')](handleError(_0x45e3a4,null));};exports['update']=function(_0x12279a,_0x505e93){if(_0x12279a[_0x031f('0x36')]['id']){delete _0x12279a[_0x031f('0x36')]['id'];}return db['FaxQueue'][_0x031f('0x3b')]({'where':{'id':_0x12279a[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](handleEntityNotFound(_0x505e93,null))['then'](saveUpdates(_0x12279a[_0x031f('0x36')],null))[_0x031f('0x15')](respondWithResult(_0x505e93,null))[_0x031f('0x28')](handleError(_0x505e93,null));};exports[_0x031f('0x16')]=function(_0x177306,_0x193b8f){return db[_0x031f('0x23')][_0x031f('0x3b')]({'where':{'id':_0x177306[_0x031f('0x2a')]['id']}})['then'](handleEntityNotFound(_0x193b8f,null))[_0x031f('0x15')](removeEntity(_0x193b8f,null))[_0x031f('0x28')](handleError(_0x193b8f,null));};exports[_0x031f('0x3d')]=function(_0x3205ce,_0xcf2072){return db[_0x031f('0x23')][_0x031f('0x3d')]()[_0x031f('0x15')](respondWithResult(_0xcf2072,null))[_0x031f('0x28')](handleError(_0xcf2072,null));};exports['getMembers']=function(_0x38539a,_0x5ec593){var _0x512937={'raw':!![],'where':{}},_0x434849={},_0x2359d1;return db[_0x031f('0x23')][_0x031f('0x3e')]({'where':{'id':_0x38539a[_0x031f('0x2a')]['id']}})['then'](handleEntityNotFound(_0x5ec593,null))[_0x031f('0x15')](function(_0x365f8c){if(_0x365f8c){_0x2359d1=_0x365f8c[_0x031f('0x17')]({'plain':!![]});_0x434849['model']=_[_0x031f('0x2c')](db[_0x031f('0x3f')][_0x031f('0x1e')]);_0x434849[_0x031f('0x25')]=_[_0x031f('0x2c')](_0x38539a[_0x031f('0x25')]);_0x434849['filters']=_['intersection'](_0x434849[_0x031f('0x2b')],_0x434849['query']);_0x512937[_0x031f('0x2f')]=_[_0x031f('0x2e')](_0x434849['model'],qs[_0x031f('0x30')](_0x38539a['query']['fields']));_0x512937[_0x031f('0x2f')]=_0x512937['attributes'][_0x031f('0x31')]?_0x512937['attributes']:_0x434849[_0x031f('0x2b')];if(!_0x38539a[_0x031f('0x25')]['hasOwnProperty'](_0x031f('0x40'))){_0x512937[_0x031f('0x11')]=qs['limit'](_0x38539a[_0x031f('0x25')]['limit']);_0x512937[_0x031f('0xf')]=qs['offset'](_0x38539a[_0x031f('0x25')][_0x031f('0xf')]);}_0x512937[_0x031f('0x41')]=qs[_0x031f('0x42')](_0x38539a[_0x031f('0x25')]['sort']);_0x512937[_0x031f('0x22')]=qs['filters'](_[_0x031f('0x43')](_0x38539a[_0x031f('0x25')],_0x434849['filters']));_0x512937[_0x031f('0x22')][_0x031f('0x44')]=_0x365f8c['id'];if(_0x38539a['query'][_0x031f('0x45')]){_0x512937[_0x031f('0x22')]=_[_0x031f('0x33')](_0x512937['where'],{'$or':_[_0x031f('0x1d')](_0x512937['attributes'],function(_0x254604){var _0x5a4aa4={};_0x5a4aa4[_0x254604]={'$like':'%'+_0x38539a[_0x031f('0x25')]['filter']+'%'};return _0x5a4aa4;})});}_0x512937=_[_0x031f('0x33')]({},_0x512937,_0x38539a[_0x031f('0x34')]);return db['UserFaxQueue']['findAll'](_0x512937);}})[_0x031f('0x15')](function(_0x10fa4c){if(_0x10fa4c){return db['User'][_0x031f('0x46')]({'where':{'id':_[_0x031f('0x1d')](_0x10fa4c,_0x031f('0x47')),'role':_0x031f('0x48')},'attributes':['id',_0x031f('0x1a'),_0x031f('0x49'),_0x031f('0x4a'),_0x031f('0x4b')]});}})['then'](function(_0xe452c2){if(_0xe452c2){return{'count':_0xe452c2[_0x031f('0x12')],'rows':_[_0x031f('0x1d')](_0xe452c2['rows'],function(_0x3937b7){return{'membername':_0x3937b7[_0x031f('0x1a')],'UserId':_0x3937b7['id'],'queue_name':_0x2359d1['name'],'FaxQueueId':_0x2359d1['id'],'interface':util[_0x031f('0x4c')](_0x031f('0x4d'),_0x031f('0x4e'),_0x3937b7[_0x031f('0x1a')]),'penalty':0x0,'paused':_0x3937b7['faxPause'],'createdAt':_0x3937b7['createdAt'],'updatedAt':_0x3937b7['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x5ec593,_0x512937))[_0x031f('0x28')](handleError(_0x5ec593,null));};exports[_0x031f('0x4f')]=function(_0x4a7fbb,_0x10531d){var _0x28f026={};var _0x508c4c={};var _0x110495;var _0x26ecb0;return db[_0x031f('0x23')][_0x031f('0x3e')]({'where':{'id':_0x4a7fbb[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](handleEntityNotFound(_0x10531d,null))[_0x031f('0x15')](function(_0x4527e5){if(_0x4527e5){_0x110495=_0x4527e5;_0x508c4c[_0x031f('0x2b')]=_['keys'](db[_0x031f('0x50')]['rawAttributes']);_0x508c4c[_0x031f('0x25')]=_[_0x031f('0x2c')](_0x4a7fbb[_0x031f('0x25')]);_0x508c4c['filters']=_['intersection'](_0x508c4c[_0x031f('0x2b')],_0x508c4c[_0x031f('0x25')]);_0x28f026[_0x031f('0x2f')]=_[_0x031f('0x2e')](_0x508c4c['model'],qs[_0x031f('0x30')](_0x4a7fbb['query']['fields']));_0x28f026[_0x031f('0x2f')]=_0x28f026['attributes']['length']?_0x28f026[_0x031f('0x2f')]:_0x508c4c[_0x031f('0x2b')];_0x28f026[_0x031f('0x41')]=qs[_0x031f('0x42')](_0x4a7fbb[_0x031f('0x25')]['sort']);_0x28f026['where']=qs[_0x031f('0x2d')](_['pick'](_0x4a7fbb[_0x031f('0x25')],_0x508c4c[_0x031f('0x2d')]));if(_0x4a7fbb['query'][_0x031f('0x45')]){_0x28f026[_0x031f('0x22')]=_[_0x031f('0x33')](_0x28f026[_0x031f('0x22')],{'$or':_[_0x031f('0x1d')](_0x28f026[_0x031f('0x2f')],function(_0x5bea08){var _0x58f012={};_0x58f012[_0x5bea08]={'$like':'%'+_0x4a7fbb[_0x031f('0x25')][_0x031f('0x45')]+'%'};return _0x58f012;})});}_0x28f026=_[_0x031f('0x33')]({},_0x28f026,_0x4a7fbb[_0x031f('0x34')]);return _0x110495[_0x031f('0x4f')](_0x28f026);}})[_0x031f('0x15')](function(_0x3cfb21){if(_0x3cfb21){_0x26ecb0=_0x3cfb21['length'];if(!_0x4a7fbb['query']['hasOwnProperty']('nolimit')){_0x28f026[_0x031f('0x11')]=qs[_0x031f('0x11')](_0x4a7fbb[_0x031f('0x25')]['limit']);_0x28f026[_0x031f('0xf')]=qs[_0x031f('0xf')](_0x4a7fbb['query'][_0x031f('0xf')]);}return _0x110495[_0x031f('0x4f')](_0x28f026);}})[_0x031f('0x15')](function(_0x140ccd){if(_0x140ccd){return _0x140ccd?{'count':_0x26ecb0,'rows':_0x140ccd}:null;}})[_0x031f('0x15')](respondWithResult(_0x10531d,null))[_0x031f('0x28')](handleError(_0x10531d,null));};exports[_0x031f('0x51')]=function(_0x5ecbd6,_0x571d15){var _0x8a448f=_0x5ecbd6['body'][_0x031f('0x52')];return db['Team'][_0x031f('0x26')]({'where':{'id':_0x8a448f},'attributes':['id'],'include':[{'model':db[_0x031f('0x53')],'as':_0x031f('0x54'),'attributes':['id','name',_0x031f('0x55'),'voicePause',_0x031f('0x56')],'raw':!![]}]})[_0x031f('0x15')](function(_0x3efa82){if(_0x3efa82){var _0x4e7251=_[_0x031f('0x57')](_0x3efa82,function(_0x398e7c){var _0x3c4b09=_0x398e7c[_0x031f('0x17')]({'plain':!![]});return _0x3c4b09[_0x031f('0x54')];});return db['FaxQueue']['find']({'where':{'id':_0x5ecbd6[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](function(_0x4bc4c7){return db[_0x031f('0x58')]['transaction'](function(_0x2dfff2){return _0x4bc4c7[_0x031f('0x51')](_0x8a448f,{'transaction':_0x2dfff2})[_0x031f('0x15')](function(){return BPromise[_0x031f('0x59')](_0x4e7251,function(_0x52bb92){return db[_0x031f('0x3f')][_0x031f('0x5a')]({'where':{'UserId':_0x52bb92['id'],'FaxQueueId':_0x5ecbd6[_0x031f('0x2a')]['id']},'transaction':_0x2dfff2});});})['then'](function(){_0x4e7251[_0x031f('0x5b')](function(_0xfda893){socket['emit'](_0x031f('0x5c'),{'UserId':_0xfda893['id'],'FaxQueueId':_0x4bc4c7['id']});});});});});}})[_0x031f('0x15')](respondWithStatusCode(_0x571d15,null))[_0x031f('0x28')](handleError(_0x571d15,null));};exports[_0x031f('0x5d')]=function(_0x104025,_0x38a8a4){return db[_0x031f('0x50')]['findAll']({'where':{'id':_0x104025[_0x031f('0x25')][_0x031f('0x52')]},'attributes':['id'],'include':[{'model':db[_0x031f('0x53')],'as':'Agents','attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0x38a8a4,null))[_0x031f('0x15')](function(_0x5bd344){var _0x54f02d=_[_0x031f('0x1d')](_0x5bd344,'id');var _0x184bbd=[];var _0x1c8055=[];var _0x1d6aca=squel[_0x031f('0x5e')]();_0x1d6aca[_0x031f('0x5f')](_0x031f('0x60'))[_0x031f('0x61')](_0x031f('0x62'),'tq')[_0x031f('0x63')](_0x031f('0x64'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x031f('0x22')](_0x031f('0x65'),_0x104025[_0x031f('0x2a')]['id']);for(var _0x8290bf=0x0;_0x8290bf<_0x5bd344['length'];_0x8290bf+=0x1){let _0x6970f5=_0x5bd344[_0x8290bf];for(var _0x5329c2=0x0;_0x5329c2<_0x6970f5['Agents'][_0x031f('0x31')];_0x5329c2+=0x1){let _0x2f4d09=_0x6970f5['Agents'][_0x5329c2];var _0x510bb6=_0x1d6aca[_0x031f('0x66')]();_0x510bb6[_0x031f('0x22')](_0x031f('0x67'),_0x2f4d09['id']);_0x1c8055[_0x031f('0x68')](db[_0x031f('0x58')][_0x031f('0x25')](_0x510bb6['toString'](),{'type':db[_0x031f('0x58')][_0x031f('0x69')]['SELECT']})[_0x031f('0x15')](function(_0x2f2e96){if(_0x2f2e96[_0x031f('0x31')]===0x1){return _0x2f4d09['id'];}else{var _0x14fc7e=_[_0x031f('0x6a')](_[_0x031f('0x1d')](_0x2f2e96,_0x031f('0x6b')),function(_0x4e9157){return _[_0x031f('0x6c')](_0x54f02d,_0x4e9157);});if(_0x14fc7e){return _0x2f4d09['id'];}}}));}}return BPromise['all'](_0x1c8055)[_0x031f('0x15')](function(_0x1d5d61){_0x184bbd=_(_0x184bbd)[_0x031f('0x6d')](_0x1d5d61)['compact']()['value']();return db['FaxQueue'][_0x031f('0x3b')]({'where':{'id':_0x104025[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](function(_0x2985fe){return db[_0x031f('0x58')][_0x031f('0x6e')](function(_0x232aa0){return _0x2985fe['removeTeams'](_0x104025['query'][_0x031f('0x52')],{'transaction':_0x232aa0})[_0x031f('0x15')](function(){if(!_['isEmpty'](_0x184bbd)){return _0x2985fe[_0x031f('0x6f')](_0x184bbd,{'transaction':_0x232aa0});}})['then'](function(){_0x184bbd[_0x031f('0x5b')](function(_0x20d85a){socket['emit'](_0x031f('0x70'),{'UserId':_0x20d85a,'FaxQueueId':_0x2985fe['id']});});});});});});})[_0x031f('0x15')](respondWithStatusCode(_0x38a8a4,null))['catch'](handleError(_0x38a8a4,null));};exports[_0x031f('0x71')]=function(_0x3c7dee,_0x1b588e){return db['FaxQueue'][_0x031f('0x3b')]({'where':{'id':_0x3c7dee[_0x031f('0x2a')]['id']}})[_0x031f('0x15')](handleEntityNotFound(_0x1b588e,null))[_0x031f('0x15')](function(_0x11165b){if(_0x11165b){return _0x11165b[_0x031f('0x71')](_0x3c7dee['body'][_0x031f('0x52')],_[_0x031f('0x72')](_0x3c7dee[_0x031f('0x36')],[_0x031f('0x52'),'id'])||{})['spread'](function(_0x33bf51){for(var _0x467a76=0x0;_0x467a76<_0x3c7dee['body'][_0x031f('0x52')][_0x031f('0x31')];_0x467a76+=0x1){socket[_0x031f('0x73')](_0x031f('0x5c'),{'UserId':Number(_0x3c7dee[_0x031f('0x36')][_0x031f('0x52')][_0x467a76]),'FaxQueueId':Number(_0x3c7dee[_0x031f('0x2a')]['id'])});}return _0x33bf51;});}})[_0x031f('0x15')](respondWithResult(_0x1b588e,null))[_0x031f('0x28')](handleError(_0x1b588e,null));};exports[_0x031f('0x6f')]=function(_0x16f7a0,_0x2b7347){return db[_0x031f('0x23')][_0x031f('0x3b')]({'where':{'id':_0x16f7a0[_0x031f('0x2a')]['id']}})['then'](handleEntityNotFound(_0x2b7347,null))[_0x031f('0x15')](function(_0x4368d6){if(_0x4368d6){return _0x4368d6[_0x031f('0x6f')](_0x16f7a0[_0x031f('0x25')][_0x031f('0x52')])[_0x031f('0x15')](function(){if(_['isArray'](_0x16f7a0['query']['ids'])){for(var _0x343acc=0x0;_0x343acc<_0x16f7a0[_0x031f('0x25')]['ids'][_0x031f('0x31')];_0x343acc+=0x1){socket[_0x031f('0x73')](_0x031f('0x70'),{'UserId':Number(_0x16f7a0[_0x031f('0x25')]['ids'][_0x343acc]),'FaxQueueId':Number(_0x16f7a0[_0x031f('0x2a')]['id'])});}}else{socket[_0x031f('0x73')](_0x031f('0x70'),{'UserId':Number(_0x16f7a0[_0x031f('0x25')][_0x031f('0x52')]),'FaxQueueId':Number(_0x16f7a0[_0x031f('0x2a')]['id'])});}});}})[_0x031f('0x15')](respondWithStatusCode(_0x2b7347,null))[_0x031f('0x28')](handleError(_0x2b7347,null));};exports[_0x031f('0x74')]=function(_0x3a798a,_0x3e3467){var _0x3eec5b={};var _0x4bd749={};var _0x2541fd;var _0x1f1f0e;return db['FaxQueue'][_0x031f('0x3e')]({'where':{'id':_0x3a798a[_0x031f('0x2a')]['id']}})['then'](handleEntityNotFound(_0x3e3467,null))[_0x031f('0x15')](function(_0x3bc88c){if(_0x3bc88c){_0x2541fd=_0x3bc88c;_0x4bd749[_0x031f('0x2b')]=_[_0x031f('0x2c')](db[_0x031f('0x53')][_0x031f('0x1e')]);_0x4bd749[_0x031f('0x25')]=_[_0x031f('0x2c')](_0x3a798a[_0x031f('0x25')]);_0x4bd749['filters']=_[_0x031f('0x2e')](_0x4bd749[_0x031f('0x2b')],_0x4bd749[_0x031f('0x25')]);_0x3eec5b['attributes']=_['intersection'](_0x4bd749[_0x031f('0x2b')],qs['fields'](_0x3a798a[_0x031f('0x25')][_0x031f('0x30')]));_0x3eec5b['attributes']=_0x3eec5b[_0x031f('0x2f')][_0x031f('0x31')]?_0x3eec5b[_0x031f('0x2f')]:_0x4bd749[_0x031f('0x2b')];_0x3eec5b[_0x031f('0x41')]=qs[_0x031f('0x42')](_0x3a798a[_0x031f('0x25')][_0x031f('0x42')]);_0x3eec5b[_0x031f('0x22')]=qs[_0x031f('0x2d')](_[_0x031f('0x43')](_0x3a798a[_0x031f('0x25')],_0x4bd749[_0x031f('0x2d')]));if(_0x3a798a['query']['filter']){_0x3eec5b[_0x031f('0x22')]=_['merge'](_0x3eec5b[_0x031f('0x22')],{'$or':_[_0x031f('0x1d')](_0x3eec5b[_0x031f('0x2f')],function(_0x513dfc){var _0x21f647={};_0x21f647[_0x513dfc]={'$like':'%'+_0x3a798a[_0x031f('0x25')]['filter']+'%'};return _0x21f647;})});}_0x3eec5b=_[_0x031f('0x33')]({},_0x3eec5b,_0x3a798a[_0x031f('0x34')]);return _0x2541fd[_0x031f('0x74')](_0x3eec5b);}})[_0x031f('0x15')](function(_0x348909){if(_0x348909){_0x1f1f0e=_0x348909[_0x031f('0x31')];if(!_0x3a798a[_0x031f('0x25')]['hasOwnProperty'](_0x031f('0x40'))){_0x3eec5b[_0x031f('0x11')]=qs[_0x031f('0x11')](_0x3a798a[_0x031f('0x25')]['limit']);_0x3eec5b['offset']=qs[_0x031f('0xf')](_0x3a798a['query']['offset']);}return _0x2541fd[_0x031f('0x74')](_0x3eec5b);}})['then'](function(_0x579ade){if(_0x579ade){return _0x579ade?{'count':_0x1f1f0e,'rows':_0x579ade}:null;}})[_0x031f('0x15')](respondWithResult(_0x3e3467,null))[_0x031f('0x28')](handleError(_0x3e3467,null));};
\ No newline at end of file