Built motion from commit 87cd5f02.|2.5.48
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index d72b7ed..663ab1c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xafdd=['to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','redis','localhost','socket.io-emitter','./faxQueue.socket','sendStatus','status','end','count','offset','limit','set','Content-Range','json','apply','reject','then','destroy','get','FaxQueues','UserProfileResource','error','stack','name','index','map','FaxQueue','rawAttributes','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll','catch','show','params','keys','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','getMembers','UserFaxQueue','hasOwnProperty','FaxQueueId','agent','updatedAt','createdAt','rows','format','SIP','getTeams','findOne','Team','addTeams','ids','Agents','online','voicePause','interface','flatMap','sequelize','transaction','each','forEach','removeTeams','User','select','tq.TeamId','from','team_has_fax_queues','join','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','SELECT','every','TeamId','includes','all','compact','value','removeAgents','emit','userFaxQueue:remove','addAgents','spread','userFaxQueue:save','isArray','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox'];(function(_0x1845a0,_0x500431){var _0x2de0bc=function(_0x1e779e){while(--_0x1e779e){_0x1845a0['push'](_0x1845a0['shift']());}};_0x2de0bc(++_0x500431);}(_0xafdd,0x19a));var _0xdafd=function(_0x1c7dd5,_0x56ae30){_0x1c7dd5=_0x1c7dd5-0x0;var _0x2714ba=_0xafdd[_0x1c7dd5];return _0x2714ba;};'use strict';var emlformat=require(_0xdafd('0x0'));var rimraf=require(_0xdafd('0x1'));var zipdir=require(_0xdafd('0x2'));var jsonpatch=require(_0xdafd('0x3'));var rp=require(_0xdafd('0x4'));var moment=require(_0xdafd('0x5'));var BPromise=require(_0xdafd('0x6'));var Mustache=require(_0xdafd('0x7'));var util=require('util');var path=require(_0xdafd('0x8'));var sox=require(_0xdafd('0x9'));var csv=require(_0xdafd('0xa'));var ejs=require(_0xdafd('0xb'));var fs=require('fs');var fs_extra=require(_0xdafd('0xc'));var _=require(_0xdafd('0xd'));var squel=require(_0xdafd('0xe'));var crypto=require('crypto');var jsforce=require(_0xdafd('0xf'));var deskjs=require(_0xdafd('0x10'));var toCsv=require(_0xdafd('0xa'));var querystring=require('querystring');var Papa=require(_0xdafd('0x11'));var Redis=require(_0xdafd('0x12'));var authService=require(_0xdafd('0x13'));var qs=require(_0xdafd('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xdafd('0x15'));var logger=require(_0xdafd('0x16'))(_0xdafd('0x17'));var utils=require(_0xdafd('0x18'));var config=require(_0xdafd('0x19'));var licenseUtil=require(_0xdafd('0x1a'));var db=require('../../mysqldb')['db'];config[_0xdafd('0x1b')]=_['defaults'](config['redis'],{'host':_0xdafd('0x1c'),'port':0x18eb});var socket=require(_0xdafd('0x1d'))(new Redis(config['redis']));require(_0xdafd('0x1e'))['register'](socket);function respondWithStatusCode(_0x4b09da,_0x1c312d){_0x1c312d=_0x1c312d||0xcc;return function(_0x14b895){if(_0x14b895){return _0x4b09da[_0xdafd('0x1f')](_0x1c312d);}return _0x4b09da[_0xdafd('0x20')](_0x1c312d)[_0xdafd('0x21')]();};}function respondWithResult(_0x496515,_0x47240f){_0x47240f=_0x47240f||0xc8;return function(_0x1842d3){if(_0x1842d3){return _0x496515[_0xdafd('0x20')](_0x47240f)['json'](_0x1842d3);}};}function respondWithFilteredResult(_0xb382ca,_0x15beca){return function(_0x4fc3a4){if(_0x4fc3a4){var _0x4e6ccc=_0x4fc3a4[_0xdafd('0x22')],_0x2569b2=_0x15beca[_0xdafd('0x23')],_0x5acc78=_0x15beca[_0xdafd('0x23')]+_0x15beca[_0xdafd('0x24')],_0x3556da;if(_0x5acc78>=_0x4e6ccc){_0x5acc78=_0x4e6ccc;_0x3556da=0xc8;}else{_0x3556da=0xce;}_0xb382ca[_0xdafd('0x20')](_0x3556da);return _0xb382ca[_0xdafd('0x25')](_0xdafd('0x26'),_0x2569b2+'-'+_0x5acc78+'/'+_0x4e6ccc)[_0xdafd('0x27')](_0x4fc3a4);}return null;};}function patchUpdates(_0x10c353){return function(_0xee767e){try{jsonpatch[_0xdafd('0x28')](_0xee767e,_0x10c353,!![]);}catch(_0xa6ddd7){return BPromise[_0xdafd('0x29')](_0xa6ddd7);}return _0xee767e['save']();};}function saveUpdates(_0x230495,_0x5127a2){return function(_0x31bcd1){if(_0x31bcd1){return _0x31bcd1['update'](_0x230495)[_0xdafd('0x2a')](function(_0x35ef78){return _0x35ef78;});}return null;};}function removeEntity(_0x7f10f6,_0x3d250d){return function(_0xfc36d7){if(_0xfc36d7){return _0xfc36d7[_0xdafd('0x2b')]()[_0xdafd('0x2a')](function(){var _0x30cba9=_0xfc36d7[_0xdafd('0x2c')]({'plain':!![]});var _0x5cd11d=_0xdafd('0x2d');return db[_0xdafd('0x2e')][_0xdafd('0x2b')]({'where':{'type':_0x5cd11d,'resourceId':_0x30cba9['id']}})[_0xdafd('0x2a')](function(){return _0xfc36d7;});})[_0xdafd('0x2a')](function(){_0x7f10f6[_0xdafd('0x20')](0xcc)[_0xdafd('0x21')]();});}};}function handleEntityNotFound(_0x29037e,_0x1c7083){return function(_0x18dd7a){if(!_0x18dd7a){_0x29037e['sendStatus'](0x194);}return _0x18dd7a;};}function handleError(_0x243182,_0x14626b){_0x14626b=_0x14626b||0x1f4;return function(_0x13ab81){logger[_0xdafd('0x2f')](_0x13ab81[_0xdafd('0x30')]);if(_0x13ab81[_0xdafd('0x31')]){delete _0x13ab81['name'];}_0x243182['status'](_0x14626b)['send'](_0x13ab81);};}exports[_0xdafd('0x32')]=function(_0xdb822e,_0x568996){var _0x4f6cb1={},_0x4172ea={},_0x3e7b4d={'count':0x0,'rows':[]};var _0x432210=_[_0xdafd('0x33')](db[_0xdafd('0x34')][_0xdafd('0x35')],function(_0x3e1287){return{'name':_0x3e1287['fieldName'],'type':_0x3e1287[_0xdafd('0x36')][_0xdafd('0x37')]};});_0x4172ea[_0xdafd('0x38')]=_['map'](_0x432210,_0xdafd('0x31'));_0x4172ea[_0xdafd('0x39')]=_['keys'](_0xdb822e[_0xdafd('0x39')]);_0x4172ea[_0xdafd('0x3a')]=_[_0xdafd('0x3b')](_0x4172ea['model'],_0x4172ea[_0xdafd('0x39')]);_0x4f6cb1[_0xdafd('0x3c')]=_[_0xdafd('0x3b')](_0x4172ea[_0xdafd('0x38')],qs[_0xdafd('0x3d')](_0xdb822e[_0xdafd('0x39')][_0xdafd('0x3d')]));_0x4f6cb1['attributes']=_0x4f6cb1[_0xdafd('0x3c')][_0xdafd('0x3e')]?_0x4f6cb1[_0xdafd('0x3c')]:_0x4172ea[_0xdafd('0x38')];if(!_0xdb822e[_0xdafd('0x39')]['hasOwnProperty'](_0xdafd('0x3f'))){_0x4f6cb1[_0xdafd('0x24')]=qs['limit'](_0xdb822e[_0xdafd('0x39')][_0xdafd('0x24')]);_0x4f6cb1[_0xdafd('0x23')]=qs[_0xdafd('0x23')](_0xdb822e[_0xdafd('0x39')][_0xdafd('0x23')]);}_0x4f6cb1[_0xdafd('0x40')]=qs[_0xdafd('0x41')](_0xdb822e[_0xdafd('0x39')][_0xdafd('0x41')]);_0x4f6cb1[_0xdafd('0x42')]=qs[_0xdafd('0x3a')](_[_0xdafd('0x43')](_0xdb822e[_0xdafd('0x39')],_0x4172ea[_0xdafd('0x3a')]),_0x432210);if(_0xdb822e[_0xdafd('0x39')][_0xdafd('0x44')]){_0x4f6cb1[_0xdafd('0x42')]=_[_0xdafd('0x45')](_0x4f6cb1[_0xdafd('0x42')],{'$or':_[_0xdafd('0x33')](_0x432210,function(_0x2605d2){if(_0x2605d2[_0xdafd('0x36')]!==_0xdafd('0x46')){var _0x46f65e={};_0x46f65e[_0x2605d2[_0xdafd('0x31')]]={'$like':'%'+_0xdb822e['query']['filter']+'%'};return _0x46f65e;}})});}_0x4f6cb1=_[_0xdafd('0x45')]({},_0x4f6cb1,_0xdb822e['options']);var _0x12d1ab={'where':_0x4f6cb1[_0xdafd('0x42')]};return db['FaxQueue']['count'](_0x12d1ab)[_0xdafd('0x2a')](function(_0x3382d3){_0x3e7b4d[_0xdafd('0x22')]=_0x3382d3;if(_0xdb822e[_0xdafd('0x39')][_0xdafd('0x47')]){_0x4f6cb1[_0xdafd('0x48')]=[{'all':!![]}];}return db[_0xdafd('0x34')][_0xdafd('0x49')](_0x4f6cb1);})[_0xdafd('0x2a')](function(_0x4bc176){_0x3e7b4d['rows']=_0x4bc176;return _0x3e7b4d;})[_0xdafd('0x2a')](respondWithFilteredResult(_0x568996,_0x4f6cb1))[_0xdafd('0x4a')](handleError(_0x568996,null));};exports[_0xdafd('0x4b')]=function(_0x42aa6c,_0x3bd35b){var _0x2d93b6={'raw':!![],'where':{'id':_0x42aa6c[_0xdafd('0x4c')]['id']}},_0x2b8b47={};_0x2b8b47[_0xdafd('0x38')]=_[_0xdafd('0x4d')](db[_0xdafd('0x34')][_0xdafd('0x35')]);_0x2b8b47[_0xdafd('0x39')]=_['keys'](_0x42aa6c[_0xdafd('0x39')]);_0x2b8b47['filters']=_[_0xdafd('0x3b')](_0x2b8b47['model'],_0x2b8b47[_0xdafd('0x39')]);_0x2d93b6[_0xdafd('0x3c')]=_[_0xdafd('0x3b')](_0x2b8b47[_0xdafd('0x38')],qs[_0xdafd('0x3d')](_0x42aa6c[_0xdafd('0x39')]['fields']));_0x2d93b6[_0xdafd('0x3c')]=_0x2d93b6[_0xdafd('0x3c')][_0xdafd('0x3e')]?_0x2d93b6[_0xdafd('0x3c')]:_0x2b8b47[_0xdafd('0x38')];if(_0x42aa6c['query']['includeAll']){_0x2d93b6[_0xdafd('0x48')]=[{'all':!![]}];}_0x2d93b6=_[_0xdafd('0x45')]({},_0x2d93b6,_0x42aa6c[_0xdafd('0x4e')]);return db[_0xdafd('0x34')][_0xdafd('0x4f')](_0x2d93b6)[_0xdafd('0x2a')](handleEntityNotFound(_0x3bd35b,null))[_0xdafd('0x2a')](respondWithResult(_0x3bd35b,null))[_0xdafd('0x4a')](handleError(_0x3bd35b,null));};exports[_0xdafd('0x50')]=function(_0x5058b1,_0x6f2f39){return db[_0xdafd('0x34')][_0xdafd('0x50')](_0x5058b1[_0xdafd('0x51')],{})['then'](function(_0xf8fcb8){var _0x343ef5=_0x5058b1[_0xdafd('0x52')][_0xdafd('0x2c')]({'plain':!![]});if(!_0x343ef5)throw new Error(_0xdafd('0x53'));if(_0x343ef5['role']==='user'){var _0xc1dadb=_0xf8fcb8[_0xdafd('0x2c')]({'plain':!![]});var _0x5a145e='FaxQueues';return db[_0xdafd('0x54')][_0xdafd('0x4f')]({'where':{'name':_0x5a145e,'userProfileId':_0x343ef5['userProfileId']},'raw':!![]})[_0xdafd('0x2a')](function(_0x5dc9a0){if(_0x5dc9a0&&_0x5dc9a0[_0xdafd('0x55')]===0x0){return db['UserProfileResource']['create']({'name':_0xc1dadb[_0xdafd('0x31')],'resourceId':_0xc1dadb['id'],'type':_0x5dc9a0[_0xdafd('0x31')],'sectionId':_0x5dc9a0['id']},{})['then'](function(){return _0xf8fcb8;});}else{return _0xf8fcb8;}})[_0xdafd('0x4a')](function(_0x4e10ce){logger['error'](_0xdafd('0x56'),_0x4e10ce);throw _0x4e10ce;});}return _0xf8fcb8;})[_0xdafd('0x2a')](respondWithResult(_0x6f2f39,0xc9))[_0xdafd('0x4a')](handleError(_0x6f2f39,null));};exports[_0xdafd('0x57')]=function(_0x150fe1,_0x307f35){if(_0x150fe1[_0xdafd('0x51')]['id']){delete _0x150fe1[_0xdafd('0x51')]['id'];}return db['FaxQueue'][_0xdafd('0x4f')]({'where':{'id':_0x150fe1[_0xdafd('0x4c')]['id']}})['then'](handleEntityNotFound(_0x307f35,null))[_0xdafd('0x2a')](saveUpdates(_0x150fe1[_0xdafd('0x51')],null))[_0xdafd('0x2a')](respondWithResult(_0x307f35,null))[_0xdafd('0x4a')](handleError(_0x307f35,null));};exports[_0xdafd('0x2b')]=function(_0x556f7e,_0x464e49){return db[_0xdafd('0x34')][_0xdafd('0x4f')]({'where':{'id':_0x556f7e[_0xdafd('0x4c')]['id']}})[_0xdafd('0x2a')](handleEntityNotFound(_0x464e49,null))['then'](removeEntity(_0x464e49,null))[_0xdafd('0x4a')](handleError(_0x464e49,null));};exports[_0xdafd('0x58')]=function(_0x55284e,_0x4f3059){return db[_0xdafd('0x34')]['describe']()[_0xdafd('0x2a')](respondWithResult(_0x4f3059,null))['catch'](handleError(_0x4f3059,null));};exports[_0xdafd('0x59')]=function(_0x12c412,_0x403a3b,_0x589664){var _0xf2f551={'raw':!![],'where':{}},_0x5210be={},_0xf9cc85;return db[_0xdafd('0x34')]['findOne']({'where':{'id':_0x12c412[_0xdafd('0x4c')]['id']}})[_0xdafd('0x2a')](handleEntityNotFound(_0x403a3b,null))[_0xdafd('0x2a')](function(_0x223190){if(_0x223190){_0xf9cc85=_0x223190[_0xdafd('0x2c')]({'plain':!![]});_0x5210be['model']=_[_0xdafd('0x4d')](db[_0xdafd('0x5a')]['rawAttributes']);_0x5210be[_0xdafd('0x39')]=_[_0xdafd('0x4d')](_0x12c412[_0xdafd('0x39')]);_0x5210be[_0xdafd('0x3a')]=_[_0xdafd('0x3b')](_0x5210be['model'],_0x5210be[_0xdafd('0x39')]);_0xf2f551['attributes']=_['intersection'](_0x5210be[_0xdafd('0x38')],qs['fields'](_0x12c412[_0xdafd('0x39')][_0xdafd('0x3d')]));_0xf2f551[_0xdafd('0x3c')]=_0xf2f551[_0xdafd('0x3c')]['length']?_0xf2f551[_0xdafd('0x3c')]:_0x5210be[_0xdafd('0x38')];if(!_0x12c412[_0xdafd('0x39')][_0xdafd('0x5b')](_0xdafd('0x3f'))){_0xf2f551[_0xdafd('0x24')]=qs[_0xdafd('0x24')](_0x12c412[_0xdafd('0x39')][_0xdafd('0x24')]);_0xf2f551[_0xdafd('0x23')]=qs[_0xdafd('0x23')](_0x12c412[_0xdafd('0x39')][_0xdafd('0x23')]);}_0xf2f551[_0xdafd('0x40')]=qs[_0xdafd('0x41')](_0x12c412[_0xdafd('0x39')][_0xdafd('0x41')]);_0xf2f551['where']=qs[_0xdafd('0x3a')](_['pick'](_0x12c412[_0xdafd('0x39')],_0x5210be['filters']));_0xf2f551[_0xdafd('0x42')][_0xdafd('0x5c')]=_0x223190['id'];if(_0x12c412['query']['filter']){_0xf2f551[_0xdafd('0x42')]=_[_0xdafd('0x45')](_0xf2f551[_0xdafd('0x42')],{'$or':_['map'](_0xf2f551['attributes'],function(_0x4f6bbb){var _0xfe8337={};_0xfe8337[_0x4f6bbb]={'$like':'%'+_0x12c412['query'][_0xdafd('0x44')]+'%'};return _0xfe8337;})});}_0xf2f551=_['merge']({},_0xf2f551,_0x12c412[_0xdafd('0x4e')]);return db[_0xdafd('0x5a')][_0xdafd('0x49')](_0xf2f551);}})[_0xdafd('0x2a')](function(_0x3f64fe){if(_0x3f64fe){return db['User']['findAndCountAll']({'where':{'id':_[_0xdafd('0x33')](_0x3f64fe,'UserId'),'role':_0xdafd('0x5d')},'attributes':['id',_0xdafd('0x31'),'faxPause',_0xdafd('0x5e'),_0xdafd('0x5f')]});}})[_0xdafd('0x2a')](function(_0x2524b5){if(_0x2524b5){return{'count':_0x2524b5[_0xdafd('0x22')],'rows':_[_0xdafd('0x33')](_0x2524b5[_0xdafd('0x60')],function(_0x1255bb){return{'membername':_0x1255bb['name'],'UserId':_0x1255bb['id'],'queue_name':_0xf9cc85[_0xdafd('0x31')],'FaxQueueId':_0xf9cc85['id'],'interface':util[_0xdafd('0x61')]('%s/%s',_0xdafd('0x62'),_0x1255bb[_0xdafd('0x31')]),'penalty':0x0,'paused':_0x1255bb['faxPause'],'createdAt':_0x1255bb[_0xdafd('0x5f')],'updatedAt':_0x1255bb[_0xdafd('0x5e')]};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x403a3b,_0xf2f551))[_0xdafd('0x4a')](handleError(_0x403a3b,null));};exports[_0xdafd('0x63')]=function(_0x1e47bf,_0x547571,_0x1a0f40){var _0xb4166f={};var _0x406001={};var _0x2ee557;var _0x4ad46f;return db['FaxQueue'][_0xdafd('0x64')]({'where':{'id':_0x1e47bf[_0xdafd('0x4c')]['id']}})['then'](handleEntityNotFound(_0x547571,null))[_0xdafd('0x2a')](function(_0x3d3862){if(_0x3d3862){_0x2ee557=_0x3d3862;_0x406001[_0xdafd('0x38')]=_[_0xdafd('0x4d')](db[_0xdafd('0x65')][_0xdafd('0x35')]);_0x406001['query']=_[_0xdafd('0x4d')](_0x1e47bf[_0xdafd('0x39')]);_0x406001['filters']=_[_0xdafd('0x3b')](_0x406001[_0xdafd('0x38')],_0x406001[_0xdafd('0x39')]);_0xb4166f[_0xdafd('0x3c')]=_[_0xdafd('0x3b')](_0x406001[_0xdafd('0x38')],qs[_0xdafd('0x3d')](_0x1e47bf[_0xdafd('0x39')][_0xdafd('0x3d')]));_0xb4166f[_0xdafd('0x3c')]=_0xb4166f[_0xdafd('0x3c')]['length']?_0xb4166f[_0xdafd('0x3c')]:_0x406001[_0xdafd('0x38')];_0xb4166f[_0xdafd('0x40')]=qs[_0xdafd('0x41')](_0x1e47bf[_0xdafd('0x39')][_0xdafd('0x41')]);_0xb4166f[_0xdafd('0x42')]=qs[_0xdafd('0x3a')](_[_0xdafd('0x43')](_0x1e47bf[_0xdafd('0x39')],_0x406001[_0xdafd('0x3a')]));if(_0x1e47bf['query'][_0xdafd('0x44')]){_0xb4166f[_0xdafd('0x42')]=_['merge'](_0xb4166f[_0xdafd('0x42')],{'$or':_[_0xdafd('0x33')](_0xb4166f[_0xdafd('0x3c')],function(_0x53e68a){var _0x153578={};_0x153578[_0x53e68a]={'$like':'%'+_0x1e47bf['query'][_0xdafd('0x44')]+'%'};return _0x153578;})});}_0xb4166f=_[_0xdafd('0x45')]({},_0xb4166f,_0x1e47bf['options']);return _0x2ee557[_0xdafd('0x63')](_0xb4166f);}})[_0xdafd('0x2a')](function(_0x2a92d6){if(_0x2a92d6){_0x4ad46f=_0x2a92d6[_0xdafd('0x3e')];if(!_0x1e47bf[_0xdafd('0x39')][_0xdafd('0x5b')](_0xdafd('0x3f'))){_0xb4166f[_0xdafd('0x24')]=qs[_0xdafd('0x24')](_0x1e47bf[_0xdafd('0x39')][_0xdafd('0x24')]);_0xb4166f[_0xdafd('0x23')]=qs['offset'](_0x1e47bf['query'][_0xdafd('0x23')]);}return _0x2ee557[_0xdafd('0x63')](_0xb4166f);}})[_0xdafd('0x2a')](function(_0x39f42d){if(_0x39f42d){return _0x39f42d?{'count':_0x4ad46f,'rows':_0x39f42d}:null;}})[_0xdafd('0x2a')](respondWithResult(_0x547571,null))[_0xdafd('0x4a')](handleError(_0x547571,null));};exports[_0xdafd('0x66')]=function(_0x65ad7b,_0x538449,_0x705220){var _0x368142=_0x65ad7b[_0xdafd('0x51')][_0xdafd('0x67')];return db['Team']['findAll']({'where':{'id':_0x368142},'attributes':['id'],'include':[{'model':db['User'],'as':_0xdafd('0x68'),'attributes':['id','name',_0xdafd('0x69'),_0xdafd('0x6a'),_0xdafd('0x6b')],'raw':!![]}]})[_0xdafd('0x2a')](function(_0x4ff7d5){if(_0x4ff7d5){var _0xed0633=_[_0xdafd('0x6c')](_0x4ff7d5,function(_0x1a3652){var _0x1243e5=_0x1a3652[_0xdafd('0x2c')]({'plain':!![]});return _0x1243e5['Agents'];});return db[_0xdafd('0x34')]['find']({'where':{'id':_0x65ad7b[_0xdafd('0x4c')]['id']}})[_0xdafd('0x2a')](function(_0x5c82e9){return db[_0xdafd('0x6d')][_0xdafd('0x6e')](function(_0x4d4d66){return _0x5c82e9[_0xdafd('0x66')](_0x368142,{'transaction':_0x4d4d66})[_0xdafd('0x2a')](function(){return BPromise[_0xdafd('0x6f')](_0xed0633,function(_0x54d7db){return db[_0xdafd('0x5a')]['findOrCreate']({'where':{'UserId':_0x54d7db['id'],'FaxQueueId':_0x65ad7b[_0xdafd('0x4c')]['id']},'transaction':_0x4d4d66});});})[_0xdafd('0x2a')](function(){_0xed0633[_0xdafd('0x70')](function(_0x2d5dd4){socket['emit']('userFaxQueue:save',{'UserId':_0x2d5dd4['id'],'FaxQueueId':_0x5c82e9['id']});});});});});}})[_0xdafd('0x2a')](respondWithStatusCode(_0x538449,null))[_0xdafd('0x4a')](handleError(_0x538449,null));};exports[_0xdafd('0x71')]=function(_0x49e087,_0x37b837,_0x2cdcff){return db[_0xdafd('0x65')][_0xdafd('0x49')]({'where':{'id':_0x49e087['query'][_0xdafd('0x67')]},'attributes':['id'],'include':[{'model':db[_0xdafd('0x72')],'as':_0xdafd('0x68'),'attributes':['id'],'raw':!![]}]})[_0xdafd('0x2a')](handleEntityNotFound(_0x37b837,null))['then'](function(_0x2fd239){var _0x342ed1=_['map'](_0x2fd239,'id');var _0xe7595d=[];var _0x2763df=[];var _0x4c910a=squel[_0xdafd('0x73')]();_0x4c910a['field'](_0xdafd('0x74'))[_0xdafd('0x75')](_0xdafd('0x76'),'tq')[_0xdafd('0x77')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0xdafd('0x42')](_0xdafd('0x78'),_0x49e087['params']['id']);for(var _0x258696=0x0;_0x258696<_0x2fd239[_0xdafd('0x3e')];_0x258696+=0x1){let _0x3b8f4b=_0x2fd239[_0x258696];for(var _0x3c08a6=0x0;_0x3c08a6<_0x3b8f4b['Agents'][_0xdafd('0x3e')];_0x3c08a6+=0x1){let _0x504358=_0x3b8f4b[_0xdafd('0x68')][_0x3c08a6];var _0x1948f7=_0x4c910a[_0xdafd('0x79')]();_0x1948f7['where'](_0xdafd('0x7a'),_0x504358['id']);_0x2763df['push'](db[_0xdafd('0x6d')][_0xdafd('0x39')](_0x1948f7[_0xdafd('0x7b')](),{'type':db[_0xdafd('0x6d')][_0xdafd('0x7c')][_0xdafd('0x7d')]})[_0xdafd('0x2a')](function(_0x58edbb){if(_0x58edbb[_0xdafd('0x3e')]===0x1){return _0x504358['id'];}else{var _0x132fdf=_[_0xdafd('0x7e')](_['map'](_0x58edbb,_0xdafd('0x7f')),function(_0x4e7112){return _[_0xdafd('0x80')](_0x342ed1,_0x4e7112);});if(_0x132fdf){return _0x504358['id'];}}}));}}return BPromise[_0xdafd('0x81')](_0x2763df)[_0xdafd('0x2a')](function(_0x1fd99b){_0xe7595d=_(_0xe7595d)['union'](_0x1fd99b)[_0xdafd('0x82')]()[_0xdafd('0x83')]();return db[_0xdafd('0x34')][_0xdafd('0x4f')]({'where':{'id':_0x49e087[_0xdafd('0x4c')]['id']}})['then'](function(_0x2f4c79){return db['sequelize'][_0xdafd('0x6e')](function(_0x3a4eb3){return _0x2f4c79['removeTeams'](_0x49e087['query'][_0xdafd('0x67')],{'transaction':_0x3a4eb3})[_0xdafd('0x2a')](function(){if(!_['isEmpty'](_0xe7595d)){return _0x2f4c79[_0xdafd('0x84')](_0xe7595d,{'transaction':_0x3a4eb3});}})['then'](function(){_0xe7595d[_0xdafd('0x70')](function(_0x26b2f3){socket[_0xdafd('0x85')](_0xdafd('0x86'),{'UserId':_0x26b2f3,'FaxQueueId':_0x2f4c79['id']});});});});});});})[_0xdafd('0x2a')](respondWithStatusCode(_0x37b837,null))[_0xdafd('0x4a')](handleError(_0x37b837,null));};exports[_0xdafd('0x87')]=function(_0x3861c1,_0x30d2d5,_0x227a8e){return db[_0xdafd('0x34')][_0xdafd('0x4f')]({'where':{'id':_0x3861c1[_0xdafd('0x4c')]['id']}})['then'](handleEntityNotFound(_0x30d2d5,null))[_0xdafd('0x2a')](function(_0x1879cb){if(_0x1879cb){return _0x1879cb[_0xdafd('0x87')](_0x3861c1['body'][_0xdafd('0x67')],_['omit'](_0x3861c1[_0xdafd('0x51')],[_0xdafd('0x67'),'id'])||{})[_0xdafd('0x88')](function(_0x418fcc){for(var _0x4d535e=0x0;_0x4d535e<_0x3861c1[_0xdafd('0x51')][_0xdafd('0x67')][_0xdafd('0x3e')];_0x4d535e+=0x1){socket[_0xdafd('0x85')](_0xdafd('0x89'),{'UserId':_0x3861c1[_0xdafd('0x51')][_0xdafd('0x67')][_0x4d535e],'FaxQueueId':_0x3861c1[_0xdafd('0x4c')]['id']});}return _0x418fcc;});}})[_0xdafd('0x2a')](respondWithResult(_0x30d2d5,null))['catch'](handleError(_0x30d2d5,null));};exports[_0xdafd('0x84')]=function(_0x47e4a2,_0x5cbc6f,_0x25d569){return db[_0xdafd('0x34')]['find']({'where':{'id':_0x47e4a2[_0xdafd('0x4c')]['id']}})[_0xdafd('0x2a')](handleEntityNotFound(_0x5cbc6f,null))[_0xdafd('0x2a')](function(_0x34b7db){if(_0x34b7db){return _0x34b7db['removeAgents'](_0x47e4a2[_0xdafd('0x39')][_0xdafd('0x67')])[_0xdafd('0x2a')](function(){if(_[_0xdafd('0x8a')](_0x47e4a2[_0xdafd('0x39')][_0xdafd('0x67')])){for(var _0x36eaa7=0x0;_0x36eaa7<_0x47e4a2[_0xdafd('0x39')][_0xdafd('0x67')][_0xdafd('0x3e')];_0x36eaa7+=0x1){socket[_0xdafd('0x85')]('userFaxQueue:remove',{'UserId':Number(_0x47e4a2['query'][_0xdafd('0x67')][_0x36eaa7]),'FaxQueueId':Number(_0x47e4a2[_0xdafd('0x4c')]['id'])});}}else{socket[_0xdafd('0x85')]('userFaxQueue:remove',{'UserId':Number(_0x47e4a2['query'][_0xdafd('0x67')]),'FaxQueueId':Number(_0x47e4a2['params']['id'])});}});}})[_0xdafd('0x2a')](respondWithStatusCode(_0x5cbc6f,null))[_0xdafd('0x4a')](handleError(_0x5cbc6f,null));};exports[_0xdafd('0x8b')]=function(_0x48acb9,_0x3d5c79,_0x13d7e9){var _0x326745={};var _0x4d3a3a={};var _0x40abe6;var _0x17e66f;return db[_0xdafd('0x34')][_0xdafd('0x64')]({'where':{'id':_0x48acb9[_0xdafd('0x4c')]['id']}})[_0xdafd('0x2a')](handleEntityNotFound(_0x3d5c79,null))[_0xdafd('0x2a')](function(_0x4ab1c8){if(_0x4ab1c8){_0x40abe6=_0x4ab1c8;_0x4d3a3a[_0xdafd('0x38')]=_[_0xdafd('0x4d')](db['User'][_0xdafd('0x35')]);_0x4d3a3a[_0xdafd('0x39')]=_[_0xdafd('0x4d')](_0x48acb9[_0xdafd('0x39')]);_0x4d3a3a['filters']=_[_0xdafd('0x3b')](_0x4d3a3a[_0xdafd('0x38')],_0x4d3a3a[_0xdafd('0x39')]);_0x326745['attributes']=_['intersection'](_0x4d3a3a['model'],qs[_0xdafd('0x3d')](_0x48acb9[_0xdafd('0x39')][_0xdafd('0x3d')]));_0x326745[_0xdafd('0x3c')]=_0x326745[_0xdafd('0x3c')][_0xdafd('0x3e')]?_0x326745[_0xdafd('0x3c')]:_0x4d3a3a['model'];_0x326745[_0xdafd('0x40')]=qs['sort'](_0x48acb9[_0xdafd('0x39')][_0xdafd('0x41')]);_0x326745[_0xdafd('0x42')]=qs[_0xdafd('0x3a')](_['pick'](_0x48acb9[_0xdafd('0x39')],_0x4d3a3a['filters']));if(_0x48acb9[_0xdafd('0x39')]['filter']){_0x326745['where']=_[_0xdafd('0x45')](_0x326745[_0xdafd('0x42')],{'$or':_['map'](_0x326745[_0xdafd('0x3c')],function(_0x5843b5){var _0x2f5efc={};_0x2f5efc[_0x5843b5]={'$like':'%'+_0x48acb9[_0xdafd('0x39')][_0xdafd('0x44')]+'%'};return _0x2f5efc;})});}_0x326745=_[_0xdafd('0x45')]({},_0x326745,_0x48acb9[_0xdafd('0x4e')]);return _0x40abe6[_0xdafd('0x8b')](_0x326745);}})[_0xdafd('0x2a')](function(_0x415849){if(_0x415849){_0x17e66f=_0x415849['length'];if(!_0x48acb9[_0xdafd('0x39')][_0xdafd('0x5b')]('nolimit')){_0x326745[_0xdafd('0x24')]=qs[_0xdafd('0x24')](_0x48acb9[_0xdafd('0x39')][_0xdafd('0x24')]);_0x326745[_0xdafd('0x23')]=qs[_0xdafd('0x23')](_0x48acb9[_0xdafd('0x39')][_0xdafd('0x23')]);}return _0x40abe6[_0xdafd('0x8b')](_0x326745);}})[_0xdafd('0x2a')](function(_0x20e712){if(_0x20e712){return _0x20e712?{'count':_0x17e66f,'rows':_0x20e712}:null;}})['then'](respondWithResult(_0x3d5c79,null))[_0xdafd('0x4a')](handleError(_0x3d5c79,null));};
\ No newline at end of file
+var _0x7715=['pick','FaxQueueId','filter','UserFaxQueue','findAll','User','findAndCountAll','UserId','faxPause','updatedAt','createdAt','%s/%s','Team','getTeams','addTeams','Agents','online','voicePause','interface','flatMap','transaction','each','findOrCreate','forEach','removeTeams','ids','tq.TeamId','from','team_has_fax_queues','join','user_has_teams','ut.TeamId\x20=\x20tq.TeamId','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','sequelize','QueryTypes','every','TeamId','includes','all','compact','value','removeAgents','addAgents','omit','emit','userFaxQueue:save','isArray','userFaxQueue:remove','getAgents','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','to-csv','querystring','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxQueue.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','save','update','then','destroy','FaxQueues','UserProfileResource','error','stack','name','index','map','FaxQueue','rawAttributes','type','key','model','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','order','where','VIRTUAL','include','rows','show','length','includeAll','merge','options','find','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','findOne','sort'];(function(_0x3a07c1,_0x34d57f){var _0x2bbe15=function(_0x5a02fb){while(--_0x5a02fb){_0x3a07c1['push'](_0x3a07c1['shift']());}};_0x2bbe15(++_0x34d57f);}(_0x7715,0x14f));var _0x5771=function(_0x1dc21e,_0x443665){_0x1dc21e=_0x1dc21e-0x0;var _0x1c975b=_0x7715[_0x1dc21e];return _0x1c975b;};'use strict';var emlformat=require(_0x5771('0x0'));var rimraf=require(_0x5771('0x1'));var zipdir=require(_0x5771('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5771('0x3'));var moment=require(_0x5771('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x5771('0x5'));var util=require(_0x5771('0x6'));var path=require(_0x5771('0x7'));var sox=require(_0x5771('0x8'));var csv=require('to-csv');var ejs=require(_0x5771('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x5771('0xa'));var squel=require(_0x5771('0xb'));var crypto=require(_0x5771('0xc'));var jsforce=require(_0x5771('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x5771('0xe'));var querystring=require(_0x5771('0xf'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x5771('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x5771('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x5771('0x12'))(_0x5771('0x13'));var utils=require(_0x5771('0x14'));var config=require(_0x5771('0x15'));var licenseUtil=require(_0x5771('0x16'));var db=require(_0x5771('0x17'))['db'];config[_0x5771('0x18')]=_['defaults'](config[_0x5771('0x18')],{'host':_0x5771('0x19'),'port':0x18eb});var socket=require(_0x5771('0x1a'))(new Redis(config[_0x5771('0x18')]));require(_0x5771('0x1b'))[_0x5771('0x1c')](socket);function respondWithStatusCode(_0x5c61e9,_0x212461){_0x212461=_0x212461||0xcc;return function(_0x477f4c){if(_0x477f4c){return _0x5c61e9[_0x5771('0x1d')](_0x212461);}return _0x5c61e9[_0x5771('0x1e')](_0x212461)[_0x5771('0x1f')]();};}function respondWithResult(_0x9ec393,_0x15073b){_0x15073b=_0x15073b||0xc8;return function(_0x591ba3){if(_0x591ba3){return _0x9ec393['status'](_0x15073b)[_0x5771('0x20')](_0x591ba3);}};}function respondWithFilteredResult(_0x57961f,_0x246c4b){return function(_0x2744ee){if(_0x2744ee){var _0x1f4e3a=typeof _0x246c4b[_0x5771('0x21')]===_0x5771('0x22')&&typeof _0x246c4b[_0x5771('0x23')]===_0x5771('0x22');var _0x10502d=_0x2744ee[_0x5771('0x24')];var _0x484c12=_0x1f4e3a?0x0:_0x246c4b[_0x5771('0x21')];var _0x590cbe=_0x1f4e3a?_0x2744ee[_0x5771('0x24')]:_0x246c4b[_0x5771('0x21')]+_0x246c4b[_0x5771('0x23')];var _0x4978ed;if(_0x590cbe>=_0x10502d){_0x590cbe=_0x10502d;_0x4978ed=0xc8;}else{_0x4978ed=0xce;}_0x57961f['status'](_0x4978ed);return _0x57961f[_0x5771('0x25')]('Content-Range',_0x484c12+'-'+_0x590cbe+'/'+_0x10502d)[_0x5771('0x20')](_0x2744ee);}return null;};}function patchUpdates(_0x1fe764){return function(_0x141fd4){try{jsonpatch[_0x5771('0x26')](_0x141fd4,_0x1fe764,!![]);}catch(_0x249794){return BPromise[_0x5771('0x27')](_0x249794);}return _0x141fd4[_0x5771('0x28')]();};}function saveUpdates(_0x915b28,_0x4b03ba){return function(_0x5eb5e2){if(_0x5eb5e2){return _0x5eb5e2[_0x5771('0x29')](_0x915b28)[_0x5771('0x2a')](function(_0x5391f4){return _0x5391f4;});}return null;};}function removeEntity(_0x44fa4c,_0x44f749){return function(_0x140809){if(_0x140809){return _0x140809[_0x5771('0x2b')]()[_0x5771('0x2a')](function(){var _0x21acdd=_0x140809['get']({'plain':!![]});var _0xbb4fa8=_0x5771('0x2c');return db[_0x5771('0x2d')][_0x5771('0x2b')]({'where':{'type':_0xbb4fa8,'resourceId':_0x21acdd['id']}})['then'](function(){return _0x140809;});})[_0x5771('0x2a')](function(){_0x44fa4c[_0x5771('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x56c33c,_0xd6b072){return function(_0x214bb8){if(!_0x214bb8){_0x56c33c[_0x5771('0x1d')](0x194);}return _0x214bb8;};}function handleError(_0x731f0e,_0x1bc878){_0x1bc878=_0x1bc878||0x1f4;return function(_0x374888){logger[_0x5771('0x2e')](_0x374888[_0x5771('0x2f')]);if(_0x374888[_0x5771('0x30')]){delete _0x374888[_0x5771('0x30')];}_0x731f0e[_0x5771('0x1e')](_0x1bc878)['send'](_0x374888);};}exports[_0x5771('0x31')]=function(_0x41a679,_0x13685f){var _0x8b328b={},_0x4d4ec8={},_0x107d1d={'count':0x0,'rows':[]};var _0x3f2fa5=_[_0x5771('0x32')](db[_0x5771('0x33')][_0x5771('0x34')],function(_0x5d97e5){return{'name':_0x5d97e5['fieldName'],'type':_0x5d97e5[_0x5771('0x35')][_0x5771('0x36')]};});_0x4d4ec8[_0x5771('0x37')]=_[_0x5771('0x32')](_0x3f2fa5,_0x5771('0x30'));_0x4d4ec8[_0x5771('0x38')]=_[_0x5771('0x39')](_0x41a679['query']);_0x4d4ec8[_0x5771('0x3a')]=_['intersection'](_0x4d4ec8[_0x5771('0x37')],_0x4d4ec8['query']);_0x8b328b[_0x5771('0x3b')]=_[_0x5771('0x3c')](_0x4d4ec8[_0x5771('0x37')],qs[_0x5771('0x3d')](_0x41a679[_0x5771('0x38')]['fields']));_0x8b328b['attributes']=_0x8b328b['attributes']['length']?_0x8b328b[_0x5771('0x3b')]:_0x4d4ec8[_0x5771('0x37')];if(!_0x41a679[_0x5771('0x38')][_0x5771('0x3e')](_0x5771('0x3f'))){_0x8b328b[_0x5771('0x23')]=qs[_0x5771('0x23')](_0x41a679[_0x5771('0x38')][_0x5771('0x23')]);_0x8b328b['offset']=qs['offset'](_0x41a679['query']['offset']);}_0x8b328b[_0x5771('0x40')]=qs['sort'](_0x41a679[_0x5771('0x38')]['sort']);_0x8b328b[_0x5771('0x41')]=qs[_0x5771('0x3a')](_['pick'](_0x41a679[_0x5771('0x38')],_0x4d4ec8[_0x5771('0x3a')]),_0x3f2fa5);if(_0x41a679[_0x5771('0x38')]['filter']){_0x8b328b[_0x5771('0x41')]=_['merge'](_0x8b328b[_0x5771('0x41')],{'$or':_[_0x5771('0x32')](_0x3f2fa5,function(_0x22828c){if(_0x22828c[_0x5771('0x35')]!==_0x5771('0x42')){var _0x430546={};_0x430546[_0x22828c[_0x5771('0x30')]]={'$like':'%'+_0x41a679['query']['filter']+'%'};return _0x430546;}})});}_0x8b328b=_['merge']({},_0x8b328b,_0x41a679['options']);var _0x43c4a7={'where':_0x8b328b['where']};return db[_0x5771('0x33')]['count'](_0x43c4a7)[_0x5771('0x2a')](function(_0x282d16){_0x107d1d['count']=_0x282d16;if(_0x41a679['query']['includeAll']){_0x8b328b[_0x5771('0x43')]=[{'all':!![]}];}return db[_0x5771('0x33')]['findAll'](_0x8b328b);})[_0x5771('0x2a')](function(_0xabbc39){_0x107d1d[_0x5771('0x44')]=_0xabbc39;return _0x107d1d;})['then'](respondWithFilteredResult(_0x13685f,_0x8b328b))['catch'](handleError(_0x13685f,null));};exports[_0x5771('0x45')]=function(_0x1dc2fb,_0x42e31a){var _0x593b2a={'raw':!![],'where':{'id':_0x1dc2fb['params']['id']}},_0x6636a0={};_0x6636a0['model']=_[_0x5771('0x39')](db[_0x5771('0x33')][_0x5771('0x34')]);_0x6636a0[_0x5771('0x38')]=_[_0x5771('0x39')](_0x1dc2fb['query']);_0x6636a0['filters']=_[_0x5771('0x3c')](_0x6636a0[_0x5771('0x37')],_0x6636a0['query']);_0x593b2a['attributes']=_[_0x5771('0x3c')](_0x6636a0[_0x5771('0x37')],qs[_0x5771('0x3d')](_0x1dc2fb[_0x5771('0x38')][_0x5771('0x3d')]));_0x593b2a['attributes']=_0x593b2a[_0x5771('0x3b')][_0x5771('0x46')]?_0x593b2a[_0x5771('0x3b')]:_0x6636a0[_0x5771('0x37')];if(_0x1dc2fb[_0x5771('0x38')][_0x5771('0x47')]){_0x593b2a[_0x5771('0x43')]=[{'all':!![]}];}_0x593b2a=_[_0x5771('0x48')]({},_0x593b2a,_0x1dc2fb[_0x5771('0x49')]);return db['FaxQueue'][_0x5771('0x4a')](_0x593b2a)['then'](handleEntityNotFound(_0x42e31a,null))[_0x5771('0x2a')](respondWithResult(_0x42e31a,null))[_0x5771('0x4b')](handleError(_0x42e31a,null));};exports[_0x5771('0x4c')]=function(_0x38d63b,_0x57dc5e){return db[_0x5771('0x33')][_0x5771('0x4c')](_0x38d63b[_0x5771('0x4d')],{})[_0x5771('0x2a')](function(_0x360212){var _0x1c7837=_0x38d63b[_0x5771('0x4e')][_0x5771('0x4f')]({'plain':!![]});if(!_0x1c7837)throw new Error(_0x5771('0x50'));if(_0x1c7837[_0x5771('0x51')]===_0x5771('0x4e')){var _0x565e7b=_0x360212['get']({'plain':!![]});var _0x56e45b='FaxQueues';return db[_0x5771('0x52')][_0x5771('0x4a')]({'where':{'name':_0x56e45b,'userProfileId':_0x1c7837[_0x5771('0x53')]},'raw':!![]})['then'](function(_0x576ec0){if(_0x576ec0&&_0x576ec0[_0x5771('0x54')]===0x0){return db['UserProfileResource']['create']({'name':_0x565e7b[_0x5771('0x30')],'resourceId':_0x565e7b['id'],'type':_0x576ec0[_0x5771('0x30')],'sectionId':_0x576ec0['id']},{})[_0x5771('0x2a')](function(){return _0x360212;});}else{return _0x360212;}})[_0x5771('0x4b')](function(_0x172eb8){logger[_0x5771('0x2e')](_0x5771('0x55'),_0x172eb8);throw _0x172eb8;});}return _0x360212;})[_0x5771('0x2a')](respondWithResult(_0x57dc5e,0xc9))[_0x5771('0x4b')](handleError(_0x57dc5e,null));};exports[_0x5771('0x29')]=function(_0x454215,_0x2f1b1d){if(_0x454215[_0x5771('0x4d')]['id']){delete _0x454215['body']['id'];}return db[_0x5771('0x33')]['find']({'where':{'id':_0x454215[_0x5771('0x56')]['id']}})[_0x5771('0x2a')](handleEntityNotFound(_0x2f1b1d,null))['then'](saveUpdates(_0x454215[_0x5771('0x4d')],null))['then'](respondWithResult(_0x2f1b1d,null))[_0x5771('0x4b')](handleError(_0x2f1b1d,null));};exports[_0x5771('0x2b')]=function(_0x2f44a1,_0x45f6f1){return db['FaxQueue'][_0x5771('0x4a')]({'where':{'id':_0x2f44a1[_0x5771('0x56')]['id']}})[_0x5771('0x2a')](handleEntityNotFound(_0x45f6f1,null))[_0x5771('0x2a')](removeEntity(_0x45f6f1,null))['catch'](handleError(_0x45f6f1,null));};exports[_0x5771('0x57')]=function(_0x55b4ea,_0x13b2e7){return db[_0x5771('0x33')][_0x5771('0x57')]()[_0x5771('0x2a')](respondWithResult(_0x13b2e7,null))[_0x5771('0x4b')](handleError(_0x13b2e7,null));};exports[_0x5771('0x58')]=function(_0x4e9e6b,_0x2f1a14,_0x4516f5){var _0x2d384b={'raw':!![],'where':{}},_0x2e8eba={},_0x315470;return db[_0x5771('0x33')][_0x5771('0x59')]({'where':{'id':_0x4e9e6b[_0x5771('0x56')]['id']}})[_0x5771('0x2a')](handleEntityNotFound(_0x2f1a14,null))[_0x5771('0x2a')](function(_0x38feb6){if(_0x38feb6){_0x315470=_0x38feb6[_0x5771('0x4f')]({'plain':!![]});_0x2e8eba[_0x5771('0x37')]=_[_0x5771('0x39')](db['UserFaxQueue'][_0x5771('0x34')]);_0x2e8eba[_0x5771('0x38')]=_['keys'](_0x4e9e6b[_0x5771('0x38')]);_0x2e8eba[_0x5771('0x3a')]=_[_0x5771('0x3c')](_0x2e8eba[_0x5771('0x37')],_0x2e8eba[_0x5771('0x38')]);_0x2d384b['attributes']=_[_0x5771('0x3c')](_0x2e8eba[_0x5771('0x37')],qs[_0x5771('0x3d')](_0x4e9e6b[_0x5771('0x38')][_0x5771('0x3d')]));_0x2d384b[_0x5771('0x3b')]=_0x2d384b[_0x5771('0x3b')][_0x5771('0x46')]?_0x2d384b['attributes']:_0x2e8eba['model'];if(!_0x4e9e6b['query'][_0x5771('0x3e')]('nolimit')){_0x2d384b[_0x5771('0x23')]=qs[_0x5771('0x23')](_0x4e9e6b[_0x5771('0x38')][_0x5771('0x23')]);_0x2d384b[_0x5771('0x21')]=qs[_0x5771('0x21')](_0x4e9e6b['query']['offset']);}_0x2d384b['order']=qs['sort'](_0x4e9e6b[_0x5771('0x38')][_0x5771('0x5a')]);_0x2d384b['where']=qs[_0x5771('0x3a')](_[_0x5771('0x5b')](_0x4e9e6b[_0x5771('0x38')],_0x2e8eba['filters']));_0x2d384b[_0x5771('0x41')][_0x5771('0x5c')]=_0x38feb6['id'];if(_0x4e9e6b[_0x5771('0x38')][_0x5771('0x5d')]){_0x2d384b['where']=_[_0x5771('0x48')](_0x2d384b[_0x5771('0x41')],{'$or':_[_0x5771('0x32')](_0x2d384b[_0x5771('0x3b')],function(_0x50a301){var _0x5d8f9c={};_0x5d8f9c[_0x50a301]={'$like':'%'+_0x4e9e6b['query']['filter']+'%'};return _0x5d8f9c;})});}_0x2d384b=_[_0x5771('0x48')]({},_0x2d384b,_0x4e9e6b[_0x5771('0x49')]);return db[_0x5771('0x5e')][_0x5771('0x5f')](_0x2d384b);}})[_0x5771('0x2a')](function(_0x49d8c2){if(_0x49d8c2){return db[_0x5771('0x60')][_0x5771('0x61')]({'where':{'id':_['map'](_0x49d8c2,_0x5771('0x62')),'role':'agent'},'attributes':['id',_0x5771('0x30'),_0x5771('0x63'),_0x5771('0x64'),_0x5771('0x65')]});}})[_0x5771('0x2a')](function(_0x3230dc){if(_0x3230dc){return{'count':_0x3230dc[_0x5771('0x24')],'rows':_[_0x5771('0x32')](_0x3230dc[_0x5771('0x44')],function(_0x1ea857){return{'membername':_0x1ea857[_0x5771('0x30')],'UserId':_0x1ea857['id'],'queue_name':_0x315470['name'],'FaxQueueId':_0x315470['id'],'interface':util['format'](_0x5771('0x66'),'SIP',_0x1ea857[_0x5771('0x30')]),'penalty':0x0,'paused':_0x1ea857['faxPause'],'createdAt':_0x1ea857[_0x5771('0x65')],'updatedAt':_0x1ea857['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x2f1a14,_0x2d384b))[_0x5771('0x4b')](handleError(_0x2f1a14,null));};exports['getTeams']=function(_0x11ee86,_0x46c836,_0x1c1b0e){var _0x1d8649={};var _0x593fd5={};var _0x54d12e;var _0x13de2f;return db[_0x5771('0x33')][_0x5771('0x59')]({'where':{'id':_0x11ee86[_0x5771('0x56')]['id']}})[_0x5771('0x2a')](handleEntityNotFound(_0x46c836,null))[_0x5771('0x2a')](function(_0x4d9398){if(_0x4d9398){_0x54d12e=_0x4d9398;_0x593fd5[_0x5771('0x37')]=_[_0x5771('0x39')](db[_0x5771('0x67')][_0x5771('0x34')]);_0x593fd5[_0x5771('0x38')]=_['keys'](_0x11ee86[_0x5771('0x38')]);_0x593fd5['filters']=_[_0x5771('0x3c')](_0x593fd5[_0x5771('0x37')],_0x593fd5['query']);_0x1d8649[_0x5771('0x3b')]=_[_0x5771('0x3c')](_0x593fd5[_0x5771('0x37')],qs[_0x5771('0x3d')](_0x11ee86[_0x5771('0x38')][_0x5771('0x3d')]));_0x1d8649[_0x5771('0x3b')]=_0x1d8649['attributes'][_0x5771('0x46')]?_0x1d8649[_0x5771('0x3b')]:_0x593fd5['model'];_0x1d8649[_0x5771('0x40')]=qs[_0x5771('0x5a')](_0x11ee86[_0x5771('0x38')][_0x5771('0x5a')]);_0x1d8649[_0x5771('0x41')]=qs[_0x5771('0x3a')](_[_0x5771('0x5b')](_0x11ee86['query'],_0x593fd5[_0x5771('0x3a')]));if(_0x11ee86[_0x5771('0x38')][_0x5771('0x5d')]){_0x1d8649[_0x5771('0x41')]=_[_0x5771('0x48')](_0x1d8649['where'],{'$or':_[_0x5771('0x32')](_0x1d8649[_0x5771('0x3b')],function(_0x213eb1){var _0x1c0983={};_0x1c0983[_0x213eb1]={'$like':'%'+_0x11ee86[_0x5771('0x38')]['filter']+'%'};return _0x1c0983;})});}_0x1d8649=_[_0x5771('0x48')]({},_0x1d8649,_0x11ee86[_0x5771('0x49')]);return _0x54d12e[_0x5771('0x68')](_0x1d8649);}})[_0x5771('0x2a')](function(_0x202290){if(_0x202290){_0x13de2f=_0x202290['length'];if(!_0x11ee86[_0x5771('0x38')][_0x5771('0x3e')](_0x5771('0x3f'))){_0x1d8649[_0x5771('0x23')]=qs[_0x5771('0x23')](_0x11ee86[_0x5771('0x38')][_0x5771('0x23')]);_0x1d8649['offset']=qs[_0x5771('0x21')](_0x11ee86[_0x5771('0x38')][_0x5771('0x21')]);}return _0x54d12e[_0x5771('0x68')](_0x1d8649);}})[_0x5771('0x2a')](function(_0x13d891){if(_0x13d891){return _0x13d891?{'count':_0x13de2f,'rows':_0x13d891}:null;}})[_0x5771('0x2a')](respondWithResult(_0x46c836,null))[_0x5771('0x4b')](handleError(_0x46c836,null));};exports[_0x5771('0x69')]=function(_0x31167b,_0x53166b,_0x53990d){var _0x3ec5a7=_0x31167b[_0x5771('0x4d')]['ids'];return db[_0x5771('0x67')]['findAll']({'where':{'id':_0x3ec5a7},'attributes':['id'],'include':[{'model':db[_0x5771('0x60')],'as':_0x5771('0x6a'),'attributes':['id',_0x5771('0x30'),_0x5771('0x6b'),_0x5771('0x6c'),_0x5771('0x6d')],'raw':!![]}]})[_0x5771('0x2a')](function(_0x3d14f9){if(_0x3d14f9){var _0x41ac96=_[_0x5771('0x6e')](_0x3d14f9,function(_0x1b0961){var _0x4505fc=_0x1b0961['get']({'plain':!![]});return _0x4505fc[_0x5771('0x6a')];});return db[_0x5771('0x33')]['find']({'where':{'id':_0x31167b['params']['id']}})[_0x5771('0x2a')](function(_0x399fa7){return db['sequelize'][_0x5771('0x6f')](function(_0x38fc95){return _0x399fa7['addTeams'](_0x3ec5a7,{'transaction':_0x38fc95})[_0x5771('0x2a')](function(){return BPromise[_0x5771('0x70')](_0x41ac96,function(_0x1eadaf){return db[_0x5771('0x5e')][_0x5771('0x71')]({'where':{'UserId':_0x1eadaf['id'],'FaxQueueId':_0x31167b[_0x5771('0x56')]['id']},'transaction':_0x38fc95});});})[_0x5771('0x2a')](function(){_0x41ac96[_0x5771('0x72')](function(_0x5c21ff){socket['emit']('userFaxQueue:save',{'UserId':_0x5c21ff['id'],'FaxQueueId':_0x399fa7['id']});});});});});}})[_0x5771('0x2a')](respondWithStatusCode(_0x53166b,null))['catch'](handleError(_0x53166b,null));};exports[_0x5771('0x73')]=function(_0x2770c2,_0x3174ed,_0x53a5db){return db[_0x5771('0x67')][_0x5771('0x5f')]({'where':{'id':_0x2770c2[_0x5771('0x38')][_0x5771('0x74')]},'attributes':['id'],'include':[{'model':db[_0x5771('0x60')],'as':_0x5771('0x6a'),'attributes':['id'],'raw':!![]}]})[_0x5771('0x2a')](handleEntityNotFound(_0x3174ed,null))[_0x5771('0x2a')](function(_0x54c7dc){var _0x37589f=_[_0x5771('0x32')](_0x54c7dc,'id');var _0x58d44e=[];var _0x26c793=[];var _0x57701a=squel['select']();_0x57701a['field'](_0x5771('0x75'))[_0x5771('0x76')](_0x5771('0x77'),'tq')[_0x5771('0x78')](_0x5771('0x79'),'ut',_0x5771('0x7a'))[_0x5771('0x41')](_0x5771('0x7b'),_0x2770c2[_0x5771('0x56')]['id']);for(var _0x58660f=0x0;_0x58660f<_0x54c7dc[_0x5771('0x46')];_0x58660f+=0x1){let _0x3b0eb5=_0x54c7dc[_0x58660f];for(var _0x37af8c=0x0;_0x37af8c<_0x3b0eb5[_0x5771('0x6a')]['length'];_0x37af8c+=0x1){let _0x4caed2=_0x3b0eb5[_0x5771('0x6a')][_0x37af8c];var _0x2fbf45=_0x57701a[_0x5771('0x7c')]();_0x2fbf45[_0x5771('0x41')](_0x5771('0x7d'),_0x4caed2['id']);_0x26c793['push'](db['sequelize']['query'](_0x2fbf45['toString'](),{'type':db[_0x5771('0x7e')][_0x5771('0x7f')]['SELECT']})['then'](function(_0x4e367){if(_0x4e367[_0x5771('0x46')]===0x1){return _0x4caed2['id'];}else{var _0x143e82=_[_0x5771('0x80')](_[_0x5771('0x32')](_0x4e367,_0x5771('0x81')),function(_0x41d190){return _[_0x5771('0x82')](_0x37589f,_0x41d190);});if(_0x143e82){return _0x4caed2['id'];}}}));}}return BPromise[_0x5771('0x83')](_0x26c793)[_0x5771('0x2a')](function(_0x240680){_0x58d44e=_(_0x58d44e)['union'](_0x240680)[_0x5771('0x84')]()[_0x5771('0x85')]();return db[_0x5771('0x33')][_0x5771('0x4a')]({'where':{'id':_0x2770c2['params']['id']}})['then'](function(_0x1080f2){return db[_0x5771('0x7e')][_0x5771('0x6f')](function(_0x2157a3){return _0x1080f2[_0x5771('0x73')](_0x2770c2['query'][_0x5771('0x74')],{'transaction':_0x2157a3})[_0x5771('0x2a')](function(){if(!_['isEmpty'](_0x58d44e)){return _0x1080f2[_0x5771('0x86')](_0x58d44e,{'transaction':_0x2157a3});}})['then'](function(){_0x58d44e[_0x5771('0x72')](function(_0xfd917a){socket['emit']('userFaxQueue:remove',{'UserId':_0xfd917a,'FaxQueueId':_0x1080f2['id']});});});});});});})[_0x5771('0x2a')](respondWithStatusCode(_0x3174ed,null))['catch'](handleError(_0x3174ed,null));};exports[_0x5771('0x87')]=function(_0x430131,_0x30d488,_0x1b9129){return db[_0x5771('0x33')][_0x5771('0x4a')]({'where':{'id':_0x430131[_0x5771('0x56')]['id']}})[_0x5771('0x2a')](handleEntityNotFound(_0x30d488,null))[_0x5771('0x2a')](function(_0x3c7396){if(_0x3c7396){return _0x3c7396['addAgents'](_0x430131[_0x5771('0x4d')][_0x5771('0x74')],_[_0x5771('0x88')](_0x430131['body'],[_0x5771('0x74'),'id'])||{})['spread'](function(_0x5753d3){for(var _0x3cf8b5=0x0;_0x3cf8b5<_0x430131['body'][_0x5771('0x74')][_0x5771('0x46')];_0x3cf8b5+=0x1){socket[_0x5771('0x89')](_0x5771('0x8a'),{'UserId':Number(_0x430131['body'][_0x5771('0x74')][_0x3cf8b5]),'FaxQueueId':Number(_0x430131[_0x5771('0x56')]['id'])});}return _0x5753d3;});}})[_0x5771('0x2a')](respondWithResult(_0x30d488,null))[_0x5771('0x4b')](handleError(_0x30d488,null));};exports[_0x5771('0x86')]=function(_0x28d195,_0xa04d4e,_0x135dc0){return db[_0x5771('0x33')]['find']({'where':{'id':_0x28d195[_0x5771('0x56')]['id']}})['then'](handleEntityNotFound(_0xa04d4e,null))[_0x5771('0x2a')](function(_0x4673b3){if(_0x4673b3){return _0x4673b3['removeAgents'](_0x28d195['query'][_0x5771('0x74')])[_0x5771('0x2a')](function(){if(_[_0x5771('0x8b')](_0x28d195[_0x5771('0x38')][_0x5771('0x74')])){for(var _0x101537=0x0;_0x101537<_0x28d195[_0x5771('0x38')]['ids']['length'];_0x101537+=0x1){socket[_0x5771('0x89')](_0x5771('0x8c'),{'UserId':Number(_0x28d195[_0x5771('0x38')][_0x5771('0x74')][_0x101537]),'FaxQueueId':Number(_0x28d195[_0x5771('0x56')]['id'])});}}else{socket[_0x5771('0x89')]('userFaxQueue:remove',{'UserId':Number(_0x28d195[_0x5771('0x38')][_0x5771('0x74')]),'FaxQueueId':Number(_0x28d195[_0x5771('0x56')]['id'])});}});}})[_0x5771('0x2a')](respondWithStatusCode(_0xa04d4e,null))[_0x5771('0x4b')](handleError(_0xa04d4e,null));};exports[_0x5771('0x8d')]=function(_0x2dbde5,_0x48157c,_0x584bbd){var _0x1590fd={};var _0x3928bd={};var _0x27ab47;var _0x472f38;return db[_0x5771('0x33')]['findOne']({'where':{'id':_0x2dbde5[_0x5771('0x56')]['id']}})['then'](handleEntityNotFound(_0x48157c,null))[_0x5771('0x2a')](function(_0x5ba119){if(_0x5ba119){_0x27ab47=_0x5ba119;_0x3928bd[_0x5771('0x37')]=_[_0x5771('0x39')](db[_0x5771('0x60')][_0x5771('0x34')]);_0x3928bd['query']=_[_0x5771('0x39')](_0x2dbde5[_0x5771('0x38')]);_0x3928bd['filters']=_[_0x5771('0x3c')](_0x3928bd[_0x5771('0x37')],_0x3928bd[_0x5771('0x38')]);_0x1590fd[_0x5771('0x3b')]=_[_0x5771('0x3c')](_0x3928bd[_0x5771('0x37')],qs[_0x5771('0x3d')](_0x2dbde5[_0x5771('0x38')][_0x5771('0x3d')]));_0x1590fd[_0x5771('0x3b')]=_0x1590fd[_0x5771('0x3b')][_0x5771('0x46')]?_0x1590fd['attributes']:_0x3928bd[_0x5771('0x37')];_0x1590fd['order']=qs[_0x5771('0x5a')](_0x2dbde5[_0x5771('0x38')][_0x5771('0x5a')]);_0x1590fd['where']=qs['filters'](_['pick'](_0x2dbde5[_0x5771('0x38')],_0x3928bd[_0x5771('0x3a')]));if(_0x2dbde5[_0x5771('0x38')][_0x5771('0x5d')]){_0x1590fd[_0x5771('0x41')]=_[_0x5771('0x48')](_0x1590fd[_0x5771('0x41')],{'$or':_[_0x5771('0x32')](_0x1590fd[_0x5771('0x3b')],function(_0x3517d6){var _0x4835c6={};_0x4835c6[_0x3517d6]={'$like':'%'+_0x2dbde5[_0x5771('0x38')][_0x5771('0x5d')]+'%'};return _0x4835c6;})});}_0x1590fd=_['merge']({},_0x1590fd,_0x2dbde5['options']);return _0x27ab47[_0x5771('0x8d')](_0x1590fd);}})[_0x5771('0x2a')](function(_0xbb8c6d){if(_0xbb8c6d){_0x472f38=_0xbb8c6d[_0x5771('0x46')];if(!_0x2dbde5[_0x5771('0x38')][_0x5771('0x3e')]('nolimit')){_0x1590fd['limit']=qs[_0x5771('0x23')](_0x2dbde5[_0x5771('0x38')]['limit']);_0x1590fd[_0x5771('0x21')]=qs[_0x5771('0x21')](_0x2dbde5[_0x5771('0x38')]['offset']);}return _0x27ab47[_0x5771('0x8d')](_0x1590fd);}})[_0x5771('0x2a')](function(_0x57ffbd){if(_0x57ffbd){return _0x57ffbd?{'count':_0x472f38,'rows':_0x57ffbd}:null;}})[_0x5771('0x2a')](respondWithResult(_0x48157c,null))[_0x5771('0x4b')](handleError(_0x48157c,null));};
\ No newline at end of file