Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / team / team.controller.js
index fd4b702..166f6a4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9324=['SELECT\x20WhatsappQueueId\x20FROM\x20team_has_whatsapp_queues\x20WHERE\x20TeamId\x20=\x20','WhatsappQueueId','TeamVoicePrefix','VoicePrefixId','send','channel','Unknown\x20channel','capitalize','toLowerCase','Queue','isValidChannel','ValidationError','add','Queues','ids','findOne','addAgents','isArray','Voice','Chat','Mail','Sms','Openchannel','Whatsapp','QueueId','TeamVoiceQueue','penalty','User','findOrCreate','emit','Queue:save','online','voicePause','interface','UserVoiceQueueRt','upsert','isNil','format','SIP/%s','all','UserVoicePrefix','spread','Fax','Queue:remove','removeAgents','getAgents','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','./team.socket','sendStatus','end','status','offset','undefined','count','limit','set','Content-Range','apply','reject','update','then','stack','name','index','map','Team','rawAttributes','fieldName','type','key','query','filters','intersection','model','attributes','fields','length','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','findAll','catch','show','keys','include','create','body','user','get','role','Teams','find','userProfileId','autoAssociation','UserProfileResource','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','destroy','transaction','SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20','sequelize','Sequelize','SELECT','UserId','SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20','UserVoiceQueue','SELECT\x20MailQueueId\x20FROM\x20team_has_mail_queues\x20WHERE\x20TeamId\x20=\x20','QueryTypes','MailQueueId','UserMailQueue','SELECT\x20SmsQueueId\x20FROM\x20team_has_sms_queues\x20WHERE\x20TeamId\x20=\x20','UserSmsQueue','ChatQueueId','UserChatQueue','FaxQueueId','UserFaxQueue','SELECT\x20OpenchannelQueueId\x20FROM\x20team_has_openchannel_queues\x20WHERE\x20TeamId\x20=\x20','OpenchannelQueueId','UserOpenchannelQueue'];(function(_0x175a55,_0x4082fd){var _0x167adf=function(_0x18ef07){while(--_0x18ef07){_0x175a55['push'](_0x175a55['shift']());}};_0x167adf(++_0x4082fd);}(_0x9324,0x164));var _0x4932=function(_0x15cef4,_0x448b97){_0x15cef4=_0x15cef4-0x0;var _0x384430=_0x9324[_0x15cef4];return _0x384430;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x4932('0x0'));var jsonpatch=require(_0x4932('0x1'));var rp=require(_0x4932('0x2'));var moment=require(_0x4932('0x3'));var BPromise=require(_0x4932('0x4'));var Mustache=require(_0x4932('0x5'));var util=require(_0x4932('0x6'));var path=require(_0x4932('0x7'));var sox=require(_0x4932('0x8'));var csv=require(_0x4932('0x9'));var ejs=require(_0x4932('0xa'));var fs=require('fs');var fs_extra=require(_0x4932('0xb'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x4932('0xc'));var jsforce=require(_0x4932('0xd'));var deskjs=require(_0x4932('0xe'));var toCsv=require(_0x4932('0x9'));var querystring=require(_0x4932('0xf'));var Papa=require(_0x4932('0x10'));var Redis=require(_0x4932('0x11'));var authService=require(_0x4932('0x12'));var qs=require(_0x4932('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4932('0x14'));var logger=require('../../config/logger')(_0x4932('0x15'));var utils=require(_0x4932('0x16'));var config=require(_0x4932('0x17'));var licenseUtil=require(_0x4932('0x18'));var db=require(_0x4932('0x19'))['db'];config['redis']=_[_0x4932('0x1a')](config[_0x4932('0x1b')],{'host':_0x4932('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4932('0x1b')]));require(_0x4932('0x1d'))['register'](socket);function respondWithStatusCode(_0x5e8ee7,_0x243409){_0x243409=_0x243409||0xcc;return function(_0x5a27c8){if(_0x5a27c8){return _0x5e8ee7[_0x4932('0x1e')](_0x243409);}return _0x5e8ee7['status'](_0x243409)[_0x4932('0x1f')]();};}function respondWithResult(_0x5a480a,_0x182d43){_0x182d43=_0x182d43||0xc8;return function(_0x120b92){if(_0x120b92){return _0x5a480a[_0x4932('0x20')](_0x182d43)['json'](_0x120b92);}};}function respondWithFilteredResult(_0x26c789,_0x5b7a49){return function(_0x12e610){if(_0x12e610){var _0x40456c=typeof _0x5b7a49[_0x4932('0x21')]==='undefined'&&typeof _0x5b7a49['limit']===_0x4932('0x22');var _0x4e8ff1=_0x12e610[_0x4932('0x23')];var _0x4afc69=_0x40456c?0x0:_0x5b7a49[_0x4932('0x21')];var _0x19b154=_0x40456c?_0x12e610[_0x4932('0x23')]:_0x5b7a49['offset']+_0x5b7a49[_0x4932('0x24')];var _0x344b6f;if(_0x19b154>=_0x4e8ff1){_0x19b154=_0x4e8ff1;_0x344b6f=0xc8;}else{_0x344b6f=0xce;}_0x26c789[_0x4932('0x20')](_0x344b6f);return _0x26c789[_0x4932('0x25')](_0x4932('0x26'),_0x4afc69+'-'+_0x19b154+'/'+_0x4e8ff1)['json'](_0x12e610);}return null;};}function patchUpdates(_0x2f619c){return function(_0x2c888e){try{jsonpatch[_0x4932('0x27')](_0x2c888e,_0x2f619c,!![]);}catch(_0x151355){return BPromise[_0x4932('0x28')](_0x151355);}return _0x2c888e['save']();};}function saveUpdates(_0xb0531a,_0x748eb8){return function(_0x49b97f){if(_0x49b97f){return _0x49b97f[_0x4932('0x29')](_0xb0531a)[_0x4932('0x2a')](function(_0x495f8d){return _0x495f8d;});}return null;};}function handleEntityNotFound(_0x310845,_0x4ea510){return function(_0x5ba7a0){if(!_0x5ba7a0){_0x310845[_0x4932('0x1e')](0x194);}return _0x5ba7a0;};}function handleError(_0x5ad108,_0x23e485){_0x23e485=_0x23e485||0x1f4;return function(_0x402f02){logger['error'](_0x402f02[_0x4932('0x2b')]);if(_0x402f02[_0x4932('0x2c')]){delete _0x402f02['name'];}_0x5ad108[_0x4932('0x20')](_0x23e485)['send'](_0x402f02);};}exports[_0x4932('0x2d')]=function(_0x196790,_0x48cdfa){var _0x13532a={},_0xe00390={},_0x5a167b={'count':0x0,'rows':[]};var _0x1fc88f=_[_0x4932('0x2e')](db[_0x4932('0x2f')][_0x4932('0x30')],function(_0x301939){return{'name':_0x301939[_0x4932('0x31')],'type':_0x301939[_0x4932('0x32')][_0x4932('0x33')]};});_0xe00390['model']=_[_0x4932('0x2e')](_0x1fc88f,_0x4932('0x2c'));_0xe00390[_0x4932('0x34')]=_['keys'](_0x196790[_0x4932('0x34')]);_0xe00390[_0x4932('0x35')]=_[_0x4932('0x36')](_0xe00390[_0x4932('0x37')],_0xe00390[_0x4932('0x34')]);_0x13532a[_0x4932('0x38')]=_[_0x4932('0x36')](_0xe00390[_0x4932('0x37')],qs['fields'](_0x196790[_0x4932('0x34')][_0x4932('0x39')]));_0x13532a[_0x4932('0x38')]=_0x13532a[_0x4932('0x38')][_0x4932('0x3a')]?_0x13532a['attributes']:_0xe00390[_0x4932('0x37')];if(!_0x196790[_0x4932('0x34')]['hasOwnProperty'](_0x4932('0x3b'))){_0x13532a[_0x4932('0x24')]=qs[_0x4932('0x24')](_0x196790[_0x4932('0x34')][_0x4932('0x24')]);_0x13532a[_0x4932('0x21')]=qs[_0x4932('0x21')](_0x196790[_0x4932('0x34')][_0x4932('0x21')]);}_0x13532a[_0x4932('0x3c')]=qs[_0x4932('0x3d')](_0x196790[_0x4932('0x34')][_0x4932('0x3d')]);_0x13532a['where']=qs[_0x4932('0x35')](_[_0x4932('0x3e')](_0x196790['query'],_0xe00390['filters']),_0x1fc88f);if(_0x196790[_0x4932('0x34')][_0x4932('0x3f')]){_0x13532a[_0x4932('0x40')]=_[_0x4932('0x41')](_0x13532a[_0x4932('0x40')],{'$or':_[_0x4932('0x2e')](_0x1fc88f,function(_0xa61b06){if(_0xa61b06['type']!==_0x4932('0x42')){var _0x12b3ba={};_0x12b3ba[_0xa61b06[_0x4932('0x2c')]]={'$like':'%'+_0x196790[_0x4932('0x34')][_0x4932('0x3f')]+'%'};return _0x12b3ba;}})});}_0x13532a=_[_0x4932('0x41')]({},_0x13532a,_0x196790[_0x4932('0x43')]);var _0x565ce0={'where':_0x13532a[_0x4932('0x40')]};return db[_0x4932('0x2f')][_0x4932('0x23')](_0x565ce0)[_0x4932('0x2a')](function(_0x5a28e9){_0x5a167b[_0x4932('0x23')]=_0x5a28e9;if(_0x196790[_0x4932('0x34')][_0x4932('0x44')]){_0x13532a['include']=[{'all':!![]}];}return db[_0x4932('0x2f')][_0x4932('0x45')](_0x13532a);})[_0x4932('0x2a')](function(_0x437b21){_0x5a167b['rows']=_0x437b21;return _0x5a167b;})['then'](respondWithFilteredResult(_0x48cdfa,_0x13532a))[_0x4932('0x46')](handleError(_0x48cdfa,null));};exports[_0x4932('0x47')]=function(_0x13a59f,_0x4ba495){var _0x193702={'raw':![],'where':{'id':_0x13a59f['params']['id']}},_0x5de367={};_0x5de367[_0x4932('0x37')]=_[_0x4932('0x48')](db['Team'][_0x4932('0x30')]);_0x5de367[_0x4932('0x34')]=_['keys'](_0x13a59f['query']);_0x5de367['filters']=_[_0x4932('0x36')](_0x5de367['model'],_0x5de367[_0x4932('0x34')]);_0x193702[_0x4932('0x38')]=_[_0x4932('0x36')](_0x5de367[_0x4932('0x37')],qs[_0x4932('0x39')](_0x13a59f[_0x4932('0x34')][_0x4932('0x39')]));_0x193702['attributes']=_0x193702[_0x4932('0x38')]['length']?_0x193702['attributes']:_0x5de367[_0x4932('0x37')];if(_0x13a59f[_0x4932('0x34')]['includeAll']){_0x193702[_0x4932('0x49')]=[{'all':!![]}];}_0x193702=_[_0x4932('0x41')]({},_0x193702,_0x13a59f[_0x4932('0x43')]);return db[_0x4932('0x2f')]['find'](_0x193702)[_0x4932('0x2a')](handleEntityNotFound(_0x4ba495,null))[_0x4932('0x2a')](respondWithResult(_0x4ba495,null))[_0x4932('0x46')](handleError(_0x4ba495,null));};exports[_0x4932('0x4a')]=function(_0x4cf603,_0x50473a){return db['Team'][_0x4932('0x4a')](_0x4cf603[_0x4932('0x4b')],{})['then'](function(_0x2c6f90){var _0x5b3da8=_0x4cf603[_0x4932('0x4c')][_0x4932('0x4d')]({'plain':!![]});if(!_0x5b3da8)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5b3da8[_0x4932('0x4e')]===_0x4932('0x4c')){var _0x3a8e7d=_0x2c6f90[_0x4932('0x4d')]({'plain':!![]});var _0x34f449=_0x4932('0x4f');return db['UserProfileSection'][_0x4932('0x50')]({'where':{'name':_0x34f449,'userProfileId':_0x5b3da8[_0x4932('0x51')]},'raw':!![]})[_0x4932('0x2a')](function(_0x511dbf){if(_0x511dbf&&_0x511dbf[_0x4932('0x52')]===0x0){return db[_0x4932('0x53')][_0x4932('0x4a')]({'name':_0x3a8e7d[_0x4932('0x2c')],'resourceId':_0x3a8e7d['id'],'type':_0x511dbf[_0x4932('0x2c')],'sectionId':_0x511dbf['id']},{})[_0x4932('0x2a')](function(){return _0x2c6f90;});}else{return _0x2c6f90;}})[_0x4932('0x46')](function(_0x1a2b21){logger[_0x4932('0x54')](_0x4932('0x55'),_0x1a2b21);throw _0x1a2b21;});}return _0x2c6f90;})[_0x4932('0x2a')](respondWithResult(_0x50473a,0xc9))[_0x4932('0x46')](handleError(_0x50473a,null));};exports[_0x4932('0x29')]=function(_0x39f8dc,_0x234213){if(_0x39f8dc['body']['id']){delete _0x39f8dc[_0x4932('0x4b')]['id'];}return db[_0x4932('0x2f')][_0x4932('0x50')]({'where':{'id':_0x39f8dc[_0x4932('0x56')]['id']}})[_0x4932('0x2a')](handleEntityNotFound(_0x234213,null))[_0x4932('0x2a')](saveUpdates(_0x39f8dc[_0x4932('0x4b')],null))[_0x4932('0x2a')](respondWithResult(_0x234213,null))[_0x4932('0x46')](handleError(_0x234213,null));};exports[_0x4932('0x57')]=function(_0x2072e5,_0x441d2e){var _0x5ed2f4=_0x2072e5[_0x4932('0x56')]['id'];var _0x1c88e6=[];return db['sequelize'][_0x4932('0x58')](function(_0x2fa96a){var _0x129d7b=_0x4932('0x59')+_0x5ed2f4;return db[_0x4932('0x5a')][_0x4932('0x34')](_0x129d7b,{'type':db[_0x4932('0x5b')]['QueryTypes'][_0x4932('0x5c')],'raw':!![],'transaction':_0x2fa96a})['then'](function(_0x57db0c){_0x1c88e6=_['map'](_0x57db0c,function(_0x1d9f4a){return Number(_0x1d9f4a[_0x4932('0x5d')]);});})[_0x4932('0x2a')](function(){var _0x3d2dd1=_0x4932('0x5e')+_0x5ed2f4;return db[_0x4932('0x5a')][_0x4932('0x34')](_0x3d2dd1,{'type':db[_0x4932('0x5b')]['QueryTypes'][_0x4932('0x5c')],'raw':!![],'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(_0x4eb2d3){var _0x40a667=_[_0x4932('0x2e')](_0x4eb2d3,function(_0x559a1b){return Number(_0x559a1b['VoiceQueueId']);});return db[_0x4932('0x5f')][_0x4932('0x57')]({'where':{'UserId':{'$in':_0x1c88e6},'VoiceQueueId':{'$in':_0x40a667}},'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(){var _0x316102=_0x4932('0x60')+_0x5ed2f4;return db[_0x4932('0x5a')][_0x4932('0x34')](_0x316102,{'type':db[_0x4932('0x5b')][_0x4932('0x61')][_0x4932('0x5c')],'raw':!![],'transaction':_0x2fa96a});})['then'](function(_0x4f2822){var _0x2ffb80=_[_0x4932('0x2e')](_0x4f2822,function(_0x2959f6){return Number(_0x2959f6[_0x4932('0x62')]);});return db[_0x4932('0x63')][_0x4932('0x57')]({'where':{'UserId':{'$in':_0x1c88e6},'MailQueueId':{'$in':_0x2ffb80}},'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(){var _0x2398f1=_0x4932('0x64')+_0x5ed2f4;return db[_0x4932('0x5a')][_0x4932('0x34')](_0x2398f1,{'type':db[_0x4932('0x5b')][_0x4932('0x61')]['SELECT'],'raw':!![],'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(_0x603951){var _0xa93f8b=_['map'](_0x603951,function(_0xe08b7c){return Number(_0xe08b7c['SmsQueueId']);});return db[_0x4932('0x65')][_0x4932('0x57')]({'where':{'UserId':{'$in':_0x1c88e6},'SmsQueueId':{'$in':_0xa93f8b}},'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(){var _0x468e01='SELECT\x20ChatQueueId\x20FROM\x20team_has_chat_queues\x20WHERE\x20TeamId\x20=\x20'+_0x5ed2f4;return db['sequelize'][_0x4932('0x34')](_0x468e01,{'type':db[_0x4932('0x5b')][_0x4932('0x61')][_0x4932('0x5c')],'raw':!![],'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(_0x3e2e3a){var _0x7ce5e5=_[_0x4932('0x2e')](_0x3e2e3a,function(_0x1f1064){return Number(_0x1f1064[_0x4932('0x66')]);});return db[_0x4932('0x67')][_0x4932('0x57')]({'where':{'UserId':{'$in':_0x1c88e6},'ChatQueueId':{'$in':_0x7ce5e5}},'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(){var _0x6b8f54='SELECT\x20FaxQueueId\x20FROM\x20team_has_fax_queues\x20WHERE\x20TeamId\x20=\x20'+_0x5ed2f4;return db['sequelize']['query'](_0x6b8f54,{'type':db['Sequelize']['QueryTypes'][_0x4932('0x5c')],'raw':!![],'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(_0x2509ec){var _0x10d6c7=_[_0x4932('0x2e')](_0x2509ec,function(_0x2183ee){return Number(_0x2183ee[_0x4932('0x68')]);});return db[_0x4932('0x69')][_0x4932('0x57')]({'where':{'UserId':{'$in':_0x1c88e6},'FaxQueueId':{'$in':_0x10d6c7}},'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(){var _0x4fda22=_0x4932('0x6a')+_0x5ed2f4;return db['sequelize']['query'](_0x4fda22,{'type':db[_0x4932('0x5b')]['QueryTypes'][_0x4932('0x5c')],'raw':!![],'transaction':_0x2fa96a});})['then'](function(_0x53e361){var _0xbcf008=_[_0x4932('0x2e')](_0x53e361,function(_0x50ea7c){return Number(_0x50ea7c[_0x4932('0x6b')]);});return db[_0x4932('0x6c')][_0x4932('0x57')]({'where':{'UserId':{'$in':_0x1c88e6},'OpenchannelQueueId':{'$in':_0xbcf008}},'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(){var _0x592f8e=_0x4932('0x6d')+_0x5ed2f4;return db[_0x4932('0x5a')][_0x4932('0x34')](_0x592f8e,{'type':db[_0x4932('0x5b')][_0x4932('0x61')]['SELECT'],'raw':!![],'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(_0x578374){var _0x344324=_[_0x4932('0x2e')](_0x578374,function(_0x2f0761){return Number(_0x2f0761[_0x4932('0x6e')]);});return db['UserWhatsappQueue'][_0x4932('0x57')]({'where':{'UserId':{'$in':_0x1c88e6},'WhatsappQueueId':{'$in':_0x344324}},'transaction':_0x2fa96a});})['then'](function(){return db[_0x4932('0x6f')]['find']({'where':{'TeamId':_0x5ed2f4}});})['then'](function(_0x1604ec){if(_0x1604ec===null){return;}return db['UserVoicePrefix'][_0x4932('0x57')]({'where':{'UserId':{'$in':_0x1c88e6},'VoicePrefixId':_0x1604ec[_0x4932('0x70')]},'transaction':_0x2fa96a});})['then'](function(){return db[_0x4932('0x2f')][_0x4932('0x57')]({'where':{'id':_0x5ed2f4},'cascade':!![],'transaction':_0x2fa96a});})[_0x4932('0x2a')](function(_0x4a892d){if(_0x4a892d===0x0){_0x441d2e[_0x4932('0x1e')](0x194);}else{return db[_0x4932('0x53')][_0x4932('0x57')]({'where':{'type':_0x4932('0x4f'),'resourceId':_0x5ed2f4},'cascade':!![],'transaction':_0x2fa96a})['then'](function(){_0x441d2e[_0x4932('0x20')](0xcc)[_0x4932('0x1f')]();});}})[_0x4932('0x46')](function(_0x465979){_0x441d2e[_0x4932('0x20')](0x1f4)[_0x4932('0x71')](_0x465979);});});};exports['getQueues']=function(_0x51151b,_0x45b803,_0x20cb3c){return db[_0x4932('0x2f')]['findOne']({'where':{'id':_0x51151b[_0x4932('0x56')]['id']}})['then'](handleEntityNotFound(_0x45b803,null))['then'](function(_0x3c4523){if(!_0x51151b[_0x4932('0x34')][_0x4932('0x72')]||!utils['isValidChannel'](_0x51151b['query'][_0x4932('0x72')])){throw new db[(_0x4932('0x5b'))]['ValidationError'](_0x4932('0x73'));}var _0x4f71d5={};var _0x4551bd={};_0x4551bd['model']=_[_0x4932('0x48')](db[_[_0x4932('0x74')](_0x51151b['query'][_0x4932('0x72')][_0x4932('0x75')]())+_0x4932('0x76')][_0x4932('0x30')]);_0x4551bd['query']=_['keys'](_0x51151b[_0x4932('0x34')]);_0x4551bd[_0x4932('0x35')]=_['intersection'](_0x4551bd[_0x4932('0x37')],_0x4551bd['query']);_0x4f71d5[_0x4932('0x38')]=_[_0x4932('0x36')](_0x4551bd[_0x4932('0x37')],qs[_0x4932('0x39')](_0x51151b[_0x4932('0x34')][_0x4932('0x39')]));_0x4f71d5[_0x4932('0x38')]=_0x4f71d5['attributes'][_0x4932('0x3a')]?_0x4f71d5['attributes']:_0x4551bd[_0x4932('0x37')];_0x4f71d5['limit']=qs[_0x4932('0x24')](_0x51151b[_0x4932('0x34')][_0x4932('0x24')]);_0x4f71d5['offset']=qs[_0x4932('0x21')](_0x51151b[_0x4932('0x34')][_0x4932('0x21')]);_0x4f71d5[_0x4932('0x3c')]=qs[_0x4932('0x3d')](_0x51151b[_0x4932('0x34')]['sort']);_0x4f71d5['where']=qs[_0x4932('0x35')](_[_0x4932('0x3e')](_0x51151b[_0x4932('0x34')],_0x4551bd[_0x4932('0x35')]));_0x4f71d5=_[_0x4932('0x41')]({},_0x4f71d5,_0x51151b[_0x4932('0x43')]);return _0x3c4523['get'+_[_0x4932('0x74')](_0x51151b['query'][_0x4932('0x72')][_0x4932('0x75')]())+'Queues'](_0x4f71d5);})[_0x4932('0x2a')](respondWithResult(_0x45b803,null))[_0x4932('0x46')](handleError(_0x45b803,null));};exports['addQueues']=function(_0x43cae6,_0x5bdb2d,_0x4ce4db){return db[_0x4932('0x2f')]['findOne']({'where':{'id':_0x43cae6[_0x4932('0x56')]['id']}})[_0x4932('0x2a')](function(_0x4c2b6f){if(_0x4c2b6f){if(!_0x43cae6['body']['channel']||!utils[_0x4932('0x77')](_0x43cae6[_0x4932('0x4b')][_0x4932('0x72')])){throw new db[(_0x4932('0x5b'))][(_0x4932('0x78'))](_0x4932('0x73'));}return _0x4c2b6f[_0x4932('0x79')+_[_0x4932('0x74')](_0x43cae6[_0x4932('0x4b')][_0x4932('0x72')][_0x4932('0x75')]())+_0x4932('0x7a')](_0x43cae6[_0x4932('0x4b')][_0x4932('0x7b')]);}return null;})[_0x4932('0x2a')](handleEntityNotFound(_0x5bdb2d,null))[_0x4932('0x2a')](respondWithStatusCode(_0x5bdb2d,null))['catch'](handleError(_0x5bdb2d,null));};exports['removeQueues']=function(_0x2ee825,_0x3b57ae,_0xb424f1){return db[_0x4932('0x2f')][_0x4932('0x7c')]({'where':{'id':_0x2ee825[_0x4932('0x56')]['id']}})[_0x4932('0x2a')](function(_0x12153a){if(_0x12153a){if(!_0x2ee825[_0x4932('0x34')][_0x4932('0x72')]||!utils[_0x4932('0x77')](_0x2ee825['query'][_0x4932('0x72')])){throw new db[(_0x4932('0x5b'))][(_0x4932('0x78'))](_0x4932('0x73'));}return _0x12153a['remove'+_[_0x4932('0x74')](_0x2ee825[_0x4932('0x34')][_0x4932('0x72')][_0x4932('0x75')]())+_0x4932('0x7a')](_0x2ee825[_0x4932('0x34')]['ids']);}return null;})[_0x4932('0x2a')](handleEntityNotFound(_0x3b57ae,null))[_0x4932('0x2a')](respondWithStatusCode(_0x3b57ae,null))[_0x4932('0x46')](handleError(_0x3b57ae,null));};exports[_0x4932('0x7d')]=function(_0x5251a4,_0x3eed93){var _0x5a4280=_[_0x4932('0x7e')](_0x5251a4[_0x4932('0x4b')]['ids'])?_0x5251a4[_0x4932('0x4b')][_0x4932('0x7b')]:[_0x5251a4['body'][_0x4932('0x7b')]];var _0x4e3748=_0x5251a4[_0x4932('0x56')]['id'];return db['Team']['find']({'where':{'id':_0x4e3748}})[_0x4932('0x2a')](handleEntityNotFound(_0x3eed93,null))[_0x4932('0x2a')](function(_0x2b9216){if(_0x2b9216){var _0x32696c=[_0x4932('0x7f'),_0x4932('0x80'),_0x4932('0x81'),_0x4932('0x82'),'Fax',_0x4932('0x83'),_0x4932('0x84')];return db[_0x4932('0x5a')][_0x4932('0x58')](function(_0x451104){var _0x2ac36=_['map'](_0x32696c,function(_0xd02f7b){var _0x4dff1d={'attributes':['id','name']};if(_0xd02f7b==='Voice'){_0x4dff1d['through']={'attributes':['penalty']};}return _0x2b9216[_0x4932('0x4d')+_0xd02f7b+_0x4932('0x7a')](_0x4dff1d)['then'](function(_0x387053){var _0x27c399=_['map'](_0x387053,function(_0x31b6bd){var _0x53e635=_['map'](_0x5a4280,function(_0x13f86d){var _0x39006b={'where':{'UserId':_0x13f86d,[_0xd02f7b+_0x4932('0x85')]:_0x31b6bd['id']},'transaction':_0x451104};if(_0xd02f7b===_0x4932('0x7f')){_0x39006b[_0x4932('0x1a')]={'penalty':_0x31b6bd[_0x4932('0x86')][_0x4932('0x87')]};}return db[_0x4932('0x88')+_0xd02f7b+'Queue'][_0x4932('0x89')](_0x39006b)[_0x4932('0x2a')](function(){socket[_0x4932('0x8a')]('user'+_0xd02f7b+_0x4932('0x8b'),{'UserId':_0x13f86d,[_0xd02f7b+_0x4932('0x85')]:_0x31b6bd['id']});if(_0xd02f7b!==_0x4932('0x7f')){return;}return db[_0x4932('0x88')][_0x4932('0x45')]({'where':{'id':_0x5a4280,'online':0x1},'attributes':['id',_0x4932('0x2c'),_0x4932('0x8c'),_0x4932('0x8d'),_0x4932('0x8e')],'raw':!![]})[_0x4932('0x2a')](function(_0x5f2f22){var _0x5eb547=_[_0x4932('0x2e')](_0x5f2f22,function(_0x5d10af){return db[_0x4932('0x8f')][_0x4932('0x90')]({'membername':_0x5d10af['name'],'UserId':_0x5d10af['id'],'queue_name':_0x31b6bd[_0x4932('0x2c')],'VoiceQueueId':_0x31b6bd['id'],'interface':_[_0x4932('0x91')](_0x5d10af[_0x4932('0x8e')])?util[_0x4932('0x92')](_0x4932('0x93'),_0x5d10af['name']):_0x5d10af['interface'],'paused':_0x5d10af[_0x4932('0x8d')]||![],'penalty':_0x31b6bd[_0x4932('0x86')][_0x4932('0x87')]},{'transaction':_0x451104});});return Promise['all'](_0x5eb547);});});});return Promise[_0x4932('0x94')](_0x53e635);});return Promise[_0x4932('0x94')](_0x27c399);})['then'](function(){return db[_0x4932('0x6f')][_0x4932('0x7c')]({'where':{'teamId':_0x4e3748}})[_0x4932('0x2a')](function(_0x3496ff){if(_0x3496ff){var _0x137ddd=_[_0x4932('0x2e')](_0x5a4280,function(_0x545f38){db[_0x4932('0x95')][_0x4932('0x90')]({'UserId':_0x545f38,'VoicePrefixId':_0x3496ff[_0x4932('0x70')]});});return Promise[_0x4932('0x94')](_0x137ddd);}});});});return Promise[_0x4932('0x94')](_0x2ac36)['then'](function(){return _0x2b9216[_0x4932('0x7d')](_0x5a4280,{'transaction':_0x451104})[_0x4932('0x96')](function(_0x3f8b99){return _0x3f8b99;});});});}})['then'](respondWithResult(_0x3eed93,null))[_0x4932('0x46')](handleError(_0x3eed93,null));};exports['removeAgents']=function(_0x208686,_0x43e9e4){var _0xed2958=_[_0x4932('0x7e')](_0x208686[_0x4932('0x34')][_0x4932('0x7b')])?_0x208686['query'][_0x4932('0x7b')]:[_0x208686[_0x4932('0x34')]['ids']];var _0x3a32c1=_0x208686[_0x4932('0x56')]['id'];return db['Team'][_0x4932('0x50')]({'where':{'id':_0x3a32c1}})[_0x4932('0x2a')](handleEntityNotFound(_0x43e9e4,null))[_0x4932('0x2a')](function(_0x1e0471){if(_0x1e0471){var _0x4ee07d=[_0x4932('0x7f'),'Chat','Mail',_0x4932('0x82'),_0x4932('0x97'),_0x4932('0x83'),'Whatsapp'];return db['sequelize'][_0x4932('0x58')](function(_0x5c5c6f){var _0x5ac17a=_[_0x4932('0x2e')](_0x4ee07d,function(_0x4f76c3){var _0x5c0adc={'attributes':['id','name']};return _0x1e0471['get'+_0x4f76c3+_0x4932('0x7a')](_0x5c0adc)[_0x4932('0x2a')](function(_0x527fee){var _0x4a1ca9=_[_0x4932('0x2e')](_0x527fee,function(_0x1ad340){return _0x1ad340['removeAgents'](_0xed2958,{'transaction':_0x5c5c6f})[_0x4932('0x2a')](function(){var _0x390715=_[_0x4932('0x2e')](_0xed2958,function(_0x4312c0){socket[_0x4932('0x8a')]('user'+_0x4f76c3+_0x4932('0x98'),{'UserId':Number(_0x4312c0),[_0x4f76c3+_0x4932('0x85')]:_0x1ad340['id']});if(_0x4f76c3!=='Voice'){return;}return db['UserVoiceQueueRt'][_0x4932('0x57')]({'where':{'VoiceQueueId':_0x1ad340['id'],'UserId':_0x4312c0},'transaction':_0x5c5c6f});});return Promise[_0x4932('0x94')](_0x390715);});});return Promise[_0x4932('0x94')](_0x4a1ca9);});});return Promise[_0x4932('0x94')](_0x5ac17a)['then'](function(){return _0x1e0471[_0x4932('0x99')](_0xed2958,{'transaction':_0x5c5c6f});})[_0x4932('0x2a')](function(){return db[_0x4932('0x6f')]['findOne']({'where':{'teamId':_0x3a32c1}})[_0x4932('0x2a')](function(_0x8ca264){if(_0x8ca264){var _0x349699=_[_0x4932('0x2e')](_0xed2958,function(_0x379478){db[_0x4932('0x95')][_0x4932('0x57')]({'where':{'UserId':_0x379478,'VoicePrefixId':_0x8ca264[_0x4932('0x70')]}});});return Promise[_0x4932('0x94')](_0x349699);}});});});}})['then'](respondWithStatusCode(_0x43e9e4,null))[_0x4932('0x46')](handleError(_0x43e9e4,null));};exports[_0x4932('0x9a')]=function(_0x4b374a,_0x263123,_0x19e5e4){var _0x47cf34={};var _0x483455={};var _0x176f2c;var _0x2d41db;return db['Team']['findOne']({'where':{'id':_0x4b374a[_0x4932('0x56')]['id']}})[_0x4932('0x2a')](handleEntityNotFound(_0x263123,null))['then'](function(_0x4cd897){if(_0x4cd897){_0x176f2c=_0x4cd897;_0x483455[_0x4932('0x37')]=_[_0x4932('0x48')](db[_0x4932('0x88')][_0x4932('0x30')]);_0x483455[_0x4932('0x34')]=_[_0x4932('0x48')](_0x4b374a[_0x4932('0x34')]);_0x483455[_0x4932('0x35')]=_['intersection'](_0x483455[_0x4932('0x37')],_0x483455[_0x4932('0x34')]);_0x47cf34[_0x4932('0x38')]=_[_0x4932('0x36')](_0x483455[_0x4932('0x37')],qs[_0x4932('0x39')](_0x4b374a[_0x4932('0x34')]['fields']));_0x47cf34[_0x4932('0x38')]=_0x47cf34[_0x4932('0x38')][_0x4932('0x3a')]?_0x47cf34[_0x4932('0x38')]:_0x483455[_0x4932('0x37')];_0x47cf34['order']=qs[_0x4932('0x3d')](_0x4b374a[_0x4932('0x34')][_0x4932('0x3d')]);_0x47cf34[_0x4932('0x40')]=qs[_0x4932('0x35')](_[_0x4932('0x3e')](_0x4b374a['query'],_0x483455[_0x4932('0x35')]));if(_0x4b374a['query'][_0x4932('0x3f')]){_0x47cf34['where']=_[_0x4932('0x41')](_0x47cf34[_0x4932('0x40')],{'$or':_[_0x4932('0x2e')](_0x47cf34[_0x4932('0x38')],function(_0x467f4a){var _0x392fb4={};_0x392fb4[_0x467f4a]={'$like':'%'+_0x4b374a['query'][_0x4932('0x3f')]+'%'};return _0x392fb4;})});}_0x47cf34=_[_0x4932('0x41')]({},_0x47cf34,_0x4b374a['options']);return _0x176f2c[_0x4932('0x9a')](_0x47cf34);}})[_0x4932('0x2a')](function(_0x2f00cc){if(_0x2f00cc){_0x2d41db=_0x2f00cc[_0x4932('0x3a')];if(!_0x4b374a[_0x4932('0x34')]['hasOwnProperty'](_0x4932('0x3b'))){_0x47cf34[_0x4932('0x24')]=qs[_0x4932('0x24')](_0x4b374a[_0x4932('0x34')]['limit']);_0x47cf34[_0x4932('0x21')]=qs[_0x4932('0x21')](_0x4b374a[_0x4932('0x34')]['offset']);}return _0x176f2c[_0x4932('0x9a')](_0x47cf34);}})[_0x4932('0x2a')](function(_0x4a93b1){if(_0x4a93b1){return _0x4a93b1?{'count':_0x2d41db,'rows':_0x4a93b1}:null;}})[_0x4932('0x2a')](respondWithResult(_0x263123,null))[_0x4932('0x46')](handleError(_0x263123,null));};
\ No newline at end of file
+var _0xf546=['model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','Team','then','rows','catch','show','params','keys','find','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Teams','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','sequelize','transaction','Sequelize','QueryTypes','UserId','SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20','SELECT','UserVoiceQueue','MailQueueId','UserMailQueue','SmsQueueId','UserSmsQueue','SELECT\x20ChatQueueId\x20FROM\x20team_has_chat_queues\x20WHERE\x20TeamId\x20=\x20','ChatQueueId','UserChatQueue','UserFaxQueue','SELECT\x20OpenchannelQueueId\x20FROM\x20team_has_openchannel_queues\x20WHERE\x20TeamId\x20=\x20','OpenchannelQueueId','UserOpenchannelQueue','SELECT\x20WhatsappQueueId\x20FROM\x20team_has_whatsapp_queues\x20WHERE\x20TeamId\x20=\x20','WhatsappQueueId','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','findOne','channel','ValidationError','Unknown\x20channel','toLowerCase','Queue','capitalize','addQueues','add','Queues','ids','removeQueues','isValidChannel','remove','addAgents','isArray','Voice','Chat','Sms','Fax','Openchannel','through','penalty','QueueId','TeamVoiceQueue','User','findOrCreate','Queue:save','findAll','online','interface','UserVoiceQueueRt','isNil','voicePause','all','upsert','removeAgents','Mail','Whatsapp','Queue:remove','getAgents','eml-format','zip-dir','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./team.socket','register','sendStatus','end','status','offset','undefined','count','limit','json','apply','reject','save','update','error','stack','name','send','index','map','rawAttributes','fieldName','type','key'];(function(_0x103801,_0x483bc4){var _0x4dfd13=function(_0x4e8871){while(--_0x4e8871){_0x103801['push'](_0x103801['shift']());}};_0x4dfd13(++_0x483bc4);}(_0xf546,0x1a1));var _0x6f54=function(_0x599b88,_0x3c4ac2){_0x599b88=_0x599b88-0x0;var _0x58fd4e=_0xf546[_0x599b88];return _0x58fd4e;};'use strict';var emlformat=require(_0x6f54('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x6f54('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x6f54('0x2'));var BPromise=require(_0x6f54('0x3'));var Mustache=require(_0x6f54('0x4'));var util=require(_0x6f54('0x5'));var path=require('path');var sox=require(_0x6f54('0x6'));var csv=require(_0x6f54('0x7'));var ejs=require(_0x6f54('0x8'));var fs=require('fs');var fs_extra=require(_0x6f54('0x9'));var _=require(_0x6f54('0xa'));var squel=require(_0x6f54('0xb'));var crypto=require('crypto');var jsforce=require(_0x6f54('0xc'));var deskjs=require(_0x6f54('0xd'));var toCsv=require(_0x6f54('0x7'));var querystring=require(_0x6f54('0xe'));var Papa=require(_0x6f54('0xf'));var Redis=require(_0x6f54('0x10'));var authService=require(_0x6f54('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x6f54('0x12'))(_0x6f54('0x13'));var utils=require(_0x6f54('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x6f54('0x15'));var db=require(_0x6f54('0x16'))['db'];config[_0x6f54('0x17')]=_[_0x6f54('0x18')](config[_0x6f54('0x17')],{'host':_0x6f54('0x19'),'port':0x18eb});var socket=require(_0x6f54('0x1a'))(new Redis(config[_0x6f54('0x17')]));require(_0x6f54('0x1b'))[_0x6f54('0x1c')](socket);function respondWithStatusCode(_0x375380,_0x4ac50e){_0x4ac50e=_0x4ac50e||0xcc;return function(_0x5d19f5){if(_0x5d19f5){return _0x375380[_0x6f54('0x1d')](_0x4ac50e);}return _0x375380['status'](_0x4ac50e)[_0x6f54('0x1e')]();};}function respondWithResult(_0x4b93b3,_0x2e2099){_0x2e2099=_0x2e2099||0xc8;return function(_0x39c0ca){if(_0x39c0ca){return _0x4b93b3[_0x6f54('0x1f')](_0x2e2099)['json'](_0x39c0ca);}};}function respondWithFilteredResult(_0x2cde80,_0x554d64){return function(_0x4d67ae){if(_0x4d67ae){var _0x3fbedc=typeof _0x554d64[_0x6f54('0x20')]===_0x6f54('0x21')&&typeof _0x554d64['limit']==='undefined';var _0x39be9f=_0x4d67ae[_0x6f54('0x22')];var _0x3606ed=_0x3fbedc?0x0:_0x554d64[_0x6f54('0x20')];var _0x534aba=_0x3fbedc?_0x4d67ae[_0x6f54('0x22')]:_0x554d64[_0x6f54('0x20')]+_0x554d64[_0x6f54('0x23')];var _0x17bda5;if(_0x534aba>=_0x39be9f){_0x534aba=_0x39be9f;_0x17bda5=0xc8;}else{_0x17bda5=0xce;}_0x2cde80[_0x6f54('0x1f')](_0x17bda5);return _0x2cde80['set']('Content-Range',_0x3606ed+'-'+_0x534aba+'/'+_0x39be9f)[_0x6f54('0x24')](_0x4d67ae);}return null;};}function patchUpdates(_0x5f20ef){return function(_0x3de0f2){try{jsonpatch[_0x6f54('0x25')](_0x3de0f2,_0x5f20ef,!![]);}catch(_0x55483a){return BPromise[_0x6f54('0x26')](_0x55483a);}return _0x3de0f2[_0x6f54('0x27')]();};}function saveUpdates(_0x1af5ee,_0x38d75f){return function(_0x416d80){if(_0x416d80){return _0x416d80[_0x6f54('0x28')](_0x1af5ee)['then'](function(_0x35c3bc){return _0x35c3bc;});}return null;};}function handleEntityNotFound(_0x4c9a20,_0x1675ed){return function(_0x228a36){if(!_0x228a36){_0x4c9a20[_0x6f54('0x1d')](0x194);}return _0x228a36;};}function handleError(_0x5dfe2a,_0x2308ac){_0x2308ac=_0x2308ac||0x1f4;return function(_0x27eb53){logger[_0x6f54('0x29')](_0x27eb53[_0x6f54('0x2a')]);if(_0x27eb53[_0x6f54('0x2b')]){delete _0x27eb53[_0x6f54('0x2b')];}_0x5dfe2a[_0x6f54('0x1f')](_0x2308ac)[_0x6f54('0x2c')](_0x27eb53);};}exports[_0x6f54('0x2d')]=function(_0xf6015e,_0x48138c){var _0x107b32={},_0x53a8d6={},_0x16e8a0={'count':0x0,'rows':[]};var _0x5d53db=_[_0x6f54('0x2e')](db['Team'][_0x6f54('0x2f')],function(_0xc0c315){return{'name':_0xc0c315[_0x6f54('0x30')],'type':_0xc0c315[_0x6f54('0x31')][_0x6f54('0x32')]};});_0x53a8d6[_0x6f54('0x33')]=_[_0x6f54('0x2e')](_0x5d53db,'name');_0x53a8d6[_0x6f54('0x34')]=_['keys'](_0xf6015e[_0x6f54('0x34')]);_0x53a8d6[_0x6f54('0x35')]=_[_0x6f54('0x36')](_0x53a8d6[_0x6f54('0x33')],_0x53a8d6['query']);_0x107b32[_0x6f54('0x37')]=_[_0x6f54('0x36')](_0x53a8d6[_0x6f54('0x33')],qs[_0x6f54('0x38')](_0xf6015e['query']['fields']));_0x107b32[_0x6f54('0x37')]=_0x107b32[_0x6f54('0x37')][_0x6f54('0x39')]?_0x107b32['attributes']:_0x53a8d6[_0x6f54('0x33')];if(!_0xf6015e[_0x6f54('0x34')][_0x6f54('0x3a')](_0x6f54('0x3b'))){_0x107b32['limit']=qs[_0x6f54('0x23')](_0xf6015e[_0x6f54('0x34')][_0x6f54('0x23')]);_0x107b32[_0x6f54('0x20')]=qs['offset'](_0xf6015e['query'][_0x6f54('0x20')]);}_0x107b32[_0x6f54('0x3c')]=qs[_0x6f54('0x3d')](_0xf6015e[_0x6f54('0x34')][_0x6f54('0x3d')]);_0x107b32[_0x6f54('0x3e')]=qs[_0x6f54('0x35')](_[_0x6f54('0x3f')](_0xf6015e[_0x6f54('0x34')],_0x53a8d6[_0x6f54('0x35')]),_0x5d53db);if(_0xf6015e['query']['filter']){_0x107b32['where']=_[_0x6f54('0x40')](_0x107b32[_0x6f54('0x3e')],{'$or':_['map'](_0x5d53db,function(_0x1f7c26){if(_0x1f7c26[_0x6f54('0x31')]!==_0x6f54('0x41')){var _0x7cf962={};_0x7cf962[_0x1f7c26[_0x6f54('0x2b')]]={'$like':'%'+_0xf6015e['query'][_0x6f54('0x42')]+'%'};return _0x7cf962;}})});}_0x107b32=_[_0x6f54('0x40')]({},_0x107b32,_0xf6015e[_0x6f54('0x43')]);var _0x350f0c={'where':_0x107b32[_0x6f54('0x3e')]};return db['Team'][_0x6f54('0x22')](_0x350f0c)['then'](function(_0x16a806){_0x16e8a0['count']=_0x16a806;if(_0xf6015e[_0x6f54('0x34')][_0x6f54('0x44')]){_0x107b32[_0x6f54('0x45')]=[{'all':!![]}];}return db[_0x6f54('0x46')]['findAll'](_0x107b32);})[_0x6f54('0x47')](function(_0x4b65c5){_0x16e8a0[_0x6f54('0x48')]=_0x4b65c5;return _0x16e8a0;})[_0x6f54('0x47')](respondWithFilteredResult(_0x48138c,_0x107b32))[_0x6f54('0x49')](handleError(_0x48138c,null));};exports[_0x6f54('0x4a')]=function(_0x227fc3,_0x283850){var _0x196a72={'raw':![],'where':{'id':_0x227fc3[_0x6f54('0x4b')]['id']}},_0x2dc01a={};_0x2dc01a[_0x6f54('0x33')]=_[_0x6f54('0x4c')](db[_0x6f54('0x46')][_0x6f54('0x2f')]);_0x2dc01a[_0x6f54('0x34')]=_[_0x6f54('0x4c')](_0x227fc3[_0x6f54('0x34')]);_0x2dc01a[_0x6f54('0x35')]=_[_0x6f54('0x36')](_0x2dc01a[_0x6f54('0x33')],_0x2dc01a[_0x6f54('0x34')]);_0x196a72[_0x6f54('0x37')]=_[_0x6f54('0x36')](_0x2dc01a['model'],qs[_0x6f54('0x38')](_0x227fc3['query'][_0x6f54('0x38')]));_0x196a72[_0x6f54('0x37')]=_0x196a72[_0x6f54('0x37')][_0x6f54('0x39')]?_0x196a72[_0x6f54('0x37')]:_0x2dc01a[_0x6f54('0x33')];if(_0x227fc3['query'][_0x6f54('0x44')]){_0x196a72[_0x6f54('0x45')]=[{'all':!![]}];}_0x196a72=_[_0x6f54('0x40')]({},_0x196a72,_0x227fc3['options']);return db[_0x6f54('0x46')][_0x6f54('0x4d')](_0x196a72)[_0x6f54('0x47')](handleEntityNotFound(_0x283850,null))[_0x6f54('0x47')](respondWithResult(_0x283850,null))['catch'](handleError(_0x283850,null));};exports[_0x6f54('0x4e')]=function(_0x18b97d,_0x11074b){return db[_0x6f54('0x46')][_0x6f54('0x4e')](_0x18b97d[_0x6f54('0x4f')],{})[_0x6f54('0x47')](function(_0x2af0c8){var _0x5efcf8=_0x18b97d[_0x6f54('0x50')][_0x6f54('0x51')]({'plain':!![]});if(!_0x5efcf8)throw new Error(_0x6f54('0x52'));if(_0x5efcf8[_0x6f54('0x53')]===_0x6f54('0x50')){var _0x316070=_0x2af0c8[_0x6f54('0x51')]({'plain':!![]});var _0x37e545=_0x6f54('0x54');return db[_0x6f54('0x55')]['find']({'where':{'name':_0x37e545,'userProfileId':_0x5efcf8[_0x6f54('0x56')]},'raw':!![]})['then'](function(_0x5a15d0){if(_0x5a15d0&&_0x5a15d0[_0x6f54('0x57')]===0x0){return db[_0x6f54('0x58')][_0x6f54('0x4e')]({'name':_0x316070[_0x6f54('0x2b')],'resourceId':_0x316070['id'],'type':_0x5a15d0['name'],'sectionId':_0x5a15d0['id']},{})[_0x6f54('0x47')](function(){return _0x2af0c8;});}else{return _0x2af0c8;}})[_0x6f54('0x49')](function(_0x450efb){logger[_0x6f54('0x29')](_0x6f54('0x59'),_0x450efb);throw _0x450efb;});}return _0x2af0c8;})['then'](respondWithResult(_0x11074b,0xc9))[_0x6f54('0x49')](handleError(_0x11074b,null));};exports[_0x6f54('0x28')]=function(_0x199223,_0x7b1a7a){if(_0x199223[_0x6f54('0x4f')]['id']){delete _0x199223[_0x6f54('0x4f')]['id'];}return db[_0x6f54('0x46')][_0x6f54('0x4d')]({'where':{'id':_0x199223[_0x6f54('0x4b')]['id']}})[_0x6f54('0x47')](handleEntityNotFound(_0x7b1a7a,null))['then'](saveUpdates(_0x199223[_0x6f54('0x4f')],null))[_0x6f54('0x47')](respondWithResult(_0x7b1a7a,null))[_0x6f54('0x49')](handleError(_0x7b1a7a,null));};exports[_0x6f54('0x5a')]=function(_0x818073,_0x2dece8){var _0x25821d=_0x818073[_0x6f54('0x4b')]['id'];var _0x39ece0=[];return db[_0x6f54('0x5b')][_0x6f54('0x5c')](function(_0x25b317){var _0x378ab7='SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20'+_0x25821d;return db[_0x6f54('0x5b')]['query'](_0x378ab7,{'type':db[_0x6f54('0x5d')][_0x6f54('0x5e')]['SELECT'],'raw':!![],'transaction':_0x25b317})['then'](function(_0xff1d48){_0x39ece0=_[_0x6f54('0x2e')](_0xff1d48,function(_0x224653){return Number(_0x224653[_0x6f54('0x5f')]);});})['then'](function(){var _0x50521e=_0x6f54('0x60')+_0x25821d;return db[_0x6f54('0x5b')][_0x6f54('0x34')](_0x50521e,{'type':db['Sequelize'][_0x6f54('0x5e')][_0x6f54('0x61')],'raw':!![],'transaction':_0x25b317});})['then'](function(_0x8d66){var _0x1a85b4=_['map'](_0x8d66,function(_0x29e3cf){return Number(_0x29e3cf['VoiceQueueId']);});return db[_0x6f54('0x62')]['destroy']({'where':{'UserId':{'$in':_0x39ece0},'VoiceQueueId':{'$in':_0x1a85b4}},'transaction':_0x25b317});})[_0x6f54('0x47')](function(){var _0x5e770b='SELECT\x20MailQueueId\x20FROM\x20team_has_mail_queues\x20WHERE\x20TeamId\x20=\x20'+_0x25821d;return db[_0x6f54('0x5b')]['query'](_0x5e770b,{'type':db[_0x6f54('0x5d')][_0x6f54('0x5e')][_0x6f54('0x61')],'raw':!![],'transaction':_0x25b317});})[_0x6f54('0x47')](function(_0x1234e0){var _0x1ffde5=_[_0x6f54('0x2e')](_0x1234e0,function(_0x1a16b8){return Number(_0x1a16b8[_0x6f54('0x63')]);});return db[_0x6f54('0x64')][_0x6f54('0x5a')]({'where':{'UserId':{'$in':_0x39ece0},'MailQueueId':{'$in':_0x1ffde5}},'transaction':_0x25b317});})[_0x6f54('0x47')](function(){var _0x3ef2dd='SELECT\x20SmsQueueId\x20FROM\x20team_has_sms_queues\x20WHERE\x20TeamId\x20=\x20'+_0x25821d;return db['sequelize'][_0x6f54('0x34')](_0x3ef2dd,{'type':db[_0x6f54('0x5d')][_0x6f54('0x5e')][_0x6f54('0x61')],'raw':!![],'transaction':_0x25b317});})[_0x6f54('0x47')](function(_0xff812e){var _0x1ca2d4=_[_0x6f54('0x2e')](_0xff812e,function(_0x213c2f){return Number(_0x213c2f[_0x6f54('0x65')]);});return db[_0x6f54('0x66')]['destroy']({'where':{'UserId':{'$in':_0x39ece0},'SmsQueueId':{'$in':_0x1ca2d4}},'transaction':_0x25b317});})['then'](function(){var _0x20ceb9=_0x6f54('0x67')+_0x25821d;return db[_0x6f54('0x5b')][_0x6f54('0x34')](_0x20ceb9,{'type':db['Sequelize'][_0x6f54('0x5e')]['SELECT'],'raw':!![],'transaction':_0x25b317});})[_0x6f54('0x47')](function(_0x331ed6){var _0x50919a=_[_0x6f54('0x2e')](_0x331ed6,function(_0x5bce88){return Number(_0x5bce88[_0x6f54('0x68')]);});return db[_0x6f54('0x69')]['destroy']({'where':{'UserId':{'$in':_0x39ece0},'ChatQueueId':{'$in':_0x50919a}},'transaction':_0x25b317});})[_0x6f54('0x47')](function(){var _0x20ac8e='SELECT\x20FaxQueueId\x20FROM\x20team_has_fax_queues\x20WHERE\x20TeamId\x20=\x20'+_0x25821d;return db[_0x6f54('0x5b')][_0x6f54('0x34')](_0x20ac8e,{'type':db[_0x6f54('0x5d')]['QueryTypes']['SELECT'],'raw':!![],'transaction':_0x25b317});})['then'](function(_0xa297b3){var _0x389b36=_[_0x6f54('0x2e')](_0xa297b3,function(_0x3d68ac){return Number(_0x3d68ac['FaxQueueId']);});return db[_0x6f54('0x6a')][_0x6f54('0x5a')]({'where':{'UserId':{'$in':_0x39ece0},'FaxQueueId':{'$in':_0x389b36}},'transaction':_0x25b317});})[_0x6f54('0x47')](function(){var _0x494175=_0x6f54('0x6b')+_0x25821d;return db['sequelize'][_0x6f54('0x34')](_0x494175,{'type':db[_0x6f54('0x5d')]['QueryTypes']['SELECT'],'raw':!![],'transaction':_0x25b317});})['then'](function(_0x541061){var _0x542658=_[_0x6f54('0x2e')](_0x541061,function(_0x1a7e9e){return Number(_0x1a7e9e[_0x6f54('0x6c')]);});return db[_0x6f54('0x6d')][_0x6f54('0x5a')]({'where':{'UserId':{'$in':_0x39ece0},'OpenchannelQueueId':{'$in':_0x542658}},'transaction':_0x25b317});})[_0x6f54('0x47')](function(){var _0x4b72da=_0x6f54('0x6e')+_0x25821d;return db[_0x6f54('0x5b')][_0x6f54('0x34')](_0x4b72da,{'type':db[_0x6f54('0x5d')]['QueryTypes'][_0x6f54('0x61')],'raw':!![],'transaction':_0x25b317});})[_0x6f54('0x47')](function(_0x42d77b){var _0x2fac5a=_['map'](_0x42d77b,function(_0x21dd65){return Number(_0x21dd65[_0x6f54('0x6f')]);});return db['UserWhatsappQueue']['destroy']({'where':{'UserId':{'$in':_0x39ece0},'WhatsappQueueId':{'$in':_0x2fac5a}},'transaction':_0x25b317});})[_0x6f54('0x47')](function(){return db[_0x6f54('0x70')]['find']({'where':{'TeamId':_0x25821d}});})[_0x6f54('0x47')](function(_0x3467f1){if(_0x3467f1===null){return;}return db[_0x6f54('0x71')][_0x6f54('0x5a')]({'where':{'UserId':{'$in':_0x39ece0},'VoicePrefixId':_0x3467f1[_0x6f54('0x72')]},'transaction':_0x25b317});})[_0x6f54('0x47')](function(){return db[_0x6f54('0x46')][_0x6f54('0x5a')]({'where':{'id':_0x25821d},'cascade':!![],'transaction':_0x25b317});})['then'](function(_0x5d6e88){if(_0x5d6e88===0x0){_0x2dece8[_0x6f54('0x1d')](0x194);}else{return db[_0x6f54('0x58')][_0x6f54('0x5a')]({'where':{'type':_0x6f54('0x54'),'resourceId':_0x25821d},'cascade':!![],'transaction':_0x25b317})[_0x6f54('0x47')](function(){_0x2dece8[_0x6f54('0x1f')](0xcc)['end']();});}})[_0x6f54('0x49')](function(_0x54ccc1){_0x2dece8[_0x6f54('0x1f')](0x1f4)['send'](_0x54ccc1);});});};exports['getQueues']=function(_0x21b4c6,_0x1c9637,_0x554d9a){return db[_0x6f54('0x46')][_0x6f54('0x73')]({'where':{'id':_0x21b4c6['params']['id']}})[_0x6f54('0x47')](handleEntityNotFound(_0x1c9637,null))[_0x6f54('0x47')](function(_0x4fac4e){if(!_0x21b4c6[_0x6f54('0x34')][_0x6f54('0x74')]||!utils['isValidChannel'](_0x21b4c6[_0x6f54('0x34')][_0x6f54('0x74')])){throw new db[(_0x6f54('0x5d'))][(_0x6f54('0x75'))](_0x6f54('0x76'));}var _0x2a1bb2={};var _0x319afc={};_0x319afc['model']=_['keys'](db[_['capitalize'](_0x21b4c6[_0x6f54('0x34')][_0x6f54('0x74')][_0x6f54('0x77')]())+_0x6f54('0x78')][_0x6f54('0x2f')]);_0x319afc[_0x6f54('0x34')]=_[_0x6f54('0x4c')](_0x21b4c6['query']);_0x319afc[_0x6f54('0x35')]=_[_0x6f54('0x36')](_0x319afc[_0x6f54('0x33')],_0x319afc[_0x6f54('0x34')]);_0x2a1bb2[_0x6f54('0x37')]=_[_0x6f54('0x36')](_0x319afc[_0x6f54('0x33')],qs[_0x6f54('0x38')](_0x21b4c6['query'][_0x6f54('0x38')]));_0x2a1bb2[_0x6f54('0x37')]=_0x2a1bb2[_0x6f54('0x37')][_0x6f54('0x39')]?_0x2a1bb2['attributes']:_0x319afc['model'];_0x2a1bb2['limit']=qs[_0x6f54('0x23')](_0x21b4c6[_0x6f54('0x34')][_0x6f54('0x23')]);_0x2a1bb2[_0x6f54('0x20')]=qs[_0x6f54('0x20')](_0x21b4c6[_0x6f54('0x34')]['offset']);_0x2a1bb2[_0x6f54('0x3c')]=qs[_0x6f54('0x3d')](_0x21b4c6['query']['sort']);_0x2a1bb2[_0x6f54('0x3e')]=qs['filters'](_[_0x6f54('0x3f')](_0x21b4c6['query'],_0x319afc[_0x6f54('0x35')]));_0x2a1bb2=_['merge']({},_0x2a1bb2,_0x21b4c6[_0x6f54('0x43')]);return _0x4fac4e[_0x6f54('0x51')+_[_0x6f54('0x79')](_0x21b4c6[_0x6f54('0x34')][_0x6f54('0x74')][_0x6f54('0x77')]())+'Queues'](_0x2a1bb2);})[_0x6f54('0x47')](respondWithResult(_0x1c9637,null))['catch'](handleError(_0x1c9637,null));};exports[_0x6f54('0x7a')]=function(_0x3f324e,_0x516cee,_0x49a397){return db[_0x6f54('0x46')][_0x6f54('0x73')]({'where':{'id':_0x3f324e[_0x6f54('0x4b')]['id']}})[_0x6f54('0x47')](function(_0x4b3ceb){if(_0x4b3ceb){if(!_0x3f324e[_0x6f54('0x4f')][_0x6f54('0x74')]||!utils['isValidChannel'](_0x3f324e['body'][_0x6f54('0x74')])){throw new db[(_0x6f54('0x5d'))]['ValidationError'](_0x6f54('0x76'));}return _0x4b3ceb[_0x6f54('0x7b')+_[_0x6f54('0x79')](_0x3f324e['body'][_0x6f54('0x74')][_0x6f54('0x77')]())+_0x6f54('0x7c')](_0x3f324e[_0x6f54('0x4f')][_0x6f54('0x7d')]);}return null;})[_0x6f54('0x47')](handleEntityNotFound(_0x516cee,null))['then'](respondWithStatusCode(_0x516cee,null))[_0x6f54('0x49')](handleError(_0x516cee,null));};exports[_0x6f54('0x7e')]=function(_0x517742,_0xffd8b7,_0x5cdf3e){return db[_0x6f54('0x46')][_0x6f54('0x73')]({'where':{'id':_0x517742[_0x6f54('0x4b')]['id']}})['then'](function(_0x477b36){if(_0x477b36){if(!_0x517742['query'][_0x6f54('0x74')]||!utils[_0x6f54('0x7f')](_0x517742[_0x6f54('0x34')]['channel'])){throw new db[(_0x6f54('0x5d'))]['ValidationError']('Unknown\x20channel');}return _0x477b36[_0x6f54('0x80')+_['capitalize'](_0x517742[_0x6f54('0x34')]['channel'][_0x6f54('0x77')]())+_0x6f54('0x7c')](_0x517742[_0x6f54('0x34')][_0x6f54('0x7d')]);}return null;})['then'](handleEntityNotFound(_0xffd8b7,null))[_0x6f54('0x47')](respondWithStatusCode(_0xffd8b7,null))[_0x6f54('0x49')](handleError(_0xffd8b7,null));};exports[_0x6f54('0x81')]=function(_0xc51c6c,_0x247b9b){var _0x2a8113=_[_0x6f54('0x82')](_0xc51c6c[_0x6f54('0x4f')]['ids'])?_0xc51c6c[_0x6f54('0x4f')][_0x6f54('0x7d')]:[_0xc51c6c[_0x6f54('0x4f')]['ids']];var _0x11f8f1=_0xc51c6c[_0x6f54('0x4b')]['id'];return db['Team'][_0x6f54('0x4d')]({'where':{'id':_0x11f8f1}})[_0x6f54('0x47')](handleEntityNotFound(_0x247b9b,null))[_0x6f54('0x47')](function(_0x232a10){if(_0x232a10){var _0x5e8b31=[_0x6f54('0x83'),_0x6f54('0x84'),'Mail',_0x6f54('0x85'),_0x6f54('0x86'),_0x6f54('0x87'),'Whatsapp'];return db[_0x6f54('0x5b')][_0x6f54('0x5c')](function(_0x4738d7){var _0x12ca36=_[_0x6f54('0x2e')](_0x5e8b31,function(_0x144e77){var _0x3b831c={'attributes':['id',_0x6f54('0x2b')]};if(_0x144e77===_0x6f54('0x83')){_0x3b831c[_0x6f54('0x88')]={'attributes':[_0x6f54('0x89')]};}return _0x232a10[_0x6f54('0x51')+_0x144e77+_0x6f54('0x7c')](_0x3b831c)[_0x6f54('0x47')](function(_0x9e724f){var _0x2eec7a=_[_0x6f54('0x2e')](_0x9e724f,function(_0x20eb61){var _0x465b34=_[_0x6f54('0x2e')](_0x2a8113,function(_0x58a640){var _0x219ee0={'where':{'UserId':_0x58a640,[_0x144e77+_0x6f54('0x8a')]:_0x20eb61['id']},'transaction':_0x4738d7};if(_0x144e77===_0x6f54('0x83')){_0x219ee0['defaults']={'penalty':_0x20eb61[_0x6f54('0x8b')][_0x6f54('0x89')]};}return db[_0x6f54('0x8c')+_0x144e77+_0x6f54('0x78')][_0x6f54('0x8d')](_0x219ee0)[_0x6f54('0x47')](function(){socket['emit'](_0x6f54('0x50')+_0x144e77+_0x6f54('0x8e'),{'UserId':_0x58a640,[_0x144e77+_0x6f54('0x8a')]:_0x20eb61['id']});if(_0x144e77!==_0x6f54('0x83')){return;}return db[_0x6f54('0x8c')][_0x6f54('0x8f')]({'where':{'id':_0x2a8113,'online':0x1},'attributes':['id',_0x6f54('0x2b'),_0x6f54('0x90'),'voicePause',_0x6f54('0x91')],'raw':!![]})[_0x6f54('0x47')](function(_0x73d27d){var _0x275895=_[_0x6f54('0x2e')](_0x73d27d,function(_0x3c89ae){return db[_0x6f54('0x92')]['upsert']({'membername':_0x3c89ae[_0x6f54('0x2b')],'UserId':_0x3c89ae['id'],'queue_name':_0x20eb61[_0x6f54('0x2b')],'VoiceQueueId':_0x20eb61['id'],'interface':_[_0x6f54('0x93')](_0x3c89ae['interface'])?util['format']('SIP/%s',_0x3c89ae['name']):_0x3c89ae[_0x6f54('0x91')],'paused':_0x3c89ae[_0x6f54('0x94')]||![],'penalty':_0x20eb61['TeamVoiceQueue']['penalty']},{'transaction':_0x4738d7});});return Promise['all'](_0x275895);});});});return Promise[_0x6f54('0x95')](_0x465b34);});return Promise[_0x6f54('0x95')](_0x2eec7a);})[_0x6f54('0x47')](function(){return db['TeamVoicePrefix'][_0x6f54('0x73')]({'where':{'teamId':_0x11f8f1}})['then'](function(_0x1fb152){if(_0x1fb152){var _0x36d07b=_['map'](_0x2a8113,function(_0x2e1070){db[_0x6f54('0x71')][_0x6f54('0x96')]({'UserId':_0x2e1070,'VoicePrefixId':_0x1fb152[_0x6f54('0x72')]});});return Promise[_0x6f54('0x95')](_0x36d07b);}});});});return Promise[_0x6f54('0x95')](_0x12ca36)[_0x6f54('0x47')](function(){return _0x232a10[_0x6f54('0x81')](_0x2a8113,{'transaction':_0x4738d7})['spread'](function(_0x2ea842){return _0x2ea842;});});});}})[_0x6f54('0x47')](respondWithResult(_0x247b9b,null))[_0x6f54('0x49')](handleError(_0x247b9b,null));};exports[_0x6f54('0x97')]=function(_0x4add51,_0x5db883){var _0x2505a0=_[_0x6f54('0x82')](_0x4add51['query'][_0x6f54('0x7d')])?_0x4add51[_0x6f54('0x34')][_0x6f54('0x7d')]:[_0x4add51[_0x6f54('0x34')][_0x6f54('0x7d')]];var _0x4ff1b5=_0x4add51[_0x6f54('0x4b')]['id'];return db[_0x6f54('0x46')][_0x6f54('0x4d')]({'where':{'id':_0x4ff1b5}})[_0x6f54('0x47')](handleEntityNotFound(_0x5db883,null))[_0x6f54('0x47')](function(_0x592456){if(_0x592456){var _0x16f38e=[_0x6f54('0x83'),'Chat',_0x6f54('0x98'),_0x6f54('0x85'),_0x6f54('0x86'),_0x6f54('0x87'),_0x6f54('0x99')];return db[_0x6f54('0x5b')]['transaction'](function(_0x14b9b2){var _0x5c446f=_[_0x6f54('0x2e')](_0x16f38e,function(_0x26273d){var _0x3c620b={'attributes':['id','name']};return _0x592456['get'+_0x26273d+_0x6f54('0x7c')](_0x3c620b)[_0x6f54('0x47')](function(_0x2f47f0){var _0x532ade=_[_0x6f54('0x2e')](_0x2f47f0,function(_0x3ba86b){return _0x3ba86b[_0x6f54('0x97')](_0x2505a0,{'transaction':_0x14b9b2})[_0x6f54('0x47')](function(){var _0x557457=_[_0x6f54('0x2e')](_0x2505a0,function(_0x28f31d){socket['emit']('user'+_0x26273d+_0x6f54('0x9a'),{'UserId':Number(_0x28f31d),[_0x26273d+'QueueId']:_0x3ba86b['id']});if(_0x26273d!==_0x6f54('0x83')){return;}return db[_0x6f54('0x92')][_0x6f54('0x5a')]({'where':{'VoiceQueueId':_0x3ba86b['id'],'UserId':_0x28f31d},'transaction':_0x14b9b2});});return Promise[_0x6f54('0x95')](_0x557457);});});return Promise[_0x6f54('0x95')](_0x532ade);});});return Promise['all'](_0x5c446f)[_0x6f54('0x47')](function(){return _0x592456[_0x6f54('0x97')](_0x2505a0,{'transaction':_0x14b9b2});})[_0x6f54('0x47')](function(){return db[_0x6f54('0x70')][_0x6f54('0x73')]({'where':{'teamId':_0x4ff1b5}})['then'](function(_0x57f81d){if(_0x57f81d){var _0x312096=_['map'](_0x2505a0,function(_0x3c72d9){db[_0x6f54('0x71')][_0x6f54('0x5a')]({'where':{'UserId':_0x3c72d9,'VoicePrefixId':_0x57f81d[_0x6f54('0x72')]}});});return Promise[_0x6f54('0x95')](_0x312096);}});});});}})[_0x6f54('0x47')](respondWithStatusCode(_0x5db883,null))[_0x6f54('0x49')](handleError(_0x5db883,null));};exports['getAgents']=function(_0x20ebeb,_0x474449,_0x3ec6bd){var _0x4bc81e={};var _0x185906={};var _0x3e7a24;var _0x258111;return db[_0x6f54('0x46')][_0x6f54('0x73')]({'where':{'id':_0x20ebeb[_0x6f54('0x4b')]['id']}})['then'](handleEntityNotFound(_0x474449,null))[_0x6f54('0x47')](function(_0x2e78d4){if(_0x2e78d4){_0x3e7a24=_0x2e78d4;_0x185906[_0x6f54('0x33')]=_[_0x6f54('0x4c')](db[_0x6f54('0x8c')][_0x6f54('0x2f')]);_0x185906[_0x6f54('0x34')]=_[_0x6f54('0x4c')](_0x20ebeb[_0x6f54('0x34')]);_0x185906[_0x6f54('0x35')]=_[_0x6f54('0x36')](_0x185906[_0x6f54('0x33')],_0x185906[_0x6f54('0x34')]);_0x4bc81e[_0x6f54('0x37')]=_[_0x6f54('0x36')](_0x185906[_0x6f54('0x33')],qs[_0x6f54('0x38')](_0x20ebeb['query'][_0x6f54('0x38')]));_0x4bc81e[_0x6f54('0x37')]=_0x4bc81e['attributes'][_0x6f54('0x39')]?_0x4bc81e[_0x6f54('0x37')]:_0x185906['model'];_0x4bc81e[_0x6f54('0x3c')]=qs['sort'](_0x20ebeb[_0x6f54('0x34')][_0x6f54('0x3d')]);_0x4bc81e['where']=qs[_0x6f54('0x35')](_[_0x6f54('0x3f')](_0x20ebeb[_0x6f54('0x34')],_0x185906['filters']));if(_0x20ebeb['query']['filter']){_0x4bc81e[_0x6f54('0x3e')]=_[_0x6f54('0x40')](_0x4bc81e[_0x6f54('0x3e')],{'$or':_[_0x6f54('0x2e')](_0x4bc81e[_0x6f54('0x37')],function(_0x25f398){var _0x4e41c8={};_0x4e41c8[_0x25f398]={'$like':'%'+_0x20ebeb[_0x6f54('0x34')]['filter']+'%'};return _0x4e41c8;})});}_0x4bc81e=_[_0x6f54('0x40')]({},_0x4bc81e,_0x20ebeb[_0x6f54('0x43')]);return _0x3e7a24['getAgents'](_0x4bc81e);}})[_0x6f54('0x47')](function(_0x20a5ad){if(_0x20a5ad){_0x258111=_0x20a5ad['length'];if(!_0x20ebeb['query'][_0x6f54('0x3a')](_0x6f54('0x3b'))){_0x4bc81e[_0x6f54('0x23')]=qs[_0x6f54('0x23')](_0x20ebeb[_0x6f54('0x34')]['limit']);_0x4bc81e[_0x6f54('0x20')]=qs[_0x6f54('0x20')](_0x20ebeb['query'][_0x6f54('0x20')]);}return _0x3e7a24[_0x6f54('0x9b')](_0x4bc81e);}})[_0x6f54('0x47')](function(_0x3f1560){if(_0x3f1560){return _0x3f1560?{'count':_0x258111,'rows':_0x3f1560}:null;}})[_0x6f54('0x47')](respondWithResult(_0x474449,null))['catch'](handleError(_0x474449,null));};
\ No newline at end of file