Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 284b26c..09d0cb3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1b05=['localhost','socket.io-emitter','./faxQueue.socket','register','sendStatus','status','end','json','undefined','limit','offset','count','set','Content-Range','reject','save','then','destroy','FaxQueues','UserProfileResource','error','stack','name','send','index','FaxQueue','key','model','map','keys','query','intersection','attributes','fields','nolimit','order','sort','where','pick','filters','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','params','rawAttributes','length','find','create','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','describe','getMembers','findOne','UserFaxQueue','hasOwnProperty','FaxQueueId','findAndCountAll','UserId','faxPause','updatedAt','createdAt','format','%s/%s','SIP','getTeams','Team','addTeams','ids','User','Agents','online','interface','flatMap','transaction','each','findOrCreate','forEach','emit','userFaxQueue:save','select','field','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','clone','push','toString','QueryTypes','every','TeamId','includes','all','union','compact','value','sequelize','isEmpty','userFaxQueue:remove','addAgents','omit','spread','removeAgents','getAgents','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','defaults','redis'];(function(_0x12db71,_0x4ac41b){var _0x2dacbd=function(_0x5b94c1){while(--_0x5b94c1){_0x12db71['push'](_0x12db71['shift']());}};_0x2dacbd(++_0x4ac41b);}(_0x1b05,0x79));var _0x51b0=function(_0x1852c4,_0x458b55){_0x1852c4=_0x1852c4-0x0;var _0x5d68e5=_0x1b05[_0x1852c4];return _0x5d68e5;};'use strict';var emlformat=require(_0x51b0('0x0'));var rimraf=require(_0x51b0('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x51b0('0x2'));var rp=require(_0x51b0('0x3'));var moment=require(_0x51b0('0x4'));var BPromise=require(_0x51b0('0x5'));var Mustache=require(_0x51b0('0x6'));var util=require(_0x51b0('0x7'));var path=require(_0x51b0('0x8'));var sox=require(_0x51b0('0x9'));var csv=require(_0x51b0('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x51b0('0xb'));var crypto=require(_0x51b0('0xc'));var jsforce=require(_0x51b0('0xd'));var deskjs=require(_0x51b0('0xe'));var toCsv=require(_0x51b0('0xa'));var querystring=require(_0x51b0('0xf'));var Papa=require(_0x51b0('0x10'));var Redis=require(_0x51b0('0x11'));var authService=require(_0x51b0('0x12'));var qs=require(_0x51b0('0x13'));var as=require(_0x51b0('0x14'));var hardwareService=require(_0x51b0('0x15'));var logger=require(_0x51b0('0x16'))(_0x51b0('0x17'));var utils=require(_0x51b0('0x18'));var config=require(_0x51b0('0x19'));var licenseUtil=require(_0x51b0('0x1a'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x51b0('0x1b')](config[_0x51b0('0x1c')],{'host':_0x51b0('0x1d'),'port':0x18eb});var socket=require(_0x51b0('0x1e'))(new Redis(config[_0x51b0('0x1c')]));require(_0x51b0('0x1f'))[_0x51b0('0x20')](socket);function respondWithStatusCode(_0x1aa3c2,_0x54aef9){_0x54aef9=_0x54aef9||0xcc;return function(_0x9ff02c){if(_0x9ff02c){return _0x1aa3c2[_0x51b0('0x21')](_0x54aef9);}return _0x1aa3c2[_0x51b0('0x22')](_0x54aef9)[_0x51b0('0x23')]();};}function respondWithResult(_0x441b7d,_0x20d7dd){_0x20d7dd=_0x20d7dd||0xc8;return function(_0x8154e0){if(_0x8154e0){return _0x441b7d[_0x51b0('0x22')](_0x20d7dd)[_0x51b0('0x24')](_0x8154e0);}};}function respondWithFilteredResult(_0x12d719,_0x29dd2f){return function(_0x594e4e){if(_0x594e4e){var _0x59e7c0=typeof _0x29dd2f['offset']===_0x51b0('0x25')&&typeof _0x29dd2f[_0x51b0('0x26')]===_0x51b0('0x25');var _0x78d3ab=_0x594e4e['count'];var _0xbd9302=_0x59e7c0?0x0:_0x29dd2f[_0x51b0('0x27')];var _0x1c3c7f=_0x59e7c0?_0x594e4e[_0x51b0('0x28')]:_0x29dd2f['offset']+_0x29dd2f[_0x51b0('0x26')];var _0x4d52ef;if(_0x1c3c7f>=_0x78d3ab){_0x1c3c7f=_0x78d3ab;_0x4d52ef=0xc8;}else{_0x4d52ef=0xce;}_0x12d719['status'](_0x4d52ef);return _0x12d719[_0x51b0('0x29')](_0x51b0('0x2a'),_0xbd9302+'-'+_0x1c3c7f+'/'+_0x78d3ab)[_0x51b0('0x24')](_0x594e4e);}return null;};}function patchUpdates(_0x113c40){return function(_0x512ca1){try{jsonpatch['apply'](_0x512ca1,_0x113c40,!![]);}catch(_0x331549){return BPromise[_0x51b0('0x2b')](_0x331549);}return _0x512ca1[_0x51b0('0x2c')]();};}function saveUpdates(_0x13ce17,_0x1492fd){return function(_0x1a380f){if(_0x1a380f){return _0x1a380f['update'](_0x13ce17)[_0x51b0('0x2d')](function(_0x2b008c){return _0x2b008c;});}return null;};}function removeEntity(_0x41b02b,_0x38dfec){return function(_0x4d2b73){if(_0x4d2b73){return _0x4d2b73[_0x51b0('0x2e')]()[_0x51b0('0x2d')](function(){var _0x161c6d=_0x4d2b73['get']({'plain':!![]});var _0x221ac4=_0x51b0('0x2f');return db[_0x51b0('0x30')][_0x51b0('0x2e')]({'where':{'type':_0x221ac4,'resourceId':_0x161c6d['id']}})[_0x51b0('0x2d')](function(){return _0x4d2b73;});})['then'](function(){_0x41b02b['status'](0xcc)[_0x51b0('0x23')]();});}};}function handleEntityNotFound(_0x263853,_0x5d76ba){return function(_0x24cbcf){if(!_0x24cbcf){_0x263853['sendStatus'](0x194);}return _0x24cbcf;};}function handleError(_0x5b8e2f,_0x2ab9ca){_0x2ab9ca=_0x2ab9ca||0x1f4;return function(_0xdb07a8){logger[_0x51b0('0x31')](_0xdb07a8[_0x51b0('0x32')]);if(_0xdb07a8['name']){delete _0xdb07a8[_0x51b0('0x33')];}_0x5b8e2f['status'](_0x2ab9ca)[_0x51b0('0x34')](_0xdb07a8);};}exports[_0x51b0('0x35')]=function(_0x3ab87d,_0x1b299d){var _0x221e56={},_0x308c9e={},_0x59d030={'count':0x0,'rows':[]};var _0x1596b0=_['map'](db[_0x51b0('0x36')]['rawAttributes'],function(_0x543746){return{'name':_0x543746['fieldName'],'type':_0x543746['type'][_0x51b0('0x37')]};});_0x308c9e[_0x51b0('0x38')]=_[_0x51b0('0x39')](_0x1596b0,_0x51b0('0x33'));_0x308c9e['query']=_[_0x51b0('0x3a')](_0x3ab87d[_0x51b0('0x3b')]);_0x308c9e['filters']=_[_0x51b0('0x3c')](_0x308c9e[_0x51b0('0x38')],_0x308c9e['query']);_0x221e56[_0x51b0('0x3d')]=_[_0x51b0('0x3c')](_0x308c9e[_0x51b0('0x38')],qs[_0x51b0('0x3e')](_0x3ab87d[_0x51b0('0x3b')]['fields']));_0x221e56[_0x51b0('0x3d')]=_0x221e56['attributes']['length']?_0x221e56[_0x51b0('0x3d')]:_0x308c9e[_0x51b0('0x38')];if(!_0x3ab87d[_0x51b0('0x3b')]['hasOwnProperty'](_0x51b0('0x3f'))){_0x221e56['limit']=qs[_0x51b0('0x26')](_0x3ab87d[_0x51b0('0x3b')][_0x51b0('0x26')]);_0x221e56[_0x51b0('0x27')]=qs['offset'](_0x3ab87d[_0x51b0('0x3b')]['offset']);}_0x221e56[_0x51b0('0x40')]=qs[_0x51b0('0x41')](_0x3ab87d[_0x51b0('0x3b')][_0x51b0('0x41')]);_0x221e56[_0x51b0('0x42')]=qs['filters'](_[_0x51b0('0x43')](_0x3ab87d[_0x51b0('0x3b')],_0x308c9e[_0x51b0('0x44')]),_0x1596b0);if(_0x3ab87d[_0x51b0('0x3b')][_0x51b0('0x45')]){_0x221e56[_0x51b0('0x42')]=_[_0x51b0('0x46')](_0x221e56['where'],{'$or':_[_0x51b0('0x39')](_0x1596b0,function(_0x4c475e){if(_0x4c475e['type']!==_0x51b0('0x47')){var _0x5c62f0={};_0x5c62f0[_0x4c475e[_0x51b0('0x33')]]={'$like':'%'+_0x3ab87d['query'][_0x51b0('0x45')]+'%'};return _0x5c62f0;}})});}_0x221e56=_[_0x51b0('0x46')]({},_0x221e56,_0x3ab87d[_0x51b0('0x48')]);var _0x420b40={'where':_0x221e56[_0x51b0('0x42')]};return db[_0x51b0('0x36')]['count'](_0x420b40)['then'](function(_0x1703cc){_0x59d030[_0x51b0('0x28')]=_0x1703cc;if(_0x3ab87d[_0x51b0('0x3b')][_0x51b0('0x49')]){_0x221e56[_0x51b0('0x4a')]=[{'all':!![]}];}return db[_0x51b0('0x36')][_0x51b0('0x4b')](_0x221e56);})['then'](function(_0x322e4c){_0x59d030[_0x51b0('0x4c')]=_0x322e4c;return _0x59d030;})[_0x51b0('0x2d')](respondWithFilteredResult(_0x1b299d,_0x221e56))[_0x51b0('0x4d')](handleError(_0x1b299d,null));};exports['show']=function(_0x361c53,_0x1f1677){var _0x4c145c={'raw':!![],'where':{'id':_0x361c53[_0x51b0('0x4e')]['id']}},_0x19ed27={};_0x19ed27[_0x51b0('0x38')]=_[_0x51b0('0x3a')](db['FaxQueue'][_0x51b0('0x4f')]);_0x19ed27[_0x51b0('0x3b')]=_[_0x51b0('0x3a')](_0x361c53[_0x51b0('0x3b')]);_0x19ed27[_0x51b0('0x44')]=_[_0x51b0('0x3c')](_0x19ed27['model'],_0x19ed27[_0x51b0('0x3b')]);_0x4c145c[_0x51b0('0x3d')]=_[_0x51b0('0x3c')](_0x19ed27['model'],qs['fields'](_0x361c53['query']['fields']));_0x4c145c[_0x51b0('0x3d')]=_0x4c145c[_0x51b0('0x3d')][_0x51b0('0x50')]?_0x4c145c[_0x51b0('0x3d')]:_0x19ed27[_0x51b0('0x38')];if(_0x361c53[_0x51b0('0x3b')][_0x51b0('0x49')]){_0x4c145c[_0x51b0('0x4a')]=[{'all':!![]}];}_0x4c145c=_['merge']({},_0x4c145c,_0x361c53[_0x51b0('0x48')]);return db[_0x51b0('0x36')][_0x51b0('0x51')](_0x4c145c)['then'](handleEntityNotFound(_0x1f1677,null))[_0x51b0('0x2d')](respondWithResult(_0x1f1677,null))[_0x51b0('0x4d')](handleError(_0x1f1677,null));};exports[_0x51b0('0x52')]=function(_0x54b5ad,_0x114aa4){return db['FaxQueue'][_0x51b0('0x52')](_0x54b5ad['body'],{})[_0x51b0('0x2d')](function(_0x3610b9){var _0x414c9c=_0x54b5ad['user'][_0x51b0('0x53')]({'plain':!![]});if(!_0x414c9c)throw new Error(_0x51b0('0x54'));if(_0x414c9c[_0x51b0('0x55')]===_0x51b0('0x56')){var _0x918cae=_0x3610b9[_0x51b0('0x53')]({'plain':!![]});var _0x233605='FaxQueues';return db[_0x51b0('0x57')][_0x51b0('0x51')]({'where':{'name':_0x233605,'userProfileId':_0x414c9c[_0x51b0('0x58')]},'raw':!![]})[_0x51b0('0x2d')](function(_0x16a621){if(_0x16a621&&_0x16a621[_0x51b0('0x59')]===0x0){return db[_0x51b0('0x30')][_0x51b0('0x52')]({'name':_0x918cae[_0x51b0('0x33')],'resourceId':_0x918cae['id'],'type':_0x16a621['name'],'sectionId':_0x16a621['id']},{})[_0x51b0('0x2d')](function(){return _0x3610b9;});}else{return _0x3610b9;}})[_0x51b0('0x4d')](function(_0x262ccf){logger[_0x51b0('0x31')](_0x51b0('0x5a'),_0x262ccf);throw _0x262ccf;});}return _0x3610b9;})['then'](respondWithResult(_0x114aa4,0xc9))['catch'](handleError(_0x114aa4,null));};exports[_0x51b0('0x5b')]=function(_0x3def02,_0x2ee030){if(_0x3def02[_0x51b0('0x5c')]['id']){delete _0x3def02[_0x51b0('0x5c')]['id'];}return db[_0x51b0('0x36')][_0x51b0('0x51')]({'where':{'id':_0x3def02['params']['id']}})[_0x51b0('0x2d')](handleEntityNotFound(_0x2ee030,null))['then'](saveUpdates(_0x3def02[_0x51b0('0x5c')],null))[_0x51b0('0x2d')](respondWithResult(_0x2ee030,null))[_0x51b0('0x4d')](handleError(_0x2ee030,null));};exports['destroy']=function(_0x459b31,_0x3061c7){return db[_0x51b0('0x36')][_0x51b0('0x51')]({'where':{'id':_0x459b31[_0x51b0('0x4e')]['id']}})[_0x51b0('0x2d')](handleEntityNotFound(_0x3061c7,null))[_0x51b0('0x2d')](removeEntity(_0x3061c7,null))[_0x51b0('0x4d')](handleError(_0x3061c7,null));};exports[_0x51b0('0x5d')]=function(_0x165e53,_0x17b2e0){return db[_0x51b0('0x36')][_0x51b0('0x5d')]()[_0x51b0('0x2d')](respondWithResult(_0x17b2e0,null))[_0x51b0('0x4d')](handleError(_0x17b2e0,null));};exports[_0x51b0('0x5e')]=function(_0x47076a,_0x1b9a47,_0x3ce3d5){var _0x222cf3={'raw':!![],'where':{}},_0x1a0db5={},_0x2e8249;return db[_0x51b0('0x36')][_0x51b0('0x5f')]({'where':{'id':_0x47076a[_0x51b0('0x4e')]['id']}})[_0x51b0('0x2d')](handleEntityNotFound(_0x1b9a47,null))[_0x51b0('0x2d')](function(_0x4fe94d){if(_0x4fe94d){_0x2e8249=_0x4fe94d[_0x51b0('0x53')]({'plain':!![]});_0x1a0db5[_0x51b0('0x38')]=_['keys'](db[_0x51b0('0x60')][_0x51b0('0x4f')]);_0x1a0db5[_0x51b0('0x3b')]=_[_0x51b0('0x3a')](_0x47076a[_0x51b0('0x3b')]);_0x1a0db5[_0x51b0('0x44')]=_['intersection'](_0x1a0db5[_0x51b0('0x38')],_0x1a0db5[_0x51b0('0x3b')]);_0x222cf3[_0x51b0('0x3d')]=_[_0x51b0('0x3c')](_0x1a0db5[_0x51b0('0x38')],qs[_0x51b0('0x3e')](_0x47076a['query'][_0x51b0('0x3e')]));_0x222cf3[_0x51b0('0x3d')]=_0x222cf3[_0x51b0('0x3d')]['length']?_0x222cf3[_0x51b0('0x3d')]:_0x1a0db5[_0x51b0('0x38')];if(!_0x47076a[_0x51b0('0x3b')][_0x51b0('0x61')]('nolimit')){_0x222cf3['limit']=qs[_0x51b0('0x26')](_0x47076a['query'][_0x51b0('0x26')]);_0x222cf3[_0x51b0('0x27')]=qs[_0x51b0('0x27')](_0x47076a[_0x51b0('0x3b')][_0x51b0('0x27')]);}_0x222cf3[_0x51b0('0x40')]=qs[_0x51b0('0x41')](_0x47076a[_0x51b0('0x3b')]['sort']);_0x222cf3[_0x51b0('0x42')]=qs['filters'](_[_0x51b0('0x43')](_0x47076a[_0x51b0('0x3b')],_0x1a0db5[_0x51b0('0x44')]));_0x222cf3[_0x51b0('0x42')][_0x51b0('0x62')]=_0x4fe94d['id'];if(_0x47076a[_0x51b0('0x3b')][_0x51b0('0x45')]){_0x222cf3[_0x51b0('0x42')]=_[_0x51b0('0x46')](_0x222cf3[_0x51b0('0x42')],{'$or':_[_0x51b0('0x39')](_0x222cf3['attributes'],function(_0x1a7b59){var _0x53c492={};_0x53c492[_0x1a7b59]={'$like':'%'+_0x47076a['query'][_0x51b0('0x45')]+'%'};return _0x53c492;})});}_0x222cf3=_[_0x51b0('0x46')]({},_0x222cf3,_0x47076a[_0x51b0('0x48')]);return db[_0x51b0('0x60')][_0x51b0('0x4b')](_0x222cf3);}})[_0x51b0('0x2d')](function(_0xece44b){if(_0xece44b){return db['User'][_0x51b0('0x63')]({'where':{'id':_['map'](_0xece44b,_0x51b0('0x64')),'role':'agent'},'attributes':['id','name',_0x51b0('0x65'),_0x51b0('0x66'),_0x51b0('0x67')]});}})[_0x51b0('0x2d')](function(_0x394d27){if(_0x394d27){return{'count':_0x394d27[_0x51b0('0x28')],'rows':_['map'](_0x394d27['rows'],function(_0x37ac1b){return{'membername':_0x37ac1b['name'],'UserId':_0x37ac1b['id'],'queue_name':_0x2e8249['name'],'FaxQueueId':_0x2e8249['id'],'interface':util[_0x51b0('0x68')](_0x51b0('0x69'),_0x51b0('0x6a'),_0x37ac1b[_0x51b0('0x33')]),'penalty':0x0,'paused':_0x37ac1b[_0x51b0('0x65')],'createdAt':_0x37ac1b[_0x51b0('0x67')],'updatedAt':_0x37ac1b[_0x51b0('0x66')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x51b0('0x2d')](respondWithFilteredResult(_0x1b9a47,_0x222cf3))[_0x51b0('0x4d')](handleError(_0x1b9a47,null));};exports[_0x51b0('0x6b')]=function(_0x117ce8,_0x456a92,_0x8876f2){var _0x381e03={};var _0x106dce={};var _0x35dca5;var _0x217daf;return db['FaxQueue'][_0x51b0('0x5f')]({'where':{'id':_0x117ce8[_0x51b0('0x4e')]['id']}})['then'](handleEntityNotFound(_0x456a92,null))['then'](function(_0x2bf52f){if(_0x2bf52f){_0x35dca5=_0x2bf52f;_0x106dce['model']=_[_0x51b0('0x3a')](db[_0x51b0('0x6c')]['rawAttributes']);_0x106dce[_0x51b0('0x3b')]=_[_0x51b0('0x3a')](_0x117ce8[_0x51b0('0x3b')]);_0x106dce[_0x51b0('0x44')]=_[_0x51b0('0x3c')](_0x106dce[_0x51b0('0x38')],_0x106dce[_0x51b0('0x3b')]);_0x381e03[_0x51b0('0x3d')]=_[_0x51b0('0x3c')](_0x106dce[_0x51b0('0x38')],qs['fields'](_0x117ce8[_0x51b0('0x3b')][_0x51b0('0x3e')]));_0x381e03['attributes']=_0x381e03[_0x51b0('0x3d')][_0x51b0('0x50')]?_0x381e03['attributes']:_0x106dce[_0x51b0('0x38')];_0x381e03['order']=qs['sort'](_0x117ce8['query']['sort']);_0x381e03[_0x51b0('0x42')]=qs[_0x51b0('0x44')](_[_0x51b0('0x43')](_0x117ce8[_0x51b0('0x3b')],_0x106dce['filters']));if(_0x117ce8[_0x51b0('0x3b')]['filter']){_0x381e03[_0x51b0('0x42')]=_['merge'](_0x381e03[_0x51b0('0x42')],{'$or':_['map'](_0x381e03[_0x51b0('0x3d')],function(_0x2935df){var _0x361ac9={};_0x361ac9[_0x2935df]={'$like':'%'+_0x117ce8[_0x51b0('0x3b')]['filter']+'%'};return _0x361ac9;})});}_0x381e03=_[_0x51b0('0x46')]({},_0x381e03,_0x117ce8[_0x51b0('0x48')]);return _0x35dca5['getTeams'](_0x381e03);}})['then'](function(_0x116efc){if(_0x116efc){_0x217daf=_0x116efc[_0x51b0('0x50')];if(!_0x117ce8[_0x51b0('0x3b')]['hasOwnProperty'](_0x51b0('0x3f'))){_0x381e03['limit']=qs['limit'](_0x117ce8[_0x51b0('0x3b')][_0x51b0('0x26')]);_0x381e03[_0x51b0('0x27')]=qs[_0x51b0('0x27')](_0x117ce8[_0x51b0('0x3b')][_0x51b0('0x27')]);}return _0x35dca5[_0x51b0('0x6b')](_0x381e03);}})[_0x51b0('0x2d')](function(_0x103b43){if(_0x103b43){return _0x103b43?{'count':_0x217daf,'rows':_0x103b43}:null;}})[_0x51b0('0x2d')](respondWithResult(_0x456a92,null))[_0x51b0('0x4d')](handleError(_0x456a92,null));};exports[_0x51b0('0x6d')]=function(_0x3c5278,_0x20958a,_0x44096e){var _0x8fb488=_0x3c5278[_0x51b0('0x5c')][_0x51b0('0x6e')];return db[_0x51b0('0x6c')][_0x51b0('0x4b')]({'where':{'id':_0x8fb488},'attributes':['id'],'include':[{'model':db[_0x51b0('0x6f')],'as':_0x51b0('0x70'),'attributes':['id',_0x51b0('0x33'),_0x51b0('0x71'),'voicePause',_0x51b0('0x72')],'raw':!![]}]})[_0x51b0('0x2d')](function(_0x41bf0f){if(_0x41bf0f){var _0x318d5f=_[_0x51b0('0x73')](_0x41bf0f,function(_0x349e85){var _0x5871eb=_0x349e85[_0x51b0('0x53')]({'plain':!![]});return _0x5871eb[_0x51b0('0x70')];});return db[_0x51b0('0x36')]['find']({'where':{'id':_0x3c5278[_0x51b0('0x4e')]['id']}})['then'](function(_0x2e2153){return db['sequelize'][_0x51b0('0x74')](function(_0x12d461){return _0x2e2153[_0x51b0('0x6d')](_0x8fb488,{'transaction':_0x12d461})[_0x51b0('0x2d')](function(){return BPromise[_0x51b0('0x75')](_0x318d5f,function(_0x264977){return db[_0x51b0('0x60')][_0x51b0('0x76')]({'where':{'UserId':_0x264977['id'],'FaxQueueId':_0x3c5278['params']['id']},'transaction':_0x12d461});});})[_0x51b0('0x2d')](function(){_0x318d5f[_0x51b0('0x77')](function(_0x1a6827){socket[_0x51b0('0x78')](_0x51b0('0x79'),{'UserId':_0x1a6827['id'],'FaxQueueId':_0x2e2153['id']});});});});});}})[_0x51b0('0x2d')](respondWithStatusCode(_0x20958a,null))[_0x51b0('0x4d')](handleError(_0x20958a,null));};exports['removeTeams']=function(_0x6dfbc1,_0x37567c,_0x5dc604){return db[_0x51b0('0x6c')]['findAll']({'where':{'id':_0x6dfbc1[_0x51b0('0x3b')][_0x51b0('0x6e')]},'attributes':['id'],'include':[{'model':db[_0x51b0('0x6f')],'as':_0x51b0('0x70'),'attributes':['id'],'raw':!![]}]})[_0x51b0('0x2d')](handleEntityNotFound(_0x37567c,null))['then'](function(_0x4c4305){var _0x4a603d=_[_0x51b0('0x39')](_0x4c4305,'id');var _0xbac7d5=[];var _0x5756cd=[];var _0x45b4ef=squel[_0x51b0('0x7a')]();_0x45b4ef[_0x51b0('0x7b')](_0x51b0('0x7c'))[_0x51b0('0x7d')](_0x51b0('0x7e'),'tq')[_0x51b0('0x7f')](_0x51b0('0x80'),'ut',_0x51b0('0x81'))[_0x51b0('0x42')](_0x51b0('0x82'),_0x6dfbc1[_0x51b0('0x4e')]['id']);for(var _0x5187fc=0x0;_0x5187fc<_0x4c4305[_0x51b0('0x50')];_0x5187fc+=0x1){let _0x43960b=_0x4c4305[_0x5187fc];for(var _0x58b4e5=0x0;_0x58b4e5<_0x43960b[_0x51b0('0x70')][_0x51b0('0x50')];_0x58b4e5+=0x1){let _0x17400d=_0x43960b[_0x51b0('0x70')][_0x58b4e5];var _0x3e323f=_0x45b4ef[_0x51b0('0x83')]();_0x3e323f[_0x51b0('0x42')]('ut.UserId\x20=\x20?',_0x17400d['id']);_0x5756cd[_0x51b0('0x84')](db['sequelize'][_0x51b0('0x3b')](_0x3e323f[_0x51b0('0x85')](),{'type':db['sequelize'][_0x51b0('0x86')]['SELECT']})['then'](function(_0x5734bc){if(_0x5734bc[_0x51b0('0x50')]===0x1){return _0x17400d['id'];}else{var _0x210315=_[_0x51b0('0x87')](_[_0x51b0('0x39')](_0x5734bc,_0x51b0('0x88')),function(_0xb655e2){return _[_0x51b0('0x89')](_0x4a603d,_0xb655e2);});if(_0x210315){return _0x17400d['id'];}}}));}}return BPromise[_0x51b0('0x8a')](_0x5756cd)[_0x51b0('0x2d')](function(_0x2cad9e){_0xbac7d5=_(_0xbac7d5)[_0x51b0('0x8b')](_0x2cad9e)[_0x51b0('0x8c')]()[_0x51b0('0x8d')]();return db[_0x51b0('0x36')][_0x51b0('0x51')]({'where':{'id':_0x6dfbc1[_0x51b0('0x4e')]['id']}})[_0x51b0('0x2d')](function(_0x46e8f3){return db[_0x51b0('0x8e')][_0x51b0('0x74')](function(_0x39d03e){return _0x46e8f3['removeTeams'](_0x6dfbc1[_0x51b0('0x3b')][_0x51b0('0x6e')],{'transaction':_0x39d03e})[_0x51b0('0x2d')](function(){if(!_[_0x51b0('0x8f')](_0xbac7d5)){return _0x46e8f3['removeAgents'](_0xbac7d5,{'transaction':_0x39d03e});}})[_0x51b0('0x2d')](function(){_0xbac7d5['forEach'](function(_0x380b5f){socket[_0x51b0('0x78')](_0x51b0('0x90'),{'UserId':_0x380b5f,'FaxQueueId':_0x46e8f3['id']});});});});});});})[_0x51b0('0x2d')](respondWithStatusCode(_0x37567c,null))[_0x51b0('0x4d')](handleError(_0x37567c,null));};exports[_0x51b0('0x91')]=function(_0x408d0b,_0x285820,_0x4fee78){return db['FaxQueue']['find']({'where':{'id':_0x408d0b[_0x51b0('0x4e')]['id']}})[_0x51b0('0x2d')](handleEntityNotFound(_0x285820,null))[_0x51b0('0x2d')](function(_0x5dde08){if(_0x5dde08){return _0x5dde08[_0x51b0('0x91')](_0x408d0b[_0x51b0('0x5c')][_0x51b0('0x6e')],_[_0x51b0('0x92')](_0x408d0b[_0x51b0('0x5c')],['ids','id'])||{})[_0x51b0('0x93')](function(_0x4a832c){for(var _0x2f1aba=0x0;_0x2f1aba<_0x408d0b[_0x51b0('0x5c')][_0x51b0('0x6e')][_0x51b0('0x50')];_0x2f1aba+=0x1){socket[_0x51b0('0x78')](_0x51b0('0x79'),{'UserId':Number(_0x408d0b['body'][_0x51b0('0x6e')][_0x2f1aba]),'FaxQueueId':Number(_0x408d0b[_0x51b0('0x4e')]['id'])});}return _0x4a832c;});}})['then'](respondWithResult(_0x285820,null))[_0x51b0('0x4d')](handleError(_0x285820,null));};exports['removeAgents']=function(_0x2115e1,_0x519cdf,_0x3f6cfc){return db[_0x51b0('0x36')][_0x51b0('0x51')]({'where':{'id':_0x2115e1[_0x51b0('0x4e')]['id']}})[_0x51b0('0x2d')](handleEntityNotFound(_0x519cdf,null))[_0x51b0('0x2d')](function(_0x37bdc4){if(_0x37bdc4){return _0x37bdc4[_0x51b0('0x94')](_0x2115e1[_0x51b0('0x3b')][_0x51b0('0x6e')])[_0x51b0('0x2d')](function(){if(_['isArray'](_0x2115e1['query'][_0x51b0('0x6e')])){for(var _0x32f6e5=0x0;_0x32f6e5<_0x2115e1[_0x51b0('0x3b')][_0x51b0('0x6e')][_0x51b0('0x50')];_0x32f6e5+=0x1){socket['emit'](_0x51b0('0x90'),{'UserId':Number(_0x2115e1[_0x51b0('0x3b')]['ids'][_0x32f6e5]),'FaxQueueId':Number(_0x2115e1['params']['id'])});}}else{socket['emit'](_0x51b0('0x90'),{'UserId':Number(_0x2115e1['query']['ids']),'FaxQueueId':Number(_0x2115e1[_0x51b0('0x4e')]['id'])});}});}})[_0x51b0('0x2d')](respondWithStatusCode(_0x519cdf,null))[_0x51b0('0x4d')](handleError(_0x519cdf,null));};exports['getAgents']=function(_0x5dd09d,_0x5d8aa9,_0x449a91){var _0x4130c4={};var _0x4615b2={};var _0x47154f;var _0x49114d;return db[_0x51b0('0x36')][_0x51b0('0x5f')]({'where':{'id':_0x5dd09d['params']['id']}})[_0x51b0('0x2d')](handleEntityNotFound(_0x5d8aa9,null))[_0x51b0('0x2d')](function(_0x5c1dea){if(_0x5c1dea){_0x47154f=_0x5c1dea;_0x4615b2[_0x51b0('0x38')]=_[_0x51b0('0x3a')](db[_0x51b0('0x6f')][_0x51b0('0x4f')]);_0x4615b2[_0x51b0('0x3b')]=_['keys'](_0x5dd09d[_0x51b0('0x3b')]);_0x4615b2[_0x51b0('0x44')]=_[_0x51b0('0x3c')](_0x4615b2[_0x51b0('0x38')],_0x4615b2['query']);_0x4130c4[_0x51b0('0x3d')]=_[_0x51b0('0x3c')](_0x4615b2[_0x51b0('0x38')],qs[_0x51b0('0x3e')](_0x5dd09d[_0x51b0('0x3b')][_0x51b0('0x3e')]));_0x4130c4[_0x51b0('0x3d')]=_0x4130c4['attributes']['length']?_0x4130c4[_0x51b0('0x3d')]:_0x4615b2['model'];_0x4130c4['order']=qs[_0x51b0('0x41')](_0x5dd09d['query'][_0x51b0('0x41')]);_0x4130c4[_0x51b0('0x42')]=qs[_0x51b0('0x44')](_['pick'](_0x5dd09d[_0x51b0('0x3b')],_0x4615b2[_0x51b0('0x44')]));if(_0x5dd09d[_0x51b0('0x3b')][_0x51b0('0x45')]){_0x4130c4[_0x51b0('0x42')]=_[_0x51b0('0x46')](_0x4130c4['where'],{'$or':_[_0x51b0('0x39')](_0x4130c4[_0x51b0('0x3d')],function(_0x1473db){var _0x3550d5={};_0x3550d5[_0x1473db]={'$like':'%'+_0x5dd09d[_0x51b0('0x3b')][_0x51b0('0x45')]+'%'};return _0x3550d5;})});}_0x4130c4=_[_0x51b0('0x46')]({},_0x4130c4,_0x5dd09d['options']);return _0x47154f[_0x51b0('0x95')](_0x4130c4);}})[_0x51b0('0x2d')](function(_0x23625d){if(_0x23625d){_0x49114d=_0x23625d['length'];if(!_0x5dd09d[_0x51b0('0x3b')][_0x51b0('0x61')](_0x51b0('0x3f'))){_0x4130c4[_0x51b0('0x26')]=qs['limit'](_0x5dd09d[_0x51b0('0x3b')][_0x51b0('0x26')]);_0x4130c4['offset']=qs[_0x51b0('0x27')](_0x5dd09d[_0x51b0('0x3b')][_0x51b0('0x27')]);}return _0x47154f[_0x51b0('0x95')](_0x4130c4);}})[_0x51b0('0x2d')](function(_0x2358ba){if(_0x2358ba){return _0x2358ba?{'count':_0x49114d,'rows':_0x2358ba}:null;}})[_0x51b0('0x2d')](respondWithResult(_0x5d8aa9,null))[_0x51b0('0x4d')](handleError(_0x5d8aa9,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