Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 11300ec..b107833 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9a1b=['map','FaxQueue','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','pick','filter','where','merge','VIRTUAL','findAll','rows','catch','params','rawAttributes','include','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','FaxQueues','UserProfileSection','autoAssociation','error','update','describe','getMembers','findOne','UserFaxQueue','order','FaxQueueId','User','findAndCountAll','agent','faxPause','updatedAt','format','%s/%s','createdAt','getTeams','Team','addTeams','voicePause','interface','Agents','sequelize','transaction','each','findOrCreate','forEach','emit','removeTeams','ids','select','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','isEmpty','userFaxQueue:remove','addAgents','omit','spread','userFaxQueue:save','removeAgents','isArray','getAgents','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','jsforce','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','localhost','socket.io-emitter','./faxQueue.socket','register','sendStatus','status','offset','undefined','limit','count','set','json','apply','reject','save','destroy','get','UserProfileResource','then','end','stack','name','send'];(function(_0xe73123,_0x5a1929){var _0x1e359b=function(_0x32be93){while(--_0x32be93){_0xe73123['push'](_0xe73123['shift']());}};_0x1e359b(++_0x5a1929);}(_0x9a1b,0x17c));var _0xb9a1=function(_0x245552,_0x3a9667){_0x245552=_0x245552-0x0;var _0x3ba039=_0x9a1b[_0x245552];return _0x3ba039;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb9a1('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb9a1('0x1'));var rp=require(_0xb9a1('0x2'));var moment=require(_0xb9a1('0x3'));var BPromise=require(_0xb9a1('0x4'));var Mustache=require(_0xb9a1('0x5'));var util=require(_0xb9a1('0x6'));var path=require(_0xb9a1('0x7'));var sox=require(_0xb9a1('0x8'));var csv=require(_0xb9a1('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb9a1('0xa'));var _=require(_0xb9a1('0xb'));var squel=require(_0xb9a1('0xc'));var crypto=require('crypto');var jsforce=require(_0xb9a1('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xb9a1('0x9'));var querystring=require(_0xb9a1('0xe'));var Papa=require(_0xb9a1('0xf'));var Redis=require(_0xb9a1('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xb9a1('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xb9a1('0x12'))('api');var utils=require(_0xb9a1('0x13'));var config=require(_0xb9a1('0x14'));var licenseUtil=require(_0xb9a1('0x15'));var db=require(_0xb9a1('0x16'))['db'];config['redis']=_['defaults'](config['redis'],{'host':_0xb9a1('0x17'),'port':0x18eb});var socket=require(_0xb9a1('0x18'))(new Redis(config['redis']));require(_0xb9a1('0x19'))[_0xb9a1('0x1a')](socket);function respondWithStatusCode(_0x3ab08b,_0x27ff76){_0x27ff76=_0x27ff76||0xcc;return function(_0x31f629){if(_0x31f629){return _0x3ab08b[_0xb9a1('0x1b')](_0x27ff76);}return _0x3ab08b[_0xb9a1('0x1c')](_0x27ff76)['end']();};}function respondWithResult(_0x188c87,_0x54db4d){_0x54db4d=_0x54db4d||0xc8;return function(_0xca76db){if(_0xca76db){return _0x188c87[_0xb9a1('0x1c')](_0x54db4d)['json'](_0xca76db);}};}function respondWithFilteredResult(_0xa873d6,_0x4067c2){return function(_0x274a42){if(_0x274a42){var _0x3557cd=typeof _0x4067c2[_0xb9a1('0x1d')]===_0xb9a1('0x1e')&&typeof _0x4067c2[_0xb9a1('0x1f')]==='undefined';var _0x39678a=_0x274a42[_0xb9a1('0x20')];var _0x566463=_0x3557cd?0x0:_0x4067c2[_0xb9a1('0x1d')];var _0x321922=_0x3557cd?_0x274a42[_0xb9a1('0x20')]:_0x4067c2[_0xb9a1('0x1d')]+_0x4067c2[_0xb9a1('0x1f')];var _0x5ca653;if(_0x321922>=_0x39678a){_0x321922=_0x39678a;_0x5ca653=0xc8;}else{_0x5ca653=0xce;}_0xa873d6[_0xb9a1('0x1c')](_0x5ca653);return _0xa873d6[_0xb9a1('0x21')]('Content-Range',_0x566463+'-'+_0x321922+'/'+_0x39678a)[_0xb9a1('0x22')](_0x274a42);}return null;};}function patchUpdates(_0x3b8efd){return function(_0x2a1f05){try{jsonpatch[_0xb9a1('0x23')](_0x2a1f05,_0x3b8efd,!![]);}catch(_0x26b9bf){return BPromise[_0xb9a1('0x24')](_0x26b9bf);}return _0x2a1f05[_0xb9a1('0x25')]();};}function saveUpdates(_0xb09311,_0x190946){return function(_0x4e051e){if(_0x4e051e){return _0x4e051e['update'](_0xb09311)['then'](function(_0x24704b){return _0x24704b;});}return null;};}function removeEntity(_0x4a8dc6,_0x390b9a){return function(_0x1962e2){if(_0x1962e2){return _0x1962e2[_0xb9a1('0x26')]()['then'](function(){var _0x1cda4d=_0x1962e2[_0xb9a1('0x27')]({'plain':!![]});var _0xd89479='FaxQueues';return db[_0xb9a1('0x28')][_0xb9a1('0x26')]({'where':{'type':_0xd89479,'resourceId':_0x1cda4d['id']}})[_0xb9a1('0x29')](function(){return _0x1962e2;});})[_0xb9a1('0x29')](function(){_0x4a8dc6[_0xb9a1('0x1c')](0xcc)[_0xb9a1('0x2a')]();});}};}function handleEntityNotFound(_0x222262,_0x43b4b7){return function(_0x56ae11){if(!_0x56ae11){_0x222262['sendStatus'](0x194);}return _0x56ae11;};}function handleError(_0x2c420c,_0x4844bd){_0x4844bd=_0x4844bd||0x1f4;return function(_0x38c8bf){logger['error'](_0x38c8bf[_0xb9a1('0x2b')]);if(_0x38c8bf[_0xb9a1('0x2c')]){delete _0x38c8bf['name'];}_0x2c420c[_0xb9a1('0x1c')](_0x4844bd)[_0xb9a1('0x2d')](_0x38c8bf);};}exports['index']=function(_0x1cee43,_0x43123){var _0xb4d88b={},_0x5e3acc={},_0x400894={'count':0x0,'rows':[]};var _0x4d3e6f=_[_0xb9a1('0x2e')](db[_0xb9a1('0x2f')]['rawAttributes'],function(_0x3a750a){return{'name':_0x3a750a[_0xb9a1('0x30')],'type':_0x3a750a[_0xb9a1('0x31')][_0xb9a1('0x32')]};});_0x5e3acc[_0xb9a1('0x33')]=_['map'](_0x4d3e6f,_0xb9a1('0x2c'));_0x5e3acc[_0xb9a1('0x34')]=_[_0xb9a1('0x35')](_0x1cee43[_0xb9a1('0x34')]);_0x5e3acc[_0xb9a1('0x36')]=_[_0xb9a1('0x37')](_0x5e3acc['model'],_0x5e3acc[_0xb9a1('0x34')]);_0xb4d88b['attributes']=_[_0xb9a1('0x37')](_0x5e3acc['model'],qs['fields'](_0x1cee43[_0xb9a1('0x34')][_0xb9a1('0x38')]));_0xb4d88b['attributes']=_0xb4d88b[_0xb9a1('0x39')][_0xb9a1('0x3a')]?_0xb4d88b[_0xb9a1('0x39')]:_0x5e3acc[_0xb9a1('0x33')];if(!_0x1cee43[_0xb9a1('0x34')][_0xb9a1('0x3b')](_0xb9a1('0x3c'))){_0xb4d88b[_0xb9a1('0x1f')]=qs['limit'](_0x1cee43['query'][_0xb9a1('0x1f')]);_0xb4d88b[_0xb9a1('0x1d')]=qs['offset'](_0x1cee43[_0xb9a1('0x34')][_0xb9a1('0x1d')]);}_0xb4d88b['order']=qs[_0xb9a1('0x3d')](_0x1cee43[_0xb9a1('0x34')][_0xb9a1('0x3d')]);_0xb4d88b['where']=qs[_0xb9a1('0x36')](_[_0xb9a1('0x3e')](_0x1cee43[_0xb9a1('0x34')],_0x5e3acc['filters']),_0x4d3e6f);if(_0x1cee43['query'][_0xb9a1('0x3f')]){_0xb4d88b[_0xb9a1('0x40')]=_[_0xb9a1('0x41')](_0xb4d88b['where'],{'$or':_[_0xb9a1('0x2e')](_0x4d3e6f,function(_0x52e146){if(_0x52e146[_0xb9a1('0x31')]!==_0xb9a1('0x42')){var _0x5e8e5a={};_0x5e8e5a[_0x52e146[_0xb9a1('0x2c')]]={'$like':'%'+_0x1cee43[_0xb9a1('0x34')][_0xb9a1('0x3f')]+'%'};return _0x5e8e5a;}})});}_0xb4d88b=_['merge']({},_0xb4d88b,_0x1cee43['options']);var _0x6ee39a={'where':_0xb4d88b[_0xb9a1('0x40')]};return db[_0xb9a1('0x2f')][_0xb9a1('0x20')](_0x6ee39a)[_0xb9a1('0x29')](function(_0x536730){_0x400894[_0xb9a1('0x20')]=_0x536730;if(_0x1cee43[_0xb9a1('0x34')]['includeAll']){_0xb4d88b['include']=[{'all':!![]}];}return db[_0xb9a1('0x2f')][_0xb9a1('0x43')](_0xb4d88b);})[_0xb9a1('0x29')](function(_0x4ff913){_0x400894[_0xb9a1('0x44')]=_0x4ff913;return _0x400894;})[_0xb9a1('0x29')](respondWithFilteredResult(_0x43123,_0xb4d88b))[_0xb9a1('0x45')](handleError(_0x43123,null));};exports['show']=function(_0x17d4de,_0xf4e775){var _0x1702a7={'raw':!![],'where':{'id':_0x17d4de[_0xb9a1('0x46')]['id']}},_0x3bc819={};_0x3bc819[_0xb9a1('0x33')]=_[_0xb9a1('0x35')](db['FaxQueue'][_0xb9a1('0x47')]);_0x3bc819[_0xb9a1('0x34')]=_[_0xb9a1('0x35')](_0x17d4de[_0xb9a1('0x34')]);_0x3bc819['filters']=_['intersection'](_0x3bc819[_0xb9a1('0x33')],_0x3bc819['query']);_0x1702a7['attributes']=_[_0xb9a1('0x37')](_0x3bc819[_0xb9a1('0x33')],qs[_0xb9a1('0x38')](_0x17d4de[_0xb9a1('0x34')][_0xb9a1('0x38')]));_0x1702a7['attributes']=_0x1702a7[_0xb9a1('0x39')][_0xb9a1('0x3a')]?_0x1702a7['attributes']:_0x3bc819['model'];if(_0x17d4de[_0xb9a1('0x34')]['includeAll']){_0x1702a7[_0xb9a1('0x48')]=[{'all':!![]}];}_0x1702a7=_[_0xb9a1('0x41')]({},_0x1702a7,_0x17d4de[_0xb9a1('0x49')]);return db[_0xb9a1('0x2f')][_0xb9a1('0x4a')](_0x1702a7)['then'](handleEntityNotFound(_0xf4e775,null))[_0xb9a1('0x29')](respondWithResult(_0xf4e775,null))[_0xb9a1('0x45')](handleError(_0xf4e775,null));};exports[_0xb9a1('0x4b')]=function(_0x5183c6,_0x45150e){return db[_0xb9a1('0x2f')][_0xb9a1('0x4b')](_0x5183c6[_0xb9a1('0x4c')],{})['then'](function(_0x2702bc){var _0x47a2ca=_0x5183c6[_0xb9a1('0x4d')][_0xb9a1('0x27')]({'plain':!![]});if(!_0x47a2ca)throw new Error(_0xb9a1('0x4e'));if(_0x47a2ca[_0xb9a1('0x4f')]===_0xb9a1('0x4d')){var _0x53e396=_0x2702bc['get']({'plain':!![]});var _0x4e72d3=_0xb9a1('0x50');return db[_0xb9a1('0x51')][_0xb9a1('0x4a')]({'where':{'name':_0x4e72d3,'userProfileId':_0x47a2ca['userProfileId']},'raw':!![]})['then'](function(_0x52995f){if(_0x52995f&&_0x52995f[_0xb9a1('0x52')]===0x0){return db['UserProfileResource'][_0xb9a1('0x4b')]({'name':_0x53e396[_0xb9a1('0x2c')],'resourceId':_0x53e396['id'],'type':_0x52995f[_0xb9a1('0x2c')],'sectionId':_0x52995f['id']},{})[_0xb9a1('0x29')](function(){return _0x2702bc;});}else{return _0x2702bc;}})[_0xb9a1('0x45')](function(_0x2cdeff){logger[_0xb9a1('0x53')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x2cdeff);throw _0x2cdeff;});}return _0x2702bc;})[_0xb9a1('0x29')](respondWithResult(_0x45150e,0xc9))['catch'](handleError(_0x45150e,null));};exports[_0xb9a1('0x54')]=function(_0x44b0e5,_0x15e8ac){if(_0x44b0e5[_0xb9a1('0x4c')]['id']){delete _0x44b0e5[_0xb9a1('0x4c')]['id'];}return db['FaxQueue'][_0xb9a1('0x4a')]({'where':{'id':_0x44b0e5[_0xb9a1('0x46')]['id']}})['then'](handleEntityNotFound(_0x15e8ac,null))['then'](saveUpdates(_0x44b0e5[_0xb9a1('0x4c')],null))[_0xb9a1('0x29')](respondWithResult(_0x15e8ac,null))[_0xb9a1('0x45')](handleError(_0x15e8ac,null));};exports[_0xb9a1('0x26')]=function(_0x15e799,_0x340747){return db['FaxQueue']['find']({'where':{'id':_0x15e799[_0xb9a1('0x46')]['id']}})['then'](handleEntityNotFound(_0x340747,null))[_0xb9a1('0x29')](removeEntity(_0x340747,null))['catch'](handleError(_0x340747,null));};exports[_0xb9a1('0x55')]=function(_0x2da26a,_0x594c17){return db[_0xb9a1('0x2f')][_0xb9a1('0x55')]()[_0xb9a1('0x29')](respondWithResult(_0x594c17,null))[_0xb9a1('0x45')](handleError(_0x594c17,null));};exports[_0xb9a1('0x56')]=function(_0x45b3ca,_0x576f86,_0xe37a0d){var _0x39045c={'raw':!![],'where':{}},_0x56e41d={},_0x64291a;return db[_0xb9a1('0x2f')][_0xb9a1('0x57')]({'where':{'id':_0x45b3ca['params']['id']}})[_0xb9a1('0x29')](handleEntityNotFound(_0x576f86,null))[_0xb9a1('0x29')](function(_0x565747){if(_0x565747){_0x64291a=_0x565747[_0xb9a1('0x27')]({'plain':!![]});_0x56e41d['model']=_[_0xb9a1('0x35')](db[_0xb9a1('0x58')]['rawAttributes']);_0x56e41d[_0xb9a1('0x34')]=_[_0xb9a1('0x35')](_0x45b3ca['query']);_0x56e41d[_0xb9a1('0x36')]=_[_0xb9a1('0x37')](_0x56e41d[_0xb9a1('0x33')],_0x56e41d['query']);_0x39045c[_0xb9a1('0x39')]=_[_0xb9a1('0x37')](_0x56e41d['model'],qs[_0xb9a1('0x38')](_0x45b3ca[_0xb9a1('0x34')]['fields']));_0x39045c[_0xb9a1('0x39')]=_0x39045c['attributes']['length']?_0x39045c[_0xb9a1('0x39')]:_0x56e41d[_0xb9a1('0x33')];if(!_0x45b3ca['query'][_0xb9a1('0x3b')](_0xb9a1('0x3c'))){_0x39045c[_0xb9a1('0x1f')]=qs[_0xb9a1('0x1f')](_0x45b3ca['query'][_0xb9a1('0x1f')]);_0x39045c['offset']=qs[_0xb9a1('0x1d')](_0x45b3ca[_0xb9a1('0x34')][_0xb9a1('0x1d')]);}_0x39045c[_0xb9a1('0x59')]=qs['sort'](_0x45b3ca[_0xb9a1('0x34')][_0xb9a1('0x3d')]);_0x39045c[_0xb9a1('0x40')]=qs[_0xb9a1('0x36')](_[_0xb9a1('0x3e')](_0x45b3ca['query'],_0x56e41d[_0xb9a1('0x36')]));_0x39045c[_0xb9a1('0x40')][_0xb9a1('0x5a')]=_0x565747['id'];if(_0x45b3ca['query']['filter']){_0x39045c[_0xb9a1('0x40')]=_[_0xb9a1('0x41')](_0x39045c[_0xb9a1('0x40')],{'$or':_[_0xb9a1('0x2e')](_0x39045c['attributes'],function(_0x22be0d){var _0x3ed9f2={};_0x3ed9f2[_0x22be0d]={'$like':'%'+_0x45b3ca[_0xb9a1('0x34')][_0xb9a1('0x3f')]+'%'};return _0x3ed9f2;})});}_0x39045c=_[_0xb9a1('0x41')]({},_0x39045c,_0x45b3ca[_0xb9a1('0x49')]);return db[_0xb9a1('0x58')][_0xb9a1('0x43')](_0x39045c);}})[_0xb9a1('0x29')](function(_0x4e8ec8){if(_0x4e8ec8){return db[_0xb9a1('0x5b')][_0xb9a1('0x5c')]({'where':{'id':_[_0xb9a1('0x2e')](_0x4e8ec8,'UserId'),'role':_0xb9a1('0x5d')},'attributes':['id','name',_0xb9a1('0x5e'),_0xb9a1('0x5f'),'createdAt']});}})[_0xb9a1('0x29')](function(_0x3d1ffa){if(_0x3d1ffa){return{'count':_0x3d1ffa[_0xb9a1('0x20')],'rows':_[_0xb9a1('0x2e')](_0x3d1ffa[_0xb9a1('0x44')],function(_0x41b89a){return{'membername':_0x41b89a[_0xb9a1('0x2c')],'UserId':_0x41b89a['id'],'queue_name':_0x64291a[_0xb9a1('0x2c')],'FaxQueueId':_0x64291a['id'],'interface':util[_0xb9a1('0x60')](_0xb9a1('0x61'),'SIP',_0x41b89a[_0xb9a1('0x2c')]),'penalty':0x0,'paused':_0x41b89a['faxPause'],'createdAt':_0x41b89a[_0xb9a1('0x62')],'updatedAt':_0x41b89a[_0xb9a1('0x5f')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x576f86,_0x39045c))['catch'](handleError(_0x576f86,null));};exports[_0xb9a1('0x63')]=function(_0x34718e,_0x2ee747,_0x29f2f7){var _0x566573={};var _0x5e5a1c={};var _0x3e5e12;var _0x75c943;return db[_0xb9a1('0x2f')][_0xb9a1('0x57')]({'where':{'id':_0x34718e[_0xb9a1('0x46')]['id']}})['then'](handleEntityNotFound(_0x2ee747,null))['then'](function(_0x4dd8ef){if(_0x4dd8ef){_0x3e5e12=_0x4dd8ef;_0x5e5a1c[_0xb9a1('0x33')]=_[_0xb9a1('0x35')](db[_0xb9a1('0x64')][_0xb9a1('0x47')]);_0x5e5a1c[_0xb9a1('0x34')]=_[_0xb9a1('0x35')](_0x34718e[_0xb9a1('0x34')]);_0x5e5a1c[_0xb9a1('0x36')]=_[_0xb9a1('0x37')](_0x5e5a1c[_0xb9a1('0x33')],_0x5e5a1c[_0xb9a1('0x34')]);_0x566573[_0xb9a1('0x39')]=_[_0xb9a1('0x37')](_0x5e5a1c[_0xb9a1('0x33')],qs[_0xb9a1('0x38')](_0x34718e[_0xb9a1('0x34')]['fields']));_0x566573[_0xb9a1('0x39')]=_0x566573[_0xb9a1('0x39')]['length']?_0x566573[_0xb9a1('0x39')]:_0x5e5a1c[_0xb9a1('0x33')];_0x566573[_0xb9a1('0x59')]=qs[_0xb9a1('0x3d')](_0x34718e[_0xb9a1('0x34')][_0xb9a1('0x3d')]);_0x566573['where']=qs[_0xb9a1('0x36')](_[_0xb9a1('0x3e')](_0x34718e[_0xb9a1('0x34')],_0x5e5a1c[_0xb9a1('0x36')]));if(_0x34718e[_0xb9a1('0x34')]['filter']){_0x566573[_0xb9a1('0x40')]=_[_0xb9a1('0x41')](_0x566573[_0xb9a1('0x40')],{'$or':_[_0xb9a1('0x2e')](_0x566573[_0xb9a1('0x39')],function(_0x37875b){var _0x3cd937={};_0x3cd937[_0x37875b]={'$like':'%'+_0x34718e[_0xb9a1('0x34')][_0xb9a1('0x3f')]+'%'};return _0x3cd937;})});}_0x566573=_['merge']({},_0x566573,_0x34718e[_0xb9a1('0x49')]);return _0x3e5e12[_0xb9a1('0x63')](_0x566573);}})[_0xb9a1('0x29')](function(_0x259628){if(_0x259628){_0x75c943=_0x259628['length'];if(!_0x34718e[_0xb9a1('0x34')]['hasOwnProperty'](_0xb9a1('0x3c'))){_0x566573['limit']=qs[_0xb9a1('0x1f')](_0x34718e[_0xb9a1('0x34')][_0xb9a1('0x1f')]);_0x566573[_0xb9a1('0x1d')]=qs[_0xb9a1('0x1d')](_0x34718e[_0xb9a1('0x34')][_0xb9a1('0x1d')]);}return _0x3e5e12[_0xb9a1('0x63')](_0x566573);}})[_0xb9a1('0x29')](function(_0x4f6646){if(_0x4f6646){return _0x4f6646?{'count':_0x75c943,'rows':_0x4f6646}:null;}})[_0xb9a1('0x29')](respondWithResult(_0x2ee747,null))[_0xb9a1('0x45')](handleError(_0x2ee747,null));};exports[_0xb9a1('0x65')]=function(_0x112048,_0x56bd8e,_0x4e1328){var _0x5c8da1=_0x112048['body']['ids'];return db[_0xb9a1('0x64')][_0xb9a1('0x43')]({'where':{'id':_0x5c8da1},'attributes':['id'],'include':[{'model':db[_0xb9a1('0x5b')],'as':'Agents','attributes':['id',_0xb9a1('0x2c'),'online',_0xb9a1('0x66'),_0xb9a1('0x67')],'raw':!![]}]})[_0xb9a1('0x29')](function(_0x443c39){if(_0x443c39){var _0x3b9bfc=_['flatMap'](_0x443c39,function(_0x541505){var _0x3ced84=_0x541505[_0xb9a1('0x27')]({'plain':!![]});return _0x3ced84[_0xb9a1('0x68')];});return db[_0xb9a1('0x2f')][_0xb9a1('0x4a')]({'where':{'id':_0x112048[_0xb9a1('0x46')]['id']}})[_0xb9a1('0x29')](function(_0x5eed48){return db[_0xb9a1('0x69')][_0xb9a1('0x6a')](function(_0x2d9c0a){return _0x5eed48['addTeams'](_0x5c8da1,{'transaction':_0x2d9c0a})['then'](function(){return BPromise[_0xb9a1('0x6b')](_0x3b9bfc,function(_0x29d0c4){return db[_0xb9a1('0x58')][_0xb9a1('0x6c')]({'where':{'UserId':_0x29d0c4['id'],'FaxQueueId':_0x112048[_0xb9a1('0x46')]['id']},'transaction':_0x2d9c0a});});})['then'](function(){_0x3b9bfc[_0xb9a1('0x6d')](function(_0xd160a8){socket[_0xb9a1('0x6e')]('userFaxQueue:save',{'UserId':_0xd160a8['id'],'FaxQueueId':_0x5eed48['id']});});});});});}})[_0xb9a1('0x29')](respondWithStatusCode(_0x56bd8e,null))[_0xb9a1('0x45')](handleError(_0x56bd8e,null));};exports[_0xb9a1('0x6f')]=function(_0x59f069,_0x127cb1,_0x30f08f){return db[_0xb9a1('0x64')][_0xb9a1('0x43')]({'where':{'id':_0x59f069[_0xb9a1('0x34')][_0xb9a1('0x70')]},'attributes':['id'],'include':[{'model':db[_0xb9a1('0x5b')],'as':_0xb9a1('0x68'),'attributes':['id'],'raw':!![]}]})[_0xb9a1('0x29')](handleEntityNotFound(_0x127cb1,null))['then'](function(_0x439cec){var _0x56d404=_[_0xb9a1('0x2e')](_0x439cec,'id');var _0x46474b=[];var _0x1504c6=[];var _0x3bac13=squel[_0xb9a1('0x71')]();_0x3bac13['field'](_0xb9a1('0x72'))[_0xb9a1('0x73')](_0xb9a1('0x74'),'tq')[_0xb9a1('0x75')](_0xb9a1('0x76'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0xb9a1('0x40')](_0xb9a1('0x77'),_0x59f069['params']['id']);for(var _0x4d24ae=0x0;_0x4d24ae<_0x439cec[_0xb9a1('0x3a')];_0x4d24ae+=0x1){let _0x440955=_0x439cec[_0x4d24ae];for(var _0x49ed76=0x0;_0x49ed76<_0x440955[_0xb9a1('0x68')][_0xb9a1('0x3a')];_0x49ed76+=0x1){let _0x2c99da=_0x440955['Agents'][_0x49ed76];var _0x1fe6a1=_0x3bac13[_0xb9a1('0x78')]();_0x1fe6a1[_0xb9a1('0x40')](_0xb9a1('0x79'),_0x2c99da['id']);_0x1504c6[_0xb9a1('0x7a')](db[_0xb9a1('0x69')]['query'](_0x1fe6a1[_0xb9a1('0x7b')](),{'type':db['sequelize'][_0xb9a1('0x7c')][_0xb9a1('0x7d')]})[_0xb9a1('0x29')](function(_0x28db4c){if(_0x28db4c[_0xb9a1('0x3a')]===0x1){return _0x2c99da['id'];}else{var _0x1da8e3=_[_0xb9a1('0x7e')](_['map'](_0x28db4c,_0xb9a1('0x7f')),function(_0x386988){return _[_0xb9a1('0x80')](_0x56d404,_0x386988);});if(_0x1da8e3){return _0x2c99da['id'];}}}));}}return BPromise[_0xb9a1('0x81')](_0x1504c6)[_0xb9a1('0x29')](function(_0x2d5f88){_0x46474b=_(_0x46474b)[_0xb9a1('0x82')](_0x2d5f88)[_0xb9a1('0x83')]()[_0xb9a1('0x84')]();return db[_0xb9a1('0x2f')]['find']({'where':{'id':_0x59f069[_0xb9a1('0x46')]['id']}})[_0xb9a1('0x29')](function(_0xc9da6b){return db[_0xb9a1('0x69')][_0xb9a1('0x6a')](function(_0x4d0cef){return _0xc9da6b['removeTeams'](_0x59f069[_0xb9a1('0x34')][_0xb9a1('0x70')],{'transaction':_0x4d0cef})[_0xb9a1('0x29')](function(){if(!_[_0xb9a1('0x85')](_0x46474b)){return _0xc9da6b['removeAgents'](_0x46474b,{'transaction':_0x4d0cef});}})[_0xb9a1('0x29')](function(){_0x46474b['forEach'](function(_0x573269){socket[_0xb9a1('0x6e')](_0xb9a1('0x86'),{'UserId':_0x573269,'FaxQueueId':_0xc9da6b['id']});});});});});});})[_0xb9a1('0x29')](respondWithStatusCode(_0x127cb1,null))['catch'](handleError(_0x127cb1,null));};exports['addAgents']=function(_0x4abb1b,_0xd1ec3b,_0x31ddd7){return db[_0xb9a1('0x2f')]['find']({'where':{'id':_0x4abb1b['params']['id']}})[_0xb9a1('0x29')](handleEntityNotFound(_0xd1ec3b,null))['then'](function(_0x322f4f){if(_0x322f4f){return _0x322f4f[_0xb9a1('0x87')](_0x4abb1b[_0xb9a1('0x4c')]['ids'],_[_0xb9a1('0x88')](_0x4abb1b['body'],[_0xb9a1('0x70'),'id'])||{})[_0xb9a1('0x89')](function(_0x5d7807){for(var _0x404757=0x0;_0x404757<_0x4abb1b[_0xb9a1('0x4c')][_0xb9a1('0x70')][_0xb9a1('0x3a')];_0x404757+=0x1){socket['emit'](_0xb9a1('0x8a'),{'UserId':Number(_0x4abb1b[_0xb9a1('0x4c')]['ids'][_0x404757]),'FaxQueueId':Number(_0x4abb1b[_0xb9a1('0x46')]['id'])});}return _0x5d7807;});}})['then'](respondWithResult(_0xd1ec3b,null))[_0xb9a1('0x45')](handleError(_0xd1ec3b,null));};exports[_0xb9a1('0x8b')]=function(_0x1c1b61,_0x4c703d,_0x494c1a){return db['FaxQueue']['find']({'where':{'id':_0x1c1b61['params']['id']}})[_0xb9a1('0x29')](handleEntityNotFound(_0x4c703d,null))[_0xb9a1('0x29')](function(_0x37fc93){if(_0x37fc93){return _0x37fc93[_0xb9a1('0x8b')](_0x1c1b61['query'][_0xb9a1('0x70')])[_0xb9a1('0x29')](function(){if(_[_0xb9a1('0x8c')](_0x1c1b61[_0xb9a1('0x34')]['ids'])){for(var _0x4ab33d=0x0;_0x4ab33d<_0x1c1b61[_0xb9a1('0x34')][_0xb9a1('0x70')][_0xb9a1('0x3a')];_0x4ab33d+=0x1){socket[_0xb9a1('0x6e')](_0xb9a1('0x86'),{'UserId':Number(_0x1c1b61[_0xb9a1('0x34')][_0xb9a1('0x70')][_0x4ab33d]),'FaxQueueId':Number(_0x1c1b61[_0xb9a1('0x46')]['id'])});}}else{socket[_0xb9a1('0x6e')]('userFaxQueue:remove',{'UserId':Number(_0x1c1b61[_0xb9a1('0x34')][_0xb9a1('0x70')]),'FaxQueueId':Number(_0x1c1b61[_0xb9a1('0x46')]['id'])});}});}})['then'](respondWithStatusCode(_0x4c703d,null))['catch'](handleError(_0x4c703d,null));};exports[_0xb9a1('0x8d')]=function(_0x2e13e2,_0x24fce9,_0x117351){var _0xb5883c={};var _0x43136d={};var _0x39fba0;var _0x52379b;return db[_0xb9a1('0x2f')][_0xb9a1('0x57')]({'where':{'id':_0x2e13e2[_0xb9a1('0x46')]['id']}})[_0xb9a1('0x29')](handleEntityNotFound(_0x24fce9,null))[_0xb9a1('0x29')](function(_0x1cd35a){if(_0x1cd35a){_0x39fba0=_0x1cd35a;_0x43136d[_0xb9a1('0x33')]=_[_0xb9a1('0x35')](db[_0xb9a1('0x5b')][_0xb9a1('0x47')]);_0x43136d[_0xb9a1('0x34')]=_[_0xb9a1('0x35')](_0x2e13e2[_0xb9a1('0x34')]);_0x43136d[_0xb9a1('0x36')]=_[_0xb9a1('0x37')](_0x43136d['model'],_0x43136d[_0xb9a1('0x34')]);_0xb5883c[_0xb9a1('0x39')]=_[_0xb9a1('0x37')](_0x43136d[_0xb9a1('0x33')],qs[_0xb9a1('0x38')](_0x2e13e2[_0xb9a1('0x34')][_0xb9a1('0x38')]));_0xb5883c[_0xb9a1('0x39')]=_0xb5883c[_0xb9a1('0x39')][_0xb9a1('0x3a')]?_0xb5883c[_0xb9a1('0x39')]:_0x43136d[_0xb9a1('0x33')];_0xb5883c[_0xb9a1('0x59')]=qs[_0xb9a1('0x3d')](_0x2e13e2[_0xb9a1('0x34')][_0xb9a1('0x3d')]);_0xb5883c[_0xb9a1('0x40')]=qs[_0xb9a1('0x36')](_[_0xb9a1('0x3e')](_0x2e13e2[_0xb9a1('0x34')],_0x43136d[_0xb9a1('0x36')]));if(_0x2e13e2[_0xb9a1('0x34')]['filter']){_0xb5883c['where']=_['merge'](_0xb5883c[_0xb9a1('0x40')],{'$or':_[_0xb9a1('0x2e')](_0xb5883c[_0xb9a1('0x39')],function(_0x38a94c){var _0x5c150e={};_0x5c150e[_0x38a94c]={'$like':'%'+_0x2e13e2['query']['filter']+'%'};return _0x5c150e;})});}_0xb5883c=_[_0xb9a1('0x41')]({},_0xb5883c,_0x2e13e2[_0xb9a1('0x49')]);return _0x39fba0[_0xb9a1('0x8d')](_0xb5883c);}})[_0xb9a1('0x29')](function(_0x3b42fb){if(_0x3b42fb){_0x52379b=_0x3b42fb[_0xb9a1('0x3a')];if(!_0x2e13e2[_0xb9a1('0x34')][_0xb9a1('0x3b')](_0xb9a1('0x3c'))){_0xb5883c[_0xb9a1('0x1f')]=qs[_0xb9a1('0x1f')](_0x2e13e2[_0xb9a1('0x34')]['limit']);_0xb5883c['offset']=qs[_0xb9a1('0x1d')](_0x2e13e2[_0xb9a1('0x34')][_0xb9a1('0x1d')]);}return _0x39fba0[_0xb9a1('0x8d')](_0xb5883c);}})['then'](function(_0xeda882){if(_0xeda882){return _0xeda882?{'count':_0x52379b,'rows':_0xeda882}:null;}})[_0xb9a1('0x29')](respondWithResult(_0x24fce9,null))[_0xb9a1('0x45')](handleError(_0x24fce9,null));};
\ No newline at end of file
+var _0x785f=['ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','./faxQueue.socket','register','sendStatus','status','json','offset','undefined','limit','count','set','apply','save','update','then','get','FaxQueues','destroy','end','error','send','index','FaxQueue','rawAttributes','fieldName','type','model','map','query','filters','attributes','intersection','fields','nolimit','order','sort','where','pick','merge','VIRTUAL','name','filter','options','include','findAll','catch','show','params','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','keys','length','hasOwnProperty','UserFaxQueue','UserId','agent','faxPause','updatedAt','createdAt','rows','format','getTeams','Team','addTeams','ids','User','Agents','online','voicePause','interface','flatMap','sequelize','each','emit','userFaxQueue:save','removeTeams','field','tq.TeamId','from','team_has_fax_queues','join','ut.TeamId\x20=\x20tq.TeamId','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','union','compact','value','transaction','removeAgents','forEach','userFaxQueue:remove','addAgents','omit','spread','isArray','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path'];(function(_0x4e8947,_0x5ca04d){var _0x29abde=function(_0x4c5158){while(--_0x4c5158){_0x4e8947['push'](_0x4e8947['shift']());}};_0x29abde(++_0x5ca04d);}(_0x785f,0x1a4));var _0xf785=function(_0x334841,_0x2bbc4c){_0x334841=_0x334841-0x0;var _0x5beb4b=_0x785f[_0x334841];return _0x5beb4b;};'use strict';var emlformat=require(_0xf785('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf785('0x1'));var jsonpatch=require(_0xf785('0x2'));var rp=require(_0xf785('0x3'));var moment=require(_0xf785('0x4'));var BPromise=require(_0xf785('0x5'));var Mustache=require(_0xf785('0x6'));var util=require(_0xf785('0x7'));var path=require(_0xf785('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xf785('0x9'));var fs=require('fs');var fs_extra=require(_0xf785('0xa'));var _=require(_0xf785('0xb'));var squel=require(_0xf785('0xc'));var crypto=require(_0xf785('0xd'));var jsforce=require(_0xf785('0xe'));var deskjs=require(_0xf785('0xf'));var toCsv=require(_0xf785('0x10'));var querystring=require(_0xf785('0x11'));var Papa=require(_0xf785('0x12'));var Redis=require(_0xf785('0x13'));var authService=require('../../components/auth/service');var qs=require(_0xf785('0x14'));var as=require(_0xf785('0x15'));var hardwareService=require(_0xf785('0x16'));var logger=require(_0xf785('0x17'))('api');var utils=require(_0xf785('0x18'));var config=require(_0xf785('0x19'));var licenseUtil=require(_0xf785('0x1a'));var db=require(_0xf785('0x1b'))['db'];config['redis']=_[_0xf785('0x1c')](config[_0xf785('0x1d')],{'host':_0xf785('0x1e'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xf785('0x1f'))[_0xf785('0x20')](socket);function respondWithStatusCode(_0x189207,_0x4dbddd){_0x4dbddd=_0x4dbddd||0xcc;return function(_0x1d4038){if(_0x1d4038){return _0x189207[_0xf785('0x21')](_0x4dbddd);}return _0x189207['status'](_0x4dbddd)['end']();};}function respondWithResult(_0x4c72a2,_0x1174d8){_0x1174d8=_0x1174d8||0xc8;return function(_0x5ee7cb){if(_0x5ee7cb){return _0x4c72a2[_0xf785('0x22')](_0x1174d8)[_0xf785('0x23')](_0x5ee7cb);}};}function respondWithFilteredResult(_0x102416,_0x36a439){return function(_0x3c0ada){if(_0x3c0ada){var _0x9bb07c=typeof _0x36a439[_0xf785('0x24')]===_0xf785('0x25')&&typeof _0x36a439[_0xf785('0x26')]===_0xf785('0x25');var _0xdc77a5=_0x3c0ada[_0xf785('0x27')];var _0x209c77=_0x9bb07c?0x0:_0x36a439[_0xf785('0x24')];var _0x54d25d=_0x9bb07c?_0x3c0ada[_0xf785('0x27')]:_0x36a439[_0xf785('0x24')]+_0x36a439[_0xf785('0x26')];var _0x3321b3;if(_0x54d25d>=_0xdc77a5){_0x54d25d=_0xdc77a5;_0x3321b3=0xc8;}else{_0x3321b3=0xce;}_0x102416['status'](_0x3321b3);return _0x102416[_0xf785('0x28')]('Content-Range',_0x209c77+'-'+_0x54d25d+'/'+_0xdc77a5)[_0xf785('0x23')](_0x3c0ada);}return null;};}function patchUpdates(_0x4b36db){return function(_0x835377){try{jsonpatch[_0xf785('0x29')](_0x835377,_0x4b36db,!![]);}catch(_0x3b7f2d){return BPromise['reject'](_0x3b7f2d);}return _0x835377[_0xf785('0x2a')]();};}function saveUpdates(_0x3cfe65,_0x58d9be){return function(_0x8060b3){if(_0x8060b3){return _0x8060b3[_0xf785('0x2b')](_0x3cfe65)[_0xf785('0x2c')](function(_0x1af9df){return _0x1af9df;});}return null;};}function removeEntity(_0x3baa0b,_0x39f9be){return function(_0xe1e616){if(_0xe1e616){return _0xe1e616['destroy']()[_0xf785('0x2c')](function(){var _0x50d25b=_0xe1e616[_0xf785('0x2d')]({'plain':!![]});var _0x15b190=_0xf785('0x2e');return db['UserProfileResource'][_0xf785('0x2f')]({'where':{'type':_0x15b190,'resourceId':_0x50d25b['id']}})[_0xf785('0x2c')](function(){return _0xe1e616;});})[_0xf785('0x2c')](function(){_0x3baa0b['status'](0xcc)[_0xf785('0x30')]();});}};}function handleEntityNotFound(_0x5237b7,_0x1d685e){return function(_0x239b7f){if(!_0x239b7f){_0x5237b7[_0xf785('0x21')](0x194);}return _0x239b7f;};}function handleError(_0x5bc371,_0x43acf0){_0x43acf0=_0x43acf0||0x1f4;return function(_0x566779){logger[_0xf785('0x31')](_0x566779['stack']);if(_0x566779['name']){delete _0x566779['name'];}_0x5bc371[_0xf785('0x22')](_0x43acf0)[_0xf785('0x32')](_0x566779);};}exports[_0xf785('0x33')]=function(_0x492ce3,_0x2fbd4a){var _0x401d3b={},_0x322709={},_0x247fcb={'count':0x0,'rows':[]};var _0x58f4b7=_['map'](db[_0xf785('0x34')][_0xf785('0x35')],function(_0x46ba94){return{'name':_0x46ba94[_0xf785('0x36')],'type':_0x46ba94[_0xf785('0x37')]['key']};});_0x322709[_0xf785('0x38')]=_[_0xf785('0x39')](_0x58f4b7,'name');_0x322709['query']=_['keys'](_0x492ce3[_0xf785('0x3a')]);_0x322709[_0xf785('0x3b')]=_['intersection'](_0x322709['model'],_0x322709['query']);_0x401d3b[_0xf785('0x3c')]=_[_0xf785('0x3d')](_0x322709[_0xf785('0x38')],qs[_0xf785('0x3e')](_0x492ce3[_0xf785('0x3a')][_0xf785('0x3e')]));_0x401d3b[_0xf785('0x3c')]=_0x401d3b[_0xf785('0x3c')]['length']?_0x401d3b[_0xf785('0x3c')]:_0x322709[_0xf785('0x38')];if(!_0x492ce3[_0xf785('0x3a')]['hasOwnProperty'](_0xf785('0x3f'))){_0x401d3b[_0xf785('0x26')]=qs[_0xf785('0x26')](_0x492ce3[_0xf785('0x3a')][_0xf785('0x26')]);_0x401d3b[_0xf785('0x24')]=qs[_0xf785('0x24')](_0x492ce3[_0xf785('0x3a')][_0xf785('0x24')]);}_0x401d3b[_0xf785('0x40')]=qs[_0xf785('0x41')](_0x492ce3[_0xf785('0x3a')][_0xf785('0x41')]);_0x401d3b[_0xf785('0x42')]=qs[_0xf785('0x3b')](_[_0xf785('0x43')](_0x492ce3['query'],_0x322709[_0xf785('0x3b')]),_0x58f4b7);if(_0x492ce3[_0xf785('0x3a')]['filter']){_0x401d3b['where']=_[_0xf785('0x44')](_0x401d3b['where'],{'$or':_[_0xf785('0x39')](_0x58f4b7,function(_0x46961d){if(_0x46961d['type']!==_0xf785('0x45')){var _0x1498a9={};_0x1498a9[_0x46961d[_0xf785('0x46')]]={'$like':'%'+_0x492ce3['query'][_0xf785('0x47')]+'%'};return _0x1498a9;}})});}_0x401d3b=_[_0xf785('0x44')]({},_0x401d3b,_0x492ce3[_0xf785('0x48')]);var _0xdb62e8={'where':_0x401d3b[_0xf785('0x42')]};return db[_0xf785('0x34')]['count'](_0xdb62e8)[_0xf785('0x2c')](function(_0x3d9bdb){_0x247fcb['count']=_0x3d9bdb;if(_0x492ce3[_0xf785('0x3a')]['includeAll']){_0x401d3b[_0xf785('0x49')]=[{'all':!![]}];}return db['FaxQueue'][_0xf785('0x4a')](_0x401d3b);})[_0xf785('0x2c')](function(_0x5c5bd8){_0x247fcb['rows']=_0x5c5bd8;return _0x247fcb;})[_0xf785('0x2c')](respondWithFilteredResult(_0x2fbd4a,_0x401d3b))[_0xf785('0x4b')](handleError(_0x2fbd4a,null));};exports[_0xf785('0x4c')]=function(_0xd99858,_0xf86d0){var _0x14cf4c={'raw':!![],'where':{'id':_0xd99858[_0xf785('0x4d')]['id']}},_0x306f20={};_0x306f20[_0xf785('0x38')]=_['keys'](db[_0xf785('0x34')][_0xf785('0x35')]);_0x306f20[_0xf785('0x3a')]=_['keys'](_0xd99858[_0xf785('0x3a')]);_0x306f20[_0xf785('0x3b')]=_['intersection'](_0x306f20[_0xf785('0x38')],_0x306f20[_0xf785('0x3a')]);_0x14cf4c[_0xf785('0x3c')]=_[_0xf785('0x3d')](_0x306f20[_0xf785('0x38')],qs['fields'](_0xd99858[_0xf785('0x3a')][_0xf785('0x3e')]));_0x14cf4c['attributes']=_0x14cf4c[_0xf785('0x3c')]['length']?_0x14cf4c[_0xf785('0x3c')]:_0x306f20[_0xf785('0x38')];if(_0xd99858[_0xf785('0x3a')][_0xf785('0x4e')]){_0x14cf4c[_0xf785('0x49')]=[{'all':!![]}];}_0x14cf4c=_[_0xf785('0x44')]({},_0x14cf4c,_0xd99858[_0xf785('0x48')]);return db[_0xf785('0x34')][_0xf785('0x4f')](_0x14cf4c)[_0xf785('0x2c')](handleEntityNotFound(_0xf86d0,null))[_0xf785('0x2c')](respondWithResult(_0xf86d0,null))['catch'](handleError(_0xf86d0,null));};exports[_0xf785('0x50')]=function(_0x2fd254,_0x55f677){return db[_0xf785('0x34')][_0xf785('0x50')](_0x2fd254[_0xf785('0x51')],{})['then'](function(_0x3d5981){var _0x3f3acd=_0x2fd254[_0xf785('0x52')]['get']({'plain':!![]});if(!_0x3f3acd)throw new Error(_0xf785('0x53'));if(_0x3f3acd[_0xf785('0x54')]==='user'){var _0x4027c1=_0x3d5981[_0xf785('0x2d')]({'plain':!![]});var _0x2ae855='FaxQueues';return db['UserProfileSection']['find']({'where':{'name':_0x2ae855,'userProfileId':_0x3f3acd['userProfileId']},'raw':!![]})[_0xf785('0x2c')](function(_0x546b53){if(_0x546b53&&_0x546b53[_0xf785('0x55')]===0x0){return db[_0xf785('0x56')][_0xf785('0x50')]({'name':_0x4027c1[_0xf785('0x46')],'resourceId':_0x4027c1['id'],'type':_0x546b53[_0xf785('0x46')],'sectionId':_0x546b53['id']},{})[_0xf785('0x2c')](function(){return _0x3d5981;});}else{return _0x3d5981;}})['catch'](function(_0x4dff77){logger[_0xf785('0x31')](_0xf785('0x57'),_0x4dff77);throw _0x4dff77;});}return _0x3d5981;})[_0xf785('0x2c')](respondWithResult(_0x55f677,0xc9))[_0xf785('0x4b')](handleError(_0x55f677,null));};exports[_0xf785('0x2b')]=function(_0x4807e1,_0x3a7e10){if(_0x4807e1[_0xf785('0x51')]['id']){delete _0x4807e1[_0xf785('0x51')]['id'];}return db[_0xf785('0x34')][_0xf785('0x4f')]({'where':{'id':_0x4807e1[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x3a7e10,null))[_0xf785('0x2c')](saveUpdates(_0x4807e1[_0xf785('0x51')],null))[_0xf785('0x2c')](respondWithResult(_0x3a7e10,null))[_0xf785('0x4b')](handleError(_0x3a7e10,null));};exports[_0xf785('0x2f')]=function(_0x2a69b0,_0x1e57ec){return db[_0xf785('0x34')][_0xf785('0x4f')]({'where':{'id':_0x2a69b0[_0xf785('0x4d')]['id']}})['then'](handleEntityNotFound(_0x1e57ec,null))[_0xf785('0x2c')](removeEntity(_0x1e57ec,null))[_0xf785('0x4b')](handleError(_0x1e57ec,null));};exports[_0xf785('0x58')]=function(_0x3d3ba5,_0x2ac6dc){return db[_0xf785('0x34')][_0xf785('0x58')]()['then'](respondWithResult(_0x2ac6dc,null))[_0xf785('0x4b')](handleError(_0x2ac6dc,null));};exports[_0xf785('0x59')]=function(_0x2bc609,_0xc75ec9,_0x291eab){var _0x4764d8={'raw':!![],'where':{}},_0x209b33={},_0x3579f3;return db[_0xf785('0x34')][_0xf785('0x5a')]({'where':{'id':_0x2bc609[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0xc75ec9,null))[_0xf785('0x2c')](function(_0x107794){if(_0x107794){_0x3579f3=_0x107794[_0xf785('0x2d')]({'plain':!![]});_0x209b33[_0xf785('0x38')]=_[_0xf785('0x5b')](db['UserFaxQueue']['rawAttributes']);_0x209b33[_0xf785('0x3a')]=_[_0xf785('0x5b')](_0x2bc609['query']);_0x209b33[_0xf785('0x3b')]=_[_0xf785('0x3d')](_0x209b33[_0xf785('0x38')],_0x209b33['query']);_0x4764d8['attributes']=_[_0xf785('0x3d')](_0x209b33[_0xf785('0x38')],qs[_0xf785('0x3e')](_0x2bc609[_0xf785('0x3a')][_0xf785('0x3e')]));_0x4764d8['attributes']=_0x4764d8[_0xf785('0x3c')][_0xf785('0x5c')]?_0x4764d8['attributes']:_0x209b33[_0xf785('0x38')];if(!_0x2bc609[_0xf785('0x3a')][_0xf785('0x5d')]('nolimit')){_0x4764d8[_0xf785('0x26')]=qs[_0xf785('0x26')](_0x2bc609['query'][_0xf785('0x26')]);_0x4764d8[_0xf785('0x24')]=qs[_0xf785('0x24')](_0x2bc609[_0xf785('0x3a')][_0xf785('0x24')]);}_0x4764d8['order']=qs['sort'](_0x2bc609['query'][_0xf785('0x41')]);_0x4764d8['where']=qs[_0xf785('0x3b')](_[_0xf785('0x43')](_0x2bc609[_0xf785('0x3a')],_0x209b33[_0xf785('0x3b')]));_0x4764d8['where']['FaxQueueId']=_0x107794['id'];if(_0x2bc609[_0xf785('0x3a')]['filter']){_0x4764d8['where']=_[_0xf785('0x44')](_0x4764d8[_0xf785('0x42')],{'$or':_[_0xf785('0x39')](_0x4764d8[_0xf785('0x3c')],function(_0x1bc1bc){var _0x3da02d={};_0x3da02d[_0x1bc1bc]={'$like':'%'+_0x2bc609['query'][_0xf785('0x47')]+'%'};return _0x3da02d;})});}_0x4764d8=_[_0xf785('0x44')]({},_0x4764d8,_0x2bc609[_0xf785('0x48')]);return db[_0xf785('0x5e')][_0xf785('0x4a')](_0x4764d8);}})[_0xf785('0x2c')](function(_0x4a3a06){if(_0x4a3a06){return db['User']['findAndCountAll']({'where':{'id':_[_0xf785('0x39')](_0x4a3a06,_0xf785('0x5f')),'role':_0xf785('0x60')},'attributes':['id',_0xf785('0x46'),_0xf785('0x61'),_0xf785('0x62'),_0xf785('0x63')]});}})['then'](function(_0x30c455){if(_0x30c455){return{'count':_0x30c455['count'],'rows':_['map'](_0x30c455[_0xf785('0x64')],function(_0x40b25c){return{'membername':_0x40b25c[_0xf785('0x46')],'UserId':_0x40b25c['id'],'queue_name':_0x3579f3[_0xf785('0x46')],'FaxQueueId':_0x3579f3['id'],'interface':util[_0xf785('0x65')]('%s/%s','SIP',_0x40b25c[_0xf785('0x46')]),'penalty':0x0,'paused':_0x40b25c['faxPause'],'createdAt':_0x40b25c[_0xf785('0x63')],'updatedAt':_0x40b25c[_0xf785('0x62')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xf785('0x2c')](respondWithFilteredResult(_0xc75ec9,_0x4764d8))['catch'](handleError(_0xc75ec9,null));};exports[_0xf785('0x66')]=function(_0x4331d3,_0x5b3739,_0x338780){var _0x16f774={};var _0x4e697c={};var _0x5d2761;var _0xfc1e4;return db[_0xf785('0x34')][_0xf785('0x5a')]({'where':{'id':_0x4331d3[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x5b3739,null))[_0xf785('0x2c')](function(_0x579f6b){if(_0x579f6b){_0x5d2761=_0x579f6b;_0x4e697c[_0xf785('0x38')]=_[_0xf785('0x5b')](db[_0xf785('0x67')][_0xf785('0x35')]);_0x4e697c[_0xf785('0x3a')]=_[_0xf785('0x5b')](_0x4331d3[_0xf785('0x3a')]);_0x4e697c[_0xf785('0x3b')]=_[_0xf785('0x3d')](_0x4e697c[_0xf785('0x38')],_0x4e697c['query']);_0x16f774[_0xf785('0x3c')]=_['intersection'](_0x4e697c[_0xf785('0x38')],qs[_0xf785('0x3e')](_0x4331d3[_0xf785('0x3a')][_0xf785('0x3e')]));_0x16f774[_0xf785('0x3c')]=_0x16f774['attributes']['length']?_0x16f774['attributes']:_0x4e697c['model'];_0x16f774[_0xf785('0x40')]=qs[_0xf785('0x41')](_0x4331d3[_0xf785('0x3a')]['sort']);_0x16f774[_0xf785('0x42')]=qs[_0xf785('0x3b')](_['pick'](_0x4331d3[_0xf785('0x3a')],_0x4e697c[_0xf785('0x3b')]));if(_0x4331d3[_0xf785('0x3a')][_0xf785('0x47')]){_0x16f774['where']=_[_0xf785('0x44')](_0x16f774[_0xf785('0x42')],{'$or':_['map'](_0x16f774[_0xf785('0x3c')],function(_0x2477c0){var _0x529fff={};_0x529fff[_0x2477c0]={'$like':'%'+_0x4331d3['query'][_0xf785('0x47')]+'%'};return _0x529fff;})});}_0x16f774=_[_0xf785('0x44')]({},_0x16f774,_0x4331d3[_0xf785('0x48')]);return _0x5d2761['getTeams'](_0x16f774);}})['then'](function(_0x1c0fe0){if(_0x1c0fe0){_0xfc1e4=_0x1c0fe0[_0xf785('0x5c')];if(!_0x4331d3[_0xf785('0x3a')]['hasOwnProperty'](_0xf785('0x3f'))){_0x16f774['limit']=qs['limit'](_0x4331d3[_0xf785('0x3a')][_0xf785('0x26')]);_0x16f774[_0xf785('0x24')]=qs[_0xf785('0x24')](_0x4331d3[_0xf785('0x3a')][_0xf785('0x24')]);}return _0x5d2761[_0xf785('0x66')](_0x16f774);}})[_0xf785('0x2c')](function(_0x4635b1){if(_0x4635b1){return _0x4635b1?{'count':_0xfc1e4,'rows':_0x4635b1}:null;}})[_0xf785('0x2c')](respondWithResult(_0x5b3739,null))['catch'](handleError(_0x5b3739,null));};exports[_0xf785('0x68')]=function(_0x53b24d,_0x52c283,_0x3f3c5a){var _0x18746e=_0x53b24d[_0xf785('0x51')][_0xf785('0x69')];return db[_0xf785('0x67')][_0xf785('0x4a')]({'where':{'id':_0x18746e},'attributes':['id'],'include':[{'model':db[_0xf785('0x6a')],'as':_0xf785('0x6b'),'attributes':['id',_0xf785('0x46'),_0xf785('0x6c'),_0xf785('0x6d'),_0xf785('0x6e')],'raw':!![]}]})['then'](function(_0xbb6ee4){if(_0xbb6ee4){var _0x533ee4=_[_0xf785('0x6f')](_0xbb6ee4,function(_0x5b5ed4){var _0x691ffa=_0x5b5ed4['get']({'plain':!![]});return _0x691ffa['Agents'];});return db[_0xf785('0x34')]['find']({'where':{'id':_0x53b24d['params']['id']}})[_0xf785('0x2c')](function(_0x4d5b36){return db[_0xf785('0x70')]['transaction'](function(_0x15bfa1){return _0x4d5b36['addTeams'](_0x18746e,{'transaction':_0x15bfa1})[_0xf785('0x2c')](function(){return BPromise[_0xf785('0x71')](_0x533ee4,function(_0x15aca4){return db[_0xf785('0x5e')]['findOrCreate']({'where':{'UserId':_0x15aca4['id'],'FaxQueueId':_0x53b24d[_0xf785('0x4d')]['id']},'transaction':_0x15bfa1});});})[_0xf785('0x2c')](function(){_0x533ee4['forEach'](function(_0x30539){socket[_0xf785('0x72')](_0xf785('0x73'),{'UserId':_0x30539['id'],'FaxQueueId':_0x4d5b36['id']});});});});});}})[_0xf785('0x2c')](respondWithStatusCode(_0x52c283,null))[_0xf785('0x4b')](handleError(_0x52c283,null));};exports[_0xf785('0x74')]=function(_0x457047,_0xfcec26,_0x42fa7c){return db[_0xf785('0x67')][_0xf785('0x4a')]({'where':{'id':_0x457047['query'][_0xf785('0x69')]},'attributes':['id'],'include':[{'model':db[_0xf785('0x6a')],'as':_0xf785('0x6b'),'attributes':['id'],'raw':!![]}]})[_0xf785('0x2c')](handleEntityNotFound(_0xfcec26,null))['then'](function(_0x428e30){var _0x48156c=_[_0xf785('0x39')](_0x428e30,'id');var _0x330b28=[];var _0x50f526=[];var _0x58189c=squel['select']();_0x58189c[_0xf785('0x75')](_0xf785('0x76'))[_0xf785('0x77')](_0xf785('0x78'),'tq')[_0xf785('0x79')]('user_has_teams','ut',_0xf785('0x7a'))['where']('FaxQueueId\x20=\x20?',_0x457047[_0xf785('0x4d')]['id']);for(var _0x1981e0=0x0;_0x1981e0<_0x428e30['length'];_0x1981e0+=0x1){let _0x42b787=_0x428e30[_0x1981e0];for(var _0x4838fd=0x0;_0x4838fd<_0x42b787[_0xf785('0x6b')][_0xf785('0x5c')];_0x4838fd+=0x1){let _0x1f7906=_0x42b787[_0xf785('0x6b')][_0x4838fd];var _0xe9ca2a=_0x58189c['clone']();_0xe9ca2a[_0xf785('0x42')]('ut.UserId\x20=\x20?',_0x1f7906['id']);_0x50f526[_0xf785('0x7b')](db[_0xf785('0x70')]['query'](_0xe9ca2a[_0xf785('0x7c')](),{'type':db['sequelize'][_0xf785('0x7d')][_0xf785('0x7e')]})['then'](function(_0x5f4012){if(_0x5f4012[_0xf785('0x5c')]===0x1){return _0x1f7906['id'];}else{var _0x2a235a=_[_0xf785('0x7f')](_[_0xf785('0x39')](_0x5f4012,_0xf785('0x80')),function(_0x551126){return _[_0xf785('0x81')](_0x48156c,_0x551126);});if(_0x2a235a){return _0x1f7906['id'];}}}));}}return BPromise[_0xf785('0x82')](_0x50f526)['then'](function(_0x25d0a2){_0x330b28=_(_0x330b28)[_0xf785('0x83')](_0x25d0a2)[_0xf785('0x84')]()[_0xf785('0x85')]();return db['FaxQueue']['find']({'where':{'id':_0x457047['params']['id']}})[_0xf785('0x2c')](function(_0x38446d){return db[_0xf785('0x70')][_0xf785('0x86')](function(_0x3d7a10){return _0x38446d[_0xf785('0x74')](_0x457047[_0xf785('0x3a')][_0xf785('0x69')],{'transaction':_0x3d7a10})['then'](function(){if(!_['isEmpty'](_0x330b28)){return _0x38446d[_0xf785('0x87')](_0x330b28,{'transaction':_0x3d7a10});}})[_0xf785('0x2c')](function(){_0x330b28[_0xf785('0x88')](function(_0x461fc4){socket[_0xf785('0x72')](_0xf785('0x89'),{'UserId':_0x461fc4,'FaxQueueId':_0x38446d['id']});});});});});});})['then'](respondWithStatusCode(_0xfcec26,null))[_0xf785('0x4b')](handleError(_0xfcec26,null));};exports[_0xf785('0x8a')]=function(_0x26fce6,_0x3862ea,_0x190385){return db['FaxQueue'][_0xf785('0x4f')]({'where':{'id':_0x26fce6['params']['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x3862ea,null))[_0xf785('0x2c')](function(_0x417864){if(_0x417864){return _0x417864['addAgents'](_0x26fce6['body']['ids'],_[_0xf785('0x8b')](_0x26fce6[_0xf785('0x51')],['ids','id'])||{})[_0xf785('0x8c')](function(_0x4a5b85){for(var _0x577b3b=0x0;_0x577b3b<_0x26fce6[_0xf785('0x51')][_0xf785('0x69')][_0xf785('0x5c')];_0x577b3b+=0x1){socket['emit'](_0xf785('0x73'),{'UserId':Number(_0x26fce6[_0xf785('0x51')][_0xf785('0x69')][_0x577b3b]),'FaxQueueId':Number(_0x26fce6[_0xf785('0x4d')]['id'])});}return _0x4a5b85;});}})[_0xf785('0x2c')](respondWithResult(_0x3862ea,null))['catch'](handleError(_0x3862ea,null));};exports[_0xf785('0x87')]=function(_0x2196a9,_0x404e92,_0x3ceb14){return db[_0xf785('0x34')][_0xf785('0x4f')]({'where':{'id':_0x2196a9[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x404e92,null))[_0xf785('0x2c')](function(_0x3e966f){if(_0x3e966f){return _0x3e966f[_0xf785('0x87')](_0x2196a9[_0xf785('0x3a')][_0xf785('0x69')])[_0xf785('0x2c')](function(){if(_[_0xf785('0x8d')](_0x2196a9[_0xf785('0x3a')]['ids'])){for(var _0x1039bb=0x0;_0x1039bb<_0x2196a9[_0xf785('0x3a')][_0xf785('0x69')][_0xf785('0x5c')];_0x1039bb+=0x1){socket[_0xf785('0x72')](_0xf785('0x89'),{'UserId':Number(_0x2196a9[_0xf785('0x3a')][_0xf785('0x69')][_0x1039bb]),'FaxQueueId':Number(_0x2196a9[_0xf785('0x4d')]['id'])});}}else{socket[_0xf785('0x72')](_0xf785('0x89'),{'UserId':Number(_0x2196a9[_0xf785('0x3a')][_0xf785('0x69')]),'FaxQueueId':Number(_0x2196a9['params']['id'])});}});}})[_0xf785('0x2c')](respondWithStatusCode(_0x404e92,null))[_0xf785('0x4b')](handleError(_0x404e92,null));};exports[_0xf785('0x8e')]=function(_0x3a64ae,_0x45e10c,_0x3cd6e6){var _0x4c95c9={};var _0x4f5cbe={};var _0x56d601;var _0xafb953;return db[_0xf785('0x34')]['findOne']({'where':{'id':_0x3a64ae[_0xf785('0x4d')]['id']}})[_0xf785('0x2c')](handleEntityNotFound(_0x45e10c,null))[_0xf785('0x2c')](function(_0x482e3e){if(_0x482e3e){_0x56d601=_0x482e3e;_0x4f5cbe['model']=_['keys'](db[_0xf785('0x6a')][_0xf785('0x35')]);_0x4f5cbe[_0xf785('0x3a')]=_['keys'](_0x3a64ae['query']);_0x4f5cbe[_0xf785('0x3b')]=_[_0xf785('0x3d')](_0x4f5cbe[_0xf785('0x38')],_0x4f5cbe[_0xf785('0x3a')]);_0x4c95c9[_0xf785('0x3c')]=_[_0xf785('0x3d')](_0x4f5cbe[_0xf785('0x38')],qs['fields'](_0x3a64ae[_0xf785('0x3a')]['fields']));_0x4c95c9['attributes']=_0x4c95c9[_0xf785('0x3c')][_0xf785('0x5c')]?_0x4c95c9['attributes']:_0x4f5cbe[_0xf785('0x38')];_0x4c95c9[_0xf785('0x40')]=qs['sort'](_0x3a64ae['query']['sort']);_0x4c95c9[_0xf785('0x42')]=qs[_0xf785('0x3b')](_[_0xf785('0x43')](_0x3a64ae[_0xf785('0x3a')],_0x4f5cbe['filters']));if(_0x3a64ae['query'][_0xf785('0x47')]){_0x4c95c9[_0xf785('0x42')]=_[_0xf785('0x44')](_0x4c95c9[_0xf785('0x42')],{'$or':_[_0xf785('0x39')](_0x4c95c9['attributes'],function(_0x5b3d3e){var _0xc236f2={};_0xc236f2[_0x5b3d3e]={'$like':'%'+_0x3a64ae[_0xf785('0x3a')][_0xf785('0x47')]+'%'};return _0xc236f2;})});}_0x4c95c9=_[_0xf785('0x44')]({},_0x4c95c9,_0x3a64ae[_0xf785('0x48')]);return _0x56d601['getAgents'](_0x4c95c9);}})[_0xf785('0x2c')](function(_0x3b77b4){if(_0x3b77b4){_0xafb953=_0x3b77b4[_0xf785('0x5c')];if(!_0x3a64ae['query'][_0xf785('0x5d')](_0xf785('0x3f'))){_0x4c95c9[_0xf785('0x26')]=qs[_0xf785('0x26')](_0x3a64ae[_0xf785('0x3a')][_0xf785('0x26')]);_0x4c95c9[_0xf785('0x24')]=qs[_0xf785('0x24')](_0x3a64ae[_0xf785('0x3a')][_0xf785('0x24')]);}return _0x56d601[_0xf785('0x8e')](_0x4c95c9);}})[_0xf785('0x2c')](function(_0x432080){if(_0x432080){return _0x432080?{'count':_0xafb953,'rows':_0x432080}:null;}})['then'](respondWithResult(_0x45e10c,null))['catch'](handleError(_0x45e10c,null));};
\ No newline at end of file