Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 70ebf83..09d0cb3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x621a=['util','sox','to-csv','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','status','offset','undefined','limit','count','set','Content-Range','json','apply','save','update','then','FaxQueues','UserProfileResource','destroy','end','name','send','index','map','FaxQueue','fieldName','type','key','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','params','rawAttributes','find','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','FaxQueueId','UserFaxQueue','findAndCountAll','UserId','updatedAt','rows','format','%s/%s','SIP','createdAt','getTeams','findOne','Team','addTeams','User','online','voicePause','flatMap','sequelize','each','emit','removeTeams','Agents','select','field','from','team_has_fax_queues','join','user_has_teams','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','includes','union','compact','transaction','isEmpty','removeAgents','forEach','userFaxQueue:remove','addAgents','ids','omit','userFaxQueue:save','isArray','getAgents','fast-json-patch','request-promise','moment','bluebird','mustache'];(function(_0x197470,_0x1cbe1e){var _0x3e670c=function(_0x57494d){while(--_0x57494d){_0x197470['push'](_0x197470['shift']());}};_0x3e670c(++_0x1cbe1e);}(_0x621a,0x82));var _0xa621=function(_0x1f0448,_0xa2865f){_0x1f0448=_0x1f0448-0x0;var _0x16fe78=_0x621a[_0x1f0448];return _0x16fe78;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xa621('0x0'));var rp=require(_0xa621('0x1'));var moment=require(_0xa621('0x2'));var BPromise=require(_0xa621('0x3'));var Mustache=require(_0xa621('0x4'));var util=require(_0xa621('0x5'));var path=require('path');var sox=require(_0xa621('0x6'));var csv=require(_0xa621('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa621('0x8'));var squel=require(_0xa621('0x9'));var crypto=require(_0xa621('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xa621('0xb'));var toCsv=require(_0xa621('0x7'));var querystring=require('querystring');var Papa=require(_0xa621('0xc'));var Redis=require(_0xa621('0xd'));var authService=require(_0xa621('0xe'));var qs=require('../../components/parsers/qs');var as=require(_0xa621('0xf'));var hardwareService=require(_0xa621('0x10'));var logger=require(_0xa621('0x11'))('api');var utils=require(_0xa621('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xa621('0x13'))['db'];config[_0xa621('0x14')]=_[_0xa621('0x15')](config['redis'],{'host':_0xa621('0x16'),'port':0x18eb});var socket=require(_0xa621('0x17'))(new Redis(config[_0xa621('0x14')]));require('./faxQueue.socket')['register'](socket);function respondWithStatusCode(_0x17787e,_0x513330){_0x513330=_0x513330||0xcc;return function(_0x5079ee){if(_0x5079ee){return _0x17787e[_0xa621('0x18')](_0x513330);}return _0x17787e[_0xa621('0x19')](_0x513330)['end']();};}function respondWithResult(_0x15a690,_0x58d545){_0x58d545=_0x58d545||0xc8;return function(_0x6e74b2){if(_0x6e74b2){return _0x15a690[_0xa621('0x19')](_0x58d545)['json'](_0x6e74b2);}};}function respondWithFilteredResult(_0x20f7b1,_0x2ba1ce){return function(_0x4fa564){if(_0x4fa564){var _0x4474ae=typeof _0x2ba1ce[_0xa621('0x1a')]===_0xa621('0x1b')&&typeof _0x2ba1ce[_0xa621('0x1c')]==='undefined';var _0x2ccf2c=_0x4fa564[_0xa621('0x1d')];var _0x267128=_0x4474ae?0x0:_0x2ba1ce[_0xa621('0x1a')];var _0x3a5aa6=_0x4474ae?_0x4fa564['count']:_0x2ba1ce['offset']+_0x2ba1ce['limit'];var _0x290667;if(_0x3a5aa6>=_0x2ccf2c){_0x3a5aa6=_0x2ccf2c;_0x290667=0xc8;}else{_0x290667=0xce;}_0x20f7b1['status'](_0x290667);return _0x20f7b1[_0xa621('0x1e')](_0xa621('0x1f'),_0x267128+'-'+_0x3a5aa6+'/'+_0x2ccf2c)[_0xa621('0x20')](_0x4fa564);}return null;};}function patchUpdates(_0x75f245){return function(_0x32d5b9){try{jsonpatch[_0xa621('0x21')](_0x32d5b9,_0x75f245,!![]);}catch(_0x44556f){return BPromise['reject'](_0x44556f);}return _0x32d5b9[_0xa621('0x22')]();};}function saveUpdates(_0x2c6cf9,_0x23d140){return function(_0x336209){if(_0x336209){return _0x336209[_0xa621('0x23')](_0x2c6cf9)[_0xa621('0x24')](function(_0x9dbb0d){return _0x9dbb0d;});}return null;};}function removeEntity(_0x341c80,_0x20e786){return function(_0xff8dee){if(_0xff8dee){return _0xff8dee['destroy']()[_0xa621('0x24')](function(){var _0x4a17b4=_0xff8dee['get']({'plain':!![]});var _0x1197eb=_0xa621('0x25');return db[_0xa621('0x26')][_0xa621('0x27')]({'where':{'type':_0x1197eb,'resourceId':_0x4a17b4['id']}})[_0xa621('0x24')](function(){return _0xff8dee;});})[_0xa621('0x24')](function(){_0x341c80[_0xa621('0x19')](0xcc)[_0xa621('0x28')]();});}};}function handleEntityNotFound(_0x528b4d,_0x40855a){return function(_0x3342c1){if(!_0x3342c1){_0x528b4d[_0xa621('0x18')](0x194);}return _0x3342c1;};}function handleError(_0x55ea72,_0x242f8e){_0x242f8e=_0x242f8e||0x1f4;return function(_0x5da66a){logger['error'](_0x5da66a['stack']);if(_0x5da66a[_0xa621('0x29')]){delete _0x5da66a[_0xa621('0x29')];}_0x55ea72[_0xa621('0x19')](_0x242f8e)[_0xa621('0x2a')](_0x5da66a);};}exports[_0xa621('0x2b')]=function(_0x168d8c,_0x537266){var _0x1c1c11={},_0x3acab5={},_0x55fb3d={'count':0x0,'rows':[]};var _0xf61a49=_[_0xa621('0x2c')](db[_0xa621('0x2d')]['rawAttributes'],function(_0x311fb7){return{'name':_0x311fb7[_0xa621('0x2e')],'type':_0x311fb7[_0xa621('0x2f')][_0xa621('0x30')]};});_0x3acab5[_0xa621('0x31')]=_[_0xa621('0x2c')](_0xf61a49,_0xa621('0x29'));_0x3acab5[_0xa621('0x32')]=_[_0xa621('0x33')](_0x168d8c[_0xa621('0x32')]);_0x3acab5['filters']=_['intersection'](_0x3acab5[_0xa621('0x31')],_0x3acab5[_0xa621('0x32')]);_0x1c1c11['attributes']=_[_0xa621('0x34')](_0x3acab5[_0xa621('0x31')],qs[_0xa621('0x35')](_0x168d8c[_0xa621('0x32')][_0xa621('0x35')]));_0x1c1c11[_0xa621('0x36')]=_0x1c1c11['attributes'][_0xa621('0x37')]?_0x1c1c11[_0xa621('0x36')]:_0x3acab5['model'];if(!_0x168d8c[_0xa621('0x32')][_0xa621('0x38')](_0xa621('0x39'))){_0x1c1c11[_0xa621('0x1c')]=qs[_0xa621('0x1c')](_0x168d8c[_0xa621('0x32')]['limit']);_0x1c1c11[_0xa621('0x1a')]=qs[_0xa621('0x1a')](_0x168d8c[_0xa621('0x32')][_0xa621('0x1a')]);}_0x1c1c11[_0xa621('0x3a')]=qs[_0xa621('0x3b')](_0x168d8c[_0xa621('0x32')][_0xa621('0x3b')]);_0x1c1c11[_0xa621('0x3c')]=qs[_0xa621('0x3d')](_[_0xa621('0x3e')](_0x168d8c[_0xa621('0x32')],_0x3acab5[_0xa621('0x3d')]),_0xf61a49);if(_0x168d8c[_0xa621('0x32')][_0xa621('0x3f')]){_0x1c1c11[_0xa621('0x3c')]=_[_0xa621('0x40')](_0x1c1c11[_0xa621('0x3c')],{'$or':_['map'](_0xf61a49,function(_0x425e24){if(_0x425e24['type']!==_0xa621('0x41')){var _0x5afc2b={};_0x5afc2b[_0x425e24[_0xa621('0x29')]]={'$like':'%'+_0x168d8c[_0xa621('0x32')][_0xa621('0x3f')]+'%'};return _0x5afc2b;}})});}_0x1c1c11=_[_0xa621('0x40')]({},_0x1c1c11,_0x168d8c[_0xa621('0x42')]);var _0x39ea7c={'where':_0x1c1c11[_0xa621('0x3c')]};return db[_0xa621('0x2d')]['count'](_0x39ea7c)[_0xa621('0x24')](function(_0x909593){_0x55fb3d['count']=_0x909593;if(_0x168d8c[_0xa621('0x32')][_0xa621('0x43')]){_0x1c1c11[_0xa621('0x44')]=[{'all':!![]}];}return db[_0xa621('0x2d')][_0xa621('0x45')](_0x1c1c11);})[_0xa621('0x24')](function(_0x326cd3){_0x55fb3d['rows']=_0x326cd3;return _0x55fb3d;})['then'](respondWithFilteredResult(_0x537266,_0x1c1c11))[_0xa621('0x46')](handleError(_0x537266,null));};exports['show']=function(_0x350e9c,_0xd0ec15){var _0x389b55={'raw':!![],'where':{'id':_0x350e9c[_0xa621('0x47')]['id']}},_0x34c1ea={};_0x34c1ea[_0xa621('0x31')]=_[_0xa621('0x33')](db['FaxQueue'][_0xa621('0x48')]);_0x34c1ea[_0xa621('0x32')]=_[_0xa621('0x33')](_0x350e9c[_0xa621('0x32')]);_0x34c1ea[_0xa621('0x3d')]=_['intersection'](_0x34c1ea['model'],_0x34c1ea[_0xa621('0x32')]);_0x389b55[_0xa621('0x36')]=_[_0xa621('0x34')](_0x34c1ea[_0xa621('0x31')],qs[_0xa621('0x35')](_0x350e9c['query'][_0xa621('0x35')]));_0x389b55[_0xa621('0x36')]=_0x389b55['attributes']['length']?_0x389b55['attributes']:_0x34c1ea[_0xa621('0x31')];if(_0x350e9c[_0xa621('0x32')]['includeAll']){_0x389b55[_0xa621('0x44')]=[{'all':!![]}];}_0x389b55=_[_0xa621('0x40')]({},_0x389b55,_0x350e9c[_0xa621('0x42')]);return db[_0xa621('0x2d')][_0xa621('0x49')](_0x389b55)['then'](handleEntityNotFound(_0xd0ec15,null))['then'](respondWithResult(_0xd0ec15,null))[_0xa621('0x46')](handleError(_0xd0ec15,null));};exports[_0xa621('0x4a')]=function(_0x4d6ab9,_0x20a3d5){return db[_0xa621('0x2d')][_0xa621('0x4a')](_0x4d6ab9[_0xa621('0x4b')],{})[_0xa621('0x24')](function(_0x7c058a){var _0x98c324=_0x4d6ab9['user'][_0xa621('0x4c')]({'plain':!![]});if(!_0x98c324)throw new Error(_0xa621('0x4d'));if(_0x98c324[_0xa621('0x4e')]===_0xa621('0x4f')){var _0x5d982b=_0x7c058a[_0xa621('0x4c')]({'plain':!![]});var _0x468782=_0xa621('0x25');return db['UserProfileSection'][_0xa621('0x49')]({'where':{'name':_0x468782,'userProfileId':_0x98c324[_0xa621('0x50')]},'raw':!![]})[_0xa621('0x24')](function(_0x366ade){if(_0x366ade&&_0x366ade[_0xa621('0x51')]===0x0){return db['UserProfileResource'][_0xa621('0x4a')]({'name':_0x5d982b[_0xa621('0x29')],'resourceId':_0x5d982b['id'],'type':_0x366ade[_0xa621('0x29')],'sectionId':_0x366ade['id']},{})[_0xa621('0x24')](function(){return _0x7c058a;});}else{return _0x7c058a;}})[_0xa621('0x46')](function(_0x1061e0){logger[_0xa621('0x52')](_0xa621('0x53'),_0x1061e0);throw _0x1061e0;});}return _0x7c058a;})[_0xa621('0x24')](respondWithResult(_0x20a3d5,0xc9))[_0xa621('0x46')](handleError(_0x20a3d5,null));};exports[_0xa621('0x23')]=function(_0x20f330,_0x16287a){if(_0x20f330[_0xa621('0x4b')]['id']){delete _0x20f330[_0xa621('0x4b')]['id'];}return db[_0xa621('0x2d')][_0xa621('0x49')]({'where':{'id':_0x20f330[_0xa621('0x47')]['id']}})[_0xa621('0x24')](handleEntityNotFound(_0x16287a,null))[_0xa621('0x24')](saveUpdates(_0x20f330[_0xa621('0x4b')],null))[_0xa621('0x24')](respondWithResult(_0x16287a,null))[_0xa621('0x46')](handleError(_0x16287a,null));};exports[_0xa621('0x27')]=function(_0x1dff0c,_0x43a253){return db['FaxQueue'][_0xa621('0x49')]({'where':{'id':_0x1dff0c['params']['id']}})[_0xa621('0x24')](handleEntityNotFound(_0x43a253,null))[_0xa621('0x24')](removeEntity(_0x43a253,null))[_0xa621('0x46')](handleError(_0x43a253,null));};exports[_0xa621('0x54')]=function(_0x39acf5,_0x40abaf){return db['FaxQueue'][_0xa621('0x54')]()[_0xa621('0x24')](respondWithResult(_0x40abaf,null))[_0xa621('0x46')](handleError(_0x40abaf,null));};exports[_0xa621('0x55')]=function(_0x33aa91,_0x4d5de5,_0x27c501){var _0x4a6b53={'raw':!![],'where':{}},_0x1a3488={},_0x3c8fd3;return db['FaxQueue']['findOne']({'where':{'id':_0x33aa91[_0xa621('0x47')]['id']}})[_0xa621('0x24')](handleEntityNotFound(_0x4d5de5,null))[_0xa621('0x24')](function(_0x5370a7){if(_0x5370a7){_0x3c8fd3=_0x5370a7[_0xa621('0x4c')]({'plain':!![]});_0x1a3488['model']=_['keys'](db['UserFaxQueue']['rawAttributes']);_0x1a3488[_0xa621('0x32')]=_[_0xa621('0x33')](_0x33aa91['query']);_0x1a3488[_0xa621('0x3d')]=_[_0xa621('0x34')](_0x1a3488[_0xa621('0x31')],_0x1a3488['query']);_0x4a6b53[_0xa621('0x36')]=_[_0xa621('0x34')](_0x1a3488['model'],qs[_0xa621('0x35')](_0x33aa91[_0xa621('0x32')]['fields']));_0x4a6b53[_0xa621('0x36')]=_0x4a6b53[_0xa621('0x36')][_0xa621('0x37')]?_0x4a6b53[_0xa621('0x36')]:_0x1a3488[_0xa621('0x31')];if(!_0x33aa91['query']['hasOwnProperty']('nolimit')){_0x4a6b53[_0xa621('0x1c')]=qs['limit'](_0x33aa91['query'][_0xa621('0x1c')]);_0x4a6b53[_0xa621('0x1a')]=qs['offset'](_0x33aa91[_0xa621('0x32')][_0xa621('0x1a')]);}_0x4a6b53['order']=qs[_0xa621('0x3b')](_0x33aa91[_0xa621('0x32')][_0xa621('0x3b')]);_0x4a6b53['where']=qs['filters'](_['pick'](_0x33aa91[_0xa621('0x32')],_0x1a3488[_0xa621('0x3d')]));_0x4a6b53['where'][_0xa621('0x56')]=_0x5370a7['id'];if(_0x33aa91[_0xa621('0x32')][_0xa621('0x3f')]){_0x4a6b53[_0xa621('0x3c')]=_[_0xa621('0x40')](_0x4a6b53[_0xa621('0x3c')],{'$or':_[_0xa621('0x2c')](_0x4a6b53['attributes'],function(_0x227b19){var _0x47290a={};_0x47290a[_0x227b19]={'$like':'%'+_0x33aa91[_0xa621('0x32')][_0xa621('0x3f')]+'%'};return _0x47290a;})});}_0x4a6b53=_['merge']({},_0x4a6b53,_0x33aa91['options']);return db[_0xa621('0x57')]['findAll'](_0x4a6b53);}})['then'](function(_0x1386cf){if(_0x1386cf){return db['User'][_0xa621('0x58')]({'where':{'id':_['map'](_0x1386cf,_0xa621('0x59')),'role':'agent'},'attributes':['id',_0xa621('0x29'),'faxPause',_0xa621('0x5a'),'createdAt']});}})[_0xa621('0x24')](function(_0x58f3d6){if(_0x58f3d6){return{'count':_0x58f3d6[_0xa621('0x1d')],'rows':_[_0xa621('0x2c')](_0x58f3d6[_0xa621('0x5b')],function(_0x14746e){return{'membername':_0x14746e[_0xa621('0x29')],'UserId':_0x14746e['id'],'queue_name':_0x3c8fd3[_0xa621('0x29')],'FaxQueueId':_0x3c8fd3['id'],'interface':util[_0xa621('0x5c')](_0xa621('0x5d'),_0xa621('0x5e'),_0x14746e[_0xa621('0x29')]),'penalty':0x0,'paused':_0x14746e['faxPause'],'createdAt':_0x14746e[_0xa621('0x5f')],'updatedAt':_0x14746e[_0xa621('0x5a')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x4d5de5,_0x4a6b53))[_0xa621('0x46')](handleError(_0x4d5de5,null));};exports[_0xa621('0x60')]=function(_0x15e384,_0x3df9c7,_0x57d838){var _0xe5c1e2={};var _0x3054e5={};var _0x3d1c9d;var _0x263b54;return db['FaxQueue'][_0xa621('0x61')]({'where':{'id':_0x15e384['params']['id']}})[_0xa621('0x24')](handleEntityNotFound(_0x3df9c7,null))[_0xa621('0x24')](function(_0x1a3b54){if(_0x1a3b54){_0x3d1c9d=_0x1a3b54;_0x3054e5[_0xa621('0x31')]=_['keys'](db[_0xa621('0x62')][_0xa621('0x48')]);_0x3054e5[_0xa621('0x32')]=_['keys'](_0x15e384[_0xa621('0x32')]);_0x3054e5[_0xa621('0x3d')]=_['intersection'](_0x3054e5['model'],_0x3054e5[_0xa621('0x32')]);_0xe5c1e2['attributes']=_[_0xa621('0x34')](_0x3054e5['model'],qs[_0xa621('0x35')](_0x15e384[_0xa621('0x32')]['fields']));_0xe5c1e2['attributes']=_0xe5c1e2['attributes']['length']?_0xe5c1e2[_0xa621('0x36')]:_0x3054e5[_0xa621('0x31')];_0xe5c1e2['order']=qs[_0xa621('0x3b')](_0x15e384['query']['sort']);_0xe5c1e2[_0xa621('0x3c')]=qs[_0xa621('0x3d')](_['pick'](_0x15e384[_0xa621('0x32')],_0x3054e5[_0xa621('0x3d')]));if(_0x15e384['query'][_0xa621('0x3f')]){_0xe5c1e2[_0xa621('0x3c')]=_['merge'](_0xe5c1e2[_0xa621('0x3c')],{'$or':_[_0xa621('0x2c')](_0xe5c1e2[_0xa621('0x36')],function(_0x1c3f4d){var _0x13618a={};_0x13618a[_0x1c3f4d]={'$like':'%'+_0x15e384['query'][_0xa621('0x3f')]+'%'};return _0x13618a;})});}_0xe5c1e2=_['merge']({},_0xe5c1e2,_0x15e384[_0xa621('0x42')]);return _0x3d1c9d[_0xa621('0x60')](_0xe5c1e2);}})[_0xa621('0x24')](function(_0x36bf22){if(_0x36bf22){_0x263b54=_0x36bf22[_0xa621('0x37')];if(!_0x15e384[_0xa621('0x32')][_0xa621('0x38')](_0xa621('0x39'))){_0xe5c1e2['limit']=qs['limit'](_0x15e384[_0xa621('0x32')]['limit']);_0xe5c1e2[_0xa621('0x1a')]=qs[_0xa621('0x1a')](_0x15e384[_0xa621('0x32')][_0xa621('0x1a')]);}return _0x3d1c9d[_0xa621('0x60')](_0xe5c1e2);}})[_0xa621('0x24')](function(_0x2f18ae){if(_0x2f18ae){return _0x2f18ae?{'count':_0x263b54,'rows':_0x2f18ae}:null;}})[_0xa621('0x24')](respondWithResult(_0x3df9c7,null))['catch'](handleError(_0x3df9c7,null));};exports[_0xa621('0x63')]=function(_0x2eec59,_0x4164d6,_0x46cc8f){var _0x4e45be=_0x2eec59['body']['ids'];return db[_0xa621('0x62')][_0xa621('0x45')]({'where':{'id':_0x4e45be},'attributes':['id'],'include':[{'model':db[_0xa621('0x64')],'as':'Agents','attributes':['id',_0xa621('0x29'),_0xa621('0x65'),_0xa621('0x66'),'interface'],'raw':!![]}]})[_0xa621('0x24')](function(_0x222e13){if(_0x222e13){var _0x2e9535=_[_0xa621('0x67')](_0x222e13,function(_0x5ec681){var _0x133a86=_0x5ec681[_0xa621('0x4c')]({'plain':!![]});return _0x133a86['Agents'];});return db['FaxQueue'][_0xa621('0x49')]({'where':{'id':_0x2eec59['params']['id']}})['then'](function(_0x1f9ab7){return db[_0xa621('0x68')]['transaction'](function(_0x49bcd9){return _0x1f9ab7['addTeams'](_0x4e45be,{'transaction':_0x49bcd9})[_0xa621('0x24')](function(){return BPromise[_0xa621('0x69')](_0x2e9535,function(_0x97a8c6){return db['UserFaxQueue']['findOrCreate']({'where':{'UserId':_0x97a8c6['id'],'FaxQueueId':_0x2eec59[_0xa621('0x47')]['id']},'transaction':_0x49bcd9});});})[_0xa621('0x24')](function(){_0x2e9535['forEach'](function(_0x3a9956){socket[_0xa621('0x6a')]('userFaxQueue:save',{'UserId':_0x3a9956['id'],'FaxQueueId':_0x1f9ab7['id']});});});});});}})[_0xa621('0x24')](respondWithStatusCode(_0x4164d6,null))[_0xa621('0x46')](handleError(_0x4164d6,null));};exports[_0xa621('0x6b')]=function(_0xf3107c,_0x5a599b,_0x2ca2bf){return db[_0xa621('0x62')][_0xa621('0x45')]({'where':{'id':_0xf3107c[_0xa621('0x32')]['ids']},'attributes':['id'],'include':[{'model':db[_0xa621('0x64')],'as':_0xa621('0x6c'),'attributes':['id'],'raw':!![]}]})[_0xa621('0x24')](handleEntityNotFound(_0x5a599b,null))[_0xa621('0x24')](function(_0x4f4bb0){var _0x27311b=_['map'](_0x4f4bb0,'id');var _0x25c523=[];var _0xc487f8=[];var _0x20f3b2=squel[_0xa621('0x6d')]();_0x20f3b2[_0xa621('0x6e')]('tq.TeamId')[_0xa621('0x6f')](_0xa621('0x70'),'tq')[_0xa621('0x71')](_0xa621('0x72'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0xa621('0x3c')]('FaxQueueId\x20=\x20?',_0xf3107c['params']['id']);for(var _0x4328e1=0x0;_0x4328e1<_0x4f4bb0['length'];_0x4328e1+=0x1){let _0x59373f=_0x4f4bb0[_0x4328e1];for(var _0x277fcb=0x0;_0x277fcb<_0x59373f[_0xa621('0x6c')][_0xa621('0x37')];_0x277fcb+=0x1){let _0x43eea2=_0x59373f[_0xa621('0x6c')][_0x277fcb];var _0x2b0d66=_0x20f3b2['clone']();_0x2b0d66[_0xa621('0x3c')](_0xa621('0x73'),_0x43eea2['id']);_0xc487f8[_0xa621('0x74')](db[_0xa621('0x68')]['query'](_0x2b0d66[_0xa621('0x75')](),{'type':db['sequelize'][_0xa621('0x76')][_0xa621('0x77')]})['then'](function(_0x435cb8){if(_0x435cb8[_0xa621('0x37')]===0x1){return _0x43eea2['id'];}else{var _0x2c52f0=_[_0xa621('0x78')](_['map'](_0x435cb8,'TeamId'),function(_0x42f094){return _[_0xa621('0x79')](_0x27311b,_0x42f094);});if(_0x2c52f0){return _0x43eea2['id'];}}}));}}return BPromise['all'](_0xc487f8)['then'](function(_0x299377){_0x25c523=_(_0x25c523)[_0xa621('0x7a')](_0x299377)[_0xa621('0x7b')]()['value']();return db['FaxQueue'][_0xa621('0x49')]({'where':{'id':_0xf3107c[_0xa621('0x47')]['id']}})[_0xa621('0x24')](function(_0x41acd6){return db[_0xa621('0x68')][_0xa621('0x7c')](function(_0x5ebd87){return _0x41acd6[_0xa621('0x6b')](_0xf3107c['query']['ids'],{'transaction':_0x5ebd87})[_0xa621('0x24')](function(){if(!_[_0xa621('0x7d')](_0x25c523)){return _0x41acd6[_0xa621('0x7e')](_0x25c523,{'transaction':_0x5ebd87});}})['then'](function(){_0x25c523[_0xa621('0x7f')](function(_0x1953d8){socket['emit'](_0xa621('0x80'),{'UserId':_0x1953d8,'FaxQueueId':_0x41acd6['id']});});});});});});})[_0xa621('0x24')](respondWithStatusCode(_0x5a599b,null))[_0xa621('0x46')](handleError(_0x5a599b,null));};exports[_0xa621('0x81')]=function(_0x46fca5,_0xb17cc0,_0x587231){return db['FaxQueue'][_0xa621('0x49')]({'where':{'id':_0x46fca5[_0xa621('0x47')]['id']}})[_0xa621('0x24')](handleEntityNotFound(_0xb17cc0,null))['then'](function(_0x5c1a6b){if(_0x5c1a6b){return _0x5c1a6b['addAgents'](_0x46fca5[_0xa621('0x4b')][_0xa621('0x82')],_[_0xa621('0x83')](_0x46fca5[_0xa621('0x4b')],[_0xa621('0x82'),'id'])||{})['spread'](function(_0x42fbd2){for(var _0x3de76e=0x0;_0x3de76e<_0x46fca5[_0xa621('0x4b')]['ids']['length'];_0x3de76e+=0x1){socket[_0xa621('0x6a')](_0xa621('0x84'),{'UserId':Number(_0x46fca5['body'][_0xa621('0x82')][_0x3de76e]),'FaxQueueId':Number(_0x46fca5[_0xa621('0x47')]['id'])});}return _0x42fbd2;});}})['then'](respondWithResult(_0xb17cc0,null))['catch'](handleError(_0xb17cc0,null));};exports[_0xa621('0x7e')]=function(_0x54ebcd,_0x2ae9f4,_0x5f0657){return db[_0xa621('0x2d')][_0xa621('0x49')]({'where':{'id':_0x54ebcd[_0xa621('0x47')]['id']}})[_0xa621('0x24')](handleEntityNotFound(_0x2ae9f4,null))[_0xa621('0x24')](function(_0x15eba6){if(_0x15eba6){return _0x15eba6[_0xa621('0x7e')](_0x54ebcd[_0xa621('0x32')]['ids'])[_0xa621('0x24')](function(){if(_[_0xa621('0x85')](_0x54ebcd[_0xa621('0x32')][_0xa621('0x82')])){for(var _0x5cfdea=0x0;_0x5cfdea<_0x54ebcd[_0xa621('0x32')][_0xa621('0x82')][_0xa621('0x37')];_0x5cfdea+=0x1){socket['emit'](_0xa621('0x80'),{'UserId':Number(_0x54ebcd['query'][_0xa621('0x82')][_0x5cfdea]),'FaxQueueId':Number(_0x54ebcd[_0xa621('0x47')]['id'])});}}else{socket[_0xa621('0x6a')]('userFaxQueue:remove',{'UserId':Number(_0x54ebcd[_0xa621('0x32')][_0xa621('0x82')]),'FaxQueueId':Number(_0x54ebcd[_0xa621('0x47')]['id'])});}});}})['then'](respondWithStatusCode(_0x2ae9f4,null))['catch'](handleError(_0x2ae9f4,null));};exports[_0xa621('0x86')]=function(_0x1049f2,_0x38e6c3,_0x590319){var _0x35de0c={};var _0xe7bb2c={};var _0x156711;var _0x5b6eb5;return db[_0xa621('0x2d')][_0xa621('0x61')]({'where':{'id':_0x1049f2['params']['id']}})[_0xa621('0x24')](handleEntityNotFound(_0x38e6c3,null))['then'](function(_0x597a3d){if(_0x597a3d){_0x156711=_0x597a3d;_0xe7bb2c[_0xa621('0x31')]=_[_0xa621('0x33')](db[_0xa621('0x64')][_0xa621('0x48')]);_0xe7bb2c['query']=_[_0xa621('0x33')](_0x1049f2[_0xa621('0x32')]);_0xe7bb2c['filters']=_[_0xa621('0x34')](_0xe7bb2c[_0xa621('0x31')],_0xe7bb2c[_0xa621('0x32')]);_0x35de0c[_0xa621('0x36')]=_[_0xa621('0x34')](_0xe7bb2c[_0xa621('0x31')],qs['fields'](_0x1049f2[_0xa621('0x32')][_0xa621('0x35')]));_0x35de0c[_0xa621('0x36')]=_0x35de0c[_0xa621('0x36')][_0xa621('0x37')]?_0x35de0c['attributes']:_0xe7bb2c[_0xa621('0x31')];_0x35de0c[_0xa621('0x3a')]=qs[_0xa621('0x3b')](_0x1049f2[_0xa621('0x32')][_0xa621('0x3b')]);_0x35de0c[_0xa621('0x3c')]=qs[_0xa621('0x3d')](_[_0xa621('0x3e')](_0x1049f2['query'],_0xe7bb2c[_0xa621('0x3d')]));if(_0x1049f2[_0xa621('0x32')]['filter']){_0x35de0c[_0xa621('0x3c')]=_[_0xa621('0x40')](_0x35de0c[_0xa621('0x3c')],{'$or':_['map'](_0x35de0c[_0xa621('0x36')],function(_0x2ea074){var _0x25b52f={};_0x25b52f[_0x2ea074]={'$like':'%'+_0x1049f2['query'][_0xa621('0x3f')]+'%'};return _0x25b52f;})});}_0x35de0c=_[_0xa621('0x40')]({},_0x35de0c,_0x1049f2['options']);return _0x156711[_0xa621('0x86')](_0x35de0c);}})[_0xa621('0x24')](function(_0x3c6ba3){if(_0x3c6ba3){_0x5b6eb5=_0x3c6ba3[_0xa621('0x37')];if(!_0x1049f2[_0xa621('0x32')]['hasOwnProperty'](_0xa621('0x39'))){_0x35de0c[_0xa621('0x1c')]=qs['limit'](_0x1049f2[_0xa621('0x32')][_0xa621('0x1c')]);_0x35de0c[_0xa621('0x1a')]=qs[_0xa621('0x1a')](_0x1049f2[_0xa621('0x32')][_0xa621('0x1a')]);}return _0x156711['getAgents'](_0x35de0c);}})[_0xa621('0x24')](function(_0x4ed237){if(_0x4ed237){return _0x4ed237?{'count':_0x5b6eb5,'rows':_0x4ed237}:null;}})[_0xa621('0x24')](respondWithResult(_0x38e6c3,null))[_0xa621('0x46')](handleError(_0x38e6c3,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