Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index b107833..8ba6959 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0x70d5=['crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','./faxQueue.socket','register','sendStatus','end','status','json','offset','limit','count','set','reject','save','then','destroy','error','stack','name','send','index','map','FaxQueue','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','pick','where','merge','options','includeAll','rows','catch','params','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','FaxQueues','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','getMembers','UserFaxQueue','sort','FaxQueueId','filter','findAll','User','findAndCountAll','UserId','faxPause','createdAt','format','%s/%s','SIP','getTeams','findOne','addTeams','ids','Team','Agents','online','interface','flatMap','sequelize','transaction','each','findOrCreate','forEach','emit','userFaxQueue:save','removeTeams','select','field','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','clone','ut.UserId\x20=\x20?','push','toString','QueryTypes','SELECT','every','TeamId','includes','all','compact','value','userFaxQueue:remove','addAgents','omit','spread','removeAgents','isArray','getAgents','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','lodash'];(function(_0x2e5e9f,_0x56933f){var _0x45036b=function(_0x9a4c69){while(--_0x9a4c69){_0x2e5e9f['push'](_0x2e5e9f['shift']());}};_0x45036b(++_0x56933f);}(_0x70d5,0x86));var _0x570d=function(_0x23d274,_0x7e1ebe){_0x23d274=_0x23d274-0x0;var _0x2b0f72=_0x70d5[_0x23d274];return _0x2b0f72;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x570d('0x0'));var zipdir=require(_0x570d('0x1'));var jsonpatch=require(_0x570d('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x570d('0x3'));var Mustache=require('mustache');var util=require(_0x570d('0x4'));var path=require(_0x570d('0x5'));var sox=require(_0x570d('0x6'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x570d('0x7'));var squel=require('squel');var crypto=require(_0x570d('0x8'));var jsforce=require(_0x570d('0x9'));var deskjs=require(_0x570d('0xa'));var toCsv=require(_0x570d('0xb'));var querystring=require(_0x570d('0xc'));var Papa=require(_0x570d('0xd'));var Redis=require('ioredis');var authService=require(_0x570d('0xe'));var qs=require(_0x570d('0xf'));var as=require(_0x570d('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x570d('0x11'))(_0x570d('0x12'));var utils=require(_0x570d('0x13'));var config=require(_0x570d('0x14'));var licenseUtil=require(_0x570d('0x15'));var db=require(_0x570d('0x16'))['db'];config['redis']=_[_0x570d('0x17')](config[_0x570d('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0x570d('0x19'))(new Redis(config[_0x570d('0x18')]));require(_0x570d('0x1a'))[_0x570d('0x1b')](socket);function respondWithStatusCode(_0x2ee1a5,_0x373f16){_0x373f16=_0x373f16||0xcc;return function(_0x259cec){if(_0x259cec){return _0x2ee1a5[_0x570d('0x1c')](_0x373f16);}return _0x2ee1a5['status'](_0x373f16)[_0x570d('0x1d')]();};}function respondWithResult(_0x3f2f51,_0x194605){_0x194605=_0x194605||0xc8;return function(_0x4c2706){if(_0x4c2706){return _0x3f2f51[_0x570d('0x1e')](_0x194605)[_0x570d('0x1f')](_0x4c2706);}};}function respondWithFilteredResult(_0x3717b6,_0x582bd0){return function(_0xbdbc){if(_0xbdbc){var _0x4851e4=typeof _0x582bd0[_0x570d('0x20')]==='undefined'&&typeof _0x582bd0[_0x570d('0x21')]==='undefined';var _0x2d786d=_0xbdbc[_0x570d('0x22')];var _0x1a1c71=_0x4851e4?0x0:_0x582bd0[_0x570d('0x20')];var _0x30f6c0=_0x4851e4?_0xbdbc['count']:_0x582bd0['offset']+_0x582bd0[_0x570d('0x21')];var _0x1c10d6;if(_0x30f6c0>=_0x2d786d){_0x30f6c0=_0x2d786d;_0x1c10d6=0xc8;}else{_0x1c10d6=0xce;}_0x3717b6[_0x570d('0x1e')](_0x1c10d6);return _0x3717b6[_0x570d('0x23')]('Content-Range',_0x1a1c71+'-'+_0x30f6c0+'/'+_0x2d786d)[_0x570d('0x1f')](_0xbdbc);}return null;};}function patchUpdates(_0x4b6cd2){return function(_0x1f1e32){try{jsonpatch['apply'](_0x1f1e32,_0x4b6cd2,!![]);}catch(_0xf9e758){return BPromise[_0x570d('0x24')](_0xf9e758);}return _0x1f1e32[_0x570d('0x25')]();};}function saveUpdates(_0x5703c3,_0x3c902d){return function(_0x2c4341){if(_0x2c4341){return _0x2c4341['update'](_0x5703c3)[_0x570d('0x26')](function(_0x357bef){return _0x357bef;});}return null;};}function removeEntity(_0x4bba41,_0x3613df){return function(_0x375594){if(_0x375594){return _0x375594[_0x570d('0x27')]()[_0x570d('0x26')](function(){var _0x47ecd2=_0x375594['get']({'plain':!![]});var _0x40a644='FaxQueues';return db['UserProfileResource'][_0x570d('0x27')]({'where':{'type':_0x40a644,'resourceId':_0x47ecd2['id']}})['then'](function(){return _0x375594;});})[_0x570d('0x26')](function(){_0x4bba41[_0x570d('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x84fdfe,_0x5e1af9){return function(_0x5db460){if(!_0x5db460){_0x84fdfe['sendStatus'](0x194);}return _0x5db460;};}function handleError(_0x57109b,_0x2b4157){_0x2b4157=_0x2b4157||0x1f4;return function(_0x5d4f78){logger[_0x570d('0x28')](_0x5d4f78[_0x570d('0x29')]);if(_0x5d4f78[_0x570d('0x2a')]){delete _0x5d4f78[_0x570d('0x2a')];}_0x57109b[_0x570d('0x1e')](_0x2b4157)[_0x570d('0x2b')](_0x5d4f78);};}exports[_0x570d('0x2c')]=function(_0x331518,_0x264b0b){var _0x38e23e={},_0x4112c7={},_0x494f17={'count':0x0,'rows':[]};var _0x166da0=_[_0x570d('0x2d')](db[_0x570d('0x2e')][_0x570d('0x2f')],function(_0x58352e){return{'name':_0x58352e[_0x570d('0x30')],'type':_0x58352e[_0x570d('0x31')][_0x570d('0x32')]};});_0x4112c7[_0x570d('0x33')]=_[_0x570d('0x2d')](_0x166da0,_0x570d('0x2a'));_0x4112c7[_0x570d('0x34')]=_[_0x570d('0x35')](_0x331518[_0x570d('0x34')]);_0x4112c7[_0x570d('0x36')]=_[_0x570d('0x37')](_0x4112c7[_0x570d('0x33')],_0x4112c7[_0x570d('0x34')]);_0x38e23e[_0x570d('0x38')]=_[_0x570d('0x37')](_0x4112c7[_0x570d('0x33')],qs['fields'](_0x331518[_0x570d('0x34')][_0x570d('0x39')]));_0x38e23e[_0x570d('0x38')]=_0x38e23e[_0x570d('0x38')][_0x570d('0x3a')]?_0x38e23e[_0x570d('0x38')]:_0x4112c7[_0x570d('0x33')];if(!_0x331518['query'][_0x570d('0x3b')](_0x570d('0x3c'))){_0x38e23e[_0x570d('0x21')]=qs[_0x570d('0x21')](_0x331518[_0x570d('0x34')][_0x570d('0x21')]);_0x38e23e[_0x570d('0x20')]=qs[_0x570d('0x20')](_0x331518[_0x570d('0x34')]['offset']);}_0x38e23e[_0x570d('0x3d')]=qs['sort'](_0x331518['query']['sort']);_0x38e23e['where']=qs[_0x570d('0x36')](_[_0x570d('0x3e')](_0x331518[_0x570d('0x34')],_0x4112c7['filters']),_0x166da0);if(_0x331518[_0x570d('0x34')]['filter']){_0x38e23e[_0x570d('0x3f')]=_['merge'](_0x38e23e[_0x570d('0x3f')],{'$or':_[_0x570d('0x2d')](_0x166da0,function(_0x47774e){if(_0x47774e[_0x570d('0x31')]!=='VIRTUAL'){var _0x2e580f={};_0x2e580f[_0x47774e[_0x570d('0x2a')]]={'$like':'%'+_0x331518[_0x570d('0x34')]['filter']+'%'};return _0x2e580f;}})});}_0x38e23e=_[_0x570d('0x40')]({},_0x38e23e,_0x331518[_0x570d('0x41')]);var _0x1df74a={'where':_0x38e23e[_0x570d('0x3f')]};return db['FaxQueue'][_0x570d('0x22')](_0x1df74a)[_0x570d('0x26')](function(_0x15c0d1){_0x494f17['count']=_0x15c0d1;if(_0x331518[_0x570d('0x34')][_0x570d('0x42')]){_0x38e23e['include']=[{'all':!![]}];}return db[_0x570d('0x2e')]['findAll'](_0x38e23e);})[_0x570d('0x26')](function(_0xfbd756){_0x494f17[_0x570d('0x43')]=_0xfbd756;return _0x494f17;})[_0x570d('0x26')](respondWithFilteredResult(_0x264b0b,_0x38e23e))[_0x570d('0x44')](handleError(_0x264b0b,null));};exports['show']=function(_0x42f03d,_0x493c0d){var _0x22f52f={'raw':!![],'where':{'id':_0x42f03d[_0x570d('0x45')]['id']}},_0x296a1f={};_0x296a1f[_0x570d('0x33')]=_[_0x570d('0x35')](db[_0x570d('0x2e')]['rawAttributes']);_0x296a1f[_0x570d('0x34')]=_[_0x570d('0x35')](_0x42f03d['query']);_0x296a1f[_0x570d('0x36')]=_['intersection'](_0x296a1f[_0x570d('0x33')],_0x296a1f[_0x570d('0x34')]);_0x22f52f[_0x570d('0x38')]=_[_0x570d('0x37')](_0x296a1f[_0x570d('0x33')],qs[_0x570d('0x39')](_0x42f03d[_0x570d('0x34')]['fields']));_0x22f52f[_0x570d('0x38')]=_0x22f52f[_0x570d('0x38')][_0x570d('0x3a')]?_0x22f52f[_0x570d('0x38')]:_0x296a1f[_0x570d('0x33')];if(_0x42f03d['query'][_0x570d('0x42')]){_0x22f52f['include']=[{'all':!![]}];}_0x22f52f=_[_0x570d('0x40')]({},_0x22f52f,_0x42f03d[_0x570d('0x41')]);return db[_0x570d('0x2e')][_0x570d('0x46')](_0x22f52f)[_0x570d('0x26')](handleEntityNotFound(_0x493c0d,null))['then'](respondWithResult(_0x493c0d,null))[_0x570d('0x44')](handleError(_0x493c0d,null));};exports[_0x570d('0x47')]=function(_0x6c55cd,_0x509cbe){return db[_0x570d('0x2e')][_0x570d('0x47')](_0x6c55cd[_0x570d('0x48')],{})[_0x570d('0x26')](function(_0x14202a){var _0x54e490=_0x6c55cd[_0x570d('0x49')]['get']({'plain':!![]});if(!_0x54e490)throw new Error(_0x570d('0x4a'));if(_0x54e490[_0x570d('0x4b')]==='user'){var _0x5ae6b2=_0x14202a[_0x570d('0x4c')]({'plain':!![]});var _0x3fb546=_0x570d('0x4d');return db[_0x570d('0x4e')]['find']({'where':{'name':_0x3fb546,'userProfileId':_0x54e490['userProfileId']},'raw':!![]})['then'](function(_0x3c3c99){if(_0x3c3c99&&_0x3c3c99[_0x570d('0x4f')]===0x0){return db[_0x570d('0x50')][_0x570d('0x47')]({'name':_0x5ae6b2[_0x570d('0x2a')],'resourceId':_0x5ae6b2['id'],'type':_0x3c3c99[_0x570d('0x2a')],'sectionId':_0x3c3c99['id']},{})[_0x570d('0x26')](function(){return _0x14202a;});}else{return _0x14202a;}})[_0x570d('0x44')](function(_0x218464){logger[_0x570d('0x28')](_0x570d('0x51'),_0x218464);throw _0x218464;});}return _0x14202a;})[_0x570d('0x26')](respondWithResult(_0x509cbe,0xc9))[_0x570d('0x44')](handleError(_0x509cbe,null));};exports[_0x570d('0x52')]=function(_0x550fb0,_0x58fa8b){if(_0x550fb0[_0x570d('0x48')]['id']){delete _0x550fb0[_0x570d('0x48')]['id'];}return db['FaxQueue']['find']({'where':{'id':_0x550fb0['params']['id']}})['then'](handleEntityNotFound(_0x58fa8b,null))[_0x570d('0x26')](saveUpdates(_0x550fb0[_0x570d('0x48')],null))[_0x570d('0x26')](respondWithResult(_0x58fa8b,null))['catch'](handleError(_0x58fa8b,null));};exports[_0x570d('0x27')]=function(_0x218f58,_0x3a0abd){return db['FaxQueue']['find']({'where':{'id':_0x218f58[_0x570d('0x45')]['id']}})[_0x570d('0x26')](handleEntityNotFound(_0x3a0abd,null))['then'](removeEntity(_0x3a0abd,null))[_0x570d('0x44')](handleError(_0x3a0abd,null));};exports[_0x570d('0x53')]=function(_0x1e7988,_0x5511b8){return db[_0x570d('0x2e')][_0x570d('0x53')]()['then'](respondWithResult(_0x5511b8,null))[_0x570d('0x44')](handleError(_0x5511b8,null));};exports[_0x570d('0x54')]=function(_0x5d6dbc,_0xe9a238,_0x10a7b6){var _0x2c40bc={'raw':!![],'where':{}},_0x588faf={},_0x42a569;return db[_0x570d('0x2e')]['findOne']({'where':{'id':_0x5d6dbc[_0x570d('0x45')]['id']}})['then'](handleEntityNotFound(_0xe9a238,null))[_0x570d('0x26')](function(_0x431775){if(_0x431775){_0x42a569=_0x431775[_0x570d('0x4c')]({'plain':!![]});_0x588faf['model']=_[_0x570d('0x35')](db[_0x570d('0x55')][_0x570d('0x2f')]);_0x588faf[_0x570d('0x34')]=_[_0x570d('0x35')](_0x5d6dbc[_0x570d('0x34')]);_0x588faf[_0x570d('0x36')]=_[_0x570d('0x37')](_0x588faf[_0x570d('0x33')],_0x588faf[_0x570d('0x34')]);_0x2c40bc['attributes']=_[_0x570d('0x37')](_0x588faf[_0x570d('0x33')],qs[_0x570d('0x39')](_0x5d6dbc['query']['fields']));_0x2c40bc['attributes']=_0x2c40bc[_0x570d('0x38')][_0x570d('0x3a')]?_0x2c40bc[_0x570d('0x38')]:_0x588faf[_0x570d('0x33')];if(!_0x5d6dbc[_0x570d('0x34')][_0x570d('0x3b')]('nolimit')){_0x2c40bc[_0x570d('0x21')]=qs[_0x570d('0x21')](_0x5d6dbc[_0x570d('0x34')][_0x570d('0x21')]);_0x2c40bc[_0x570d('0x20')]=qs[_0x570d('0x20')](_0x5d6dbc[_0x570d('0x34')][_0x570d('0x20')]);}_0x2c40bc['order']=qs[_0x570d('0x56')](_0x5d6dbc[_0x570d('0x34')][_0x570d('0x56')]);_0x2c40bc[_0x570d('0x3f')]=qs[_0x570d('0x36')](_[_0x570d('0x3e')](_0x5d6dbc[_0x570d('0x34')],_0x588faf['filters']));_0x2c40bc[_0x570d('0x3f')][_0x570d('0x57')]=_0x431775['id'];if(_0x5d6dbc[_0x570d('0x34')][_0x570d('0x58')]){_0x2c40bc[_0x570d('0x3f')]=_[_0x570d('0x40')](_0x2c40bc[_0x570d('0x3f')],{'$or':_['map'](_0x2c40bc[_0x570d('0x38')],function(_0x5e6b0c){var _0x449490={};_0x449490[_0x5e6b0c]={'$like':'%'+_0x5d6dbc[_0x570d('0x34')][_0x570d('0x58')]+'%'};return _0x449490;})});}_0x2c40bc=_[_0x570d('0x40')]({},_0x2c40bc,_0x5d6dbc[_0x570d('0x41')]);return db[_0x570d('0x55')][_0x570d('0x59')](_0x2c40bc);}})[_0x570d('0x26')](function(_0x2883f2){if(_0x2883f2){return db[_0x570d('0x5a')][_0x570d('0x5b')]({'where':{'id':_[_0x570d('0x2d')](_0x2883f2,_0x570d('0x5c')),'role':'agent'},'attributes':['id','name',_0x570d('0x5d'),'updatedAt',_0x570d('0x5e')]});}})[_0x570d('0x26')](function(_0x336fd0){if(_0x336fd0){return{'count':_0x336fd0[_0x570d('0x22')],'rows':_['map'](_0x336fd0['rows'],function(_0x5480f4){return{'membername':_0x5480f4[_0x570d('0x2a')],'UserId':_0x5480f4['id'],'queue_name':_0x42a569[_0x570d('0x2a')],'FaxQueueId':_0x42a569['id'],'interface':util[_0x570d('0x5f')](_0x570d('0x60'),_0x570d('0x61'),_0x5480f4[_0x570d('0x2a')]),'penalty':0x0,'paused':_0x5480f4[_0x570d('0x5d')],'createdAt':_0x5480f4[_0x570d('0x5e')],'updatedAt':_0x5480f4['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0xe9a238,_0x2c40bc))['catch'](handleError(_0xe9a238,null));};exports[_0x570d('0x62')]=function(_0x4a191e,_0x1cad42,_0x25b577){var _0x34ee65={};var _0xe5b08={};var _0x361251;var _0x497788;return db['FaxQueue'][_0x570d('0x63')]({'where':{'id':_0x4a191e[_0x570d('0x45')]['id']}})[_0x570d('0x26')](handleEntityNotFound(_0x1cad42,null))['then'](function(_0x22c247){if(_0x22c247){_0x361251=_0x22c247;_0xe5b08[_0x570d('0x33')]=_[_0x570d('0x35')](db['Team']['rawAttributes']);_0xe5b08['query']=_[_0x570d('0x35')](_0x4a191e[_0x570d('0x34')]);_0xe5b08[_0x570d('0x36')]=_[_0x570d('0x37')](_0xe5b08['model'],_0xe5b08[_0x570d('0x34')]);_0x34ee65['attributes']=_[_0x570d('0x37')](_0xe5b08[_0x570d('0x33')],qs['fields'](_0x4a191e[_0x570d('0x34')][_0x570d('0x39')]));_0x34ee65['attributes']=_0x34ee65['attributes'][_0x570d('0x3a')]?_0x34ee65['attributes']:_0xe5b08[_0x570d('0x33')];_0x34ee65[_0x570d('0x3d')]=qs[_0x570d('0x56')](_0x4a191e[_0x570d('0x34')]['sort']);_0x34ee65[_0x570d('0x3f')]=qs[_0x570d('0x36')](_['pick'](_0x4a191e[_0x570d('0x34')],_0xe5b08[_0x570d('0x36')]));if(_0x4a191e[_0x570d('0x34')][_0x570d('0x58')]){_0x34ee65['where']=_['merge'](_0x34ee65[_0x570d('0x3f')],{'$or':_[_0x570d('0x2d')](_0x34ee65[_0x570d('0x38')],function(_0x3afeba){var _0x1fa653={};_0x1fa653[_0x3afeba]={'$like':'%'+_0x4a191e[_0x570d('0x34')]['filter']+'%'};return _0x1fa653;})});}_0x34ee65=_[_0x570d('0x40')]({},_0x34ee65,_0x4a191e[_0x570d('0x41')]);return _0x361251[_0x570d('0x62')](_0x34ee65);}})[_0x570d('0x26')](function(_0xa7b362){if(_0xa7b362){_0x497788=_0xa7b362['length'];if(!_0x4a191e[_0x570d('0x34')][_0x570d('0x3b')]('nolimit')){_0x34ee65['limit']=qs[_0x570d('0x21')](_0x4a191e['query'][_0x570d('0x21')]);_0x34ee65[_0x570d('0x20')]=qs[_0x570d('0x20')](_0x4a191e[_0x570d('0x34')][_0x570d('0x20')]);}return _0x361251[_0x570d('0x62')](_0x34ee65);}})[_0x570d('0x26')](function(_0x2d8c29){if(_0x2d8c29){return _0x2d8c29?{'count':_0x497788,'rows':_0x2d8c29}:null;}})['then'](respondWithResult(_0x1cad42,null))[_0x570d('0x44')](handleError(_0x1cad42,null));};exports[_0x570d('0x64')]=function(_0x5be296,_0x5a4bc9,_0x2e989d){var _0x5a800a=_0x5be296[_0x570d('0x48')][_0x570d('0x65')];return db[_0x570d('0x66')][_0x570d('0x59')]({'where':{'id':_0x5a800a},'attributes':['id'],'include':[{'model':db[_0x570d('0x5a')],'as':_0x570d('0x67'),'attributes':['id',_0x570d('0x2a'),_0x570d('0x68'),'voicePause',_0x570d('0x69')],'raw':!![]}]})[_0x570d('0x26')](function(_0xd56b2e){if(_0xd56b2e){var _0x592b44=_[_0x570d('0x6a')](_0xd56b2e,function(_0x1ae174){var _0x5d02c2=_0x1ae174[_0x570d('0x4c')]({'plain':!![]});return _0x5d02c2[_0x570d('0x67')];});return db[_0x570d('0x2e')][_0x570d('0x46')]({'where':{'id':_0x5be296['params']['id']}})[_0x570d('0x26')](function(_0x5aee47){return db[_0x570d('0x6b')][_0x570d('0x6c')](function(_0x39d970){return _0x5aee47[_0x570d('0x64')](_0x5a800a,{'transaction':_0x39d970})[_0x570d('0x26')](function(){return BPromise[_0x570d('0x6d')](_0x592b44,function(_0xe49478){return db['UserFaxQueue'][_0x570d('0x6e')]({'where':{'UserId':_0xe49478['id'],'FaxQueueId':_0x5be296[_0x570d('0x45')]['id']},'transaction':_0x39d970});});})[_0x570d('0x26')](function(){_0x592b44[_0x570d('0x6f')](function(_0x4c4b65){socket[_0x570d('0x70')](_0x570d('0x71'),{'UserId':_0x4c4b65['id'],'FaxQueueId':_0x5aee47['id']});});});});});}})['then'](respondWithStatusCode(_0x5a4bc9,null))[_0x570d('0x44')](handleError(_0x5a4bc9,null));};exports[_0x570d('0x72')]=function(_0x193ddc,_0xc1df7b,_0x3dcc8e){return db[_0x570d('0x66')][_0x570d('0x59')]({'where':{'id':_0x193ddc[_0x570d('0x34')][_0x570d('0x65')]},'attributes':['id'],'include':[{'model':db[_0x570d('0x5a')],'as':_0x570d('0x67'),'attributes':['id'],'raw':!![]}]})['then'](handleEntityNotFound(_0xc1df7b,null))[_0x570d('0x26')](function(_0x4b7835){var _0x1a90c1=_['map'](_0x4b7835,'id');var _0x2959d5=[];var _0x40ecdb=[];var _0x377625=squel[_0x570d('0x73')]();_0x377625[_0x570d('0x74')](_0x570d('0x75'))[_0x570d('0x76')](_0x570d('0x77'),'tq')[_0x570d('0x78')](_0x570d('0x79'),'ut',_0x570d('0x7a'))[_0x570d('0x3f')]('FaxQueueId\x20=\x20?',_0x193ddc[_0x570d('0x45')]['id']);for(var _0xe2107a=0x0;_0xe2107a<_0x4b7835[_0x570d('0x3a')];_0xe2107a+=0x1){let _0xea9781=_0x4b7835[_0xe2107a];for(var _0x46d5e2=0x0;_0x46d5e2<_0xea9781[_0x570d('0x67')]['length'];_0x46d5e2+=0x1){let _0x3a7aef=_0xea9781['Agents'][_0x46d5e2];var _0x364252=_0x377625[_0x570d('0x7b')]();_0x364252[_0x570d('0x3f')](_0x570d('0x7c'),_0x3a7aef['id']);_0x40ecdb[_0x570d('0x7d')](db[_0x570d('0x6b')][_0x570d('0x34')](_0x364252[_0x570d('0x7e')](),{'type':db[_0x570d('0x6b')][_0x570d('0x7f')][_0x570d('0x80')]})[_0x570d('0x26')](function(_0x32c05f){if(_0x32c05f['length']===0x1){return _0x3a7aef['id'];}else{var _0x530149=_[_0x570d('0x81')](_['map'](_0x32c05f,_0x570d('0x82')),function(_0x1ba1bb){return _[_0x570d('0x83')](_0x1a90c1,_0x1ba1bb);});if(_0x530149){return _0x3a7aef['id'];}}}));}}return BPromise[_0x570d('0x84')](_0x40ecdb)[_0x570d('0x26')](function(_0x14a2ad){_0x2959d5=_(_0x2959d5)['union'](_0x14a2ad)[_0x570d('0x85')]()[_0x570d('0x86')]();return db['FaxQueue'][_0x570d('0x46')]({'where':{'id':_0x193ddc[_0x570d('0x45')]['id']}})[_0x570d('0x26')](function(_0x5bfe04){return db['sequelize'][_0x570d('0x6c')](function(_0xb37a68){return _0x5bfe04[_0x570d('0x72')](_0x193ddc[_0x570d('0x34')][_0x570d('0x65')],{'transaction':_0xb37a68})[_0x570d('0x26')](function(){if(!_['isEmpty'](_0x2959d5)){return _0x5bfe04['removeAgents'](_0x2959d5,{'transaction':_0xb37a68});}})[_0x570d('0x26')](function(){_0x2959d5['forEach'](function(_0x5c3b0c){socket[_0x570d('0x70')](_0x570d('0x87'),{'UserId':_0x5c3b0c,'FaxQueueId':_0x5bfe04['id']});});});});});});})[_0x570d('0x26')](respondWithStatusCode(_0xc1df7b,null))[_0x570d('0x44')](handleError(_0xc1df7b,null));};exports[_0x570d('0x88')]=function(_0x3c976b,_0x40750b,_0x8a67db){return db[_0x570d('0x2e')]['find']({'where':{'id':_0x3c976b['params']['id']}})[_0x570d('0x26')](handleEntityNotFound(_0x40750b,null))[_0x570d('0x26')](function(_0x187aeb){if(_0x187aeb){return _0x187aeb[_0x570d('0x88')](_0x3c976b['body']['ids'],_[_0x570d('0x89')](_0x3c976b[_0x570d('0x48')],['ids','id'])||{})[_0x570d('0x8a')](function(_0x34713d){for(var _0x29e41c=0x0;_0x29e41c<_0x3c976b[_0x570d('0x48')][_0x570d('0x65')][_0x570d('0x3a')];_0x29e41c+=0x1){socket[_0x570d('0x70')](_0x570d('0x71'),{'UserId':Number(_0x3c976b['body'][_0x570d('0x65')][_0x29e41c]),'FaxQueueId':Number(_0x3c976b[_0x570d('0x45')]['id'])});}return _0x34713d;});}})[_0x570d('0x26')](respondWithResult(_0x40750b,null))[_0x570d('0x44')](handleError(_0x40750b,null));};exports[_0x570d('0x8b')]=function(_0x2b4c76,_0x9b0b23,_0x18822d){return db[_0x570d('0x2e')][_0x570d('0x46')]({'where':{'id':_0x2b4c76[_0x570d('0x45')]['id']}})[_0x570d('0x26')](handleEntityNotFound(_0x9b0b23,null))[_0x570d('0x26')](function(_0x5c0937){if(_0x5c0937){return _0x5c0937[_0x570d('0x8b')](_0x2b4c76[_0x570d('0x34')][_0x570d('0x65')])[_0x570d('0x26')](function(){if(_[_0x570d('0x8c')](_0x2b4c76[_0x570d('0x34')][_0x570d('0x65')])){for(var _0x39739f=0x0;_0x39739f<_0x2b4c76[_0x570d('0x34')][_0x570d('0x65')]['length'];_0x39739f+=0x1){socket[_0x570d('0x70')]('userFaxQueue:remove',{'UserId':Number(_0x2b4c76[_0x570d('0x34')][_0x570d('0x65')][_0x39739f]),'FaxQueueId':Number(_0x2b4c76[_0x570d('0x45')]['id'])});}}else{socket[_0x570d('0x70')](_0x570d('0x87'),{'UserId':Number(_0x2b4c76[_0x570d('0x34')][_0x570d('0x65')]),'FaxQueueId':Number(_0x2b4c76[_0x570d('0x45')]['id'])});}});}})['then'](respondWithStatusCode(_0x9b0b23,null))[_0x570d('0x44')](handleError(_0x9b0b23,null));};exports[_0x570d('0x8d')]=function(_0x71b28c,_0x238e8b,_0x3cd6b6){var _0x5f21dd={};var _0x559e64={};var _0x146e84;var _0x476f18;return db['FaxQueue'][_0x570d('0x63')]({'where':{'id':_0x71b28c[_0x570d('0x45')]['id']}})['then'](handleEntityNotFound(_0x238e8b,null))[_0x570d('0x26')](function(_0x480547){if(_0x480547){_0x146e84=_0x480547;_0x559e64[_0x570d('0x33')]=_['keys'](db['User']['rawAttributes']);_0x559e64[_0x570d('0x34')]=_[_0x570d('0x35')](_0x71b28c[_0x570d('0x34')]);_0x559e64['filters']=_[_0x570d('0x37')](_0x559e64[_0x570d('0x33')],_0x559e64[_0x570d('0x34')]);_0x5f21dd['attributes']=_[_0x570d('0x37')](_0x559e64[_0x570d('0x33')],qs['fields'](_0x71b28c[_0x570d('0x34')]['fields']));_0x5f21dd[_0x570d('0x38')]=_0x5f21dd[_0x570d('0x38')][_0x570d('0x3a')]?_0x5f21dd[_0x570d('0x38')]:_0x559e64[_0x570d('0x33')];_0x5f21dd['order']=qs[_0x570d('0x56')](_0x71b28c[_0x570d('0x34')][_0x570d('0x56')]);_0x5f21dd[_0x570d('0x3f')]=qs[_0x570d('0x36')](_[_0x570d('0x3e')](_0x71b28c[_0x570d('0x34')],_0x559e64[_0x570d('0x36')]));if(_0x71b28c[_0x570d('0x34')][_0x570d('0x58')]){_0x5f21dd['where']=_[_0x570d('0x40')](_0x5f21dd[_0x570d('0x3f')],{'$or':_[_0x570d('0x2d')](_0x5f21dd[_0x570d('0x38')],function(_0x23024a){var _0x462f11={};_0x462f11[_0x23024a]={'$like':'%'+_0x71b28c[_0x570d('0x34')][_0x570d('0x58')]+'%'};return _0x462f11;})});}_0x5f21dd=_[_0x570d('0x40')]({},_0x5f21dd,_0x71b28c[_0x570d('0x41')]);return _0x146e84[_0x570d('0x8d')](_0x5f21dd);}})[_0x570d('0x26')](function(_0x2ef47c){if(_0x2ef47c){_0x476f18=_0x2ef47c[_0x570d('0x3a')];if(!_0x71b28c['query'][_0x570d('0x3b')](_0x570d('0x3c'))){_0x5f21dd[_0x570d('0x21')]=qs[_0x570d('0x21')](_0x71b28c[_0x570d('0x34')][_0x570d('0x21')]);_0x5f21dd[_0x570d('0x20')]=qs[_0x570d('0x20')](_0x71b28c[_0x570d('0x34')][_0x570d('0x20')]);}return _0x146e84[_0x570d('0x8d')](_0x5f21dd);}})[_0x570d('0x26')](function(_0xa16f04){if(_0xa16f04){return _0xa16f04?{'count':_0x476f18,'rows':_0xa16f04}:null;}})[_0x570d('0x26')](respondWithResult(_0x238e8b,null))[_0x570d('0x44')](handleError(_0x238e8b,null));};
\ No newline at end of file