Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / team / team.controller.js
index 934771c..1614d51 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa8f7=['addAgents','removeAgents','Chat','Sms','Queue:remove','getAgents','hasOwnProperty','rimraf','zip-dir','moment','bluebird','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','offset','limit','count','set','Content-Range','apply','reject','save','update','error','stack','name','index','map','Team','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','then','includeAll','include','findAll','catch','show','params','find','create','body','get','role','user','Teams','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','sequelize','Sequelize','SELECT','UserId','SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20','QueryTypes','VoiceQueueId','SELECT\x20MailQueueId\x20FROM\x20team_has_mail_queues\x20WHERE\x20TeamId\x20=\x20','MailQueueId','UserMailQueue','SELECT\x20SmsQueueId\x20FROM\x20team_has_sms_queues\x20WHERE\x20TeamId\x20=\x20','SmsQueueId','UserSmsQueue','SELECT\x20ChatQueueId\x20FROM\x20team_has_chat_queues\x20WHERE\x20TeamId\x20=\x20','ChatQueueId','UserChatQueue','SELECT\x20FaxQueueId\x20FROM\x20team_has_fax_queues\x20WHERE\x20TeamId\x20=\x20','FaxQueueId','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','UserWhatsappQueue','VoicePrefixId','UserProfileResource','send','getQueues','findOne','channel','isValidChannel','ValidationError','Unknown\x20channel','capitalize','toLowerCase','Queue','addQueues','Queues','ids','removeQueues','remove','isArray','Voice','Mail','Fax','Openchannel','Whatsapp','transaction','through','defaults','TeamVoiceQueue','penalty','findOrCreate','emit','Queue:save','QueueId','User','online','voicePause','UserVoiceQueueRt','isNil','interface','format','SIP/%s','all','TeamVoicePrefix','UserVoicePrefix','upsert'];(function(_0x274638,_0x578968){var _0x5755df=function(_0x3227d5){while(--_0x3227d5){_0x274638['push'](_0x274638['shift']());}};_0x5755df(++_0x578968);}(_0xa8f7,0xac));var _0x7a8f=function(_0x3660db,_0x218d3f){_0x3660db=_0x3660db-0x0;var _0x3b394e=_0xa8f7[_0x3660db];return _0x3b394e;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x7a8f('0x0'));var zipdir=require(_0x7a8f('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x7a8f('0x2'));var BPromise=require(_0x7a8f('0x3'));var Mustache=require(_0x7a8f('0x4'));var util=require(_0x7a8f('0x5'));var path=require(_0x7a8f('0x6'));var sox=require(_0x7a8f('0x7'));var csv=require('to-csv');var ejs=require(_0x7a8f('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x7a8f('0x9'));var squel=require(_0x7a8f('0xa'));var crypto=require(_0x7a8f('0xb'));var jsforce=require(_0x7a8f('0xc'));var deskjs=require(_0x7a8f('0xd'));var toCsv=require(_0x7a8f('0xe'));var querystring=require(_0x7a8f('0xf'));var Papa=require(_0x7a8f('0x10'));var Redis=require(_0x7a8f('0x11'));var authService=require(_0x7a8f('0x12'));var qs=require(_0x7a8f('0x13'));var as=require(_0x7a8f('0x14'));var hardwareService=require(_0x7a8f('0x15'));var logger=require(_0x7a8f('0x16'))(_0x7a8f('0x17'));var utils=require('../../config/utils');var config=require(_0x7a8f('0x18'));var licenseUtil=require(_0x7a8f('0x19'));var db=require(_0x7a8f('0x1a'))['db'];config[_0x7a8f('0x1b')]=_['defaults'](config[_0x7a8f('0x1b')],{'host':_0x7a8f('0x1c'),'port':0x18eb});var socket=require(_0x7a8f('0x1d'))(new Redis(config[_0x7a8f('0x1b')]));require('./team.socket')[_0x7a8f('0x1e')](socket);function respondWithStatusCode(_0x39098d,_0x1fedbc){_0x1fedbc=_0x1fedbc||0xcc;return function(_0x59592f){if(_0x59592f){return _0x39098d[_0x7a8f('0x1f')](_0x1fedbc);}return _0x39098d[_0x7a8f('0x20')](_0x1fedbc)[_0x7a8f('0x21')]();};}function respondWithResult(_0x58c66f,_0xcb856c){_0xcb856c=_0xcb856c||0xc8;return function(_0x5c1e2f){if(_0x5c1e2f){return _0x58c66f[_0x7a8f('0x20')](_0xcb856c)[_0x7a8f('0x22')](_0x5c1e2f);}};}function respondWithFilteredResult(_0x22c28d,_0x418e81){return function(_0x41065f){if(_0x41065f){var _0x21b79c=typeof _0x418e81[_0x7a8f('0x23')]==='undefined'&&typeof _0x418e81[_0x7a8f('0x24')]==='undefined';var _0x5e1cc2=_0x41065f[_0x7a8f('0x25')];var _0x14560b=_0x21b79c?0x0:_0x418e81['offset'];var _0x13b22b=_0x21b79c?_0x41065f[_0x7a8f('0x25')]:_0x418e81[_0x7a8f('0x23')]+_0x418e81['limit'];var _0x2edd34;if(_0x13b22b>=_0x5e1cc2){_0x13b22b=_0x5e1cc2;_0x2edd34=0xc8;}else{_0x2edd34=0xce;}_0x22c28d[_0x7a8f('0x20')](_0x2edd34);return _0x22c28d[_0x7a8f('0x26')](_0x7a8f('0x27'),_0x14560b+'-'+_0x13b22b+'/'+_0x5e1cc2)[_0x7a8f('0x22')](_0x41065f);}return null;};}function patchUpdates(_0x1cb497){return function(_0x35fd68){try{jsonpatch[_0x7a8f('0x28')](_0x35fd68,_0x1cb497,!![]);}catch(_0x349820){return BPromise[_0x7a8f('0x29')](_0x349820);}return _0x35fd68[_0x7a8f('0x2a')]();};}function saveUpdates(_0x38a630,_0x21fe33){return function(_0x70b0be){if(_0x70b0be){return _0x70b0be[_0x7a8f('0x2b')](_0x38a630)['then'](function(_0x342a62){return _0x342a62;});}return null;};}function handleEntityNotFound(_0x59d687,_0x85e982){return function(_0x1ce638){if(!_0x1ce638){_0x59d687['sendStatus'](0x194);}return _0x1ce638;};}function handleError(_0x647dcb,_0x3d034d){_0x3d034d=_0x3d034d||0x1f4;return function(_0x2e71f7){logger[_0x7a8f('0x2c')](_0x2e71f7[_0x7a8f('0x2d')]);if(_0x2e71f7[_0x7a8f('0x2e')]){delete _0x2e71f7['name'];}_0x647dcb[_0x7a8f('0x20')](_0x3d034d)['send'](_0x2e71f7);};}exports[_0x7a8f('0x2f')]=function(_0x20031b,_0x40b569){var _0x4f0fbd={},_0x46f638={},_0x5e9ac9={'count':0x0,'rows':[]};var _0x22bd33=_[_0x7a8f('0x30')](db[_0x7a8f('0x31')][_0x7a8f('0x32')],function(_0x1654ac){return{'name':_0x1654ac[_0x7a8f('0x33')],'type':_0x1654ac[_0x7a8f('0x34')][_0x7a8f('0x35')]};});_0x46f638[_0x7a8f('0x36')]=_['map'](_0x22bd33,_0x7a8f('0x2e'));_0x46f638[_0x7a8f('0x37')]=_[_0x7a8f('0x38')](_0x20031b[_0x7a8f('0x37')]);_0x46f638[_0x7a8f('0x39')]=_['intersection'](_0x46f638[_0x7a8f('0x36')],_0x46f638[_0x7a8f('0x37')]);_0x4f0fbd[_0x7a8f('0x3a')]=_[_0x7a8f('0x3b')](_0x46f638['model'],qs['fields'](_0x20031b['query'][_0x7a8f('0x3c')]));_0x4f0fbd[_0x7a8f('0x3a')]=_0x4f0fbd['attributes'][_0x7a8f('0x3d')]?_0x4f0fbd['attributes']:_0x46f638[_0x7a8f('0x36')];if(!_0x20031b[_0x7a8f('0x37')]['hasOwnProperty'](_0x7a8f('0x3e'))){_0x4f0fbd[_0x7a8f('0x24')]=qs['limit'](_0x20031b[_0x7a8f('0x37')][_0x7a8f('0x24')]);_0x4f0fbd['offset']=qs[_0x7a8f('0x23')](_0x20031b[_0x7a8f('0x37')][_0x7a8f('0x23')]);}_0x4f0fbd[_0x7a8f('0x3f')]=qs[_0x7a8f('0x40')](_0x20031b[_0x7a8f('0x37')][_0x7a8f('0x40')]);_0x4f0fbd[_0x7a8f('0x41')]=qs[_0x7a8f('0x39')](_[_0x7a8f('0x42')](_0x20031b[_0x7a8f('0x37')],_0x46f638[_0x7a8f('0x39')]),_0x22bd33);if(_0x20031b[_0x7a8f('0x37')][_0x7a8f('0x43')]){_0x4f0fbd[_0x7a8f('0x41')]=_[_0x7a8f('0x44')](_0x4f0fbd[_0x7a8f('0x41')],{'$or':_[_0x7a8f('0x30')](_0x22bd33,function(_0x328073){if(_0x328073[_0x7a8f('0x34')]!==_0x7a8f('0x45')){var _0x4c6498={};_0x4c6498[_0x328073[_0x7a8f('0x2e')]]={'$like':'%'+_0x20031b[_0x7a8f('0x37')][_0x7a8f('0x43')]+'%'};return _0x4c6498;}})});}_0x4f0fbd=_['merge']({},_0x4f0fbd,_0x20031b[_0x7a8f('0x46')]);var _0xa55d71={'where':_0x4f0fbd[_0x7a8f('0x41')]};return db[_0x7a8f('0x31')][_0x7a8f('0x25')](_0xa55d71)[_0x7a8f('0x47')](function(_0x55b25b){_0x5e9ac9[_0x7a8f('0x25')]=_0x55b25b;if(_0x20031b[_0x7a8f('0x37')][_0x7a8f('0x48')]){_0x4f0fbd[_0x7a8f('0x49')]=[{'all':!![]}];}return db['Team'][_0x7a8f('0x4a')](_0x4f0fbd);})[_0x7a8f('0x47')](function(_0x1a2859){_0x5e9ac9['rows']=_0x1a2859;return _0x5e9ac9;})[_0x7a8f('0x47')](respondWithFilteredResult(_0x40b569,_0x4f0fbd))[_0x7a8f('0x4b')](handleError(_0x40b569,null));};exports[_0x7a8f('0x4c')]=function(_0x4e3eb9,_0x2d6965){var _0x1afa3e={'raw':![],'where':{'id':_0x4e3eb9[_0x7a8f('0x4d')]['id']}},_0x328402={};_0x328402[_0x7a8f('0x36')]=_[_0x7a8f('0x38')](db[_0x7a8f('0x31')]['rawAttributes']);_0x328402[_0x7a8f('0x37')]=_['keys'](_0x4e3eb9[_0x7a8f('0x37')]);_0x328402['filters']=_[_0x7a8f('0x3b')](_0x328402[_0x7a8f('0x36')],_0x328402[_0x7a8f('0x37')]);_0x1afa3e[_0x7a8f('0x3a')]=_[_0x7a8f('0x3b')](_0x328402['model'],qs[_0x7a8f('0x3c')](_0x4e3eb9[_0x7a8f('0x37')][_0x7a8f('0x3c')]));_0x1afa3e[_0x7a8f('0x3a')]=_0x1afa3e[_0x7a8f('0x3a')][_0x7a8f('0x3d')]?_0x1afa3e[_0x7a8f('0x3a')]:_0x328402[_0x7a8f('0x36')];if(_0x4e3eb9[_0x7a8f('0x37')][_0x7a8f('0x48')]){_0x1afa3e[_0x7a8f('0x49')]=[{'all':!![]}];}_0x1afa3e=_[_0x7a8f('0x44')]({},_0x1afa3e,_0x4e3eb9['options']);return db['Team'][_0x7a8f('0x4e')](_0x1afa3e)[_0x7a8f('0x47')](handleEntityNotFound(_0x2d6965,null))[_0x7a8f('0x47')](respondWithResult(_0x2d6965,null))[_0x7a8f('0x4b')](handleError(_0x2d6965,null));};exports[_0x7a8f('0x4f')]=function(_0x5d8b59,_0x226c5e){return db[_0x7a8f('0x31')][_0x7a8f('0x4f')](_0x5d8b59[_0x7a8f('0x50')],{})['then'](function(_0x5b16ef){var _0x57f7b4=_0x5d8b59['user'][_0x7a8f('0x51')]({'plain':!![]});if(!_0x57f7b4)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x57f7b4[_0x7a8f('0x52')]===_0x7a8f('0x53')){var _0x4cf6a7=_0x5b16ef[_0x7a8f('0x51')]({'plain':!![]});var _0x332e46=_0x7a8f('0x54');return db[_0x7a8f('0x55')][_0x7a8f('0x4e')]({'where':{'name':_0x332e46,'userProfileId':_0x57f7b4[_0x7a8f('0x56')]},'raw':!![]})[_0x7a8f('0x47')](function(_0x212d30){if(_0x212d30&&_0x212d30[_0x7a8f('0x57')]===0x0){return db['UserProfileResource']['create']({'name':_0x4cf6a7[_0x7a8f('0x2e')],'resourceId':_0x4cf6a7['id'],'type':_0x212d30[_0x7a8f('0x2e')],'sectionId':_0x212d30['id']},{})[_0x7a8f('0x47')](function(){return _0x5b16ef;});}else{return _0x5b16ef;}})[_0x7a8f('0x4b')](function(_0x47f52e){logger[_0x7a8f('0x2c')](_0x7a8f('0x58'),_0x47f52e);throw _0x47f52e;});}return _0x5b16ef;})[_0x7a8f('0x47')](respondWithResult(_0x226c5e,0xc9))[_0x7a8f('0x4b')](handleError(_0x226c5e,null));};exports[_0x7a8f('0x2b')]=function(_0x13d8ff,_0x50817b){if(_0x13d8ff[_0x7a8f('0x50')]['id']){delete _0x13d8ff[_0x7a8f('0x50')]['id'];}return db['Team']['find']({'where':{'id':_0x13d8ff[_0x7a8f('0x4d')]['id']}})[_0x7a8f('0x47')](handleEntityNotFound(_0x50817b,null))[_0x7a8f('0x47')](saveUpdates(_0x13d8ff['body'],null))['then'](respondWithResult(_0x50817b,null))[_0x7a8f('0x4b')](handleError(_0x50817b,null));};exports[_0x7a8f('0x59')]=function(_0x50312f,_0x4000ee){var _0x537236=_0x50312f[_0x7a8f('0x4d')]['id'];var _0x511591=[];return db[_0x7a8f('0x5a')]['transaction'](function(_0x1382d4){var _0x336a47='SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20'+_0x537236;return db['sequelize']['query'](_0x336a47,{'type':db[_0x7a8f('0x5b')]['QueryTypes'][_0x7a8f('0x5c')],'raw':!![],'transaction':_0x1382d4})['then'](function(_0x4c7444){_0x511591=_['map'](_0x4c7444,function(_0x51a33d){return Number(_0x51a33d[_0x7a8f('0x5d')]);});})[_0x7a8f('0x47')](function(){var _0x20bcf6=_0x7a8f('0x5e')+_0x537236;return db[_0x7a8f('0x5a')][_0x7a8f('0x37')](_0x20bcf6,{'type':db[_0x7a8f('0x5b')][_0x7a8f('0x5f')][_0x7a8f('0x5c')],'raw':!![],'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(_0x4caac5){var _0xf407a3=_[_0x7a8f('0x30')](_0x4caac5,function(_0x270271){return Number(_0x270271[_0x7a8f('0x60')]);});return db['UserVoiceQueue'][_0x7a8f('0x59')]({'where':{'UserId':{'$in':_0x511591},'VoiceQueueId':{'$in':_0xf407a3}},'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(){var _0x171ab4=_0x7a8f('0x61')+_0x537236;return db[_0x7a8f('0x5a')][_0x7a8f('0x37')](_0x171ab4,{'type':db[_0x7a8f('0x5b')]['QueryTypes'][_0x7a8f('0x5c')],'raw':!![],'transaction':_0x1382d4});})['then'](function(_0xdfcb10){var _0x28b52c=_['map'](_0xdfcb10,function(_0x5d1e85){return Number(_0x5d1e85[_0x7a8f('0x62')]);});return db[_0x7a8f('0x63')]['destroy']({'where':{'UserId':{'$in':_0x511591},'MailQueueId':{'$in':_0x28b52c}},'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(){var _0xe3da26=_0x7a8f('0x64')+_0x537236;return db[_0x7a8f('0x5a')]['query'](_0xe3da26,{'type':db[_0x7a8f('0x5b')]['QueryTypes'][_0x7a8f('0x5c')],'raw':!![],'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(_0x5da3bb){var _0x1b65c8=_[_0x7a8f('0x30')](_0x5da3bb,function(_0x3675ef){return Number(_0x3675ef[_0x7a8f('0x65')]);});return db[_0x7a8f('0x66')]['destroy']({'where':{'UserId':{'$in':_0x511591},'SmsQueueId':{'$in':_0x1b65c8}},'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(){var _0xf5830=_0x7a8f('0x67')+_0x537236;return db['sequelize']['query'](_0xf5830,{'type':db[_0x7a8f('0x5b')][_0x7a8f('0x5f')][_0x7a8f('0x5c')],'raw':!![],'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(_0x1bfdf0){var _0x3af696=_['map'](_0x1bfdf0,function(_0x158e5a){return Number(_0x158e5a[_0x7a8f('0x68')]);});return db[_0x7a8f('0x69')][_0x7a8f('0x59')]({'where':{'UserId':{'$in':_0x511591},'ChatQueueId':{'$in':_0x3af696}},'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(){var _0x437ab2=_0x7a8f('0x6a')+_0x537236;return db[_0x7a8f('0x5a')][_0x7a8f('0x37')](_0x437ab2,{'type':db['Sequelize']['QueryTypes'][_0x7a8f('0x5c')],'raw':!![],'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(_0x285e3a){var _0x64e808=_[_0x7a8f('0x30')](_0x285e3a,function(_0x4ea673){return Number(_0x4ea673[_0x7a8f('0x6b')]);});return db[_0x7a8f('0x6c')][_0x7a8f('0x59')]({'where':{'UserId':{'$in':_0x511591},'FaxQueueId':{'$in':_0x64e808}},'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(){var _0x5d12b1=_0x7a8f('0x6d')+_0x537236;return db[_0x7a8f('0x5a')][_0x7a8f('0x37')](_0x5d12b1,{'type':db['Sequelize'][_0x7a8f('0x5f')][_0x7a8f('0x5c')],'raw':!![],'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(_0x3d37bf){var _0x4926e2=_[_0x7a8f('0x30')](_0x3d37bf,function(_0x24b5d3){return Number(_0x24b5d3[_0x7a8f('0x6e')]);});return db[_0x7a8f('0x6f')][_0x7a8f('0x59')]({'where':{'UserId':{'$in':_0x511591},'OpenchannelQueueId':{'$in':_0x4926e2}},'transaction':_0x1382d4});})['then'](function(){var _0x27d11d=_0x7a8f('0x70')+_0x537236;return db[_0x7a8f('0x5a')][_0x7a8f('0x37')](_0x27d11d,{'type':db[_0x7a8f('0x5b')][_0x7a8f('0x5f')][_0x7a8f('0x5c')],'raw':!![],'transaction':_0x1382d4});})['then'](function(_0x20e4da){var _0x3b4526=_[_0x7a8f('0x30')](_0x20e4da,function(_0x4dde2e){return Number(_0x4dde2e['WhatsappQueueId']);});return db[_0x7a8f('0x71')][_0x7a8f('0x59')]({'where':{'UserId':{'$in':_0x511591},'WhatsappQueueId':{'$in':_0x3b4526}},'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(){return db['TeamVoicePrefix']['find']({'where':{'TeamId':_0x537236}});})[_0x7a8f('0x47')](function(_0x111efe){if(_0x111efe===null){return;}return db['UserVoicePrefix'][_0x7a8f('0x59')]({'where':{'UserId':{'$in':_0x511591},'VoicePrefixId':_0x111efe[_0x7a8f('0x72')]},'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(){return db['Team'][_0x7a8f('0x59')]({'where':{'id':_0x537236},'cascade':!![],'transaction':_0x1382d4});})[_0x7a8f('0x47')](function(_0x261935){if(_0x261935===0x0){_0x4000ee[_0x7a8f('0x1f')](0x194);}else{return db[_0x7a8f('0x73')]['destroy']({'where':{'type':'Teams','resourceId':_0x537236},'cascade':!![],'transaction':_0x1382d4})['then'](function(){_0x4000ee['status'](0xcc)['end']();});}})[_0x7a8f('0x4b')](function(_0x5b9f0f){_0x4000ee['status'](0x1f4)[_0x7a8f('0x74')](_0x5b9f0f);});});};exports[_0x7a8f('0x75')]=function(_0x5c2608,_0x216603,_0x121fa2){return db[_0x7a8f('0x31')][_0x7a8f('0x76')]({'where':{'id':_0x5c2608[_0x7a8f('0x4d')]['id']}})['then'](handleEntityNotFound(_0x216603,null))[_0x7a8f('0x47')](function(_0x5177a4){if(!_0x5c2608[_0x7a8f('0x37')][_0x7a8f('0x77')]||!utils[_0x7a8f('0x78')](_0x5c2608['query'][_0x7a8f('0x77')])){throw new db[(_0x7a8f('0x5b'))][(_0x7a8f('0x79'))](_0x7a8f('0x7a'));}var _0x2e662c={};var _0x2a7d8b={};_0x2a7d8b[_0x7a8f('0x36')]=_['keys'](db[_[_0x7a8f('0x7b')](_0x5c2608[_0x7a8f('0x37')][_0x7a8f('0x77')][_0x7a8f('0x7c')]())+_0x7a8f('0x7d')][_0x7a8f('0x32')]);_0x2a7d8b['query']=_[_0x7a8f('0x38')](_0x5c2608['query']);_0x2a7d8b[_0x7a8f('0x39')]=_[_0x7a8f('0x3b')](_0x2a7d8b[_0x7a8f('0x36')],_0x2a7d8b['query']);_0x2e662c[_0x7a8f('0x3a')]=_['intersection'](_0x2a7d8b[_0x7a8f('0x36')],qs[_0x7a8f('0x3c')](_0x5c2608[_0x7a8f('0x37')]['fields']));_0x2e662c[_0x7a8f('0x3a')]=_0x2e662c[_0x7a8f('0x3a')][_0x7a8f('0x3d')]?_0x2e662c[_0x7a8f('0x3a')]:_0x2a7d8b['model'];_0x2e662c[_0x7a8f('0x24')]=qs[_0x7a8f('0x24')](_0x5c2608['query'][_0x7a8f('0x24')]);_0x2e662c[_0x7a8f('0x23')]=qs[_0x7a8f('0x23')](_0x5c2608[_0x7a8f('0x37')][_0x7a8f('0x23')]);_0x2e662c[_0x7a8f('0x3f')]=qs[_0x7a8f('0x40')](_0x5c2608[_0x7a8f('0x37')]['sort']);_0x2e662c[_0x7a8f('0x41')]=qs['filters'](_[_0x7a8f('0x42')](_0x5c2608[_0x7a8f('0x37')],_0x2a7d8b['filters']));_0x2e662c=_[_0x7a8f('0x44')]({},_0x2e662c,_0x5c2608['options']);return _0x5177a4[_0x7a8f('0x51')+_[_0x7a8f('0x7b')](_0x5c2608['query'][_0x7a8f('0x77')][_0x7a8f('0x7c')]())+'Queues'](_0x2e662c);})[_0x7a8f('0x47')](respondWithResult(_0x216603,null))[_0x7a8f('0x4b')](handleError(_0x216603,null));};exports[_0x7a8f('0x7e')]=function(_0x2f9f2a,_0x7aead1,_0x18bae6){return db[_0x7a8f('0x31')]['findOne']({'where':{'id':_0x2f9f2a[_0x7a8f('0x4d')]['id']}})['then'](function(_0x3537d5){if(_0x3537d5){if(!_0x2f9f2a[_0x7a8f('0x50')][_0x7a8f('0x77')]||!utils[_0x7a8f('0x78')](_0x2f9f2a[_0x7a8f('0x50')][_0x7a8f('0x77')])){throw new db[(_0x7a8f('0x5b'))]['ValidationError'](_0x7a8f('0x7a'));}return _0x3537d5['add'+_[_0x7a8f('0x7b')](_0x2f9f2a[_0x7a8f('0x50')][_0x7a8f('0x77')][_0x7a8f('0x7c')]())+_0x7a8f('0x7f')](_0x2f9f2a[_0x7a8f('0x50')][_0x7a8f('0x80')]);}return null;})['then'](handleEntityNotFound(_0x7aead1,null))['then'](respondWithStatusCode(_0x7aead1,null))[_0x7a8f('0x4b')](handleError(_0x7aead1,null));};exports[_0x7a8f('0x81')]=function(_0x37e4a0,_0x3d7099,_0x444634){return db['Team'][_0x7a8f('0x76')]({'where':{'id':_0x37e4a0['params']['id']}})['then'](function(_0x4c14dc){if(_0x4c14dc){if(!_0x37e4a0[_0x7a8f('0x37')][_0x7a8f('0x77')]||!utils[_0x7a8f('0x78')](_0x37e4a0[_0x7a8f('0x37')]['channel'])){throw new db[(_0x7a8f('0x5b'))][(_0x7a8f('0x79'))](_0x7a8f('0x7a'));}return _0x4c14dc[_0x7a8f('0x82')+_[_0x7a8f('0x7b')](_0x37e4a0[_0x7a8f('0x37')][_0x7a8f('0x77')][_0x7a8f('0x7c')]())+'Queues'](_0x37e4a0[_0x7a8f('0x37')][_0x7a8f('0x80')]);}return null;})[_0x7a8f('0x47')](handleEntityNotFound(_0x3d7099,null))[_0x7a8f('0x47')](respondWithStatusCode(_0x3d7099,null))[_0x7a8f('0x4b')](handleError(_0x3d7099,null));};exports['addAgents']=function(_0x21444e,_0x2af480){var _0xda60e3=_[_0x7a8f('0x83')](_0x21444e[_0x7a8f('0x50')][_0x7a8f('0x80')])?_0x21444e[_0x7a8f('0x50')][_0x7a8f('0x80')]:[_0x21444e['body'][_0x7a8f('0x80')]];var _0x27693b=_0x21444e[_0x7a8f('0x4d')]['id'];return db[_0x7a8f('0x31')][_0x7a8f('0x4e')]({'where':{'id':_0x27693b}})[_0x7a8f('0x47')](handleEntityNotFound(_0x2af480,null))[_0x7a8f('0x47')](function(_0x564196){if(_0x564196){var _0x4c2643=[_0x7a8f('0x84'),'Chat',_0x7a8f('0x85'),'Sms',_0x7a8f('0x86'),_0x7a8f('0x87'),_0x7a8f('0x88')];return db[_0x7a8f('0x5a')][_0x7a8f('0x89')](function(_0x5d75ad){var _0x336554=_[_0x7a8f('0x30')](_0x4c2643,function(_0x36bb8b){var _0x2e04d3={'attributes':['id',_0x7a8f('0x2e')]};if(_0x36bb8b==='Voice'){_0x2e04d3[_0x7a8f('0x8a')]={'attributes':['penalty']};}return _0x564196[_0x7a8f('0x51')+_0x36bb8b+_0x7a8f('0x7f')](_0x2e04d3)[_0x7a8f('0x47')](function(_0x35e297){var _0x22c208=_[_0x7a8f('0x30')](_0x35e297,function(_0x4ab0d3){var _0x347d4a=_[_0x7a8f('0x30')](_0xda60e3,function(_0x9d3919){var _0x3b2a03={'where':{'UserId':_0x9d3919,[_0x36bb8b+'QueueId']:_0x4ab0d3['id']},'transaction':_0x5d75ad};if(_0x36bb8b===_0x7a8f('0x84')){_0x3b2a03[_0x7a8f('0x8b')]={'penalty':_0x4ab0d3[_0x7a8f('0x8c')][_0x7a8f('0x8d')]};}return db['User'+_0x36bb8b+'Queue'][_0x7a8f('0x8e')](_0x3b2a03)['then'](function(){socket[_0x7a8f('0x8f')](_0x7a8f('0x53')+_0x36bb8b+_0x7a8f('0x90'),{'UserId':_0x9d3919,[_0x36bb8b+_0x7a8f('0x91')]:_0x4ab0d3['id']});if(_0x36bb8b!==_0x7a8f('0x84')){return;}return db[_0x7a8f('0x92')][_0x7a8f('0x4a')]({'where':{'id':_0xda60e3,'online':0x1},'attributes':['id',_0x7a8f('0x2e'),_0x7a8f('0x93'),_0x7a8f('0x94'),'interface'],'raw':!![]})[_0x7a8f('0x47')](function(_0xa4420c){var _0x4d92c1=_['map'](_0xa4420c,function(_0x48f88f){return db[_0x7a8f('0x95')]['upsert']({'membername':_0x48f88f['name'],'UserId':_0x48f88f['id'],'queue_name':_0x4ab0d3[_0x7a8f('0x2e')],'VoiceQueueId':_0x4ab0d3['id'],'interface':_[_0x7a8f('0x96')](_0x48f88f[_0x7a8f('0x97')])?util[_0x7a8f('0x98')](_0x7a8f('0x99'),_0x48f88f[_0x7a8f('0x2e')]):_0x48f88f['interface'],'paused':_0x48f88f['voicePause']||![],'penalty':_0x4ab0d3[_0x7a8f('0x8c')][_0x7a8f('0x8d')]},{'transaction':_0x5d75ad});});return Promise['all'](_0x4d92c1);});});});return Promise[_0x7a8f('0x9a')](_0x347d4a);});return Promise[_0x7a8f('0x9a')](_0x22c208);})['then'](function(){return db[_0x7a8f('0x9b')][_0x7a8f('0x76')]({'where':{'teamId':_0x27693b}})[_0x7a8f('0x47')](function(_0x46d49c){if(_0x46d49c){var _0x39c09b=_[_0x7a8f('0x30')](_0xda60e3,function(_0x41d8b6){db[_0x7a8f('0x9c')][_0x7a8f('0x9d')]({'UserId':_0x41d8b6,'VoicePrefixId':_0x46d49c['VoicePrefixId']});});return Promise[_0x7a8f('0x9a')](_0x39c09b);}});});});return Promise[_0x7a8f('0x9a')](_0x336554)['then'](function(){return _0x564196[_0x7a8f('0x9e')](_0xda60e3,{'transaction':_0x5d75ad})['spread'](function(_0x132e7e){return _0x132e7e;});});});}})[_0x7a8f('0x47')](respondWithResult(_0x2af480,null))[_0x7a8f('0x4b')](handleError(_0x2af480,null));};exports[_0x7a8f('0x9f')]=function(_0x3763fe,_0x1992b5){var _0x57542a=_[_0x7a8f('0x83')](_0x3763fe[_0x7a8f('0x37')][_0x7a8f('0x80')])?_0x3763fe[_0x7a8f('0x37')][_0x7a8f('0x80')]:[_0x3763fe['query']['ids']];var _0x5a310b=_0x3763fe['params']['id'];return db[_0x7a8f('0x31')]['find']({'where':{'id':_0x5a310b}})[_0x7a8f('0x47')](handleEntityNotFound(_0x1992b5,null))[_0x7a8f('0x47')](function(_0x5ed0b2){if(_0x5ed0b2){var _0x41aea2=[_0x7a8f('0x84'),_0x7a8f('0xa0'),_0x7a8f('0x85'),_0x7a8f('0xa1'),'Fax',_0x7a8f('0x87'),_0x7a8f('0x88')];return db[_0x7a8f('0x5a')][_0x7a8f('0x89')](function(_0x2fa54b){var _0x2d8f73=_[_0x7a8f('0x30')](_0x41aea2,function(_0x416279){var _0x50137b={'attributes':['id',_0x7a8f('0x2e')]};return _0x5ed0b2[_0x7a8f('0x51')+_0x416279+_0x7a8f('0x7f')](_0x50137b)[_0x7a8f('0x47')](function(_0x4af53a){var _0x322bdb=_[_0x7a8f('0x30')](_0x4af53a,function(_0x1dea56){return _0x1dea56[_0x7a8f('0x9f')](_0x57542a,{'transaction':_0x2fa54b})[_0x7a8f('0x47')](function(){var _0x288b47=_[_0x7a8f('0x30')](_0x57542a,function(_0x8df7df){socket[_0x7a8f('0x8f')]('user'+_0x416279+_0x7a8f('0xa2'),{'UserId':Number(_0x8df7df),[_0x416279+'QueueId']:_0x1dea56['id']});if(_0x416279!==_0x7a8f('0x84')){return;}return db[_0x7a8f('0x95')][_0x7a8f('0x59')]({'where':{'VoiceQueueId':_0x1dea56['id'],'UserId':_0x8df7df},'transaction':_0x2fa54b});});return Promise[_0x7a8f('0x9a')](_0x288b47);});});return Promise[_0x7a8f('0x9a')](_0x322bdb);});});return Promise[_0x7a8f('0x9a')](_0x2d8f73)[_0x7a8f('0x47')](function(){return _0x5ed0b2[_0x7a8f('0x9f')](_0x57542a,{'transaction':_0x2fa54b});})[_0x7a8f('0x47')](function(){return db[_0x7a8f('0x9b')][_0x7a8f('0x76')]({'where':{'teamId':_0x5a310b}})[_0x7a8f('0x47')](function(_0x406ae4){if(_0x406ae4){var _0x490ae3=_[_0x7a8f('0x30')](_0x57542a,function(_0x4d9e09){db['UserVoicePrefix'][_0x7a8f('0x59')]({'where':{'UserId':_0x4d9e09,'VoicePrefixId':_0x406ae4[_0x7a8f('0x72')]}});});return Promise['all'](_0x490ae3);}});});});}})[_0x7a8f('0x47')](respondWithStatusCode(_0x1992b5,null))[_0x7a8f('0x4b')](handleError(_0x1992b5,null));};exports[_0x7a8f('0xa3')]=function(_0x10c0a0,_0x507043,_0xda122b){var _0x1e503d={};var _0x963f1={};var _0xc18c31;var _0x2fda0e;return db['Team'][_0x7a8f('0x76')]({'where':{'id':_0x10c0a0[_0x7a8f('0x4d')]['id']}})['then'](handleEntityNotFound(_0x507043,null))[_0x7a8f('0x47')](function(_0x5de3a0){if(_0x5de3a0){_0xc18c31=_0x5de3a0;_0x963f1['model']=_[_0x7a8f('0x38')](db['User'][_0x7a8f('0x32')]);_0x963f1[_0x7a8f('0x37')]=_['keys'](_0x10c0a0[_0x7a8f('0x37')]);_0x963f1['filters']=_['intersection'](_0x963f1[_0x7a8f('0x36')],_0x963f1['query']);_0x1e503d['attributes']=_[_0x7a8f('0x3b')](_0x963f1[_0x7a8f('0x36')],qs[_0x7a8f('0x3c')](_0x10c0a0['query']['fields']));_0x1e503d[_0x7a8f('0x3a')]=_0x1e503d[_0x7a8f('0x3a')]['length']?_0x1e503d[_0x7a8f('0x3a')]:_0x963f1['model'];_0x1e503d[_0x7a8f('0x3f')]=qs['sort'](_0x10c0a0[_0x7a8f('0x37')]['sort']);_0x1e503d[_0x7a8f('0x41')]=qs[_0x7a8f('0x39')](_[_0x7a8f('0x42')](_0x10c0a0[_0x7a8f('0x37')],_0x963f1['filters']));if(_0x10c0a0[_0x7a8f('0x37')][_0x7a8f('0x43')]){_0x1e503d['where']=_[_0x7a8f('0x44')](_0x1e503d[_0x7a8f('0x41')],{'$or':_[_0x7a8f('0x30')](_0x1e503d[_0x7a8f('0x3a')],function(_0x3077ff){var _0x62d017={};_0x62d017[_0x3077ff]={'$like':'%'+_0x10c0a0[_0x7a8f('0x37')][_0x7a8f('0x43')]+'%'};return _0x62d017;})});}_0x1e503d=_[_0x7a8f('0x44')]({},_0x1e503d,_0x10c0a0[_0x7a8f('0x46')]);return _0xc18c31[_0x7a8f('0xa3')](_0x1e503d);}})[_0x7a8f('0x47')](function(_0x2bea3b){if(_0x2bea3b){_0x2fda0e=_0x2bea3b[_0x7a8f('0x3d')];if(!_0x10c0a0['query'][_0x7a8f('0xa4')](_0x7a8f('0x3e'))){_0x1e503d[_0x7a8f('0x24')]=qs[_0x7a8f('0x24')](_0x10c0a0[_0x7a8f('0x37')][_0x7a8f('0x24')]);_0x1e503d[_0x7a8f('0x23')]=qs['offset'](_0x10c0a0[_0x7a8f('0x37')][_0x7a8f('0x23')]);}return _0xc18c31[_0x7a8f('0xa3')](_0x1e503d);}})[_0x7a8f('0x47')](function(_0x21ed10){if(_0x21ed10){return _0x21ed10?{'count':_0x2fda0e,'rows':_0x21ed10}:null;}})[_0x7a8f('0x47')](respondWithResult(_0x507043,null))[_0x7a8f('0x4b')](handleError(_0x507043,null));};
\ No newline at end of file
+var _0x6380=['Queue','Queues','ValidationError','add','removeQueues','remove','addAgents','isArray','ids','Voice','Chat','Mail','Sms','Openchannel','Whatsapp','through','penalty','QueueId','defaults','TeamVoiceQueue','User','Queue:save','online','voicePause','interface','UserVoiceQueueRt','upsert','isNil','format','SIP/%s','all','spread','removeAgents','Fax','Queue:remove','getAgents','hasOwnProperty','zip-dir','bluebird','mustache','util','sox','to-csv','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./team.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','save','error','stack','name','send','index','Team','rawAttributes','fieldName','type','key','map','query','keys','intersection','model','attributes','fields','length','order','sort','where','filters','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','then','rows','params','find','catch','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','update','body','sequelize','transaction','SELECT\x20UserId\x20FROM\x20user_has_teams\x20WHERE\x20TeamId\x20=\x20','Sequelize','QueryTypes','SELECT','SELECT\x20VoiceQueueId\x20FROM\x20team_has_voice_queues\x20WHERE\x20TeamId\x20=\x20','VoiceQueueId','UserVoiceQueue','destroy','SELECT\x20MailQueueId\x20FROM\x20team_has_mail_queues\x20WHERE\x20TeamId\x20=\x20','MailQueueId','UserMailQueue','UserSmsQueue','SELECT\x20ChatQueueId\x20FROM\x20team_has_chat_queues\x20WHERE\x20TeamId\x20=\x20','ChatQueueId','UserChatQueue','UserFaxQueue','OpenchannelQueueId','UserOpenchannelQueue','SELECT\x20WhatsappQueueId\x20FROM\x20team_has_whatsapp_queues\x20WHERE\x20TeamId\x20=\x20','WhatsappQueueId','UserWhatsappQueue','TeamVoicePrefix','UserVoicePrefix','VoicePrefixId','getQueues','findOne','channel','isValidChannel','Unknown\x20channel','capitalize','toLowerCase'];(function(_0x44260e,_0x562865){var _0x244282=function(_0x4d5be6){while(--_0x4d5be6){_0x44260e['push'](_0x44260e['shift']());}};_0x244282(++_0x562865);}(_0x6380,0x1e4));var _0x0638=function(_0x2e9916,_0x1233c3){_0x2e9916=_0x2e9916-0x0;var _0x39af2b=_0x6380[_0x2e9916];return _0x39af2b;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x0638('0x0'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x0638('0x1'));var Mustache=require(_0x0638('0x2'));var util=require(_0x0638('0x3'));var path=require('path');var sox=require(_0x0638('0x4'));var csv=require(_0x0638('0x5'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x0638('0x6'));var squel=require(_0x0638('0x7'));var crypto=require(_0x0638('0x8'));var jsforce=require('jsforce');var deskjs=require(_0x0638('0x9'));var toCsv=require(_0x0638('0x5'));var querystring=require(_0x0638('0xa'));var Papa=require(_0x0638('0xb'));var Redis=require(_0x0638('0xc'));var authService=require(_0x0638('0xd'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0638('0xe'));var logger=require('../../config/logger')(_0x0638('0xf'));var utils=require(_0x0638('0x10'));var config=require(_0x0638('0x11'));var licenseUtil=require('../../config/license/util');var db=require(_0x0638('0x12'))['db'];config[_0x0638('0x13')]=_['defaults'](config[_0x0638('0x13')],{'host':_0x0638('0x14'),'port':0x18eb});var socket=require(_0x0638('0x15'))(new Redis(config[_0x0638('0x13')]));require(_0x0638('0x16'))[_0x0638('0x17')](socket);function respondWithStatusCode(_0x514a9f,_0x9277bf){_0x9277bf=_0x9277bf||0xcc;return function(_0x5a5aae){if(_0x5a5aae){return _0x514a9f[_0x0638('0x18')](_0x9277bf);}return _0x514a9f[_0x0638('0x19')](_0x9277bf)[_0x0638('0x1a')]();};}function respondWithResult(_0x5dd86a,_0x59e031){_0x59e031=_0x59e031||0xc8;return function(_0x2d0b6d){if(_0x2d0b6d){return _0x5dd86a['status'](_0x59e031)[_0x0638('0x1b')](_0x2d0b6d);}};}function respondWithFilteredResult(_0x3fbb5c,_0xe78f58){return function(_0x2c4523){if(_0x2c4523){var _0x35a698=typeof _0xe78f58[_0x0638('0x1c')]===_0x0638('0x1d')&&typeof _0xe78f58[_0x0638('0x1e')]==='undefined';var _0x3319d9=_0x2c4523['count'];var _0x1a62a2=_0x35a698?0x0:_0xe78f58['offset'];var _0x321ece=_0x35a698?_0x2c4523[_0x0638('0x1f')]:_0xe78f58[_0x0638('0x1c')]+_0xe78f58[_0x0638('0x1e')];var _0xa5d939;if(_0x321ece>=_0x3319d9){_0x321ece=_0x3319d9;_0xa5d939=0xc8;}else{_0xa5d939=0xce;}_0x3fbb5c['status'](_0xa5d939);return _0x3fbb5c['set']('Content-Range',_0x1a62a2+'-'+_0x321ece+'/'+_0x3319d9)[_0x0638('0x1b')](_0x2c4523);}return null;};}function patchUpdates(_0x46447e){return function(_0x2e41c4){try{jsonpatch['apply'](_0x2e41c4,_0x46447e,!![]);}catch(_0x306c8a){return BPromise['reject'](_0x306c8a);}return _0x2e41c4[_0x0638('0x20')]();};}function saveUpdates(_0x3ad81f,_0x47da71){return function(_0x5b5a1c){if(_0x5b5a1c){return _0x5b5a1c['update'](_0x3ad81f)['then'](function(_0x2b36bc){return _0x2b36bc;});}return null;};}function handleEntityNotFound(_0x4538c8,_0x507250){return function(_0x5603a1){if(!_0x5603a1){_0x4538c8[_0x0638('0x18')](0x194);}return _0x5603a1;};}function handleError(_0x4fbeeb,_0x2688d5){_0x2688d5=_0x2688d5||0x1f4;return function(_0x1618f5){logger[_0x0638('0x21')](_0x1618f5[_0x0638('0x22')]);if(_0x1618f5[_0x0638('0x23')]){delete _0x1618f5['name'];}_0x4fbeeb[_0x0638('0x19')](_0x2688d5)[_0x0638('0x24')](_0x1618f5);};}exports[_0x0638('0x25')]=function(_0x124a7d,_0x595f4a){var _0x162603={},_0x3d7a1b={},_0x4564f4={'count':0x0,'rows':[]};var _0x18b501=_['map'](db[_0x0638('0x26')][_0x0638('0x27')],function(_0x5d452f){return{'name':_0x5d452f[_0x0638('0x28')],'type':_0x5d452f[_0x0638('0x29')][_0x0638('0x2a')]};});_0x3d7a1b['model']=_[_0x0638('0x2b')](_0x18b501,'name');_0x3d7a1b[_0x0638('0x2c')]=_[_0x0638('0x2d')](_0x124a7d[_0x0638('0x2c')]);_0x3d7a1b['filters']=_[_0x0638('0x2e')](_0x3d7a1b[_0x0638('0x2f')],_0x3d7a1b[_0x0638('0x2c')]);_0x162603[_0x0638('0x30')]=_['intersection'](_0x3d7a1b[_0x0638('0x2f')],qs['fields'](_0x124a7d[_0x0638('0x2c')][_0x0638('0x31')]));_0x162603[_0x0638('0x30')]=_0x162603[_0x0638('0x30')][_0x0638('0x32')]?_0x162603[_0x0638('0x30')]:_0x3d7a1b['model'];if(!_0x124a7d['query']['hasOwnProperty']('nolimit')){_0x162603[_0x0638('0x1e')]=qs[_0x0638('0x1e')](_0x124a7d[_0x0638('0x2c')][_0x0638('0x1e')]);_0x162603['offset']=qs[_0x0638('0x1c')](_0x124a7d[_0x0638('0x2c')]['offset']);}_0x162603[_0x0638('0x33')]=qs[_0x0638('0x34')](_0x124a7d['query'][_0x0638('0x34')]);_0x162603[_0x0638('0x35')]=qs[_0x0638('0x36')](_[_0x0638('0x37')](_0x124a7d['query'],_0x3d7a1b[_0x0638('0x36')]),_0x18b501);if(_0x124a7d[_0x0638('0x2c')]['filter']){_0x162603[_0x0638('0x35')]=_[_0x0638('0x38')](_0x162603[_0x0638('0x35')],{'$or':_[_0x0638('0x2b')](_0x18b501,function(_0x4283b3){if(_0x4283b3['type']!==_0x0638('0x39')){var _0x48d9a1={};_0x48d9a1[_0x4283b3['name']]={'$like':'%'+_0x124a7d[_0x0638('0x2c')][_0x0638('0x3a')]+'%'};return _0x48d9a1;}})});}_0x162603=_[_0x0638('0x38')]({},_0x162603,_0x124a7d[_0x0638('0x3b')]);var _0x223d48={'where':_0x162603[_0x0638('0x35')]};return db[_0x0638('0x26')][_0x0638('0x1f')](_0x223d48)['then'](function(_0x261d0f){_0x4564f4['count']=_0x261d0f;if(_0x124a7d['query'][_0x0638('0x3c')]){_0x162603[_0x0638('0x3d')]=[{'all':!![]}];}return db['Team'][_0x0638('0x3e')](_0x162603);})[_0x0638('0x3f')](function(_0x21ae57){_0x4564f4[_0x0638('0x40')]=_0x21ae57;return _0x4564f4;})[_0x0638('0x3f')](respondWithFilteredResult(_0x595f4a,_0x162603))['catch'](handleError(_0x595f4a,null));};exports['show']=function(_0x12883f,_0x19ff11){var _0x566c75={'raw':![],'where':{'id':_0x12883f[_0x0638('0x41')]['id']}},_0x232105={};_0x232105[_0x0638('0x2f')]=_[_0x0638('0x2d')](db[_0x0638('0x26')][_0x0638('0x27')]);_0x232105['query']=_['keys'](_0x12883f['query']);_0x232105['filters']=_[_0x0638('0x2e')](_0x232105[_0x0638('0x2f')],_0x232105[_0x0638('0x2c')]);_0x566c75['attributes']=_[_0x0638('0x2e')](_0x232105[_0x0638('0x2f')],qs[_0x0638('0x31')](_0x12883f[_0x0638('0x2c')][_0x0638('0x31')]));_0x566c75[_0x0638('0x30')]=_0x566c75[_0x0638('0x30')]['length']?_0x566c75['attributes']:_0x232105[_0x0638('0x2f')];if(_0x12883f[_0x0638('0x2c')]['includeAll']){_0x566c75[_0x0638('0x3d')]=[{'all':!![]}];}_0x566c75=_[_0x0638('0x38')]({},_0x566c75,_0x12883f['options']);return db[_0x0638('0x26')][_0x0638('0x42')](_0x566c75)[_0x0638('0x3f')](handleEntityNotFound(_0x19ff11,null))['then'](respondWithResult(_0x19ff11,null))[_0x0638('0x43')](handleError(_0x19ff11,null));};exports[_0x0638('0x44')]=function(_0x3df8ac,_0x7ed923){return db[_0x0638('0x26')]['create'](_0x3df8ac['body'],{})[_0x0638('0x3f')](function(_0x28959d){var _0x3202a5=_0x3df8ac[_0x0638('0x45')][_0x0638('0x46')]({'plain':!![]});if(!_0x3202a5)throw new Error(_0x0638('0x47'));if(_0x3202a5[_0x0638('0x48')]===_0x0638('0x45')){var _0x504e0c=_0x28959d[_0x0638('0x46')]({'plain':!![]});var _0x5722c9='Teams';return db[_0x0638('0x49')]['find']({'where':{'name':_0x5722c9,'userProfileId':_0x3202a5[_0x0638('0x4a')]},'raw':!![]})['then'](function(_0xc20e98){if(_0xc20e98&&_0xc20e98[_0x0638('0x4b')]===0x0){return db[_0x0638('0x4c')]['create']({'name':_0x504e0c[_0x0638('0x23')],'resourceId':_0x504e0c['id'],'type':_0xc20e98[_0x0638('0x23')],'sectionId':_0xc20e98['id']},{})['then'](function(){return _0x28959d;});}else{return _0x28959d;}})[_0x0638('0x43')](function(_0x453584){logger[_0x0638('0x21')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x453584);throw _0x453584;});}return _0x28959d;})['then'](respondWithResult(_0x7ed923,0xc9))['catch'](handleError(_0x7ed923,null));};exports[_0x0638('0x4d')]=function(_0x250298,_0xa65efa){if(_0x250298[_0x0638('0x4e')]['id']){delete _0x250298[_0x0638('0x4e')]['id'];}return db[_0x0638('0x26')][_0x0638('0x42')]({'where':{'id':_0x250298['params']['id']}})[_0x0638('0x3f')](handleEntityNotFound(_0xa65efa,null))[_0x0638('0x3f')](saveUpdates(_0x250298[_0x0638('0x4e')],null))[_0x0638('0x3f')](respondWithResult(_0xa65efa,null))[_0x0638('0x43')](handleError(_0xa65efa,null));};exports['destroy']=function(_0x5c19dd,_0x222a69){var _0x21f69f=_0x5c19dd[_0x0638('0x41')]['id'];var _0x446a51=[];return db[_0x0638('0x4f')][_0x0638('0x50')](function(_0x5b8793){var _0x4a10e3=_0x0638('0x51')+_0x21f69f;return db[_0x0638('0x4f')][_0x0638('0x2c')](_0x4a10e3,{'type':db[_0x0638('0x52')][_0x0638('0x53')][_0x0638('0x54')],'raw':!![],'transaction':_0x5b8793})['then'](function(_0x4001c7){_0x446a51=_['map'](_0x4001c7,function(_0x1c5684){return Number(_0x1c5684['UserId']);});})[_0x0638('0x3f')](function(){var _0x191548=_0x0638('0x55')+_0x21f69f;return db['sequelize'][_0x0638('0x2c')](_0x191548,{'type':db[_0x0638('0x52')][_0x0638('0x53')][_0x0638('0x54')],'raw':!![],'transaction':_0x5b8793});})[_0x0638('0x3f')](function(_0x2adaf8){var _0x1d951e=_['map'](_0x2adaf8,function(_0x28ad67){return Number(_0x28ad67[_0x0638('0x56')]);});return db[_0x0638('0x57')][_0x0638('0x58')]({'where':{'UserId':{'$in':_0x446a51},'VoiceQueueId':{'$in':_0x1d951e}},'transaction':_0x5b8793});})['then'](function(){var _0x32e786=_0x0638('0x59')+_0x21f69f;return db['sequelize'][_0x0638('0x2c')](_0x32e786,{'type':db[_0x0638('0x52')][_0x0638('0x53')][_0x0638('0x54')],'raw':!![],'transaction':_0x5b8793});})[_0x0638('0x3f')](function(_0x2e11c1){var _0x404a14=_['map'](_0x2e11c1,function(_0x459fbb){return Number(_0x459fbb[_0x0638('0x5a')]);});return db[_0x0638('0x5b')]['destroy']({'where':{'UserId':{'$in':_0x446a51},'MailQueueId':{'$in':_0x404a14}},'transaction':_0x5b8793});})['then'](function(){var _0x558071='SELECT\x20SmsQueueId\x20FROM\x20team_has_sms_queues\x20WHERE\x20TeamId\x20=\x20'+_0x21f69f;return db['sequelize'][_0x0638('0x2c')](_0x558071,{'type':db['Sequelize'][_0x0638('0x53')]['SELECT'],'raw':!![],'transaction':_0x5b8793});})[_0x0638('0x3f')](function(_0x4032b4){var _0x15d9f7=_[_0x0638('0x2b')](_0x4032b4,function(_0x1bffe0){return Number(_0x1bffe0['SmsQueueId']);});return db[_0x0638('0x5c')][_0x0638('0x58')]({'where':{'UserId':{'$in':_0x446a51},'SmsQueueId':{'$in':_0x15d9f7}},'transaction':_0x5b8793});})[_0x0638('0x3f')](function(){var _0x54ae3a=_0x0638('0x5d')+_0x21f69f;return db[_0x0638('0x4f')][_0x0638('0x2c')](_0x54ae3a,{'type':db[_0x0638('0x52')][_0x0638('0x53')]['SELECT'],'raw':!![],'transaction':_0x5b8793});})['then'](function(_0xac88aa){var _0x429c56=_['map'](_0xac88aa,function(_0x4cd70f){return Number(_0x4cd70f[_0x0638('0x5e')]);});return db[_0x0638('0x5f')][_0x0638('0x58')]({'where':{'UserId':{'$in':_0x446a51},'ChatQueueId':{'$in':_0x429c56}},'transaction':_0x5b8793});})['then'](function(){var _0x113672='SELECT\x20FaxQueueId\x20FROM\x20team_has_fax_queues\x20WHERE\x20TeamId\x20=\x20'+_0x21f69f;return db['sequelize'][_0x0638('0x2c')](_0x113672,{'type':db[_0x0638('0x52')][_0x0638('0x53')][_0x0638('0x54')],'raw':!![],'transaction':_0x5b8793});})[_0x0638('0x3f')](function(_0x24fc3e){var _0x38ba95=_[_0x0638('0x2b')](_0x24fc3e,function(_0x8011e7){return Number(_0x8011e7['FaxQueueId']);});return db[_0x0638('0x60')][_0x0638('0x58')]({'where':{'UserId':{'$in':_0x446a51},'FaxQueueId':{'$in':_0x38ba95}},'transaction':_0x5b8793});})[_0x0638('0x3f')](function(){var _0x114770='SELECT\x20OpenchannelQueueId\x20FROM\x20team_has_openchannel_queues\x20WHERE\x20TeamId\x20=\x20'+_0x21f69f;return db[_0x0638('0x4f')]['query'](_0x114770,{'type':db[_0x0638('0x52')][_0x0638('0x53')][_0x0638('0x54')],'raw':!![],'transaction':_0x5b8793});})[_0x0638('0x3f')](function(_0x3b3a70){var _0x4a7a06=_[_0x0638('0x2b')](_0x3b3a70,function(_0x2276a4){return Number(_0x2276a4[_0x0638('0x61')]);});return db[_0x0638('0x62')][_0x0638('0x58')]({'where':{'UserId':{'$in':_0x446a51},'OpenchannelQueueId':{'$in':_0x4a7a06}},'transaction':_0x5b8793});})[_0x0638('0x3f')](function(){var _0x4b654e=_0x0638('0x63')+_0x21f69f;return db['sequelize']['query'](_0x4b654e,{'type':db[_0x0638('0x52')][_0x0638('0x53')][_0x0638('0x54')],'raw':!![],'transaction':_0x5b8793});})[_0x0638('0x3f')](function(_0x22bfcd){var _0x3a050f=_[_0x0638('0x2b')](_0x22bfcd,function(_0x31010a){return Number(_0x31010a[_0x0638('0x64')]);});return db[_0x0638('0x65')][_0x0638('0x58')]({'where':{'UserId':{'$in':_0x446a51},'WhatsappQueueId':{'$in':_0x3a050f}},'transaction':_0x5b8793});})[_0x0638('0x3f')](function(){return db[_0x0638('0x66')][_0x0638('0x42')]({'where':{'TeamId':_0x21f69f}});})[_0x0638('0x3f')](function(_0x15b1a5){if(_0x15b1a5===null){return;}return db[_0x0638('0x67')][_0x0638('0x58')]({'where':{'UserId':{'$in':_0x446a51},'VoicePrefixId':_0x15b1a5[_0x0638('0x68')]},'transaction':_0x5b8793});})[_0x0638('0x3f')](function(){return db['Team'][_0x0638('0x58')]({'where':{'id':_0x21f69f},'cascade':!![],'transaction':_0x5b8793});})[_0x0638('0x3f')](function(_0x131636){if(_0x131636===0x0){_0x222a69['sendStatus'](0x194);}else{return db[_0x0638('0x4c')]['destroy']({'where':{'type':'Teams','resourceId':_0x21f69f},'cascade':!![],'transaction':_0x5b8793})[_0x0638('0x3f')](function(){_0x222a69[_0x0638('0x19')](0xcc)[_0x0638('0x1a')]();});}})['catch'](function(_0xb6503f){_0x222a69[_0x0638('0x19')](0x1f4)[_0x0638('0x24')](_0xb6503f);});});};exports[_0x0638('0x69')]=function(_0x3fa5d2,_0x34fce4,_0x2c4a4a){return db[_0x0638('0x26')][_0x0638('0x6a')]({'where':{'id':_0x3fa5d2[_0x0638('0x41')]['id']}})[_0x0638('0x3f')](handleEntityNotFound(_0x34fce4,null))[_0x0638('0x3f')](function(_0x3ce0e3){if(!_0x3fa5d2['query'][_0x0638('0x6b')]||!utils[_0x0638('0x6c')](_0x3fa5d2[_0x0638('0x2c')][_0x0638('0x6b')])){throw new db[(_0x0638('0x52'))]['ValidationError'](_0x0638('0x6d'));}var _0x53bd49={};var _0x5bfe64={};_0x5bfe64[_0x0638('0x2f')]=_[_0x0638('0x2d')](db[_[_0x0638('0x6e')](_0x3fa5d2['query'][_0x0638('0x6b')][_0x0638('0x6f')]())+_0x0638('0x70')][_0x0638('0x27')]);_0x5bfe64[_0x0638('0x2c')]=_[_0x0638('0x2d')](_0x3fa5d2[_0x0638('0x2c')]);_0x5bfe64['filters']=_['intersection'](_0x5bfe64['model'],_0x5bfe64[_0x0638('0x2c')]);_0x53bd49[_0x0638('0x30')]=_[_0x0638('0x2e')](_0x5bfe64[_0x0638('0x2f')],qs['fields'](_0x3fa5d2[_0x0638('0x2c')]['fields']));_0x53bd49[_0x0638('0x30')]=_0x53bd49[_0x0638('0x30')][_0x0638('0x32')]?_0x53bd49['attributes']:_0x5bfe64[_0x0638('0x2f')];_0x53bd49[_0x0638('0x1e')]=qs['limit'](_0x3fa5d2['query'][_0x0638('0x1e')]);_0x53bd49[_0x0638('0x1c')]=qs[_0x0638('0x1c')](_0x3fa5d2[_0x0638('0x2c')][_0x0638('0x1c')]);_0x53bd49[_0x0638('0x33')]=qs['sort'](_0x3fa5d2[_0x0638('0x2c')][_0x0638('0x34')]);_0x53bd49[_0x0638('0x35')]=qs[_0x0638('0x36')](_[_0x0638('0x37')](_0x3fa5d2[_0x0638('0x2c')],_0x5bfe64[_0x0638('0x36')]));_0x53bd49=_[_0x0638('0x38')]({},_0x53bd49,_0x3fa5d2[_0x0638('0x3b')]);return _0x3ce0e3[_0x0638('0x46')+_[_0x0638('0x6e')](_0x3fa5d2[_0x0638('0x2c')]['channel']['toLowerCase']())+_0x0638('0x71')](_0x53bd49);})[_0x0638('0x3f')](respondWithResult(_0x34fce4,null))[_0x0638('0x43')](handleError(_0x34fce4,null));};exports['addQueues']=function(_0x432bfa,_0x3ffab3,_0x492d5d){return db[_0x0638('0x26')]['findOne']({'where':{'id':_0x432bfa['params']['id']}})[_0x0638('0x3f')](function(_0x3385e5){if(_0x3385e5){if(!_0x432bfa[_0x0638('0x4e')][_0x0638('0x6b')]||!utils[_0x0638('0x6c')](_0x432bfa['body'][_0x0638('0x6b')])){throw new db['Sequelize'][(_0x0638('0x72'))](_0x0638('0x6d'));}return _0x3385e5[_0x0638('0x73')+_[_0x0638('0x6e')](_0x432bfa[_0x0638('0x4e')][_0x0638('0x6b')][_0x0638('0x6f')]())+_0x0638('0x71')](_0x432bfa[_0x0638('0x4e')]['ids']);}return null;})[_0x0638('0x3f')](handleEntityNotFound(_0x3ffab3,null))[_0x0638('0x3f')](respondWithStatusCode(_0x3ffab3,null))[_0x0638('0x43')](handleError(_0x3ffab3,null));};exports[_0x0638('0x74')]=function(_0x416b21,_0x50d104,_0x3027ca){return db[_0x0638('0x26')][_0x0638('0x6a')]({'where':{'id':_0x416b21[_0x0638('0x41')]['id']}})[_0x0638('0x3f')](function(_0x41f2d7){if(_0x41f2d7){if(!_0x416b21[_0x0638('0x2c')][_0x0638('0x6b')]||!utils[_0x0638('0x6c')](_0x416b21[_0x0638('0x2c')][_0x0638('0x6b')])){throw new db[(_0x0638('0x52'))]['ValidationError']('Unknown\x20channel');}return _0x41f2d7[_0x0638('0x75')+_['capitalize'](_0x416b21[_0x0638('0x2c')][_0x0638('0x6b')]['toLowerCase']())+_0x0638('0x71')](_0x416b21['query']['ids']);}return null;})[_0x0638('0x3f')](handleEntityNotFound(_0x50d104,null))['then'](respondWithStatusCode(_0x50d104,null))['catch'](handleError(_0x50d104,null));};exports[_0x0638('0x76')]=function(_0x117b35,_0x135288){var _0x297d51=_[_0x0638('0x77')](_0x117b35['body'][_0x0638('0x78')])?_0x117b35['body'][_0x0638('0x78')]:[_0x117b35['body'][_0x0638('0x78')]];var _0x8ae1f5=_0x117b35[_0x0638('0x41')]['id'];return db[_0x0638('0x26')][_0x0638('0x42')]({'where':{'id':_0x8ae1f5}})[_0x0638('0x3f')](handleEntityNotFound(_0x135288,null))['then'](function(_0x247a12){if(_0x247a12){var _0x3ef298=[_0x0638('0x79'),_0x0638('0x7a'),_0x0638('0x7b'),_0x0638('0x7c'),'Fax',_0x0638('0x7d'),_0x0638('0x7e')];return db[_0x0638('0x4f')][_0x0638('0x50')](function(_0x2ddfd2){var _0x3a0aa9=_[_0x0638('0x2b')](_0x3ef298,function(_0x175bc6){var _0xed155f={'attributes':['id',_0x0638('0x23')]};if(_0x175bc6==='Voice'){_0xed155f[_0x0638('0x7f')]={'attributes':[_0x0638('0x80')]};}return _0x247a12[_0x0638('0x46')+_0x175bc6+_0x0638('0x71')](_0xed155f)['then'](function(_0x112b20){var _0x3cf005=_[_0x0638('0x2b')](_0x112b20,function(_0x56583b){var _0x56a830=_[_0x0638('0x2b')](_0x297d51,function(_0x5c5088){var _0x7e80b8={'where':{'UserId':_0x5c5088,[_0x175bc6+_0x0638('0x81')]:_0x56583b['id']},'transaction':_0x2ddfd2};if(_0x175bc6===_0x0638('0x79')){_0x7e80b8[_0x0638('0x82')]={'penalty':_0x56583b[_0x0638('0x83')][_0x0638('0x80')]};}return db[_0x0638('0x84')+_0x175bc6+_0x0638('0x70')]['findOrCreate'](_0x7e80b8)[_0x0638('0x3f')](function(){socket['emit']('user'+_0x175bc6+_0x0638('0x85'),{'UserId':_0x5c5088,[_0x175bc6+_0x0638('0x81')]:_0x56583b['id']});if(_0x175bc6!==_0x0638('0x79')){return;}return db[_0x0638('0x84')]['findAll']({'where':{'id':_0x297d51,'online':0x1},'attributes':['id','name',_0x0638('0x86'),_0x0638('0x87'),_0x0638('0x88')],'raw':!![]})[_0x0638('0x3f')](function(_0x11a91f){var _0x1f8b39=_['map'](_0x11a91f,function(_0x2e6b07){return db[_0x0638('0x89')][_0x0638('0x8a')]({'membername':_0x2e6b07[_0x0638('0x23')],'UserId':_0x2e6b07['id'],'queue_name':_0x56583b[_0x0638('0x23')],'VoiceQueueId':_0x56583b['id'],'interface':_[_0x0638('0x8b')](_0x2e6b07[_0x0638('0x88')])?util[_0x0638('0x8c')](_0x0638('0x8d'),_0x2e6b07['name']):_0x2e6b07[_0x0638('0x88')],'paused':_0x2e6b07[_0x0638('0x87')]||![],'penalty':_0x56583b[_0x0638('0x83')][_0x0638('0x80')]},{'transaction':_0x2ddfd2});});return Promise[_0x0638('0x8e')](_0x1f8b39);});});});return Promise[_0x0638('0x8e')](_0x56a830);});return Promise[_0x0638('0x8e')](_0x3cf005);})[_0x0638('0x3f')](function(){return db[_0x0638('0x66')][_0x0638('0x6a')]({'where':{'teamId':_0x8ae1f5}})[_0x0638('0x3f')](function(_0x26cc23){if(_0x26cc23){var _0x1a0bb3=_[_0x0638('0x2b')](_0x297d51,function(_0x501e88){db[_0x0638('0x67')]['upsert']({'UserId':_0x501e88,'VoicePrefixId':_0x26cc23[_0x0638('0x68')]});});return Promise[_0x0638('0x8e')](_0x1a0bb3);}});});});return Promise[_0x0638('0x8e')](_0x3a0aa9)[_0x0638('0x3f')](function(){return _0x247a12[_0x0638('0x76')](_0x297d51,{'transaction':_0x2ddfd2})[_0x0638('0x8f')](function(_0x397ed7){return _0x397ed7;});});});}})['then'](respondWithResult(_0x135288,null))[_0x0638('0x43')](handleError(_0x135288,null));};exports[_0x0638('0x90')]=function(_0x121ce9,_0x16a38c){var _0x4c0947=_[_0x0638('0x77')](_0x121ce9['query'][_0x0638('0x78')])?_0x121ce9[_0x0638('0x2c')][_0x0638('0x78')]:[_0x121ce9[_0x0638('0x2c')][_0x0638('0x78')]];var _0x40800f=_0x121ce9[_0x0638('0x41')]['id'];return db[_0x0638('0x26')][_0x0638('0x42')]({'where':{'id':_0x40800f}})[_0x0638('0x3f')](handleEntityNotFound(_0x16a38c,null))[_0x0638('0x3f')](function(_0x547537){if(_0x547537){var _0x236244=[_0x0638('0x79'),'Chat',_0x0638('0x7b'),_0x0638('0x7c'),_0x0638('0x91'),_0x0638('0x7d'),_0x0638('0x7e')];return db[_0x0638('0x4f')][_0x0638('0x50')](function(_0x592a5){var _0x148dc7=_[_0x0638('0x2b')](_0x236244,function(_0x26408d){var _0x294e3a={'attributes':['id','name']};return _0x547537[_0x0638('0x46')+_0x26408d+_0x0638('0x71')](_0x294e3a)['then'](function(_0x4bf80){var _0x4d9123=_[_0x0638('0x2b')](_0x4bf80,function(_0x197fb5){return _0x197fb5[_0x0638('0x90')](_0x4c0947,{'transaction':_0x592a5})[_0x0638('0x3f')](function(){var _0x4d3888=_[_0x0638('0x2b')](_0x4c0947,function(_0x132517){socket['emit'](_0x0638('0x45')+_0x26408d+_0x0638('0x92'),{'UserId':Number(_0x132517),[_0x26408d+_0x0638('0x81')]:_0x197fb5['id']});if(_0x26408d!==_0x0638('0x79')){return;}return db['UserVoiceQueueRt'][_0x0638('0x58')]({'where':{'VoiceQueueId':_0x197fb5['id'],'UserId':_0x132517},'transaction':_0x592a5});});return Promise[_0x0638('0x8e')](_0x4d3888);});});return Promise['all'](_0x4d9123);});});return Promise[_0x0638('0x8e')](_0x148dc7)[_0x0638('0x3f')](function(){return _0x547537[_0x0638('0x90')](_0x4c0947,{'transaction':_0x592a5});})[_0x0638('0x3f')](function(){return db['TeamVoicePrefix'][_0x0638('0x6a')]({'where':{'teamId':_0x40800f}})[_0x0638('0x3f')](function(_0x4633bc){if(_0x4633bc){var _0x3d4cbe=_['map'](_0x4c0947,function(_0xe30c4d){db[_0x0638('0x67')][_0x0638('0x58')]({'where':{'UserId':_0xe30c4d,'VoicePrefixId':_0x4633bc[_0x0638('0x68')]}});});return Promise[_0x0638('0x8e')](_0x3d4cbe);}});});});}})[_0x0638('0x3f')](respondWithStatusCode(_0x16a38c,null))[_0x0638('0x43')](handleError(_0x16a38c,null));};exports[_0x0638('0x93')]=function(_0x384164,_0x31b756,_0x3d6cc9){var _0x65d476={};var _0x3423fa={};var _0x1fb457;var _0x5d172e;return db[_0x0638('0x26')][_0x0638('0x6a')]({'where':{'id':_0x384164[_0x0638('0x41')]['id']}})[_0x0638('0x3f')](handleEntityNotFound(_0x31b756,null))[_0x0638('0x3f')](function(_0x2b1863){if(_0x2b1863){_0x1fb457=_0x2b1863;_0x3423fa[_0x0638('0x2f')]=_[_0x0638('0x2d')](db[_0x0638('0x84')][_0x0638('0x27')]);_0x3423fa[_0x0638('0x2c')]=_[_0x0638('0x2d')](_0x384164[_0x0638('0x2c')]);_0x3423fa[_0x0638('0x36')]=_[_0x0638('0x2e')](_0x3423fa[_0x0638('0x2f')],_0x3423fa[_0x0638('0x2c')]);_0x65d476[_0x0638('0x30')]=_['intersection'](_0x3423fa[_0x0638('0x2f')],qs[_0x0638('0x31')](_0x384164[_0x0638('0x2c')][_0x0638('0x31')]));_0x65d476['attributes']=_0x65d476[_0x0638('0x30')][_0x0638('0x32')]?_0x65d476[_0x0638('0x30')]:_0x3423fa[_0x0638('0x2f')];_0x65d476[_0x0638('0x33')]=qs[_0x0638('0x34')](_0x384164['query'][_0x0638('0x34')]);_0x65d476[_0x0638('0x35')]=qs[_0x0638('0x36')](_[_0x0638('0x37')](_0x384164[_0x0638('0x2c')],_0x3423fa[_0x0638('0x36')]));if(_0x384164[_0x0638('0x2c')][_0x0638('0x3a')]){_0x65d476[_0x0638('0x35')]=_[_0x0638('0x38')](_0x65d476[_0x0638('0x35')],{'$or':_[_0x0638('0x2b')](_0x65d476[_0x0638('0x30')],function(_0x350062){var _0x1569aa={};_0x1569aa[_0x350062]={'$like':'%'+_0x384164['query'][_0x0638('0x3a')]+'%'};return _0x1569aa;})});}_0x65d476=_[_0x0638('0x38')]({},_0x65d476,_0x384164['options']);return _0x1fb457[_0x0638('0x93')](_0x65d476);}})[_0x0638('0x3f')](function(_0x49a0db){if(_0x49a0db){_0x5d172e=_0x49a0db[_0x0638('0x32')];if(!_0x384164[_0x0638('0x2c')][_0x0638('0x94')]('nolimit')){_0x65d476['limit']=qs[_0x0638('0x1e')](_0x384164[_0x0638('0x2c')]['limit']);_0x65d476[_0x0638('0x1c')]=qs[_0x0638('0x1c')](_0x384164['query'][_0x0638('0x1c')]);}return _0x1fb457['getAgents'](_0x65d476);}})[_0x0638('0x3f')](function(_0x403c53){if(_0x403c53){return _0x403c53?{'count':_0x5d172e,'rows':_0x403c53}:null;}})[_0x0638('0x3f')](respondWithResult(_0x31b756,null))['catch'](handleError(_0x31b756,null));};
\ No newline at end of file