Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / faxQueue / faxQueue.controller.js
index 7d5b723..065482d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe651=['emit','userFaxQueue:save','select','field','from','team_has_fax_queues','user_has_teams','FaxQueueId\x20=\x20?','ut.UserId\x20=\x20?','push','sequelize','toString','SELECT','every','TeamId','includes','all','value','removeTeams','isEmpty','addAgents','omit','removeAgents','isArray','userFaxQueue:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','crypto','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','get','FaxQueues','UserProfileResource','end','stack','name','send','index','FaxQueue','rawAttributes','fieldName','type','keys','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','catch','params','length','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','getMembers','findOne','UserFaxQueue','FaxQueueId','User','findAndCountAll','UserId','agent','faxPause','createdAt','map','format','%s/%s','SIP','updatedAt','Team','getTeams','ids','Agents','interface','flatMap','transaction','each','findOrCreate','forEach'];(function(_0x3ff4a3,_0xa5bfa6){var _0x38676f=function(_0x3ab2b1){while(--_0x3ab2b1){_0x3ff4a3['push'](_0x3ff4a3['shift']());}};_0x38676f(++_0xa5bfa6);}(_0xe651,0xa4));var _0x1e65=function(_0x3e478c,_0x3afee8){_0x3e478c=_0x3e478c-0x0;var _0x3a0906=_0xe651[_0x3e478c];return _0x3a0906;};'use strict';var emlformat=require(_0x1e65('0x0'));var rimraf=require(_0x1e65('0x1'));var zipdir=require(_0x1e65('0x2'));var jsonpatch=require(_0x1e65('0x3'));var rp=require(_0x1e65('0x4'));var moment=require(_0x1e65('0x5'));var BPromise=require(_0x1e65('0x6'));var Mustache=require(_0x1e65('0x7'));var util=require(_0x1e65('0x8'));var path=require('path');var sox=require(_0x1e65('0x9'));var csv=require(_0x1e65('0xa'));var ejs=require(_0x1e65('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0x1e65('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x1e65('0xa'));var querystring=require(_0x1e65('0xd'));var Papa=require(_0x1e65('0xe'));var Redis=require(_0x1e65('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x1e65('0x10'));var hardwareService=require(_0x1e65('0x11'));var logger=require(_0x1e65('0x12'))(_0x1e65('0x13'));var utils=require('../../config/utils');var config=require(_0x1e65('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0x1e65('0x15'))['db'];config[_0x1e65('0x16')]=_[_0x1e65('0x17')](config[_0x1e65('0x16')],{'host':_0x1e65('0x18'),'port':0x18eb});var socket=require(_0x1e65('0x19'))(new Redis(config[_0x1e65('0x16')]));require('./faxQueue.socket')['register'](socket);function respondWithStatusCode(_0x5d2c8,_0x1e1a10){_0x1e1a10=_0x1e1a10||0xcc;return function(_0x2f47fb){if(_0x2f47fb){return _0x5d2c8[_0x1e65('0x1a')](_0x1e1a10);}return _0x5d2c8[_0x1e65('0x1b')](_0x1e1a10)['end']();};}function respondWithResult(_0x96a6ae,_0x281d51){_0x281d51=_0x281d51||0xc8;return function(_0x4baae1){if(_0x4baae1){return _0x96a6ae[_0x1e65('0x1b')](_0x281d51)[_0x1e65('0x1c')](_0x4baae1);}};}function respondWithFilteredResult(_0x4ef4e9,_0x238dc8){return function(_0x4b3f45){if(_0x4b3f45){var _0x3cbfd1=typeof _0x238dc8[_0x1e65('0x1d')]===_0x1e65('0x1e')&&typeof _0x238dc8['limit']===_0x1e65('0x1e');var _0x346a8e=_0x4b3f45[_0x1e65('0x1f')];var _0x147275=_0x3cbfd1?0x0:_0x238dc8[_0x1e65('0x1d')];var _0x158f2f=_0x3cbfd1?_0x4b3f45[_0x1e65('0x1f')]:_0x238dc8[_0x1e65('0x1d')]+_0x238dc8[_0x1e65('0x20')];var _0x8f6022;if(_0x158f2f>=_0x346a8e){_0x158f2f=_0x346a8e;_0x8f6022=0xc8;}else{_0x8f6022=0xce;}_0x4ef4e9[_0x1e65('0x1b')](_0x8f6022);return _0x4ef4e9[_0x1e65('0x21')](_0x1e65('0x22'),_0x147275+'-'+_0x158f2f+'/'+_0x346a8e)['json'](_0x4b3f45);}return null;};}function patchUpdates(_0x4041b5){return function(_0x1c23c1){try{jsonpatch[_0x1e65('0x23')](_0x1c23c1,_0x4041b5,!![]);}catch(_0x1cfafd){return BPromise[_0x1e65('0x24')](_0x1cfafd);}return _0x1c23c1[_0x1e65('0x25')]();};}function saveUpdates(_0x5a38b6,_0xd2586a){return function(_0x5ca1d3){if(_0x5ca1d3){return _0x5ca1d3[_0x1e65('0x26')](_0x5a38b6)[_0x1e65('0x27')](function(_0x1cf1fd){return _0x1cf1fd;});}return null;};}function removeEntity(_0x2fa233,_0x79aa3d){return function(_0x330484){if(_0x330484){return _0x330484[_0x1e65('0x28')]()[_0x1e65('0x27')](function(){var _0x1e100f=_0x330484[_0x1e65('0x29')]({'plain':!![]});var _0x451331=_0x1e65('0x2a');return db[_0x1e65('0x2b')][_0x1e65('0x28')]({'where':{'type':_0x451331,'resourceId':_0x1e100f['id']}})['then'](function(){return _0x330484;});})[_0x1e65('0x27')](function(){_0x2fa233[_0x1e65('0x1b')](0xcc)[_0x1e65('0x2c')]();});}};}function handleEntityNotFound(_0x182510,_0x4be838){return function(_0x49f99d){if(!_0x49f99d){_0x182510['sendStatus'](0x194);}return _0x49f99d;};}function handleError(_0x9535e7,_0x1a901f){_0x1a901f=_0x1a901f||0x1f4;return function(_0x18f55d){logger['error'](_0x18f55d[_0x1e65('0x2d')]);if(_0x18f55d[_0x1e65('0x2e')]){delete _0x18f55d[_0x1e65('0x2e')];}_0x9535e7['status'](_0x1a901f)[_0x1e65('0x2f')](_0x18f55d);};}exports[_0x1e65('0x30')]=function(_0x51c988,_0x179292){var _0x2acebb={},_0x550559={},_0x23ca63={'count':0x0,'rows':[]};var _0x51053b=_['map'](db[_0x1e65('0x31')][_0x1e65('0x32')],function(_0x2f6855){return{'name':_0x2f6855[_0x1e65('0x33')],'type':_0x2f6855[_0x1e65('0x34')]['key']};});_0x550559['model']=_['map'](_0x51053b,'name');_0x550559['query']=_[_0x1e65('0x35')](_0x51c988[_0x1e65('0x36')]);_0x550559[_0x1e65('0x37')]=_[_0x1e65('0x38')](_0x550559[_0x1e65('0x39')],_0x550559[_0x1e65('0x36')]);_0x2acebb[_0x1e65('0x3a')]=_[_0x1e65('0x38')](_0x550559[_0x1e65('0x39')],qs['fields'](_0x51c988['query'][_0x1e65('0x3b')]));_0x2acebb[_0x1e65('0x3a')]=_0x2acebb['attributes']['length']?_0x2acebb['attributes']:_0x550559[_0x1e65('0x39')];if(!_0x51c988[_0x1e65('0x36')][_0x1e65('0x3c')](_0x1e65('0x3d'))){_0x2acebb[_0x1e65('0x20')]=qs[_0x1e65('0x20')](_0x51c988['query'][_0x1e65('0x20')]);_0x2acebb[_0x1e65('0x1d')]=qs['offset'](_0x51c988[_0x1e65('0x36')]['offset']);}_0x2acebb[_0x1e65('0x3e')]=qs[_0x1e65('0x3f')](_0x51c988[_0x1e65('0x36')][_0x1e65('0x3f')]);_0x2acebb[_0x1e65('0x40')]=qs[_0x1e65('0x37')](_[_0x1e65('0x41')](_0x51c988['query'],_0x550559['filters']),_0x51053b);if(_0x51c988['query'][_0x1e65('0x42')]){_0x2acebb[_0x1e65('0x40')]=_[_0x1e65('0x43')](_0x2acebb['where'],{'$or':_['map'](_0x51053b,function(_0x4edf4c){if(_0x4edf4c[_0x1e65('0x34')]!==_0x1e65('0x44')){var _0x7b305e={};_0x7b305e[_0x4edf4c[_0x1e65('0x2e')]]={'$like':'%'+_0x51c988[_0x1e65('0x36')]['filter']+'%'};return _0x7b305e;}})});}_0x2acebb=_[_0x1e65('0x43')]({},_0x2acebb,_0x51c988[_0x1e65('0x45')]);var _0x3bc825={'where':_0x2acebb['where']};return db[_0x1e65('0x31')][_0x1e65('0x1f')](_0x3bc825)[_0x1e65('0x27')](function(_0xd19ee){_0x23ca63[_0x1e65('0x1f')]=_0xd19ee;if(_0x51c988[_0x1e65('0x36')][_0x1e65('0x46')]){_0x2acebb['include']=[{'all':!![]}];}return db[_0x1e65('0x31')][_0x1e65('0x47')](_0x2acebb);})[_0x1e65('0x27')](function(_0x4e2402){_0x23ca63['rows']=_0x4e2402;return _0x23ca63;})['then'](respondWithFilteredResult(_0x179292,_0x2acebb))[_0x1e65('0x48')](handleError(_0x179292,null));};exports['show']=function(_0x222c12,_0x46d752){var _0x43d745={'raw':!![],'where':{'id':_0x222c12[_0x1e65('0x49')]['id']}},_0x329f79={};_0x329f79[_0x1e65('0x39')]=_[_0x1e65('0x35')](db['FaxQueue'][_0x1e65('0x32')]);_0x329f79[_0x1e65('0x36')]=_['keys'](_0x222c12[_0x1e65('0x36')]);_0x329f79[_0x1e65('0x37')]=_['intersection'](_0x329f79['model'],_0x329f79[_0x1e65('0x36')]);_0x43d745['attributes']=_[_0x1e65('0x38')](_0x329f79['model'],qs[_0x1e65('0x3b')](_0x222c12['query']['fields']));_0x43d745[_0x1e65('0x3a')]=_0x43d745['attributes'][_0x1e65('0x4a')]?_0x43d745['attributes']:_0x329f79[_0x1e65('0x39')];if(_0x222c12[_0x1e65('0x36')][_0x1e65('0x46')]){_0x43d745['include']=[{'all':!![]}];}_0x43d745=_[_0x1e65('0x43')]({},_0x43d745,_0x222c12[_0x1e65('0x45')]);return db[_0x1e65('0x31')][_0x1e65('0x4b')](_0x43d745)[_0x1e65('0x27')](handleEntityNotFound(_0x46d752,null))[_0x1e65('0x27')](respondWithResult(_0x46d752,null))[_0x1e65('0x48')](handleError(_0x46d752,null));};exports['create']=function(_0xed79b6,_0x631984){return db[_0x1e65('0x31')][_0x1e65('0x4c')](_0xed79b6[_0x1e65('0x4d')],{})[_0x1e65('0x27')](function(_0x346a90){var _0x4d32a0=_0xed79b6[_0x1e65('0x4e')][_0x1e65('0x29')]({'plain':!![]});if(!_0x4d32a0)throw new Error(_0x1e65('0x4f'));if(_0x4d32a0[_0x1e65('0x50')]===_0x1e65('0x4e')){var _0x35d632=_0x346a90[_0x1e65('0x29')]({'plain':!![]});var _0x2197bd=_0x1e65('0x2a');return db[_0x1e65('0x51')][_0x1e65('0x4b')]({'where':{'name':_0x2197bd,'userProfileId':_0x4d32a0[_0x1e65('0x52')]},'raw':!![]})[_0x1e65('0x27')](function(_0x32ecb2){if(_0x32ecb2&&_0x32ecb2[_0x1e65('0x53')]===0x0){return db[_0x1e65('0x2b')][_0x1e65('0x4c')]({'name':_0x35d632[_0x1e65('0x2e')],'resourceId':_0x35d632['id'],'type':_0x32ecb2[_0x1e65('0x2e')],'sectionId':_0x32ecb2['id']},{})[_0x1e65('0x27')](function(){return _0x346a90;});}else{return _0x346a90;}})[_0x1e65('0x48')](function(_0x3bb697){logger[_0x1e65('0x54')](_0x1e65('0x55'),_0x3bb697);throw _0x3bb697;});}return _0x346a90;})['then'](respondWithResult(_0x631984,0xc9))[_0x1e65('0x48')](handleError(_0x631984,null));};exports[_0x1e65('0x26')]=function(_0x45d3ae,_0x57ae2c){if(_0x45d3ae[_0x1e65('0x4d')]['id']){delete _0x45d3ae[_0x1e65('0x4d')]['id'];}return db[_0x1e65('0x31')][_0x1e65('0x4b')]({'where':{'id':_0x45d3ae[_0x1e65('0x49')]['id']}})['then'](handleEntityNotFound(_0x57ae2c,null))['then'](saveUpdates(_0x45d3ae[_0x1e65('0x4d')],null))[_0x1e65('0x27')](respondWithResult(_0x57ae2c,null))[_0x1e65('0x48')](handleError(_0x57ae2c,null));};exports[_0x1e65('0x28')]=function(_0x127809,_0x49abc6){return db[_0x1e65('0x31')][_0x1e65('0x4b')]({'where':{'id':_0x127809['params']['id']}})[_0x1e65('0x27')](handleEntityNotFound(_0x49abc6,null))[_0x1e65('0x27')](removeEntity(_0x49abc6,null))[_0x1e65('0x48')](handleError(_0x49abc6,null));};exports['describe']=function(_0x31bfc0,_0x206acd){return db[_0x1e65('0x31')][_0x1e65('0x56')]()[_0x1e65('0x27')](respondWithResult(_0x206acd,null))[_0x1e65('0x48')](handleError(_0x206acd,null));};exports[_0x1e65('0x57')]=function(_0x5651a7,_0x54fd9c,_0xb2ed19){var _0x6ea1fe={'raw':!![],'where':{}},_0x5aaed6={},_0x27e23c;return db[_0x1e65('0x31')][_0x1e65('0x58')]({'where':{'id':_0x5651a7[_0x1e65('0x49')]['id']}})[_0x1e65('0x27')](handleEntityNotFound(_0x54fd9c,null))[_0x1e65('0x27')](function(_0x29262e){if(_0x29262e){_0x27e23c=_0x29262e[_0x1e65('0x29')]({'plain':!![]});_0x5aaed6['model']=_[_0x1e65('0x35')](db[_0x1e65('0x59')][_0x1e65('0x32')]);_0x5aaed6[_0x1e65('0x36')]=_['keys'](_0x5651a7[_0x1e65('0x36')]);_0x5aaed6[_0x1e65('0x37')]=_[_0x1e65('0x38')](_0x5aaed6[_0x1e65('0x39')],_0x5aaed6['query']);_0x6ea1fe[_0x1e65('0x3a')]=_[_0x1e65('0x38')](_0x5aaed6[_0x1e65('0x39')],qs['fields'](_0x5651a7['query'][_0x1e65('0x3b')]));_0x6ea1fe['attributes']=_0x6ea1fe['attributes']['length']?_0x6ea1fe[_0x1e65('0x3a')]:_0x5aaed6[_0x1e65('0x39')];if(!_0x5651a7[_0x1e65('0x36')]['hasOwnProperty'](_0x1e65('0x3d'))){_0x6ea1fe[_0x1e65('0x20')]=qs[_0x1e65('0x20')](_0x5651a7['query'][_0x1e65('0x20')]);_0x6ea1fe[_0x1e65('0x1d')]=qs['offset'](_0x5651a7[_0x1e65('0x36')][_0x1e65('0x1d')]);}_0x6ea1fe[_0x1e65('0x3e')]=qs[_0x1e65('0x3f')](_0x5651a7[_0x1e65('0x36')][_0x1e65('0x3f')]);_0x6ea1fe['where']=qs[_0x1e65('0x37')](_['pick'](_0x5651a7[_0x1e65('0x36')],_0x5aaed6[_0x1e65('0x37')]));_0x6ea1fe[_0x1e65('0x40')][_0x1e65('0x5a')]=_0x29262e['id'];if(_0x5651a7[_0x1e65('0x36')]['filter']){_0x6ea1fe[_0x1e65('0x40')]=_[_0x1e65('0x43')](_0x6ea1fe[_0x1e65('0x40')],{'$or':_['map'](_0x6ea1fe['attributes'],function(_0x4d7b3){var _0x26b392={};_0x26b392[_0x4d7b3]={'$like':'%'+_0x5651a7[_0x1e65('0x36')][_0x1e65('0x42')]+'%'};return _0x26b392;})});}_0x6ea1fe=_[_0x1e65('0x43')]({},_0x6ea1fe,_0x5651a7['options']);return db[_0x1e65('0x59')][_0x1e65('0x47')](_0x6ea1fe);}})[_0x1e65('0x27')](function(_0x34fd4f){if(_0x34fd4f){return db[_0x1e65('0x5b')][_0x1e65('0x5c')]({'where':{'id':_['map'](_0x34fd4f,_0x1e65('0x5d')),'role':_0x1e65('0x5e')},'attributes':['id','name',_0x1e65('0x5f'),'updatedAt',_0x1e65('0x60')]});}})['then'](function(_0x4e7280){if(_0x4e7280){return{'count':_0x4e7280[_0x1e65('0x1f')],'rows':_[_0x1e65('0x61')](_0x4e7280['rows'],function(_0x1db27e){return{'membername':_0x1db27e['name'],'UserId':_0x1db27e['id'],'queue_name':_0x27e23c['name'],'FaxQueueId':_0x27e23c['id'],'interface':util[_0x1e65('0x62')](_0x1e65('0x63'),_0x1e65('0x64'),_0x1db27e[_0x1e65('0x2e')]),'penalty':0x0,'paused':_0x1db27e[_0x1e65('0x5f')],'createdAt':_0x1db27e[_0x1e65('0x60')],'updatedAt':_0x1db27e[_0x1e65('0x65')]};})};}else{return{'count':0x0,'rows':[]};}})[_0x1e65('0x27')](respondWithFilteredResult(_0x54fd9c,_0x6ea1fe))[_0x1e65('0x48')](handleError(_0x54fd9c,null));};exports['getTeams']=function(_0x5a2557,_0x1457d0,_0x5c8e04){var _0x12597e={};var _0x17392b={};var _0x281cb8;var _0x38b5a5;return db[_0x1e65('0x31')][_0x1e65('0x58')]({'where':{'id':_0x5a2557['params']['id']}})['then'](handleEntityNotFound(_0x1457d0,null))[_0x1e65('0x27')](function(_0x2985c2){if(_0x2985c2){_0x281cb8=_0x2985c2;_0x17392b[_0x1e65('0x39')]=_['keys'](db[_0x1e65('0x66')]['rawAttributes']);_0x17392b[_0x1e65('0x36')]=_[_0x1e65('0x35')](_0x5a2557[_0x1e65('0x36')]);_0x17392b[_0x1e65('0x37')]=_[_0x1e65('0x38')](_0x17392b[_0x1e65('0x39')],_0x17392b[_0x1e65('0x36')]);_0x12597e[_0x1e65('0x3a')]=_[_0x1e65('0x38')](_0x17392b[_0x1e65('0x39')],qs[_0x1e65('0x3b')](_0x5a2557[_0x1e65('0x36')]['fields']));_0x12597e['attributes']=_0x12597e[_0x1e65('0x3a')]['length']?_0x12597e[_0x1e65('0x3a')]:_0x17392b[_0x1e65('0x39')];_0x12597e['order']=qs['sort'](_0x5a2557[_0x1e65('0x36')][_0x1e65('0x3f')]);_0x12597e[_0x1e65('0x40')]=qs[_0x1e65('0x37')](_[_0x1e65('0x41')](_0x5a2557['query'],_0x17392b['filters']));if(_0x5a2557[_0x1e65('0x36')]['filter']){_0x12597e[_0x1e65('0x40')]=_[_0x1e65('0x43')](_0x12597e[_0x1e65('0x40')],{'$or':_[_0x1e65('0x61')](_0x12597e[_0x1e65('0x3a')],function(_0x15954d){var _0x565c8c={};_0x565c8c[_0x15954d]={'$like':'%'+_0x5a2557[_0x1e65('0x36')][_0x1e65('0x42')]+'%'};return _0x565c8c;})});}_0x12597e=_[_0x1e65('0x43')]({},_0x12597e,_0x5a2557[_0x1e65('0x45')]);return _0x281cb8[_0x1e65('0x67')](_0x12597e);}})[_0x1e65('0x27')](function(_0x2f1eec){if(_0x2f1eec){_0x38b5a5=_0x2f1eec[_0x1e65('0x4a')];if(!_0x5a2557['query'][_0x1e65('0x3c')](_0x1e65('0x3d'))){_0x12597e['limit']=qs[_0x1e65('0x20')](_0x5a2557['query']['limit']);_0x12597e[_0x1e65('0x1d')]=qs[_0x1e65('0x1d')](_0x5a2557['query'][_0x1e65('0x1d')]);}return _0x281cb8['getTeams'](_0x12597e);}})[_0x1e65('0x27')](function(_0x82ba01){if(_0x82ba01){return _0x82ba01?{'count':_0x38b5a5,'rows':_0x82ba01}:null;}})['then'](respondWithResult(_0x1457d0,null))[_0x1e65('0x48')](handleError(_0x1457d0,null));};exports['addTeams']=function(_0x36d77b,_0x2a82fb,_0x3907b9){var _0x24f807=_0x36d77b[_0x1e65('0x4d')][_0x1e65('0x68')];return db[_0x1e65('0x66')][_0x1e65('0x47')]({'where':{'id':_0x24f807},'attributes':['id'],'include':[{'model':db['User'],'as':_0x1e65('0x69'),'attributes':['id',_0x1e65('0x2e'),'online','voicePause',_0x1e65('0x6a')],'raw':!![]}]})[_0x1e65('0x27')](function(_0x395a74){if(_0x395a74){var _0x5ce566=_[_0x1e65('0x6b')](_0x395a74,function(_0x2a319c){var _0x5b7434=_0x2a319c[_0x1e65('0x29')]({'plain':!![]});return _0x5b7434[_0x1e65('0x69')];});return db['FaxQueue'][_0x1e65('0x4b')]({'where':{'id':_0x36d77b[_0x1e65('0x49')]['id']}})[_0x1e65('0x27')](function(_0x66cfd7){return db['sequelize'][_0x1e65('0x6c')](function(_0x2df9a1){return _0x66cfd7['addTeams'](_0x24f807,{'transaction':_0x2df9a1})[_0x1e65('0x27')](function(){return BPromise[_0x1e65('0x6d')](_0x5ce566,function(_0x5e2951){return db[_0x1e65('0x59')][_0x1e65('0x6e')]({'where':{'UserId':_0x5e2951['id'],'FaxQueueId':_0x36d77b['params']['id']},'transaction':_0x2df9a1});});})[_0x1e65('0x27')](function(){_0x5ce566[_0x1e65('0x6f')](function(_0x49a394){socket[_0x1e65('0x70')](_0x1e65('0x71'),{'UserId':_0x49a394['id'],'FaxQueueId':_0x66cfd7['id']});});});});});}})[_0x1e65('0x27')](respondWithStatusCode(_0x2a82fb,null))['catch'](handleError(_0x2a82fb,null));};exports['removeTeams']=function(_0x3fe232,_0x21e518,_0xd320af){return db[_0x1e65('0x66')]['findAll']({'where':{'id':_0x3fe232['query'][_0x1e65('0x68')]},'attributes':['id'],'include':[{'model':db['User'],'as':_0x1e65('0x69'),'attributes':['id'],'raw':!![]}]})[_0x1e65('0x27')](handleEntityNotFound(_0x21e518,null))['then'](function(_0x5b1175){var _0x4e5e5a=_[_0x1e65('0x61')](_0x5b1175,'id');var _0x117e4e=[];var _0x37de0a=[];var _0x4b1f50=squel[_0x1e65('0x72')]();_0x4b1f50[_0x1e65('0x73')]('tq.TeamId')[_0x1e65('0x74')](_0x1e65('0x75'),'tq')['join'](_0x1e65('0x76'),'ut','ut.TeamId\x20=\x20tq.TeamId')[_0x1e65('0x40')](_0x1e65('0x77'),_0x3fe232['params']['id']);for(var _0x33d31f=0x0;_0x33d31f<_0x5b1175[_0x1e65('0x4a')];_0x33d31f+=0x1){let _0x573cd3=_0x5b1175[_0x33d31f];for(var _0x5ab6f4=0x0;_0x5ab6f4<_0x573cd3[_0x1e65('0x69')]['length'];_0x5ab6f4+=0x1){let _0x558e2b=_0x573cd3['Agents'][_0x5ab6f4];var _0x29b611=_0x4b1f50['clone']();_0x29b611[_0x1e65('0x40')](_0x1e65('0x78'),_0x558e2b['id']);_0x37de0a[_0x1e65('0x79')](db[_0x1e65('0x7a')][_0x1e65('0x36')](_0x29b611[_0x1e65('0x7b')](),{'type':db[_0x1e65('0x7a')]['QueryTypes'][_0x1e65('0x7c')]})[_0x1e65('0x27')](function(_0x4b768a){if(_0x4b768a[_0x1e65('0x4a')]===0x1){return _0x558e2b['id'];}else{var _0x31993c=_[_0x1e65('0x7d')](_['map'](_0x4b768a,_0x1e65('0x7e')),function(_0x1d4eca){return _[_0x1e65('0x7f')](_0x4e5e5a,_0x1d4eca);});if(_0x31993c){return _0x558e2b['id'];}}}));}}return BPromise[_0x1e65('0x80')](_0x37de0a)['then'](function(_0x626a00){_0x117e4e=_(_0x117e4e)['union'](_0x626a00)['compact']()[_0x1e65('0x81')]();return db[_0x1e65('0x31')][_0x1e65('0x4b')]({'where':{'id':_0x3fe232[_0x1e65('0x49')]['id']}})['then'](function(_0x1907f0){return db[_0x1e65('0x7a')]['transaction'](function(_0x51bf90){return _0x1907f0[_0x1e65('0x82')](_0x3fe232[_0x1e65('0x36')]['ids'],{'transaction':_0x51bf90})['then'](function(){if(!_[_0x1e65('0x83')](_0x117e4e)){return _0x1907f0['removeAgents'](_0x117e4e,{'transaction':_0x51bf90});}})[_0x1e65('0x27')](function(){_0x117e4e['forEach'](function(_0x1b09d4){socket[_0x1e65('0x70')]('userFaxQueue:remove',{'UserId':_0x1b09d4,'FaxQueueId':_0x1907f0['id']});});});});});});})[_0x1e65('0x27')](respondWithStatusCode(_0x21e518,null))[_0x1e65('0x48')](handleError(_0x21e518,null));};exports[_0x1e65('0x84')]=function(_0x34a012,_0x49f12a,_0xb825de){return db[_0x1e65('0x31')][_0x1e65('0x4b')]({'where':{'id':_0x34a012[_0x1e65('0x49')]['id']}})[_0x1e65('0x27')](handleEntityNotFound(_0x49f12a,null))[_0x1e65('0x27')](function(_0x1c87d8){if(_0x1c87d8){return _0x1c87d8[_0x1e65('0x84')](_0x34a012[_0x1e65('0x4d')][_0x1e65('0x68')],_[_0x1e65('0x85')](_0x34a012[_0x1e65('0x4d')],['ids','id'])||{})['spread'](function(_0x56b1d3){for(var _0x102f19=0x0;_0x102f19<_0x34a012['body'][_0x1e65('0x68')]['length'];_0x102f19+=0x1){socket[_0x1e65('0x70')]('userFaxQueue:save',{'UserId':Number(_0x34a012[_0x1e65('0x4d')][_0x1e65('0x68')][_0x102f19]),'FaxQueueId':Number(_0x34a012[_0x1e65('0x49')]['id'])});}return _0x56b1d3;});}})[_0x1e65('0x27')](respondWithResult(_0x49f12a,null))[_0x1e65('0x48')](handleError(_0x49f12a,null));};exports['removeAgents']=function(_0x338efe,_0x11050e,_0x24f70c){return db[_0x1e65('0x31')]['find']({'where':{'id':_0x338efe['params']['id']}})[_0x1e65('0x27')](handleEntityNotFound(_0x11050e,null))['then'](function(_0x17ce16){if(_0x17ce16){return _0x17ce16[_0x1e65('0x86')](_0x338efe[_0x1e65('0x36')][_0x1e65('0x68')])['then'](function(){if(_[_0x1e65('0x87')](_0x338efe[_0x1e65('0x36')][_0x1e65('0x68')])){for(var _0x29389c=0x0;_0x29389c<_0x338efe[_0x1e65('0x36')]['ids'][_0x1e65('0x4a')];_0x29389c+=0x1){socket[_0x1e65('0x70')]('userFaxQueue:remove',{'UserId':Number(_0x338efe[_0x1e65('0x36')][_0x1e65('0x68')][_0x29389c]),'FaxQueueId':Number(_0x338efe[_0x1e65('0x49')]['id'])});}}else{socket[_0x1e65('0x70')](_0x1e65('0x88'),{'UserId':Number(_0x338efe[_0x1e65('0x36')][_0x1e65('0x68')]),'FaxQueueId':Number(_0x338efe[_0x1e65('0x49')]['id'])});}});}})[_0x1e65('0x27')](respondWithStatusCode(_0x11050e,null))[_0x1e65('0x48')](handleError(_0x11050e,null));};exports[_0x1e65('0x89')]=function(_0x305627,_0x14a5dd,_0x1d3b79){var _0x1efdc8={};var _0x345ff9={};var _0x1175de;var _0x3fa4fe;return db['FaxQueue']['findOne']({'where':{'id':_0x305627[_0x1e65('0x49')]['id']}})['then'](handleEntityNotFound(_0x14a5dd,null))[_0x1e65('0x27')](function(_0x7a85cb){if(_0x7a85cb){_0x1175de=_0x7a85cb;_0x345ff9['model']=_[_0x1e65('0x35')](db[_0x1e65('0x5b')][_0x1e65('0x32')]);_0x345ff9['query']=_[_0x1e65('0x35')](_0x305627[_0x1e65('0x36')]);_0x345ff9[_0x1e65('0x37')]=_[_0x1e65('0x38')](_0x345ff9[_0x1e65('0x39')],_0x345ff9[_0x1e65('0x36')]);_0x1efdc8[_0x1e65('0x3a')]=_[_0x1e65('0x38')](_0x345ff9[_0x1e65('0x39')],qs[_0x1e65('0x3b')](_0x305627['query'][_0x1e65('0x3b')]));_0x1efdc8[_0x1e65('0x3a')]=_0x1efdc8[_0x1e65('0x3a')]['length']?_0x1efdc8['attributes']:_0x345ff9[_0x1e65('0x39')];_0x1efdc8[_0x1e65('0x3e')]=qs[_0x1e65('0x3f')](_0x305627[_0x1e65('0x36')][_0x1e65('0x3f')]);_0x1efdc8['where']=qs[_0x1e65('0x37')](_[_0x1e65('0x41')](_0x305627[_0x1e65('0x36')],_0x345ff9['filters']));if(_0x305627[_0x1e65('0x36')][_0x1e65('0x42')]){_0x1efdc8[_0x1e65('0x40')]=_[_0x1e65('0x43')](_0x1efdc8['where'],{'$or':_['map'](_0x1efdc8[_0x1e65('0x3a')],function(_0x449220){var _0x2ed866={};_0x2ed866[_0x449220]={'$like':'%'+_0x305627['query'][_0x1e65('0x42')]+'%'};return _0x2ed866;})});}_0x1efdc8=_[_0x1e65('0x43')]({},_0x1efdc8,_0x305627[_0x1e65('0x45')]);return _0x1175de[_0x1e65('0x89')](_0x1efdc8);}})['then'](function(_0x34b71f){if(_0x34b71f){_0x3fa4fe=_0x34b71f[_0x1e65('0x4a')];if(!_0x305627[_0x1e65('0x36')][_0x1e65('0x3c')](_0x1e65('0x3d'))){_0x1efdc8['limit']=qs[_0x1e65('0x20')](_0x305627['query']['limit']);_0x1efdc8[_0x1e65('0x1d')]=qs[_0x1e65('0x1d')](_0x305627[_0x1e65('0x36')][_0x1e65('0x1d')]);}return _0x1175de[_0x1e65('0x89')](_0x1efdc8);}})[_0x1e65('0x27')](function(_0x5cfd11){if(_0x5cfd11){return _0x5cfd11?{'count':_0x3fa4fe,'rows':_0x5cfd11}:null;}})[_0x1e65('0x27')](respondWithResult(_0x14a5dd,null))[_0x1e65('0x48')](handleError(_0x14a5dd,null));};
\ No newline at end of file
+var _0x9cef=['limit','count','set','Content-Range','apply','reject','save','update','then','destroy','FaxQueues','UserProfileResource','end','name','index','map','FaxQueue','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','findAll','rows','catch','show','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','getMembers','findOne','FaxQueueId','UserFaxQueue','User','findAndCountAll','UserId','agent','faxPause','updatedAt','createdAt','format','SIP','Team','getTeams','addTeams','Agents','online','voicePause','interface','sequelize','each','forEach','emit','userFaxQueue:save','removeTeams','ids','field','tq.TeamId','from','team_has_fax_queues','join','FaxQueueId\x20=\x20?','clone','ut.UserId\x20=\x20?','toString','QueryTypes','every','TeamId','includes','union','compact','transaction','isEmpty','removeAgents','userFaxQueue:remove','addAgents','spread','isArray','getAgents','eml-format','request-promise','moment','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','redis','defaults','localhost','./faxQueue.socket','register','sendStatus','status','json','offset','undefined'];(function(_0x5b644e,_0x2e5e07){var _0x49c6bf=function(_0x3032d9){while(--_0x3032d9){_0x5b644e['push'](_0x5b644e['shift']());}};_0x49c6bf(++_0x2e5e07);}(_0x9cef,0x184));var _0xf9ce=function(_0x36c55d,_0x1c8efa){_0x36c55d=_0x36c55d-0x0;var _0xa16625=_0x9cef[_0x36c55d];return _0xa16625;};'use strict';var emlformat=require(_0xf9ce('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xf9ce('0x1'));var moment=require(_0xf9ce('0x2'));var BPromise=require(_0xf9ce('0x3'));var Mustache=require(_0xf9ce('0x4'));var util=require('util');var path=require('path');var sox=require(_0xf9ce('0x5'));var csv=require(_0xf9ce('0x6'));var ejs=require(_0xf9ce('0x7'));var fs=require('fs');var fs_extra=require(_0xf9ce('0x8'));var _=require(_0xf9ce('0x9'));var squel=require(_0xf9ce('0xa'));var crypto=require(_0xf9ce('0xb'));var jsforce=require(_0xf9ce('0xc'));var deskjs=require(_0xf9ce('0xd'));var toCsv=require(_0xf9ce('0x6'));var querystring=require(_0xf9ce('0xe'));var Papa=require(_0xf9ce('0xf'));var Redis=require(_0xf9ce('0x10'));var authService=require(_0xf9ce('0x11'));var qs=require(_0xf9ce('0x12'));var as=require(_0xf9ce('0x13'));var hardwareService=require(_0xf9ce('0x14'));var logger=require(_0xf9ce('0x15'))(_0xf9ce('0x16'));var utils=require(_0xf9ce('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0xf9ce('0x18'));var db=require('../../mysqldb')['db'];config[_0xf9ce('0x19')]=_[_0xf9ce('0x1a')](config[_0xf9ce('0x19')],{'host':_0xf9ce('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf9ce('0x19')]));require(_0xf9ce('0x1c'))[_0xf9ce('0x1d')](socket);function respondWithStatusCode(_0x9352bc,_0xf06ba0){_0xf06ba0=_0xf06ba0||0xcc;return function(_0x3a8777){if(_0x3a8777){return _0x9352bc[_0xf9ce('0x1e')](_0xf06ba0);}return _0x9352bc[_0xf9ce('0x1f')](_0xf06ba0)['end']();};}function respondWithResult(_0x3fda05,_0x203e90){_0x203e90=_0x203e90||0xc8;return function(_0xfc87f1){if(_0xfc87f1){return _0x3fda05[_0xf9ce('0x1f')](_0x203e90)[_0xf9ce('0x20')](_0xfc87f1);}};}function respondWithFilteredResult(_0x5e4fb2,_0x4e02d8){return function(_0x54fe01){if(_0x54fe01){var _0x4dda82=typeof _0x4e02d8[_0xf9ce('0x21')]===_0xf9ce('0x22')&&typeof _0x4e02d8[_0xf9ce('0x23')]===_0xf9ce('0x22');var _0x5366d4=_0x54fe01[_0xf9ce('0x24')];var _0x176457=_0x4dda82?0x0:_0x4e02d8[_0xf9ce('0x21')];var _0x23c8be=_0x4dda82?_0x54fe01[_0xf9ce('0x24')]:_0x4e02d8[_0xf9ce('0x21')]+_0x4e02d8[_0xf9ce('0x23')];var _0x1c06dc;if(_0x23c8be>=_0x5366d4){_0x23c8be=_0x5366d4;_0x1c06dc=0xc8;}else{_0x1c06dc=0xce;}_0x5e4fb2[_0xf9ce('0x1f')](_0x1c06dc);return _0x5e4fb2[_0xf9ce('0x25')](_0xf9ce('0x26'),_0x176457+'-'+_0x23c8be+'/'+_0x5366d4)['json'](_0x54fe01);}return null;};}function patchUpdates(_0x466108){return function(_0x45b2bb){try{jsonpatch[_0xf9ce('0x27')](_0x45b2bb,_0x466108,!![]);}catch(_0x54f7d1){return BPromise[_0xf9ce('0x28')](_0x54f7d1);}return _0x45b2bb[_0xf9ce('0x29')]();};}function saveUpdates(_0x6aa708,_0x5893e7){return function(_0xee2a69){if(_0xee2a69){return _0xee2a69[_0xf9ce('0x2a')](_0x6aa708)[_0xf9ce('0x2b')](function(_0x5723b5){return _0x5723b5;});}return null;};}function removeEntity(_0xb6dacf,_0x36dc99){return function(_0x30e90a){if(_0x30e90a){return _0x30e90a[_0xf9ce('0x2c')]()[_0xf9ce('0x2b')](function(){var _0x5dde91=_0x30e90a['get']({'plain':!![]});var _0x4fa297=_0xf9ce('0x2d');return db[_0xf9ce('0x2e')][_0xf9ce('0x2c')]({'where':{'type':_0x4fa297,'resourceId':_0x5dde91['id']}})['then'](function(){return _0x30e90a;});})['then'](function(){_0xb6dacf['status'](0xcc)[_0xf9ce('0x2f')]();});}};}function handleEntityNotFound(_0x2707bc,_0x506d4e){return function(_0x1629ac){if(!_0x1629ac){_0x2707bc[_0xf9ce('0x1e')](0x194);}return _0x1629ac;};}function handleError(_0x14cde1,_0x208b24){_0x208b24=_0x208b24||0x1f4;return function(_0x373cda){logger['error'](_0x373cda['stack']);if(_0x373cda[_0xf9ce('0x30')]){delete _0x373cda[_0xf9ce('0x30')];}_0x14cde1['status'](_0x208b24)['send'](_0x373cda);};}exports[_0xf9ce('0x31')]=function(_0x2e55dd,_0x40c3c7){var _0x555eac={},_0xe08770={},_0x210a8a={'count':0x0,'rows':[]};var _0x51e871=_[_0xf9ce('0x32')](db[_0xf9ce('0x33')][_0xf9ce('0x34')],function(_0x4ee1a4){return{'name':_0x4ee1a4[_0xf9ce('0x35')],'type':_0x4ee1a4[_0xf9ce('0x36')][_0xf9ce('0x37')]};});_0xe08770[_0xf9ce('0x38')]=_[_0xf9ce('0x32')](_0x51e871,_0xf9ce('0x30'));_0xe08770[_0xf9ce('0x39')]=_[_0xf9ce('0x3a')](_0x2e55dd['query']);_0xe08770[_0xf9ce('0x3b')]=_[_0xf9ce('0x3c')](_0xe08770[_0xf9ce('0x38')],_0xe08770[_0xf9ce('0x39')]);_0x555eac[_0xf9ce('0x3d')]=_['intersection'](_0xe08770[_0xf9ce('0x38')],qs[_0xf9ce('0x3e')](_0x2e55dd['query'][_0xf9ce('0x3e')]));_0x555eac[_0xf9ce('0x3d')]=_0x555eac['attributes'][_0xf9ce('0x3f')]?_0x555eac[_0xf9ce('0x3d')]:_0xe08770[_0xf9ce('0x38')];if(!_0x2e55dd[_0xf9ce('0x39')][_0xf9ce('0x40')](_0xf9ce('0x41'))){_0x555eac[_0xf9ce('0x23')]=qs[_0xf9ce('0x23')](_0x2e55dd[_0xf9ce('0x39')][_0xf9ce('0x23')]);_0x555eac['offset']=qs[_0xf9ce('0x21')](_0x2e55dd[_0xf9ce('0x39')][_0xf9ce('0x21')]);}_0x555eac[_0xf9ce('0x42')]=qs[_0xf9ce('0x43')](_0x2e55dd['query'][_0xf9ce('0x43')]);_0x555eac[_0xf9ce('0x44')]=qs['filters'](_[_0xf9ce('0x45')](_0x2e55dd[_0xf9ce('0x39')],_0xe08770['filters']),_0x51e871);if(_0x2e55dd['query'][_0xf9ce('0x46')]){_0x555eac[_0xf9ce('0x44')]=_['merge'](_0x555eac[_0xf9ce('0x44')],{'$or':_[_0xf9ce('0x32')](_0x51e871,function(_0x23603d){if(_0x23603d[_0xf9ce('0x36')]!==_0xf9ce('0x47')){var _0x5e3a50={};_0x5e3a50[_0x23603d[_0xf9ce('0x30')]]={'$like':'%'+_0x2e55dd[_0xf9ce('0x39')]['filter']+'%'};return _0x5e3a50;}})});}_0x555eac=_[_0xf9ce('0x48')]({},_0x555eac,_0x2e55dd[_0xf9ce('0x49')]);var _0xe54498={'where':_0x555eac[_0xf9ce('0x44')]};return db[_0xf9ce('0x33')]['count'](_0xe54498)['then'](function(_0x895bd5){_0x210a8a[_0xf9ce('0x24')]=_0x895bd5;if(_0x2e55dd['query']['includeAll']){_0x555eac['include']=[{'all':!![]}];}return db[_0xf9ce('0x33')][_0xf9ce('0x4a')](_0x555eac);})[_0xf9ce('0x2b')](function(_0x2a76a4){_0x210a8a[_0xf9ce('0x4b')]=_0x2a76a4;return _0x210a8a;})[_0xf9ce('0x2b')](respondWithFilteredResult(_0x40c3c7,_0x555eac))[_0xf9ce('0x4c')](handleError(_0x40c3c7,null));};exports[_0xf9ce('0x4d')]=function(_0x1e13af,_0x5c2a0c){var _0xee2a11={'raw':!![],'where':{'id':_0x1e13af['params']['id']}},_0x5de8d9={};_0x5de8d9[_0xf9ce('0x38')]=_[_0xf9ce('0x3a')](db[_0xf9ce('0x33')][_0xf9ce('0x34')]);_0x5de8d9[_0xf9ce('0x39')]=_[_0xf9ce('0x3a')](_0x1e13af[_0xf9ce('0x39')]);_0x5de8d9[_0xf9ce('0x3b')]=_['intersection'](_0x5de8d9[_0xf9ce('0x38')],_0x5de8d9[_0xf9ce('0x39')]);_0xee2a11['attributes']=_[_0xf9ce('0x3c')](_0x5de8d9[_0xf9ce('0x38')],qs['fields'](_0x1e13af[_0xf9ce('0x39')]['fields']));_0xee2a11[_0xf9ce('0x3d')]=_0xee2a11[_0xf9ce('0x3d')][_0xf9ce('0x3f')]?_0xee2a11[_0xf9ce('0x3d')]:_0x5de8d9[_0xf9ce('0x38')];if(_0x1e13af[_0xf9ce('0x39')]['includeAll']){_0xee2a11['include']=[{'all':!![]}];}_0xee2a11=_[_0xf9ce('0x48')]({},_0xee2a11,_0x1e13af[_0xf9ce('0x49')]);return db['FaxQueue'][_0xf9ce('0x4e')](_0xee2a11)[_0xf9ce('0x2b')](handleEntityNotFound(_0x5c2a0c,null))['then'](respondWithResult(_0x5c2a0c,null))['catch'](handleError(_0x5c2a0c,null));};exports[_0xf9ce('0x4f')]=function(_0x3253b9,_0x34c29c){return db[_0xf9ce('0x33')]['create'](_0x3253b9[_0xf9ce('0x50')],{})[_0xf9ce('0x2b')](function(_0x42bddb){var _0x199dd1=_0x3253b9[_0xf9ce('0x51')][_0xf9ce('0x52')]({'plain':!![]});if(!_0x199dd1)throw new Error(_0xf9ce('0x53'));if(_0x199dd1[_0xf9ce('0x54')]===_0xf9ce('0x51')){var _0x2664c2=_0x42bddb[_0xf9ce('0x52')]({'plain':!![]});var _0x901f98=_0xf9ce('0x2d');return db['UserProfileSection'][_0xf9ce('0x4e')]({'where':{'name':_0x901f98,'userProfileId':_0x199dd1[_0xf9ce('0x55')]},'raw':!![]})['then'](function(_0x4eb8ff){if(_0x4eb8ff&&_0x4eb8ff[_0xf9ce('0x56')]===0x0){return db['UserProfileResource']['create']({'name':_0x2664c2[_0xf9ce('0x30')],'resourceId':_0x2664c2['id'],'type':_0x4eb8ff[_0xf9ce('0x30')],'sectionId':_0x4eb8ff['id']},{})['then'](function(){return _0x42bddb;});}else{return _0x42bddb;}})[_0xf9ce('0x4c')](function(_0x2ef6eb){logger[_0xf9ce('0x57')](_0xf9ce('0x58'),_0x2ef6eb);throw _0x2ef6eb;});}return _0x42bddb;})['then'](respondWithResult(_0x34c29c,0xc9))[_0xf9ce('0x4c')](handleError(_0x34c29c,null));};exports['update']=function(_0x3ad57a,_0xcac946){if(_0x3ad57a[_0xf9ce('0x50')]['id']){delete _0x3ad57a['body']['id'];}return db[_0xf9ce('0x33')][_0xf9ce('0x4e')]({'where':{'id':_0x3ad57a[_0xf9ce('0x59')]['id']}})[_0xf9ce('0x2b')](handleEntityNotFound(_0xcac946,null))['then'](saveUpdates(_0x3ad57a['body'],null))[_0xf9ce('0x2b')](respondWithResult(_0xcac946,null))[_0xf9ce('0x4c')](handleError(_0xcac946,null));};exports[_0xf9ce('0x2c')]=function(_0x2d14ef,_0x262aab){return db['FaxQueue']['find']({'where':{'id':_0x2d14ef[_0xf9ce('0x59')]['id']}})[_0xf9ce('0x2b')](handleEntityNotFound(_0x262aab,null))[_0xf9ce('0x2b')](removeEntity(_0x262aab,null))[_0xf9ce('0x4c')](handleError(_0x262aab,null));};exports[_0xf9ce('0x5a')]=function(_0x1fa785,_0x2a71ce){return db[_0xf9ce('0x33')][_0xf9ce('0x5a')]()[_0xf9ce('0x2b')](respondWithResult(_0x2a71ce,null))[_0xf9ce('0x4c')](handleError(_0x2a71ce,null));};exports[_0xf9ce('0x5b')]=function(_0x22707f,_0x5509be,_0xeb45db){var _0x351867={'raw':!![],'where':{}},_0x1662f7={},_0x3c786c;return db['FaxQueue'][_0xf9ce('0x5c')]({'where':{'id':_0x22707f[_0xf9ce('0x59')]['id']}})['then'](handleEntityNotFound(_0x5509be,null))[_0xf9ce('0x2b')](function(_0x52f1d4){if(_0x52f1d4){_0x3c786c=_0x52f1d4[_0xf9ce('0x52')]({'plain':!![]});_0x1662f7[_0xf9ce('0x38')]=_[_0xf9ce('0x3a')](db['UserFaxQueue'][_0xf9ce('0x34')]);_0x1662f7[_0xf9ce('0x39')]=_[_0xf9ce('0x3a')](_0x22707f[_0xf9ce('0x39')]);_0x1662f7[_0xf9ce('0x3b')]=_[_0xf9ce('0x3c')](_0x1662f7[_0xf9ce('0x38')],_0x1662f7[_0xf9ce('0x39')]);_0x351867[_0xf9ce('0x3d')]=_['intersection'](_0x1662f7[_0xf9ce('0x38')],qs[_0xf9ce('0x3e')](_0x22707f[_0xf9ce('0x39')]['fields']));_0x351867[_0xf9ce('0x3d')]=_0x351867['attributes'][_0xf9ce('0x3f')]?_0x351867['attributes']:_0x1662f7[_0xf9ce('0x38')];if(!_0x22707f[_0xf9ce('0x39')][_0xf9ce('0x40')](_0xf9ce('0x41'))){_0x351867[_0xf9ce('0x23')]=qs['limit'](_0x22707f[_0xf9ce('0x39')][_0xf9ce('0x23')]);_0x351867[_0xf9ce('0x21')]=qs['offset'](_0x22707f[_0xf9ce('0x39')][_0xf9ce('0x21')]);}_0x351867[_0xf9ce('0x42')]=qs[_0xf9ce('0x43')](_0x22707f[_0xf9ce('0x39')][_0xf9ce('0x43')]);_0x351867[_0xf9ce('0x44')]=qs[_0xf9ce('0x3b')](_[_0xf9ce('0x45')](_0x22707f['query'],_0x1662f7['filters']));_0x351867[_0xf9ce('0x44')][_0xf9ce('0x5d')]=_0x52f1d4['id'];if(_0x22707f[_0xf9ce('0x39')][_0xf9ce('0x46')]){_0x351867[_0xf9ce('0x44')]=_['merge'](_0x351867['where'],{'$or':_[_0xf9ce('0x32')](_0x351867[_0xf9ce('0x3d')],function(_0x266334){var _0x26a9a6={};_0x26a9a6[_0x266334]={'$like':'%'+_0x22707f[_0xf9ce('0x39')][_0xf9ce('0x46')]+'%'};return _0x26a9a6;})});}_0x351867=_[_0xf9ce('0x48')]({},_0x351867,_0x22707f[_0xf9ce('0x49')]);return db[_0xf9ce('0x5e')][_0xf9ce('0x4a')](_0x351867);}})[_0xf9ce('0x2b')](function(_0x1fe9f){if(_0x1fe9f){return db[_0xf9ce('0x5f')][_0xf9ce('0x60')]({'where':{'id':_[_0xf9ce('0x32')](_0x1fe9f,_0xf9ce('0x61')),'role':_0xf9ce('0x62')},'attributes':['id',_0xf9ce('0x30'),_0xf9ce('0x63'),_0xf9ce('0x64'),_0xf9ce('0x65')]});}})[_0xf9ce('0x2b')](function(_0x2bcd99){if(_0x2bcd99){return{'count':_0x2bcd99['count'],'rows':_[_0xf9ce('0x32')](_0x2bcd99[_0xf9ce('0x4b')],function(_0x2f66ed){return{'membername':_0x2f66ed[_0xf9ce('0x30')],'UserId':_0x2f66ed['id'],'queue_name':_0x3c786c[_0xf9ce('0x30')],'FaxQueueId':_0x3c786c['id'],'interface':util[_0xf9ce('0x66')]('%s/%s',_0xf9ce('0x67'),_0x2f66ed[_0xf9ce('0x30')]),'penalty':0x0,'paused':_0x2f66ed[_0xf9ce('0x63')],'createdAt':_0x2f66ed[_0xf9ce('0x65')],'updatedAt':_0x2f66ed['updatedAt']};})};}else{return{'count':0x0,'rows':[]};}})['then'](respondWithFilteredResult(_0x5509be,_0x351867))[_0xf9ce('0x4c')](handleError(_0x5509be,null));};exports['getTeams']=function(_0x4f798b,_0x1a3ef9,_0x2e884d){var _0x10f318={};var _0x4fe54d={};var _0x58300f;var _0x1074a1;return db[_0xf9ce('0x33')]['findOne']({'where':{'id':_0x4f798b[_0xf9ce('0x59')]['id']}})[_0xf9ce('0x2b')](handleEntityNotFound(_0x1a3ef9,null))[_0xf9ce('0x2b')](function(_0x16359d){if(_0x16359d){_0x58300f=_0x16359d;_0x4fe54d[_0xf9ce('0x38')]=_[_0xf9ce('0x3a')](db[_0xf9ce('0x68')][_0xf9ce('0x34')]);_0x4fe54d[_0xf9ce('0x39')]=_[_0xf9ce('0x3a')](_0x4f798b[_0xf9ce('0x39')]);_0x4fe54d[_0xf9ce('0x3b')]=_[_0xf9ce('0x3c')](_0x4fe54d['model'],_0x4fe54d[_0xf9ce('0x39')]);_0x10f318[_0xf9ce('0x3d')]=_[_0xf9ce('0x3c')](_0x4fe54d[_0xf9ce('0x38')],qs[_0xf9ce('0x3e')](_0x4f798b[_0xf9ce('0x39')][_0xf9ce('0x3e')]));_0x10f318[_0xf9ce('0x3d')]=_0x10f318[_0xf9ce('0x3d')][_0xf9ce('0x3f')]?_0x10f318[_0xf9ce('0x3d')]:_0x4fe54d[_0xf9ce('0x38')];_0x10f318[_0xf9ce('0x42')]=qs['sort'](_0x4f798b[_0xf9ce('0x39')][_0xf9ce('0x43')]);_0x10f318[_0xf9ce('0x44')]=qs[_0xf9ce('0x3b')](_[_0xf9ce('0x45')](_0x4f798b[_0xf9ce('0x39')],_0x4fe54d[_0xf9ce('0x3b')]));if(_0x4f798b[_0xf9ce('0x39')]['filter']){_0x10f318[_0xf9ce('0x44')]=_[_0xf9ce('0x48')](_0x10f318[_0xf9ce('0x44')],{'$or':_[_0xf9ce('0x32')](_0x10f318[_0xf9ce('0x3d')],function(_0x1864b5){var _0x3749ad={};_0x3749ad[_0x1864b5]={'$like':'%'+_0x4f798b[_0xf9ce('0x39')]['filter']+'%'};return _0x3749ad;})});}_0x10f318=_[_0xf9ce('0x48')]({},_0x10f318,_0x4f798b[_0xf9ce('0x49')]);return _0x58300f[_0xf9ce('0x69')](_0x10f318);}})[_0xf9ce('0x2b')](function(_0x5541d1){if(_0x5541d1){_0x1074a1=_0x5541d1['length'];if(!_0x4f798b[_0xf9ce('0x39')][_0xf9ce('0x40')](_0xf9ce('0x41'))){_0x10f318[_0xf9ce('0x23')]=qs[_0xf9ce('0x23')](_0x4f798b[_0xf9ce('0x39')][_0xf9ce('0x23')]);_0x10f318[_0xf9ce('0x21')]=qs[_0xf9ce('0x21')](_0x4f798b[_0xf9ce('0x39')][_0xf9ce('0x21')]);}return _0x58300f['getTeams'](_0x10f318);}})[_0xf9ce('0x2b')](function(_0x7459b2){if(_0x7459b2){return _0x7459b2?{'count':_0x1074a1,'rows':_0x7459b2}:null;}})[_0xf9ce('0x2b')](respondWithResult(_0x1a3ef9,null))['catch'](handleError(_0x1a3ef9,null));};exports[_0xf9ce('0x6a')]=function(_0x390603,_0x1e3505,_0x471a36){var _0x35b38d=_0x390603[_0xf9ce('0x50')]['ids'];return db[_0xf9ce('0x68')][_0xf9ce('0x4a')]({'where':{'id':_0x35b38d},'attributes':['id'],'include':[{'model':db[_0xf9ce('0x5f')],'as':_0xf9ce('0x6b'),'attributes':['id','name',_0xf9ce('0x6c'),_0xf9ce('0x6d'),_0xf9ce('0x6e')],'raw':!![]}]})[_0xf9ce('0x2b')](function(_0x18e35d){if(_0x18e35d){var _0x4ecae0=_['flatMap'](_0x18e35d,function(_0x24e087){var _0x32c21c=_0x24e087[_0xf9ce('0x52')]({'plain':!![]});return _0x32c21c['Agents'];});return db['FaxQueue']['find']({'where':{'id':_0x390603[_0xf9ce('0x59')]['id']}})['then'](function(_0x53f549){return db[_0xf9ce('0x6f')]['transaction'](function(_0x36c1b1){return _0x53f549[_0xf9ce('0x6a')](_0x35b38d,{'transaction':_0x36c1b1})[_0xf9ce('0x2b')](function(){return BPromise[_0xf9ce('0x70')](_0x4ecae0,function(_0x17300a){return db['UserFaxQueue']['findOrCreate']({'where':{'UserId':_0x17300a['id'],'FaxQueueId':_0x390603[_0xf9ce('0x59')]['id']},'transaction':_0x36c1b1});});})[_0xf9ce('0x2b')](function(){_0x4ecae0[_0xf9ce('0x71')](function(_0x4a53e3){socket[_0xf9ce('0x72')](_0xf9ce('0x73'),{'UserId':_0x4a53e3['id'],'FaxQueueId':_0x53f549['id']});});});});});}})['then'](respondWithStatusCode(_0x1e3505,null))[_0xf9ce('0x4c')](handleError(_0x1e3505,null));};exports[_0xf9ce('0x74')]=function(_0x507a88,_0x295efd,_0x35df38){return db[_0xf9ce('0x68')][_0xf9ce('0x4a')]({'where':{'id':_0x507a88[_0xf9ce('0x39')][_0xf9ce('0x75')]},'attributes':['id'],'include':[{'model':db[_0xf9ce('0x5f')],'as':_0xf9ce('0x6b'),'attributes':['id'],'raw':!![]}]})[_0xf9ce('0x2b')](handleEntityNotFound(_0x295efd,null))[_0xf9ce('0x2b')](function(_0x4c662d){var _0x548c3d=_[_0xf9ce('0x32')](_0x4c662d,'id');var _0x56e771=[];var _0x289419=[];var _0x4d26d4=squel['select']();_0x4d26d4[_0xf9ce('0x76')](_0xf9ce('0x77'))[_0xf9ce('0x78')](_0xf9ce('0x79'),'tq')[_0xf9ce('0x7a')]('user_has_teams','ut','ut.TeamId\x20=\x20tq.TeamId')[_0xf9ce('0x44')](_0xf9ce('0x7b'),_0x507a88['params']['id']);for(var _0x595781=0x0;_0x595781<_0x4c662d[_0xf9ce('0x3f')];_0x595781+=0x1){let _0x2e3826=_0x4c662d[_0x595781];for(var _0x4d3132=0x0;_0x4d3132<_0x2e3826[_0xf9ce('0x6b')][_0xf9ce('0x3f')];_0x4d3132+=0x1){let _0x2edaaf=_0x2e3826[_0xf9ce('0x6b')][_0x4d3132];var _0x404035=_0x4d26d4[_0xf9ce('0x7c')]();_0x404035['where'](_0xf9ce('0x7d'),_0x2edaaf['id']);_0x289419['push'](db['sequelize'][_0xf9ce('0x39')](_0x404035[_0xf9ce('0x7e')](),{'type':db['sequelize'][_0xf9ce('0x7f')]['SELECT']})[_0xf9ce('0x2b')](function(_0x30079f){if(_0x30079f[_0xf9ce('0x3f')]===0x1){return _0x2edaaf['id'];}else{var _0x2849b=_[_0xf9ce('0x80')](_['map'](_0x30079f,_0xf9ce('0x81')),function(_0x1303b5){return _[_0xf9ce('0x82')](_0x548c3d,_0x1303b5);});if(_0x2849b){return _0x2edaaf['id'];}}}));}}return BPromise['all'](_0x289419)[_0xf9ce('0x2b')](function(_0x41d759){_0x56e771=_(_0x56e771)[_0xf9ce('0x83')](_0x41d759)[_0xf9ce('0x84')]()['value']();return db['FaxQueue']['find']({'where':{'id':_0x507a88['params']['id']}})[_0xf9ce('0x2b')](function(_0x55ef96){return db['sequelize'][_0xf9ce('0x85')](function(_0x331bb1){return _0x55ef96[_0xf9ce('0x74')](_0x507a88[_0xf9ce('0x39')][_0xf9ce('0x75')],{'transaction':_0x331bb1})[_0xf9ce('0x2b')](function(){if(!_[_0xf9ce('0x86')](_0x56e771)){return _0x55ef96[_0xf9ce('0x87')](_0x56e771,{'transaction':_0x331bb1});}})['then'](function(){_0x56e771[_0xf9ce('0x71')](function(_0x4d5a80){socket['emit'](_0xf9ce('0x88'),{'UserId':_0x4d5a80,'FaxQueueId':_0x55ef96['id']});});});});});});})[_0xf9ce('0x2b')](respondWithStatusCode(_0x295efd,null))[_0xf9ce('0x4c')](handleError(_0x295efd,null));};exports[_0xf9ce('0x89')]=function(_0x427a7d,_0x2d593b,_0x4d7cb1){return db[_0xf9ce('0x33')][_0xf9ce('0x4e')]({'where':{'id':_0x427a7d['params']['id']}})[_0xf9ce('0x2b')](handleEntityNotFound(_0x2d593b,null))[_0xf9ce('0x2b')](function(_0x1edc16){if(_0x1edc16){return _0x1edc16[_0xf9ce('0x89')](_0x427a7d[_0xf9ce('0x50')][_0xf9ce('0x75')],_['omit'](_0x427a7d['body'],[_0xf9ce('0x75'),'id'])||{})[_0xf9ce('0x8a')](function(_0x3afa8e){for(var _0xf1af90=0x0;_0xf1af90<_0x427a7d[_0xf9ce('0x50')]['ids'][_0xf9ce('0x3f')];_0xf1af90+=0x1){socket[_0xf9ce('0x72')](_0xf9ce('0x73'),{'UserId':Number(_0x427a7d[_0xf9ce('0x50')][_0xf9ce('0x75')][_0xf1af90]),'FaxQueueId':Number(_0x427a7d[_0xf9ce('0x59')]['id'])});}return _0x3afa8e;});}})[_0xf9ce('0x2b')](respondWithResult(_0x2d593b,null))['catch'](handleError(_0x2d593b,null));};exports[_0xf9ce('0x87')]=function(_0x43d417,_0x5e4f53,_0x1db5da){return db[_0xf9ce('0x33')]['find']({'where':{'id':_0x43d417['params']['id']}})[_0xf9ce('0x2b')](handleEntityNotFound(_0x5e4f53,null))['then'](function(_0x4bc5bd){if(_0x4bc5bd){return _0x4bc5bd[_0xf9ce('0x87')](_0x43d417['query'][_0xf9ce('0x75')])[_0xf9ce('0x2b')](function(){if(_[_0xf9ce('0x8b')](_0x43d417['query']['ids'])){for(var _0x4fb685=0x0;_0x4fb685<_0x43d417[_0xf9ce('0x39')][_0xf9ce('0x75')]['length'];_0x4fb685+=0x1){socket[_0xf9ce('0x72')](_0xf9ce('0x88'),{'UserId':Number(_0x43d417['query'][_0xf9ce('0x75')][_0x4fb685]),'FaxQueueId':Number(_0x43d417[_0xf9ce('0x59')]['id'])});}}else{socket[_0xf9ce('0x72')](_0xf9ce('0x88'),{'UserId':Number(_0x43d417[_0xf9ce('0x39')][_0xf9ce('0x75')]),'FaxQueueId':Number(_0x43d417[_0xf9ce('0x59')]['id'])});}});}})['then'](respondWithStatusCode(_0x5e4f53,null))[_0xf9ce('0x4c')](handleError(_0x5e4f53,null));};exports['getAgents']=function(_0x52d38f,_0x56f404,_0x1200c2){var _0x4484bd={};var _0x4e09a2={};var _0x359615;var _0x94bc4f;return db['FaxQueue']['findOne']({'where':{'id':_0x52d38f[_0xf9ce('0x59')]['id']}})[_0xf9ce('0x2b')](handleEntityNotFound(_0x56f404,null))[_0xf9ce('0x2b')](function(_0x263566){if(_0x263566){_0x359615=_0x263566;_0x4e09a2[_0xf9ce('0x38')]=_[_0xf9ce('0x3a')](db['User'][_0xf9ce('0x34')]);_0x4e09a2[_0xf9ce('0x39')]=_['keys'](_0x52d38f[_0xf9ce('0x39')]);_0x4e09a2['filters']=_[_0xf9ce('0x3c')](_0x4e09a2[_0xf9ce('0x38')],_0x4e09a2[_0xf9ce('0x39')]);_0x4484bd[_0xf9ce('0x3d')]=_['intersection'](_0x4e09a2['model'],qs[_0xf9ce('0x3e')](_0x52d38f['query'][_0xf9ce('0x3e')]));_0x4484bd[_0xf9ce('0x3d')]=_0x4484bd['attributes'][_0xf9ce('0x3f')]?_0x4484bd[_0xf9ce('0x3d')]:_0x4e09a2[_0xf9ce('0x38')];_0x4484bd[_0xf9ce('0x42')]=qs[_0xf9ce('0x43')](_0x52d38f[_0xf9ce('0x39')][_0xf9ce('0x43')]);_0x4484bd[_0xf9ce('0x44')]=qs['filters'](_['pick'](_0x52d38f[_0xf9ce('0x39')],_0x4e09a2['filters']));if(_0x52d38f['query'][_0xf9ce('0x46')]){_0x4484bd[_0xf9ce('0x44')]=_[_0xf9ce('0x48')](_0x4484bd[_0xf9ce('0x44')],{'$or':_[_0xf9ce('0x32')](_0x4484bd[_0xf9ce('0x3d')],function(_0x532c35){var _0x47a3dc={};_0x47a3dc[_0x532c35]={'$like':'%'+_0x52d38f[_0xf9ce('0x39')][_0xf9ce('0x46')]+'%'};return _0x47a3dc;})});}_0x4484bd=_[_0xf9ce('0x48')]({},_0x4484bd,_0x52d38f[_0xf9ce('0x49')]);return _0x359615['getAgents'](_0x4484bd);}})['then'](function(_0x15097a){if(_0x15097a){_0x94bc4f=_0x15097a['length'];if(!_0x52d38f[_0xf9ce('0x39')][_0xf9ce('0x40')](_0xf9ce('0x41'))){_0x4484bd[_0xf9ce('0x23')]=qs[_0xf9ce('0x23')](_0x52d38f['query'][_0xf9ce('0x23')]);_0x4484bd[_0xf9ce('0x21')]=qs[_0xf9ce('0x21')](_0x52d38f['query']['offset']);}return _0x359615[_0xf9ce('0x8c')](_0x4484bd);}})['then'](function(_0x5d4c1e){if(_0x5d4c1e){return _0x5d4c1e?{'count':_0x94bc4f,'rows':_0x5d4c1e}:null;}})[_0xf9ce('0x2b')](respondWithResult(_0x56f404,null))['catch'](handleError(_0x56f404,null));};
\ No newline at end of file