Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / userProfile / userProfile.model.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x5f73=['SmsAccount','WhatsappQueue','whatsappaccounts','WhatsappAccount','teams','Team','voicequeues','queuecampaigns','users','agents','telephones','zendeskaccounts','ZendeskAccount','SalesforceAccount','freshdeskaccounts','FreshdeskAccount','SugarcrmAccount','deskaccounts','DeskAccount','zohoaccounts','ZohoAccount','vtigeraccounts','cannedanswers','CannedAnswer','customdashboards','Dashboard','intervals','Interval','scheduler','Schedule','Sound','Tag','Trigger','trunks','Trunk','variables','Variable','extractedreports','Reports','reportId','metrics','AnalyticMetric','charAt','toUpperCase','slice','Sequelize','QueryTypes','SELECT','select','ui.','InteractionId','from','user_has_','where','query','toString','OpenTabs','define','UserProfile','section','mergeResources','Invalid\x20section\x20\x27','UserProfileSection','find','params','all','ignore','isEmpty','union','length','autoAssociation','push','model','rawAttributes','keys','attributes','intersection','fields','hasOwnProperty','nolimit','limit','offset','order','sort','filters','merge','VIRTUAL','foreignKey','forEach','options','includeAll','reportType','count','rows','ids','customSorting','extraQueryConditions','include','color','ThroughTags','tag','openTabs','true','chat','dataValues','fax','mail','openchannel','whatsapp','lodash','./userProfile.attributes','squel','exports','filter','field','value','findAll','associatedResources','map','name','resolve','UserProfileResource','then','AnalyticExtractedReport','resourceId','catch','toLowerCase','squareprojects','childModel','SquareRecording','parentSections','projectName','projects','JscriptyProject','contacts','CmContact','Lists','lists','CmList','companies','globalcustomfields','CmCustomField','chatqueues','ChatQueue','chatwebsites','ChatWebsite','faxqueues','FaxQueue','faxaccounts','FaxAccount','inboundroutes','internalroutes','VoiceExtension','contexts','voicemails','voicerecordings','VoiceRecording','Agents','membername','User','role','agent','Telephones','telephone','VoiceQueues','queue','VoiceQueue','type','inbound','QueueCampaigns','outbound','musiconholds','VoiceMusicOnHold','chanspies','VoiceChanSpy','voiceprefixes','VoicePrefix','ivrcampaigns','Campaign','mailqueues','MailQueue','mailaccounts','MailAccount','mailsubstatuses','MailSubstatus','OpenchannelQueue','openchannelaccounts','OpenchannelAccount','smsqueues','SmsQueue','smsaccounts'];(function(_0x1d2e84,_0x31f1be){var _0x3cb2d3=function(_0x277371){while(--_0x277371){_0x1d2e84['push'](_0x1d2e84['shift']());}};_0x3cb2d3(++_0x31f1be);}(_0x5f73,0x1eb));var _0x35f7=function(_0x2848fa,_0x12075){_0x2848fa=_0x2848fa-0x0;var _0x379d74=_0x5f73[_0x2848fa];return _0x379d74;};'use strict';var _=require(_0x35f7('0x0'));var attributes=require(_0x35f7('0x1'));var qs=require('../../components/parsers/qs');var squel=require(_0x35f7('0x2'));module[_0x35f7('0x3')]=function(_0x570238){var _0xce97cb=_0x570238['models'];function _0x4cd2fd(_0x455823,_0x3171ec){return new Promise(function(_0x302944,_0xe58fbf){if(!_0x3171ec)return _0x302944(null);var _0x27acd3=_0x3171ec[_0x35f7('0x4')]?{[_0x3171ec[_0x35f7('0x4')][_0x35f7('0x5')]]:_0x3171ec[_0x35f7('0x4')][_0x35f7('0x6')]}:undefined;return _0xce97cb[_0x455823][_0x35f7('0x7')]({'where':_0x27acd3,'raw':!![]})['then'](function(_0x32399d){_0x3171ec[_0x35f7('0x8')]=_[_0x35f7('0x9')](_0x32399d,'id');_0x302944(_0x3171ec);})['catch'](function(_0x94ff9f){_0xe58fbf(_0x94ff9f);});});}function _0x5c8ebe(_0x521221,_0x196d6d){return new Promise(function(_0x165292,_0x33e59a){var _0x145e86=_0x521221[_0x35f7('0x4')]?{[_0x521221[_0x35f7('0x4')][_0x35f7('0x5')]]:_0x521221[_0x35f7('0x4')][_0x35f7('0x6')]}:undefined;return _0xce97cb[_0x521221['model']][_0x35f7('0x7')]({'where':_0x145e86,'raw':!![]})['then'](function(_0x12b85e){_0x196d6d[_0x35f7('0x8')]=_[_0x35f7('0x9')](_0x12b85e,function(_0x4acdfa){return _0x4acdfa[_0x35f7('0xa')];});_0x165292(_0x196d6d);})['catch'](function(_0x452c5b){_0x33e59a(_0x452c5b);});});}function _0x385c46(_0x8f3621,_0x5b8753,_0x408bb8){if(!_0x5b8753)return Promise[_0x35f7('0xb')](null);return new Promise(function(_0x17d00a,_0x5a55a3){return _0xce97cb[_0x35f7('0xc')][_0x35f7('0x7')]({'where':{'sectionId':_0x5b8753['id']},'raw':!![]})[_0x35f7('0xd')](function(_0x14c5c3){if(_0x8f3621[_0x35f7('0x5')]&&_0x8f3621[_0x35f7('0x5')]!=='id'){_0x5b8753[_0x35f7('0x8')]=_['map'](_0x14c5c3,function(_0x29fe6d){return _0x29fe6d[_0x8f3621[_0x35f7('0x5')]];});}else{if(_0x408bb8===_0x35f7('0xe')){_0x5b8753['associatedResources']=_[_0x35f7('0x9')](_0x14c5c3,function(_0x407681){return{'id':_0x407681[_0x35f7('0xf')],'type':_0x407681['type']};});}else{_0x5b8753[_0x35f7('0x8')]=_[_0x35f7('0x9')](_0x14c5c3,function(_0x31d136){return _0x31d136[_0x35f7('0xf')];});}}_0x17d00a(_0x5b8753);})[_0x35f7('0x10')](function(_0x42c1d6){_0x5a55a3(_0x42c1d6);});});}function _0xbd2555(_0x13f071,_0x17fe14){var _0x5269c4={'parentSections':[]};switch(_0x13f071[_0x35f7('0x11')]()){case _0x35f7('0x12'):_0x5269c4[_0x35f7('0x13')]='SquareProject';break;case'odbc':_0x5269c4[_0x35f7('0x13')]='SquareOdbc';break;case'squarerecordings':_0x5269c4['childModel']=_0x35f7('0x14');_0x5269c4[_0x35f7('0x15')]=[{'name':'SquareProjects','field':'name','foreignKey':_0x35f7('0x16')}];break;case _0x35f7('0x17'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x18');break;case _0x35f7('0x19'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x1a');_0x5269c4[_0x35f7('0x15')]=[{'name':_0x35f7('0x1b'),'field':'id','foreignKey':'ListId'}];break;case _0x35f7('0x1c'):_0x5269c4['childModel']=_0x35f7('0x1d');break;case _0x35f7('0x1e'):_0x5269c4[_0x35f7('0x13')]='CmCompany';break;case _0x35f7('0x1f'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x20');break;case _0x35f7('0x21'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x22');break;case _0x35f7('0x23'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x24');break;case _0x35f7('0x25'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x26');break;case _0x35f7('0x27'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x28');break;case _0x35f7('0x29'):case _0x35f7('0x2a'):case'outboundroutes':_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x2b');break;case _0x35f7('0x2c'):_0x5269c4[_0x35f7('0x13')]='VoiceContext';break;case _0x35f7('0x2d'):_0x5269c4['childModel']='VoiceMail';break;case _0x35f7('0x2e'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x2f');_0x5269c4['parentSections']=[{'name':_0x35f7('0x30'),'field':_0x35f7('0xa'),'foreignKey':_0x35f7('0x31'),'model':_0x35f7('0x32'),'filter':{'field':_0x35f7('0x33'),'value':[_0x35f7('0x34')]}},{'name':_0x35f7('0x35'),'field':_0x35f7('0xa'),'foreignKey':_0x35f7('0x31'),'model':_0x35f7('0x32'),'filter':{'field':_0x35f7('0x33'),'value':[_0x35f7('0x36')]}},{'name':_0x35f7('0x37'),'field':_0x35f7('0xa'),'foreignKey':_0x35f7('0x38'),'model':_0x35f7('0x39'),'filter':{'field':_0x35f7('0x3a'),'value':[_0x35f7('0x3b')]}},{'name':_0x35f7('0x3c'),'field':_0x35f7('0xa'),'foreignKey':'queue','model':_0x35f7('0x39'),'filter':{'field':_0x35f7('0x3a'),'value':[_0x35f7('0x3d')]}}];break;case _0x35f7('0x3e'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x3f');break;case _0x35f7('0x40'):_0x5269c4['childModel']=_0x35f7('0x41');break;case _0x35f7('0x42'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x43');break;case _0x35f7('0x44'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x45');break;case _0x35f7('0x46'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x47');break;case _0x35f7('0x48'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x49');break;case _0x35f7('0x4a'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x4b');break;case'openchannelqueues':_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x4c');break;case _0x35f7('0x4d'):_0x5269c4['childModel']=_0x35f7('0x4e');break;case _0x35f7('0x4f'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x50');break;case _0x35f7('0x51'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x52');break;case'whatsappqueues':_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x53');break;case _0x35f7('0x54'):_0x5269c4['childModel']=_0x35f7('0x55');break;case _0x35f7('0x56'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x57');break;case _0x35f7('0x58'):case _0x35f7('0x59'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x39');if(_0x17fe14){_0x5269c4['parentSections']=[{'name':_0x35f7('0x37')},{'name':_0x35f7('0x3c')}];}break;case _0x35f7('0x5a'):case _0x35f7('0x5b'):case _0x35f7('0x5c'):_0x5269c4[_0x35f7('0x13')]='User';if(_0x17fe14){_0x5269c4['parentSections']=[{'name':'Users','filter':{'field':'role','value':['admin','user']},'ignore':!![]},{'name':_0x35f7('0x30')},{'name':'Telephones'}];}break;case _0x35f7('0x5d'):_0x5269c4['childModel']=_0x35f7('0x5e');break;case'salesforceaccounts':_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x5f');break;case _0x35f7('0x60'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x61');break;case'sugarcrmaccounts':_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x62');break;case _0x35f7('0x63'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x64');break;case _0x35f7('0x65'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x66');break;case _0x35f7('0x67'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x32');break;case _0x35f7('0x68'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x69');break;case'dispositions':_0x5269c4[_0x35f7('0x13')]='Disposition';break;case _0x35f7('0x6a'):_0x5269c4['childModel']=_0x35f7('0x6b');break;case _0x35f7('0x6c'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x6d');break;case'pauses':_0x5269c4[_0x35f7('0x13')]='Pause';break;case _0x35f7('0x6e'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x6f');break;case'sounds':_0x5269c4['childModel']=_0x35f7('0x70');break;case'tags':_0x5269c4['childModel']=_0x35f7('0x71');break;case'templates':_0x5269c4[_0x35f7('0x13')]='Template';break;case'triggers':_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x72');break;case _0x35f7('0x73'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x74');break;case _0x35f7('0x75'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x76');break;case'plugins':_0x5269c4['childModel']='Plugin';break;case _0x35f7('0x77'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0xe');_0x5269c4[_0x35f7('0x15')]=[{'name':_0x35f7('0x78'),'field':'id','foreignKey':_0x35f7('0x79')}];break;case _0x35f7('0x7a'):_0x5269c4[_0x35f7('0x13')]=_0x35f7('0x7b');break;}return _0x5269c4;}function _0x316cf4(_0x779be6,_0x34e43a){var _0x49a5cb=_0x779be6[_0x35f7('0x7c')](0x0)[_0x35f7('0x7d')]()+_0x779be6[_0x35f7('0x7e')](0x1);var _0x4f6476={'type':_0xce97cb[_0x35f7('0x7f')][_0x35f7('0x80')][_0x35f7('0x81')],'raw':!![]};return new Promise(function(_0x42b6d6,_0x127d65){var _0x34361c=squel[_0x35f7('0x82')]()[_0x35f7('0x5')](_0x35f7('0x83')+_0x49a5cb+_0x35f7('0x84'),'id')[_0x35f7('0x5')]('ui.createdAt')[_0x35f7('0x85')](_0x35f7('0x86')+_0x779be6+'_interactions','ui')[_0x35f7('0x87')]('ui.UserId\x20=\x20?',_0x34e43a['id']);return _0xce97cb['sequelize'][_0x35f7('0x88')](_0x34361c[_0x35f7('0x89')](),_0x4f6476)[_0x35f7('0xd')](function(_0x376db4){_0x34e43a[_0x49a5cb+_0x35f7('0x8a')]=_0x376db4;_0x42b6d6(_0x376db4);})[_0x35f7('0x10')](function(_0xcbbb27){_0x127d65(_0xcbbb27);});});}return _0x570238[_0x35f7('0x8b')](_0x35f7('0x8c'),attributes,{'tableName':'user_profiles','paranoid':![],'indexes':[],'timestamps':!![],'classMethods':{'getResources':function(_0x240f44){var _0x3c294b={'raw':_0x240f44[_0x35f7('0x88')]['raw'],'where':{}};var _0x5ad2b0={};var _0x199d4b={'count':0x0,'rows':[]};var _0x3c2c77=_0x240f44[_0x35f7('0x88')][_0x35f7('0x8d')];var _0x4c496b=_0x240f44[_0x35f7('0x88')][_0x35f7('0x8e')]||![];var _0x507c00=_0xbd2555(_0x3c2c77,_0x4c496b);if(!_0x507c00[_0x35f7('0x13')])throw new Error(_0x35f7('0x8f')+_0x3c2c77+'\x27');var _0x391311=[{'name':_0x3c2c77}];if(!_['isEmpty'](_0x507c00[_0x35f7('0x15')]))_0x391311=_0x507c00['parentSections'];var _0x5d0207=[];for(var _0x556d55=0x0;_0x556d55<_0x391311['length'];_0x556d55++){_0x5d0207['push'](_0xce97cb[_0x35f7('0x90')][_0x35f7('0x91')]({'where':{'userProfileId':_0x240f44[_0x35f7('0x92')]['id'],'name':_0x391311[_0x556d55]['name']},'raw':!![]}));}return Promise[_0x35f7('0x93')](_0x5d0207)[_0x35f7('0xd')](function(_0x588018){var _0x5b43f2=_[_0x35f7('0x4')](_0x588018,function(_0x3b7769){return _0x3b7769?_0x3b7769:undefined;});var _0x3ec2c5=_[_0x35f7('0x4')](_0x391311,[_0x35f7('0x94'),!![]]);var _0x20fbde=_['isEmpty'](_0x5b43f2)&&_[_0x35f7('0x95')](_0x3ec2c5)?null:_[_0x35f7('0x96')](_0x3ec2c5,_0x5b43f2);if(!_0x20fbde)return null;var _0x41faad=[];for(var _0x881076=0x0;_0x881076<_0x20fbde[_0x35f7('0x97')];_0x881076++){var _0x544f8=_[_0x35f7('0x91')](_0x391311,function(_0x502a77){return _0x20fbde[_0x881076]?_0x502a77[_0x35f7('0xa')]===_0x20fbde[_0x881076][_0x35f7('0xa')]:null;});if(_0x544f8){if(_0x20fbde[_0x881076]['ignore']){_0x41faad['push'](_0x4cd2fd(_0x507c00[_0x35f7('0x13')],_0x20fbde[_0x881076]));}else{if(!_0x20fbde[_0x881076][_0x35f7('0x98')]){_0x41faad[_0x35f7('0x99')](_0x385c46(_0x544f8,_0x20fbde[_0x881076],_0x507c00[_0x35f7('0x13')]));}else{if(_0x544f8[_0x35f7('0x9a')]){_0x41faad['push'](_0x5c8ebe(_0x544f8,_0x20fbde[_0x881076]));}}}}}return Promise[_0x35f7('0x93')](_0x41faad);})[_0x35f7('0xd')](function(_0x62e245){var _0x242597=_0x62e245;var _0x5975e2=null;if(_0x242597){_0x5975e2=_0x242597[_0x35f7('0x97')]===0x1?_0x242597[0x0]:null;}if(!_0x5975e2&&!_0x242597)return _0x199d4b;var _0x4e1ae0=_0xce97cb[_0x507c00[_0x35f7('0x13')]][_0x35f7('0x9b')];_0x5ad2b0[_0x35f7('0x9a')]=_[_0x35f7('0x9c')](_0x4e1ae0);_0x5ad2b0[_0x35f7('0x88')]=_[_0x35f7('0x9c')](_0x240f44[_0x35f7('0x88')]);_0x5ad2b0['filters']=_['intersection'](_0x5ad2b0['model'],_0x5ad2b0[_0x35f7('0x88')]);_0x3c294b[_0x35f7('0x9d')]=_[_0x35f7('0x9e')](_0x5ad2b0[_0x35f7('0x9a')],qs[_0x35f7('0x9f')](_0x240f44[_0x35f7('0x88')][_0x35f7('0x9f')]));_0x3c294b['attributes']=_0x3c294b[_0x35f7('0x9d')][_0x35f7('0x97')]?_0x3c294b[_0x35f7('0x9d')]:_0x5ad2b0[_0x35f7('0x9a')];if(!_0x240f44[_0x35f7('0x88')][_0x35f7('0xa0')](_0x35f7('0xa1'))){_0x3c294b[_0x35f7('0xa2')]=qs[_0x35f7('0xa2')](_0x240f44[_0x35f7('0x88')]['limit']);_0x3c294b[_0x35f7('0xa3')]=qs[_0x35f7('0xa3')](_0x240f44[_0x35f7('0x88')]['offset']);}_0x3c294b[_0x35f7('0xa4')]=qs[_0x35f7('0xa5')](_0x240f44[_0x35f7('0x88')][_0x35f7('0xa5')]);_0x3c294b['where']=qs['filters'](_['pick'](_0x240f44[_0x35f7('0x88')],_0x5ad2b0[_0x35f7('0xa6')]));if(_0x240f44['query'][_0x35f7('0x4')]){_0x3c294b[_0x35f7('0x87')]=_[_0x35f7('0xa7')](_0x3c294b['where'],{'$or':_[_0x35f7('0x9')](_0x4e1ae0,function(_0x3ec559){if(_0x3ec559['type']['key']!==_0x35f7('0xa8')){var _0xf45e70={};_0xf45e70[_0x3ec559[_0x35f7('0x5')]]={'$like':'%'+_0x240f44[_0x35f7('0x88')][_0x35f7('0x4')]+'%'};return _0xf45e70;}})});}var _0xd8c767=[];var _0x2c4448=null;var _0x36c766={};if(_0x5975e2){_0x2c4448=_[_0x35f7('0x91')](_0x391311,['name',_0x5975e2[_0x35f7('0xa')]]);if(_0x2c4448[_0x35f7('0x5')]){_0x36c766={};if(_0x507c00['childModel']===_0x35f7('0xe')){_0x36c766[_0x2c4448[_0x35f7('0xa9')]]=_['map'](_0x5975e2[_0x35f7('0x8')],'id');}else{_0x36c766[_0x2c4448[_0x35f7('0xa9')]]=_0x5975e2['associatedResources'];}_0xd8c767['push'](_0x36c766);}else{_0x3c294b['where']['id']=_0x5975e2[_0x35f7('0x8')];}}else{for(var _0x3bef00=0x0;_0x3bef00<_0x242597[_0x35f7('0x97')];_0x3bef00++){_0x2c4448=_['find'](_0x391311,[_0x35f7('0xa'),_0x242597[_0x3bef00][_0x35f7('0xa')]]);if(_0x2c4448[_0x35f7('0x5')]){_0x36c766={};_0x36c766[_0x2c4448[_0x35f7('0xa9')]]=_0x242597[_0x3bef00][_0x35f7('0x8')];_0xd8c767[_0x35f7('0x99')](_0x36c766);}else{if(!_0x3c294b[_0x35f7('0x87')]['id'])_0x3c294b[_0x35f7('0x87')]['id']=[];_0x242597[_0x3bef00][_0x35f7('0x8')][_0x35f7('0xaa')](function(_0x487c80){_0x3c294b['where']['id'][_0x35f7('0x99')](_0x487c80);});}}}if(!_[_0x35f7('0x95')](_0xd8c767)){_0x3c294b[_0x35f7('0x87')]=_[_0x35f7('0xa7')](_0x3c294b[_0x35f7('0x87')],{'$and':{'$or':_0xd8c767}});}_0x3c294b=_[_0x35f7('0xa7')]({},_0x3c294b,_0x240f44[_0x35f7('0xab')]);if(_0x5975e2&&!_0x5975e2['autoAssociation']&&_0x507c00[_0x35f7('0x13')]==='AnalyticExtractedReport'){if(_0x240f44[_0x35f7('0x88')][_0x35f7('0xac')]){_0x3c294b['include']=[{'all':!![]}];}return _0xce97cb[_0x507c00[_0x35f7('0x13')]][_0x35f7('0x7')](_0x3c294b)['then'](function(_0x51216f){var _0x31f6e5=[];_0x51216f['forEach'](function(_0x26911c){var _0x338361;switch(_0x26911c[_0x35f7('0xad')]){case'default':_0x338361=_[_0x35f7('0x91')](_0x5975e2['associatedResources'],function(_0x3297ea){return _0x3297ea['id']===_0x26911c['reportId']&&_0x3297ea[_0x35f7('0x3a')]==='DefaultReports';});break;case'custom':_0x338361=_[_0x35f7('0x91')](_0x5975e2[_0x35f7('0x8')],function(_0x4fc458){return _0x4fc458['id']===_0x26911c[_0x35f7('0x79')]&&_0x4fc458[_0x35f7('0x3a')]==='CustomReports';});break;}if(_0x338361)_0x31f6e5[_0x35f7('0x99')](_0x26911c);});_0x199d4b[_0x35f7('0xae')]=_0x31f6e5[_0x35f7('0x97')];_0x199d4b[_0x35f7('0xaf')]=_0x31f6e5;return _0x199d4b;});}else{if(!_['isEmpty'](_0x240f44['query'][_0x35f7('0xb0')])){_0x3c294b[_0x35f7('0x87')]['id']=_0x3c294b[_0x35f7('0x87')]['id']?_['intersection'](_0x3c294b['where']['id'],_0x240f44[_0x35f7('0x88')]['ids']):_0x240f44[_0x35f7('0x88')][_0x35f7('0xb0')];if(_0x240f44[_0x35f7('0x88')][_0x35f7('0xb1')]){_0x3c294b[_0x35f7('0xa4')]=_0x240f44[_0x35f7('0x88')][_0x35f7('0xb1')];}}if(_0x240f44['query'][_0x35f7('0xb2')]){_0x3c294b[_0x35f7('0x87')]=_[_0x35f7('0xa7')](_0x3c294b[_0x35f7('0x87')],{'$and':_0x240f44[_0x35f7('0x88')][_0x35f7('0xb2')]});}return _0xce97cb[_0x507c00[_0x35f7('0x13')]][_0x35f7('0xae')]({'where':_0x3c294b[_0x35f7('0x87')]})[_0x35f7('0xd')](function(_0x1dab8f){_0x199d4b[_0x35f7('0xae')]=_0x1dab8f;if(_0x240f44[_0x35f7('0x88')]['includeAll']){if(_0x507c00[_0x35f7('0x13')]===_0x35f7('0x1a')){_0x3c294b[_0x35f7('0xb3')]=[{'model':_0xce97cb['Tag'],'as':'Tags','attributes':['id','name',_0x35f7('0xb4')],'required':_0x240f44[_0x35f7('0x88')]['tag']?!![]:![]},{'model':_0xce97cb[_0x35f7('0x71')],'as':_0x35f7('0xb5'),'attributes':['id',_0x35f7('0xa'),_0x35f7('0xb4')],'through':_0x240f44[_0x35f7('0x88')][_0x35f7('0xb6')]?{'attributes':[],'where':{'TagId':_0x240f44['query']['tag']||undefined}}:{},'required':_0x240f44[_0x35f7('0x88')][_0x35f7('0xb6')]?!![]:![]}];}else{_0x3c294b[_0x35f7('0xb3')]=[{'all':!![]}];}}return _0xce97cb[_0x507c00[_0x35f7('0x13')]][_0x35f7('0x7')](_0x3c294b);})['then'](function(_0x2c6584){_0x199d4b['rows']=_0x2c6584;if(_0x3c2c77==='Agents'&&_0x240f44['query'][_0x35f7('0xb7')]===_0x35f7('0xb8')){var _0x33cca9=[];for(var _0x3a0c28=0x0;_0x3a0c28<_0x199d4b[_0x35f7('0xaf')]['length'];_0x3a0c28++){_0x33cca9[_0x35f7('0x99')](_0x316cf4(_0x35f7('0xb9'),_0x199d4b[_0x35f7('0xaf')][_0x3a0c28][_0x35f7('0xba')]));_0x33cca9['push'](_0x316cf4('sms',_0x199d4b['rows'][_0x3a0c28][_0x35f7('0xba')]));_0x33cca9['push'](_0x316cf4(_0x35f7('0xbb'),_0x199d4b[_0x35f7('0xaf')][_0x3a0c28][_0x35f7('0xba')]));_0x33cca9[_0x35f7('0x99')](_0x316cf4(_0x35f7('0xbc'),_0x199d4b[_0x35f7('0xaf')][_0x3a0c28][_0x35f7('0xba')]));_0x33cca9[_0x35f7('0x99')](_0x316cf4(_0x35f7('0xbd'),_0x199d4b[_0x35f7('0xaf')][_0x3a0c28][_0x35f7('0xba')]));_0x33cca9['push'](_0x316cf4(_0x35f7('0xbe'),_0x199d4b['rows'][_0x3a0c28][_0x35f7('0xba')]));}return Promise[_0x35f7('0x93')](_0x33cca9)[_0x35f7('0xd')](function(){return _0x199d4b;});}return _0x199d4b;});}});}}});};