Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index d7b2d2a..b107833 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc9cc=['transaction','each','findOrCreate','forEach','userFaxQueue:save','removeTeams','select','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','push','sequelize','QueryTypes','SELECT','every','TeamId','all','union','compact','value','isEmpty','removeAgents','emit','userFaxQueue:remove','addAgents','spread','isArray','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','path','to-csv','lodash','squel','crypto','jsforce','desk.js','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxQueue.socket','register','sendStatus','status','end','json','count','offset','Content-Range','apply','reject','save','update','then','FaxQueues','destroy','error','stack','name','send','index','map','FaxQueue','rawAttributes','fieldName','type','query','keys','intersection','model','attributes','fields','hasOwnProperty','nolimit','limit','order','sort','where','filters','pick','filter','merge','include','findAll','catch','show','params','length','includeAll','options','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','describe','getMembers','UserFaxQueue','FaxQueueId','UserId','agent','faxPause','updatedAt','createdAt','rows','format','SIP','findOne','Team','getTeams','addTeams','ids','User','Agents','voicePause','interface','flatMap'];(function(_0x30595a,_0x2fe77d){var _0x570e62=function(_0xa57766){while(--_0xa57766){_0x30595a['push'](_0x30595a['shift']());}};_0x570e62(++_0x2fe77d);}(_0xc9cc,0xb0));var _0xcc9c=function(_0x424d1d,_0x33893a){_0x424d1d=_0x424d1d-0x0;var _0xc6947f=_0xc9cc[_0x424d1d];return _0xc6947f;};'use strict';var pdf=require(_0xcc9c('0x0'));var emlformat=require(_0xcc9c('0x1'));var rimraf=require(_0xcc9c('0x2'));var zipdir=require(_0xcc9c('0x3'));var jsonpatch=require(_0xcc9c('0x4'));var rp=require(_0xcc9c('0x5'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xcc9c('0x6'));var util=require('util');var path=require(_0xcc9c('0x7'));var sox=require('sox');var csv=require(_0xcc9c('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xcc9c('0x9'));var squel=require(_0xcc9c('0xa'));var crypto=require(_0xcc9c('0xb'));var jsforce=require(_0xcc9c('0xc'));var deskjs=require(_0xcc9c('0xd'));var toCsv=require(_0xcc9c('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xcc9c('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xcc9c('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xcc9c('0x10'));var logger=require(_0xcc9c('0x11'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xcc9c('0x12'));var db=require(_0xcc9c('0x13'))['db'];config[_0xcc9c('0x14')]=_[_0xcc9c('0x15')](config[_0xcc9c('0x14')],{'host':_0xcc9c('0x16'),'port':0x18eb});var socket=require(_0xcc9c('0x17'))(new Redis(config['redis']));require(_0xcc9c('0x18'))[_0xcc9c('0x19')](socket);function respondWithStatusCode(_0x1e6480,_0xabc8d6){_0xabc8d6=_0xabc8d6||0xcc;return function(_0x245a5f){if(_0x245a5f){return _0x1e6480[_0xcc9c('0x1a')](_0xabc8d6);}return _0x1e6480[_0xcc9c('0x1b')](_0xabc8d6)[_0xcc9c('0x1c')]();};}function respondWithResult(_0x5917ba,_0x41da2a){_0x41da2a=_0x41da2a||0xc8;return function(_0x1d0f7b){if(_0x1d0f7b){return _0x5917ba[_0xcc9c('0x1b')](_0x41da2a)[_0xcc9c('0x1d')](_0x1d0f7b);}};}function respondWithFilteredResult(_0x1fe884,_0x2228c6){return function(_0x332582){if(_0x332582){var _0x3977e7=_0x332582[_0xcc9c('0x1e')],_0x564661=_0x2228c6[_0xcc9c('0x1f')],_0x2d0f1c=_0x2228c6[_0xcc9c('0x1f')]+_0x2228c6['limit'],_0x423759;if(_0x2d0f1c>=_0x3977e7){_0x2d0f1c=_0x3977e7;_0x423759=0xc8;}else{_0x423759=0xce;}_0x1fe884[_0xcc9c('0x1b')](_0x423759);return _0x1fe884['set'](_0xcc9c('0x20'),_0x564661+'-'+_0x2d0f1c+'/'+_0x3977e7)[_0xcc9c('0x1d')](_0x332582);}return null;};}function patchUpdates(_0x1a889d){return function(_0xbe0f41){try{jsonpatch[_0xcc9c('0x21')](_0xbe0f41,_0x1a889d,!![]);}catch(_0x46c73e){return BPromise[_0xcc9c('0x22')](_0x46c73e);}return _0xbe0f41[_0xcc9c('0x23')]();};}function saveUpdates(_0x34a940,_0x2655a6){return function(_0x2c5e3d){if(_0x2c5e3d){return _0x2c5e3d[_0xcc9c('0x24')](_0x34a940)[_0xcc9c('0x25')](function(_0x2fd3e3){return _0x2fd3e3;});}return null;};}function removeEntity(_0x4d9031,_0xe116a5){return function(_0x1deb3f){if(_0x1deb3f){return _0x1deb3f['destroy']()[_0xcc9c('0x25')](function(){var _0x13df75=_0x1deb3f['get']({'plain':!![]});var _0x29a392=_0xcc9c('0x26');return db['UserProfileResource'][_0xcc9c('0x27')]({'where':{'type':_0x29a392,'resourceId':_0x13df75['id']}})[_0xcc9c('0x25')](function(){return _0x1deb3f;});})['then'](function(){_0x4d9031[_0xcc9c('0x1b')](0xcc)[_0xcc9c('0x1c')]();});}};}function handleEntityNotFound(_0x5aa33c,_0x15fcce){return function(_0x52af01){if(!_0x52af01){_0x5aa33c['sendStatus'](0x194);}return _0x52af01;};}function handleError(_0x3b1e7b,_0x44d17d){_0x44d17d=_0x44d17d||0x1f4;return function(_0xeea7da){logger[_0xcc9c('0x28')](_0xeea7da[_0xcc9c('0x29')]);if(_0xeea7da['name']){delete _0xeea7da[_0xcc9c('0x2a')];}_0x3b1e7b[_0xcc9c('0x1b')](_0x44d17d)[_0xcc9c('0x2b')](_0xeea7da);};}exports[_0xcc9c('0x2c')]=function(_0x3e4da6,_0x4f8e42){var _0x1f472d={},_0x3e4aeb={},_0x6718e0={'count':0x0,'rows':[]};var _0x49f664=_[_0xcc9c('0x2d')](db[_0xcc9c('0x2e')][_0xcc9c('0x2f')],function(_0x891de2){return{'name':_0x891de2[_0xcc9c('0x30')],'type':_0x891de2[_0xcc9c('0x31')]['key']};});_0x3e4aeb['model']=_[_0xcc9c('0x2d')](_0x49f664,'name');_0x3e4aeb[_0xcc9c('0x32')]=_[_0xcc9c('0x33')](_0x3e4da6[_0xcc9c('0x32')]);_0x3e4aeb['filters']=_[_0xcc9c('0x34')](_0x3e4aeb[_0xcc9c('0x35')],_0x3e4aeb[_0xcc9c('0x32')]);_0x1f472d[_0xcc9c('0x36')]=_[_0xcc9c('0x34')](_0x3e4aeb[_0xcc9c('0x35')],qs[_0xcc9c('0x37')](_0x3e4da6['query'][_0xcc9c('0x37')]));_0x1f472d[_0xcc9c('0x36')]=_0x1f472d[_0xcc9c('0x36')]['length']?_0x1f472d[_0xcc9c('0x36')]:_0x3e4aeb[_0xcc9c('0x35')];if(!_0x3e4da6['query'][_0xcc9c('0x38')](_0xcc9c('0x39'))){_0x1f472d[_0xcc9c('0x3a')]=qs[_0xcc9c('0x3a')](_0x3e4da6[_0xcc9c('0x32')][_0xcc9c('0x3a')]);_0x1f472d[_0xcc9c('0x1f')]=qs['offset'](_0x3e4da6[_0xcc9c('0x32')][_0xcc9c('0x1f')]);}_0x1f472d[_0xcc9c('0x3b')]=qs[_0xcc9c('0x3c')](_0x3e4da6['query'][_0xcc9c('0x3c')]);_0x1f472d[_0xcc9c('0x3d')]=qs[_0xcc9c('0x3e')](_[_0xcc9c('0x3f')](_0x3e4da6[_0xcc9c('0x32')],_0x3e4aeb[_0xcc9c('0x3e')]),_0x49f664);if(_0x3e4da6[_0xcc9c('0x32')][_0xcc9c('0x40')]){_0x1f472d[_0xcc9c('0x3d')]=_['merge'](_0x1f472d['where'],{'$or':_[_0xcc9c('0x2d')](_0x49f664,function(_0xadd585){if(_0xadd585['type']!=='VIRTUAL'){var _0x2d68d0={};_0x2d68d0[_0xadd585[_0xcc9c('0x2a')]]={'$like':'%'+_0x3e4da6[_0xcc9c('0x32')][_0xcc9c('0x40')]+'%'};return _0x2d68d0;}})});}_0x1f472d=_[_0xcc9c('0x41')]({},_0x1f472d,_0x3e4da6['options']);var _0x3d9b35={'where':_0x1f472d[_0xcc9c('0x3d')]};return db[_0xcc9c('0x2e')][_0xcc9c('0x1e')](_0x3d9b35)[_0xcc9c('0x25')](function(_0x590197){_0x6718e0['count']=_0x590197;if(_0x3e4da6[_0xcc9c('0x32')]['includeAll']){_0x1f472d[_0xcc9c('0x42')]=[{'all':!![]}];}return db[_0xcc9c('0x2e')][_0xcc9c('0x43')](_0x1f472d);})['then'](function(_0x5a0f4d){_0x6718e0['rows']=_0x5a0f4d;return _0x6718e0;})['then'](respondWithFilteredResult(_0x4f8e42,_0x1f472d))[_0xcc9c('0x44')](handleError(_0x4f8e42,null));};exports[_0xcc9c('0x45')]=function(_0x5a14fd,_0x2c61ad){var _0x42ecff={'raw':!![],'where':{'id':_0x5a14fd[_0xcc9c('0x46')]['id']}},_0x5f2af0={};_0x5f2af0[_0xcc9c('0x35')]=_[_0xcc9c('0x33')](db[_0xcc9c('0x2e')][_0xcc9c('0x2f')]);_0x5f2af0[_0xcc9c('0x32')]=_[_0xcc9c('0x33')](_0x5a14fd[_0xcc9c('0x32')]);_0x5f2af0[_0xcc9c('0x3e')]=_['intersection'](_0x5f2af0[_0xcc9c('0x35')],_0x5f2af0[_0xcc9c('0x32')]);_0x42ecff[_0xcc9c('0x36')]=_['intersection'](_0x5f2af0[_0xcc9c('0x35')],qs['fields'](_0x5a14fd[_0xcc9c('0x32')][_0xcc9c('0x37')]));_0x42ecff[_0xcc9c('0x36')]=_0x42ecff[_0xcc9c('0x36')][_0xcc9c('0x47')]?_0x42ecff[_0xcc9c('0x36')]:_0x5f2af0[_0xcc9c('0x35')];if(_0x5a14fd[_0xcc9c('0x32')][_0xcc9c('0x48')]){_0x42ecff[_0xcc9c('0x42')]=[{'all':!![]}];}_0x42ecff=_['merge']({},_0x42ecff,_0x5a14fd[_0xcc9c('0x49')]);return db[_0xcc9c('0x2e')]['find'](_0x42ecff)['then'](handleEntityNotFound(_0x2c61ad,null))[_0xcc9c('0x25')](respondWithResult(_0x2c61ad,null))['catch'](handleError(_0x2c61ad,null));};exports[_0xcc9c('0x4a')]=function(_0x493f1e,_0x1be988){return db[_0xcc9c('0x2e')][_0xcc9c('0x4a')](_0x493f1e[_0xcc9c('0x4b')],{})['then'](function(_0x493e75){var _0x4e1925=_0x493f1e[_0xcc9c('0x4c')][_0xcc9c('0x4d')]({'plain':!![]});if(!_0x4e1925)throw new Error(_0xcc9c('0x4e'));if(_0x4e1925[_0xcc9c('0x4f')]===_0xcc9c('0x4c')){var _0x51c041=_0x493e75[_0xcc9c('0x4d')]({'plain':!![]});var _0x415e86=_0xcc9c('0x26');return db[_0xcc9c('0x50')]['find']({'where':{'name':_0x415e86,'userProfileId':_0x4e1925[_0xcc9c('0x51')]},'raw':!![]})[_0xcc9c('0x25')](function(_0x21d13b){if(_0x21d13b&&_0x21d13b[_0xcc9c('0x52')]===0x0){return db[_0xcc9c('0x53')][_0xcc9c('0x4a')]({'name':_0x51c041[_0xcc9c('0x2a')],'resourceId':_0x51c041['id'],'type':_0x21d13b[_0xcc9c('0x2a')],'sectionId':_0x21d13b['id']},{})[_0xcc9c('0x25')](function(){return _0x493e75;});}else{return _0x493e75;}})[_0xcc9c('0x44')](function(_0x239016){logger[_0xcc9c('0x28')](_0xcc9c('0x54'),_0x239016);throw _0x239016;});}return _0x493e75;})[_0xcc9c('0x25')](respondWithResult(_0x1be988,0xc9))[_0xcc9c('0x44')](handleError(_0x1be988,null));};exports['update']=function(_0x172d04,_0x390344){if(_0x172d04['body']['id']){delete _0x172d04[_0xcc9c('0x4b')]['id'];}return db[_0xcc9c('0x2e')][_0xcc9c('0x55')]({'where':{'id':_0x172d04[_0xcc9c('0x46')]['id']}})[_0xcc9c('0x25')](handleEntityNotFound(_0x390344,null))['then'](saveUpdates(_0x172d04[_0xcc9c('0x4b')],null))['then'](respondWithResult(_0x390344,null))[_0xcc9c('0x44')](handleError(_0x390344,null));};exports[_0xcc9c('0x27')]=function(_0x3e6c7a,_0x28e138){return db[_0xcc9c('0x2e')][_0xcc9c('0x55')]({'where':{'id':_0x3e6c7a[_0xcc9c('0x46')]['id']}})[_0xcc9c('0x25')](handleEntityNotFound(_0x28e138,null))[_0xcc9c('0x25')](removeEntity(_0x28e138,null))['catch'](handleError(_0x28e138,null));};exports[_0xcc9c('0x56')]=function(_0xa5c9c9,_0x37f3c8){return db[_0xcc9c('0x2e')][_0xcc9c('0x56')]()[_0xcc9c('0x25')](respondWithResult(_0x37f3c8,null))[_0xcc9c('0x44')](handleError(_0x37f3c8,null));};exports[_0xcc9c('0x57')]=function(_0x30d984,_0x7b53dd,_0x34e6da){var _0x5a8a75={'raw':!![],'where':{}},_0x44b92a={},_0x1b2eb6;return db[_0xcc9c('0x2e')]['findOne']({'where':{'id':_0x30d984[_0xcc9c('0x46')]['id']}})[_0xcc9c('0x25')](handleEntityNotFound(_0x7b53dd,null))[_0xcc9c('0x25')](function(_0x475680){if(_0x475680){_0x1b2eb6=_0x475680[_0xcc9c('0x4d')]({'plain':!![]});_0x44b92a[_0xcc9c('0x35')]=_[_0xcc9c('0x33')](db[_0xcc9c('0x58')][_0xcc9c('0x2f')]);_0x44b92a[_0xcc9c('0x32')]=_[_0xcc9c('0x33')](_0x30d984[_0xcc9c('0x32')]);_0x44b92a[_0xcc9c('0x3e')]=_[_0xcc9c('0x34')](_0x44b92a['model'],_0x44b92a['query']);_0x5a8a75[_0xcc9c('0x36')]=_['intersection'](_0x44b92a[_0xcc9c('0x35')],qs[_0xcc9c('0x37')](_0x30d984[_0xcc9c('0x32')]['fields']));_0x5a8a75[_0xcc9c('0x36')]=_0x5a8a75['attributes'][_0xcc9c('0x47')]?_0x5a8a75[_0xcc9c('0x36')]:_0x44b92a[_0xcc9c('0x35')];if(!_0x30d984['query'][_0xcc9c('0x38')](_0xcc9c('0x39'))){_0x5a8a75[_0xcc9c('0x3a')]=qs[_0xcc9c('0x3a')](_0x30d984[_0xcc9c('0x32')][_0xcc9c('0x3a')]);_0x5a8a75[_0xcc9c('0x1f')]=qs[_0xcc9c('0x1f')](_0x30d984[_0xcc9c('0x32')][_0xcc9c('0x1f')]);}_0x5a8a75[_0xcc9c('0x3b')]=qs[_0xcc9c('0x3c')](_0x30d984[_0xcc9c('0x32')][_0xcc9c('0x3c')]);_0x5a8a75[_0xcc9c('0x3d')]=qs[_0xcc9c('0x3e')](_[_0xcc9c('0x3f')](_0x30d984[_0xcc9c('0x32')],_0x44b92a[_0xcc9c('0x3e')]));_0x5a8a75[_0xcc9c('0x3d')][_0xcc9c('0x59')]=_0x475680['id'];if(_0x30d984[_0xcc9c('0x32')][_0xcc9c('0x40')]){_0x5a8a75[_0xcc9c('0x3d')]=_[_0xcc9c('0x41')](_0x5a8a75[_0xcc9c('0x3d')],{'$or':_['map'](_0x5a8a75['attributes'],function(_0x2298e0){var _0x555e7a={};_0x555e7a[_0x2298e0]={'$like':'%'+_0x30d984[_0xcc9c('0x32')][_0xcc9c('0x40')]+'%'};return _0x555e7a;})});}_0x5a8a75=_[_0xcc9c('0x41')]({},_0x5a8a75,_0x30d984[_0xcc9c('0x49')]);return db[_0xcc9c('0x58')][_0xcc9c('0x43')](_0x5a8a75);}})[_0xcc9c('0x25')](function(_0x3c6665){if(_0x3c6665){return db['User']['findAndCountAll']({'where':{'id':_[_0xcc9c('0x2d')](_0x3c6665,_0xcc9c('0x5a')),'role':_0xcc9c('0x5b')},'attributes':['id',_0xcc9c('0x2a'),_0xcc9c('0x5c'),_0xcc9c('0x5d'),_0xcc9c('0x5e')]});}})['then'](function(_0x183029){if(_0x183029){return{'count':_0x183029[_0xcc9c('0x1e')],'rows':_[_0xcc9c('0x2d')](_0x183029[_0xcc9c('0x5f')],function(_0x56f3db){return{'membername':_0x56f3db['name'],'UserId':_0x56f3db['id'],'queue_name':_0x1b2eb6['name'],'FaxQueueId':_0x1b2eb6['id'],'interface':util[_0xcc9c('0x60')]('%s/%s',_0xcc9c('0x61'),_0x56f3db[_0xcc9c('0x2a')]),'penalty':0x0,'paused':_0x56f3db['faxPause'],'createdAt':_0x56f3db[_0xcc9c('0x5e')],'updatedAt':_0x56f3db[_0xcc9c('0x5d')]};})};}else{return{'count':0x0,'rows':[]};}})[_0xcc9c('0x25')](respondWithFilteredResult(_0x7b53dd,_0x5a8a75))[_0xcc9c('0x44')](handleError(_0x7b53dd,null));};exports['getTeams']=function(_0x3cf519,_0x1a9358,_0x2ce6d5){var _0x5b0a9e={};var _0x1ef03a={};var _0x17ffa3;var _0x24ada3;return db[_0xcc9c('0x2e')][_0xcc9c('0x62')]({'where':{'id':_0x3cf519['params']['id']}})['then'](handleEntityNotFound(_0x1a9358,null))[_0xcc9c('0x25')](function(_0x3d1ee6){if(_0x3d1ee6){_0x17ffa3=_0x3d1ee6;_0x1ef03a['model']=_[_0xcc9c('0x33')](db[_0xcc9c('0x63')][_0xcc9c('0x2f')]);_0x1ef03a[_0xcc9c('0x32')]=_[_0xcc9c('0x33')](_0x3cf519[_0xcc9c('0x32')]);_0x1ef03a[_0xcc9c('0x3e')]=_[_0xcc9c('0x34')](_0x1ef03a[_0xcc9c('0x35')],_0x1ef03a[_0xcc9c('0x32')]);_0x5b0a9e[_0xcc9c('0x36')]=_[_0xcc9c('0x34')](_0x1ef03a[_0xcc9c('0x35')],qs['fields'](_0x3cf519[_0xcc9c('0x32')][_0xcc9c('0x37')]));_0x5b0a9e[_0xcc9c('0x36')]=_0x5b0a9e[_0xcc9c('0x36')][_0xcc9c('0x47')]?_0x5b0a9e['attributes']:_0x1ef03a['model'];_0x5b0a9e[_0xcc9c('0x3b')]=qs['sort'](_0x3cf519[_0xcc9c('0x32')][_0xcc9c('0x3c')]);_0x5b0a9e[_0xcc9c('0x3d')]=qs[_0xcc9c('0x3e')](_[_0xcc9c('0x3f')](_0x3cf519['query'],_0x1ef03a[_0xcc9c('0x3e')]));if(_0x3cf519[_0xcc9c('0x32')]['filter']){_0x5b0a9e[_0xcc9c('0x3d')]=_[_0xcc9c('0x41')](_0x5b0a9e[_0xcc9c('0x3d')],{'$or':_[_0xcc9c('0x2d')](_0x5b0a9e['attributes'],function(_0x4f026c){var _0x12fc15={};_0x12fc15[_0x4f026c]={'$like':'%'+_0x3cf519[_0xcc9c('0x32')][_0xcc9c('0x40')]+'%'};return _0x12fc15;})});}_0x5b0a9e=_[_0xcc9c('0x41')]({},_0x5b0a9e,_0x3cf519[_0xcc9c('0x49')]);return _0x17ffa3[_0xcc9c('0x64')](_0x5b0a9e);}})['then'](function(_0x3cc1b7){if(_0x3cc1b7){_0x24ada3=_0x3cc1b7[_0xcc9c('0x47')];if(!_0x3cf519[_0xcc9c('0x32')][_0xcc9c('0x38')]('nolimit')){_0x5b0a9e[_0xcc9c('0x3a')]=qs[_0xcc9c('0x3a')](_0x3cf519[_0xcc9c('0x32')][_0xcc9c('0x3a')]);_0x5b0a9e[_0xcc9c('0x1f')]=qs[_0xcc9c('0x1f')](_0x3cf519[_0xcc9c('0x32')]['offset']);}return _0x17ffa3['getTeams'](_0x5b0a9e);}})[_0xcc9c('0x25')](function(_0x325e33){if(_0x325e33){return _0x325e33?{'count':_0x24ada3,'rows':_0x325e33}:null;}})['then'](respondWithResult(_0x1a9358,null))[_0xcc9c('0x44')](handleError(_0x1a9358,null));};exports[_0xcc9c('0x65')]=function(_0x23e8bf,_0x5210c3,_0x40336f){var _0x10d2b4=_0x23e8bf[_0xcc9c('0x4b')][_0xcc9c('0x66')];return db[_0xcc9c('0x63')][_0xcc9c('0x43')]({'where':{'id':_0x10d2b4},'attributes':['id'],'include':[{'model':db[_0xcc9c('0x67')],'as':_0xcc9c('0x68'),'attributes':['id','name','online',_0xcc9c('0x69'),_0xcc9c('0x6a')],'raw':!![]}]})[_0xcc9c('0x25')](function(_0x5d7b2d){if(_0x5d7b2d){var _0xa79d5c=_[_0xcc9c('0x6b')](_0x5d7b2d,function(_0x1434a1){var _0x231d65=_0x1434a1[_0xcc9c('0x4d')]({'plain':!![]});return _0x231d65['Agents'];});return db[_0xcc9c('0x2e')]['find']({'where':{'id':_0x23e8bf[_0xcc9c('0x46')]['id']}})[_0xcc9c('0x25')](function(_0x29764e){return db['sequelize'][_0xcc9c('0x6c')](function(_0x26ddcb){return _0x29764e[_0xcc9c('0x65')](_0x10d2b4,{'transaction':_0x26ddcb})[_0xcc9c('0x25')](function(){return BPromise[_0xcc9c('0x6d')](_0xa79d5c,function(_0x27db56){return db[_0xcc9c('0x58')][_0xcc9c('0x6e')]({'where':{'UserId':_0x27db56['id'],'FaxQueueId':_0x23e8bf['params']['id']},'transaction':_0x26ddcb});});})['then'](function(){_0xa79d5c[_0xcc9c('0x6f')](function(_0x56c180){socket['emit'](_0xcc9c('0x70'),{'UserId':_0x56c180['id'],'FaxQueueId':_0x29764e['id']});});});});});}})[_0xcc9c('0x25')](respondWithStatusCode(_0x5210c3,null))['catch'](handleError(_0x5210c3,null));};exports[_0xcc9c('0x71')]=function(_0x156b7a,_0x1df49b,_0x99a430){return db['Team']['findAll']({'where':{'id':_0x156b7a[_0xcc9c('0x32')][_0xcc9c('0x66')]},'attributes':['id'],'include':[{'model':db[_0xcc9c('0x67')],'as':_0xcc9c('0x68'),'attributes':['id'],'raw':!![]}]})[_0xcc9c('0x25')](handleEntityNotFound(_0x1df49b,null))[_0xcc9c('0x25')](function(_0x1ef934){var _0x308ec9=_[_0xcc9c('0x2d')](_0x1ef934,'id');var _0x3f2e97=[];var _0x55f435=[];var _0x24c019=squel[_0xcc9c('0x72')]();_0x24c019['field'](_0xcc9c('0x73'))[_0xcc9c('0x74')](_0xcc9c('0x75'),'tq')[_0xcc9c('0x76')](_0xcc9c('0x77'),'ut',_0xcc9c('0x78'))[_0xcc9c('0x3d')](_0xcc9c('0x79'),_0x156b7a[_0xcc9c('0x46')]['id']);for(var _0x12f7db=0x0;_0x12f7db<_0x1ef934[_0xcc9c('0x47')];_0x12f7db+=0x1){let _0xf2d8da=_0x1ef934[_0x12f7db];for(var _0x14cfc8=0x0;_0x14cfc8<_0xf2d8da[_0xcc9c('0x68')][_0xcc9c('0x47')];_0x14cfc8+=0x1){let _0x559630=_0xf2d8da[_0xcc9c('0x68')][_0x14cfc8];var _0x553f04=_0x24c019[_0xcc9c('0x7a')]();_0x553f04[_0xcc9c('0x3d')](_0xcc9c('0x7b'),_0x559630['id']);_0x55f435[_0xcc9c('0x7c')](db[_0xcc9c('0x7d')][_0xcc9c('0x32')](_0x553f04['toString'](),{'type':db[_0xcc9c('0x7d')][_0xcc9c('0x7e')][_0xcc9c('0x7f')]})[_0xcc9c('0x25')](function(_0x40b2b7){if(_0x40b2b7['length']===0x1){return _0x559630['id'];}else{var _0x44bfe8=_[_0xcc9c('0x80')](_[_0xcc9c('0x2d')](_0x40b2b7,_0xcc9c('0x81')),function(_0x3f5808){return _['includes'](_0x308ec9,_0x3f5808);});if(_0x44bfe8){return _0x559630['id'];}}}));}}return BPromise[_0xcc9c('0x82')](_0x55f435)['then'](function(_0x205f19){_0x3f2e97=_(_0x3f2e97)[_0xcc9c('0x83')](_0x205f19)[_0xcc9c('0x84')]()[_0xcc9c('0x85')]();return db[_0xcc9c('0x2e')][_0xcc9c('0x55')]({'where':{'id':_0x156b7a['params']['id']}})[_0xcc9c('0x25')](function(_0x4df004){return db[_0xcc9c('0x7d')]['transaction'](function(_0x3113da){return _0x4df004[_0xcc9c('0x71')](_0x156b7a[_0xcc9c('0x32')][_0xcc9c('0x66')],{'transaction':_0x3113da})[_0xcc9c('0x25')](function(){if(!_[_0xcc9c('0x86')](_0x3f2e97)){return _0x4df004[_0xcc9c('0x87')](_0x3f2e97,{'transaction':_0x3113da});}})[_0xcc9c('0x25')](function(){_0x3f2e97[_0xcc9c('0x6f')](function(_0x520c91){socket[_0xcc9c('0x88')](_0xcc9c('0x89'),{'UserId':_0x520c91,'FaxQueueId':_0x4df004['id']});});});});});});})[_0xcc9c('0x25')](respondWithStatusCode(_0x1df49b,null))['catch'](handleError(_0x1df49b,null));};exports[_0xcc9c('0x8a')]=function(_0x159eae,_0x4d81ae,_0x32a998){return db[_0xcc9c('0x2e')][_0xcc9c('0x55')]({'where':{'id':_0x159eae[_0xcc9c('0x46')]['id']}})[_0xcc9c('0x25')](handleEntityNotFound(_0x4d81ae,null))[_0xcc9c('0x25')](function(_0xe89c1f){if(_0xe89c1f){return _0xe89c1f[_0xcc9c('0x8a')](_0x159eae[_0xcc9c('0x4b')][_0xcc9c('0x66')],_['omit'](_0x159eae[_0xcc9c('0x4b')],['ids','id'])||{})[_0xcc9c('0x8b')](function(_0x5f5060){for(var _0x2e626d=0x0;_0x2e626d<_0x159eae[_0xcc9c('0x4b')][_0xcc9c('0x66')][_0xcc9c('0x47')];_0x2e626d+=0x1){socket[_0xcc9c('0x88')]('userFaxQueue:save',{'UserId':_0x159eae['body'][_0xcc9c('0x66')][_0x2e626d],'FaxQueueId':_0x159eae[_0xcc9c('0x46')]['id']});}return _0x5f5060;});}})[_0xcc9c('0x25')](respondWithResult(_0x4d81ae,null))[_0xcc9c('0x44')](handleError(_0x4d81ae,null));};exports['removeAgents']=function(_0x476793,_0x2c42be,_0x1d9dcb){return db[_0xcc9c('0x2e')][_0xcc9c('0x55')]({'where':{'id':_0x476793[_0xcc9c('0x46')]['id']}})['then'](handleEntityNotFound(_0x2c42be,null))[_0xcc9c('0x25')](function(_0x329598){if(_0x329598){return _0x329598[_0xcc9c('0x87')](_0x476793['query'][_0xcc9c('0x66')])[_0xcc9c('0x25')](function(){if(_[_0xcc9c('0x8c')](_0x476793[_0xcc9c('0x32')][_0xcc9c('0x66')])){for(var _0x4b4510=0x0;_0x4b4510<_0x476793[_0xcc9c('0x32')][_0xcc9c('0x66')]['length'];_0x4b4510+=0x1){socket[_0xcc9c('0x88')](_0xcc9c('0x89'),{'UserId':Number(_0x476793[_0xcc9c('0x32')][_0xcc9c('0x66')][_0x4b4510]),'FaxQueueId':Number(_0x476793[_0xcc9c('0x46')]['id'])});}}else{socket[_0xcc9c('0x88')](_0xcc9c('0x89'),{'UserId':Number(_0x476793[_0xcc9c('0x32')][_0xcc9c('0x66')]),'FaxQueueId':Number(_0x476793['params']['id'])});}});}})[_0xcc9c('0x25')](respondWithStatusCode(_0x2c42be,null))[_0xcc9c('0x44')](handleError(_0x2c42be,null));};exports['getAgents']=function(_0x23fd93,_0x55989a,_0x3898c9){var _0x3668c0={};var _0xaf0c80={};var _0x1b1ab1;var _0x28eaff;return db[_0xcc9c('0x2e')][_0xcc9c('0x62')]({'where':{'id':_0x23fd93[_0xcc9c('0x46')]['id']}})[_0xcc9c('0x25')](handleEntityNotFound(_0x55989a,null))[_0xcc9c('0x25')](function(_0x1180aa){if(_0x1180aa){_0x1b1ab1=_0x1180aa;_0xaf0c80[_0xcc9c('0x35')]=_['keys'](db[_0xcc9c('0x67')][_0xcc9c('0x2f')]);_0xaf0c80[_0xcc9c('0x32')]=_[_0xcc9c('0x33')](_0x23fd93['query']);_0xaf0c80[_0xcc9c('0x3e')]=_[_0xcc9c('0x34')](_0xaf0c80[_0xcc9c('0x35')],_0xaf0c80[_0xcc9c('0x32')]);_0x3668c0[_0xcc9c('0x36')]=_[_0xcc9c('0x34')](_0xaf0c80[_0xcc9c('0x35')],qs['fields'](_0x23fd93[_0xcc9c('0x32')][_0xcc9c('0x37')]));_0x3668c0[_0xcc9c('0x36')]=_0x3668c0['attributes'][_0xcc9c('0x47')]?_0x3668c0[_0xcc9c('0x36')]:_0xaf0c80[_0xcc9c('0x35')];_0x3668c0[_0xcc9c('0x3b')]=qs[_0xcc9c('0x3c')](_0x23fd93['query'][_0xcc9c('0x3c')]);_0x3668c0[_0xcc9c('0x3d')]=qs['filters'](_['pick'](_0x23fd93[_0xcc9c('0x32')],_0xaf0c80[_0xcc9c('0x3e')]));if(_0x23fd93[_0xcc9c('0x32')][_0xcc9c('0x40')]){_0x3668c0[_0xcc9c('0x3d')]=_[_0xcc9c('0x41')](_0x3668c0[_0xcc9c('0x3d')],{'$or':_['map'](_0x3668c0[_0xcc9c('0x36')],function(_0x1874bc){var _0x5751eb={};_0x5751eb[_0x1874bc]={'$like':'%'+_0x23fd93[_0xcc9c('0x32')][_0xcc9c('0x40')]+'%'};return _0x5751eb;})});}_0x3668c0=_[_0xcc9c('0x41')]({},_0x3668c0,_0x23fd93[_0xcc9c('0x49')]);return _0x1b1ab1[_0xcc9c('0x8d')](_0x3668c0);}})[_0xcc9c('0x25')](function(_0x308236){if(_0x308236){_0x28eaff=_0x308236[_0xcc9c('0x47')];if(!_0x23fd93[_0xcc9c('0x32')]['hasOwnProperty']('nolimit')){_0x3668c0[_0xcc9c('0x3a')]=qs[_0xcc9c('0x3a')](_0x23fd93['query']['limit']);_0x3668c0['offset']=qs[_0xcc9c('0x1f')](_0x23fd93[_0xcc9c('0x32')][_0xcc9c('0x1f')]);}return _0x1b1ab1['getAgents'](_0x3668c0);}})['then'](function(_0x112698){if(_0x112698){return _0x112698?{'count':_0x28eaff,'rows':_0x112698}:null;}})['then'](respondWithResult(_0x55989a,null))[_0xcc9c('0x44')](handleError(_0x55989a,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