6f960a8dec4fa6fef217e7a8d91281f723d42333
[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 _0x7a9f=['from','_interactions','where','ui.UserId\x20=\x20?','sequelize','query','toString','OpenTabs','define','user_profiles','section','mergeResources','isEmpty','length','push','UserProfileSection','find','params','all','ignore','union','autoAssociation','keys','intersection','attributes','fields','hasOwnProperty','limit','offset','order','sort','filters','merge','VIRTUAL','forEach','options','reportType','default','reportId','DefaultReports','custom','count','rows','ids','customSorting','extraQueryConditions','includeAll','include','Tags','color','tag','ThroughTags','openTabs','true','chat','dataValues','mail','lodash','./userProfile.attributes','exports','models','filter','field','findAll','then','model','associatedResources','map','name','catch','resolve','AnalyticExtractedReport','resourceId','type','squareprojects','childModel','SquareProject','squarerecordings','SquareRecording','parentSections','projectName','projects','JscriptyProject','contacts','CmContact','Lists','ListId','lists','CmList','companies','CmCompany','CmCustomField','chatqueues','ChatQueue','chatwebsites','ChatWebsite','FaxQueue','faxaccounts','FaxAccount','inboundroutes','internalroutes','outboundroutes','VoiceExtension','contexts','voicemails','VoiceMail','voicerecordings','VoiceRecording','Agents','User','role','agent','Telephones','membername','VoiceQueues','queue','VoiceQueue','outbound','musiconholds','voiceprefixes','VoicePrefix','ivrcampaigns','MailQueue','mailaccounts','MailAccount','mailsubstatuses','MailSubstatus','openchannelqueues','OpenchannelQueue','openchannelaccounts','OpenchannelAccount','smsqueues','SmsQueue','whatsappaccounts','WhatsappAccount','teams','Team','voicequeues','queuecampaigns','QueueCampaigns','agents','telephones','Users','admin','user','zendeskaccounts','salesforceaccounts','SalesforceAccount','FreshdeskAccount','SugarcrmAccount','zohoaccounts','cannedanswers','CannedAnswer','dispositions','Disposition','customdashboards','intervals','Interval','pauses','Pause','scheduler','sounds','Sound','tags','Tag','templates','triggers','Trigger','trunks','variables','Plugin','extractedreports','Reports','metrics','AnalyticMetric','charAt','slice','Sequelize','SELECT','ui.createdAt'];(function(_0x5484cb,_0x225674){var _0x5dffb2=function(_0x924de6){while(--_0x924de6){_0x5484cb['push'](_0x5484cb['shift']());}};_0x5dffb2(++_0x225674);}(_0x7a9f,0x1a1));var _0xf7a9=function(_0x44a6bc,_0xa0794c){_0x44a6bc=_0x44a6bc-0x0;var _0x1f87b1=_0x7a9f[_0x44a6bc];return _0x1f87b1;};'use strict';var _=require(_0xf7a9('0x0'));var attributes=require(_0xf7a9('0x1'));var squel=require('squel');module[_0xf7a9('0x2')]=function(_0x587f4b){var _0x116c4e=_0x587f4b[_0xf7a9('0x3')];function _0x348eab(_0x184634,_0x15a359){return new Promise(function(_0x4b9084,_0x38353c){if(!_0x15a359)return _0x4b9084(null);var _0x254398=_0x15a359[_0xf7a9('0x4')]?{[_0x15a359['filter'][_0xf7a9('0x5')]]:_0x15a359[_0xf7a9('0x4')]['value']}:undefined;return _0x116c4e[_0x184634][_0xf7a9('0x6')]({'where':_0x254398,'raw':!![]})[_0xf7a9('0x7')](function(_0x1d8057){_0x15a359['associatedResources']=_['map'](_0x1d8057,'id');_0x4b9084(_0x15a359);})['catch'](function(_0x22a3fe){_0x38353c(_0x22a3fe);});});}function _0x302bde(_0x1b0455,_0x555986){return new Promise(function(_0x1493ab,_0xe3e87a){var _0x5c3e91=_0x1b0455[_0xf7a9('0x4')]?{[_0x1b0455[_0xf7a9('0x4')][_0xf7a9('0x5')]]:_0x1b0455[_0xf7a9('0x4')]['value']}:undefined;return _0x116c4e[_0x1b0455[_0xf7a9('0x8')]]['findAll']({'where':_0x5c3e91,'raw':!![]})[_0xf7a9('0x7')](function(_0x58d943){_0x555986[_0xf7a9('0x9')]=_[_0xf7a9('0xa')](_0x58d943,function(_0x4128ca){return _0x4128ca[_0xf7a9('0xb')];});_0x1493ab(_0x555986);})[_0xf7a9('0xc')](function(_0x5cf683){_0xe3e87a(_0x5cf683);});});}function _0x5ed739(_0x657449,_0x3a9782,_0x25cc2f){if(!_0x3a9782)return Promise[_0xf7a9('0xd')](null);return new Promise(function(_0x4dbe26,_0x38df37){return _0x116c4e['UserProfileResource']['findAll']({'where':{'sectionId':_0x3a9782['id']},'raw':!![]})['then'](function(_0x2ce8f7){if(_0x657449[_0xf7a9('0x5')]&&_0x657449[_0xf7a9('0x5')]!=='id'){_0x3a9782[_0xf7a9('0x9')]=_[_0xf7a9('0xa')](_0x2ce8f7,function(_0x243ae5){return _0x243ae5[_0x657449[_0xf7a9('0x5')]];});}else{if(_0x25cc2f===_0xf7a9('0xe')){_0x3a9782['associatedResources']=_[_0xf7a9('0xa')](_0x2ce8f7,function(_0xc6f106){return{'id':_0xc6f106[_0xf7a9('0xf')],'type':_0xc6f106[_0xf7a9('0x10')]};});}else{_0x3a9782[_0xf7a9('0x9')]=_['map'](_0x2ce8f7,function(_0x27382d){return _0x27382d[_0xf7a9('0xf')];});}}_0x4dbe26(_0x3a9782);})[_0xf7a9('0xc')](function(_0x173126){_0x38df37(_0x173126);});});}function _0x9d3870(_0x51a244,_0x3d405f){var _0x465346={'parentSections':[]};switch(_0x51a244['toLowerCase']()){case _0xf7a9('0x11'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x13');break;case'odbc':_0x465346[_0xf7a9('0x12')]='SquareOdbc';break;case _0xf7a9('0x14'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x15');_0x465346[_0xf7a9('0x16')]=[{'name':'SquareProjects','field':_0xf7a9('0xb'),'foreignKey':_0xf7a9('0x17')}];break;case _0xf7a9('0x18'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x19');break;case _0xf7a9('0x1a'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x1b');_0x465346[_0xf7a9('0x16')]=[{'name':_0xf7a9('0x1c'),'field':'id','foreignKey':_0xf7a9('0x1d')}];break;case _0xf7a9('0x1e'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x1f');break;case _0xf7a9('0x20'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x21');break;case'globalcustomfields':_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x22');break;case _0xf7a9('0x23'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x24');break;case _0xf7a9('0x25'):_0x465346['childModel']=_0xf7a9('0x26');break;case'faxqueues':_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x27');break;case _0xf7a9('0x28'):_0x465346['childModel']=_0xf7a9('0x29');break;case _0xf7a9('0x2a'):case _0xf7a9('0x2b'):case _0xf7a9('0x2c'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x2d');break;case _0xf7a9('0x2e'):_0x465346[_0xf7a9('0x12')]='VoiceContext';break;case _0xf7a9('0x2f'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x30');break;case _0xf7a9('0x31'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x32');_0x465346[_0xf7a9('0x16')]=[{'name':_0xf7a9('0x33'),'field':_0xf7a9('0xb'),'foreignKey':'membername','model':_0xf7a9('0x34'),'filter':{'field':_0xf7a9('0x35'),'value':[_0xf7a9('0x36')]}},{'name':_0xf7a9('0x37'),'field':_0xf7a9('0xb'),'foreignKey':_0xf7a9('0x38'),'model':_0xf7a9('0x34'),'filter':{'field':'role','value':['telephone']}},{'name':_0xf7a9('0x39'),'field':_0xf7a9('0xb'),'foreignKey':_0xf7a9('0x3a'),'model':_0xf7a9('0x3b'),'filter':{'field':_0xf7a9('0x10'),'value':['inbound']}},{'name':'QueueCampaigns','field':'name','foreignKey':_0xf7a9('0x3a'),'model':'VoiceQueue','filter':{'field':_0xf7a9('0x10'),'value':[_0xf7a9('0x3c')]}}];break;case _0xf7a9('0x3d'):_0x465346[_0xf7a9('0x12')]='VoiceMusicOnHold';break;case'chanspies':_0x465346[_0xf7a9('0x12')]='VoiceChanSpy';break;case _0xf7a9('0x3e'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x3f');break;case _0xf7a9('0x40'):_0x465346[_0xf7a9('0x12')]='Campaign';break;case'mailqueues':_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x41');break;case _0xf7a9('0x42'):_0x465346['childModel']=_0xf7a9('0x43');break;case _0xf7a9('0x44'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x45');break;case _0xf7a9('0x46'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x47');break;case _0xf7a9('0x48'):_0x465346['childModel']=_0xf7a9('0x49');break;case _0xf7a9('0x4a'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x4b');break;case'smsaccounts':_0x465346[_0xf7a9('0x12')]='SmsAccount';break;case'whatsappqueues':_0x465346['childModel']='WhatsappQueue';break;case _0xf7a9('0x4c'):_0x465346['childModel']=_0xf7a9('0x4d');break;case _0xf7a9('0x4e'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x4f');break;case _0xf7a9('0x50'):case _0xf7a9('0x51'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x3b');if(_0x3d405f){_0x465346[_0xf7a9('0x16')]=[{'name':_0xf7a9('0x39')},{'name':_0xf7a9('0x52')}];}break;case'users':case _0xf7a9('0x53'):case _0xf7a9('0x54'):_0x465346['childModel']=_0xf7a9('0x34');if(_0x3d405f){_0x465346[_0xf7a9('0x16')]=[{'name':_0xf7a9('0x55'),'filter':{'field':_0xf7a9('0x35'),'value':[_0xf7a9('0x56'),_0xf7a9('0x57')]},'ignore':!![]},{'name':_0xf7a9('0x33')},{'name':_0xf7a9('0x37')}];}break;case _0xf7a9('0x58'):_0x465346[_0xf7a9('0x12')]='ZendeskAccount';break;case _0xf7a9('0x59'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x5a');break;case'freshdeskaccounts':_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x5b');break;case'sugarcrmaccounts':_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x5c');break;case'deskaccounts':_0x465346[_0xf7a9('0x12')]='DeskAccount';break;case _0xf7a9('0x5d'):_0x465346[_0xf7a9('0x12')]='ZohoAccount';break;case'vtigeraccounts':_0x465346[_0xf7a9('0x12')]='User';break;case _0xf7a9('0x5e'):_0x465346['childModel']=_0xf7a9('0x5f');break;case _0xf7a9('0x60'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x61');break;case _0xf7a9('0x62'):_0x465346[_0xf7a9('0x12')]='Dashboard';break;case _0xf7a9('0x63'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x64');break;case _0xf7a9('0x65'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x66');break;case _0xf7a9('0x67'):_0x465346[_0xf7a9('0x12')]='Schedule';break;case _0xf7a9('0x68'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x69');break;case _0xf7a9('0x6a'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x6b');break;case _0xf7a9('0x6c'):_0x465346['childModel']='Template';break;case _0xf7a9('0x6d'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x6e');break;case _0xf7a9('0x6f'):_0x465346[_0xf7a9('0x12')]='Trunk';break;case _0xf7a9('0x70'):_0x465346[_0xf7a9('0x12')]='Variable';break;case'plugins':_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x71');break;case _0xf7a9('0x72'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0xe');_0x465346['parentSections']=[{'name':_0xf7a9('0x73'),'field':'id','foreignKey':'reportId'}];break;case _0xf7a9('0x74'):_0x465346[_0xf7a9('0x12')]=_0xf7a9('0x75');break;}return _0x465346;}function _0x5b0514(_0xcfc7b0,_0x76b4db){var _0xbcc2d7=_0xcfc7b0[_0xf7a9('0x76')](0x0)['toUpperCase']()+_0xcfc7b0[_0xf7a9('0x77')](0x1);var _0x31d0b0={'type':_0x116c4e[_0xf7a9('0x78')]['QueryTypes'][_0xf7a9('0x79')],'raw':!![]};return new Promise(function(_0x54ae4a,_0x242bbf){var _0x3e83a4=squel['select']()[_0xf7a9('0x5')]('ui.'+_0xbcc2d7+'InteractionId','id')[_0xf7a9('0x5')](_0xf7a9('0x7a'))[_0xf7a9('0x7b')]('user_has_'+_0xcfc7b0+_0xf7a9('0x7c'),'ui')[_0xf7a9('0x7d')](_0xf7a9('0x7e'),_0x76b4db['id']);return _0x116c4e[_0xf7a9('0x7f')][_0xf7a9('0x80')](_0x3e83a4[_0xf7a9('0x81')](),_0x31d0b0)[_0xf7a9('0x7')](function(_0x478fb8){_0x76b4db[_0xbcc2d7+_0xf7a9('0x82')]=_0x478fb8;_0x54ae4a(_0x478fb8);})['catch'](function(_0x4a5d28){_0x242bbf(_0x4a5d28);});});}return _0x587f4b[_0xf7a9('0x83')]('UserProfile',attributes,{'tableName':_0xf7a9('0x84'),'paranoid':![],'indexes':[],'timestamps':!![],'classMethods':{'getResources':function(_0x358a45){var _0x114821=require('../../components/parsers/qs');var _0x30943d={'raw':_0x358a45[_0xf7a9('0x80')]['raw'],'where':{}};var _0x295ae3={};var _0x226071={'count':0x0,'rows':[]};var _0xbd4554=_0x358a45['query'][_0xf7a9('0x85')];var _0x1f3e77=_0x358a45[_0xf7a9('0x80')][_0xf7a9('0x86')]||![];var _0x35c6e7=_0x9d3870(_0xbd4554,_0x1f3e77);if(!_0x35c6e7[_0xf7a9('0x12')])throw new Error('Invalid\x20section\x20\x27'+_0xbd4554+'\x27');var _0x4bd2be=[{'name':_0xbd4554}];if(!_[_0xf7a9('0x87')](_0x35c6e7[_0xf7a9('0x16')]))_0x4bd2be=_0x35c6e7['parentSections'];var _0x5f3d83=[];for(var _0x438422=0x0;_0x438422<_0x4bd2be[_0xf7a9('0x88')];_0x438422++){_0x5f3d83[_0xf7a9('0x89')](_0x116c4e[_0xf7a9('0x8a')][_0xf7a9('0x8b')]({'where':{'userProfileId':_0x358a45[_0xf7a9('0x8c')]['id'],'name':_0x4bd2be[_0x438422]['name']},'raw':!![]}));}return Promise[_0xf7a9('0x8d')](_0x5f3d83)[_0xf7a9('0x7')](function(_0x18507f){var _0x4024b5=_[_0xf7a9('0x4')](_0x18507f,function(_0x2f92c3){return _0x2f92c3?_0x2f92c3:undefined;});var _0x1a3e94=_['filter'](_0x4bd2be,[_0xf7a9('0x8e'),!![]]);var _0x2c3a86=_['isEmpty'](_0x4024b5)&&_[_0xf7a9('0x87')](_0x1a3e94)?null:_[_0xf7a9('0x8f')](_0x1a3e94,_0x4024b5);if(!_0x2c3a86)return null;var _0x42f2a1=[];for(var _0x261445=0x0;_0x261445<_0x2c3a86[_0xf7a9('0x88')];_0x261445++){var _0x26e439=_['find'](_0x4bd2be,function(_0xa36314){return _0x2c3a86[_0x261445]?_0xa36314[_0xf7a9('0xb')]===_0x2c3a86[_0x261445]['name']:null;});if(_0x26e439){if(_0x2c3a86[_0x261445][_0xf7a9('0x8e')]){_0x42f2a1[_0xf7a9('0x89')](_0x348eab(_0x35c6e7[_0xf7a9('0x12')],_0x2c3a86[_0x261445]));}else{if(!_0x2c3a86[_0x261445][_0xf7a9('0x90')]){_0x42f2a1[_0xf7a9('0x89')](_0x5ed739(_0x26e439,_0x2c3a86[_0x261445],_0x35c6e7['childModel']));}else{if(_0x26e439[_0xf7a9('0x8')]){_0x42f2a1[_0xf7a9('0x89')](_0x302bde(_0x26e439,_0x2c3a86[_0x261445]));}}}}}return Promise[_0xf7a9('0x8d')](_0x42f2a1);})[_0xf7a9('0x7')](function(_0x590c24){var _0xd08f7b=_0x590c24;var _0x4771d0=null;if(_0xd08f7b){_0x4771d0=_0xd08f7b[_0xf7a9('0x88')]===0x1?_0xd08f7b[0x0]:null;}if(!_0x4771d0&&!_0xd08f7b)return _0x226071;var _0x205b1c=_0x116c4e[_0x35c6e7[_0xf7a9('0x12')]]['rawAttributes'];_0x295ae3['model']=_[_0xf7a9('0x91')](_0x205b1c);_0x295ae3[_0xf7a9('0x80')]=_[_0xf7a9('0x91')](_0x358a45[_0xf7a9('0x80')]);_0x295ae3['filters']=_[_0xf7a9('0x92')](_0x295ae3['model'],_0x295ae3[_0xf7a9('0x80')]);_0x30943d[_0xf7a9('0x93')]=_[_0xf7a9('0x92')](_0x295ae3[_0xf7a9('0x8')],_0x114821[_0xf7a9('0x94')](_0x358a45[_0xf7a9('0x80')][_0xf7a9('0x94')]));_0x30943d['attributes']=_0x30943d[_0xf7a9('0x93')][_0xf7a9('0x88')]?_0x30943d[_0xf7a9('0x93')]:_0x295ae3['model'];if(!_0x358a45[_0xf7a9('0x80')][_0xf7a9('0x95')]('nolimit')){_0x30943d['limit']=_0x114821[_0xf7a9('0x96')](_0x358a45[_0xf7a9('0x80')]['limit']);_0x30943d[_0xf7a9('0x97')]=_0x114821[_0xf7a9('0x97')](_0x358a45[_0xf7a9('0x80')][_0xf7a9('0x97')]);}_0x30943d[_0xf7a9('0x98')]=_0x114821[_0xf7a9('0x99')](_0x358a45['query'][_0xf7a9('0x99')]);_0x30943d[_0xf7a9('0x7d')]=_0x114821[_0xf7a9('0x9a')](_['pick'](_0x358a45[_0xf7a9('0x80')],_0x295ae3['filters']));if(_0x358a45[_0xf7a9('0x80')][_0xf7a9('0x4')]){_0x30943d[_0xf7a9('0x7d')]=_[_0xf7a9('0x9b')](_0x30943d[_0xf7a9('0x7d')],{'$or':_[_0xf7a9('0xa')](_0x205b1c,function(_0x43bd55){if(_0x43bd55[_0xf7a9('0x10')]['key']!==_0xf7a9('0x9c')){var _0x44c5f6={};_0x44c5f6[_0x43bd55[_0xf7a9('0x5')]]={'$like':'%'+_0x358a45[_0xf7a9('0x80')][_0xf7a9('0x4')]+'%'};return _0x44c5f6;}})});}var _0x26996b=[];var _0x44d44b=null;var _0x29036c={};if(_0x4771d0){_0x44d44b=_[_0xf7a9('0x8b')](_0x4bd2be,[_0xf7a9('0xb'),_0x4771d0['name']]);if(_0x44d44b[_0xf7a9('0x5')]){_0x29036c={};if(_0x35c6e7['childModel']===_0xf7a9('0xe')){_0x29036c[_0x44d44b['foreignKey']]=_['map'](_0x4771d0['associatedResources'],'id');}else{_0x29036c[_0x44d44b['foreignKey']]=_0x4771d0[_0xf7a9('0x9')];}_0x26996b[_0xf7a9('0x89')](_0x29036c);}else{_0x30943d['where']['id']=_0x4771d0[_0xf7a9('0x9')];}}else{for(var _0x514fa1=0x0;_0x514fa1<_0xd08f7b[_0xf7a9('0x88')];_0x514fa1++){_0x44d44b=_['find'](_0x4bd2be,[_0xf7a9('0xb'),_0xd08f7b[_0x514fa1][_0xf7a9('0xb')]]);if(_0x44d44b['field']){_0x29036c={};_0x29036c[_0x44d44b['foreignKey']]=_0xd08f7b[_0x514fa1][_0xf7a9('0x9')];_0x26996b[_0xf7a9('0x89')](_0x29036c);}else{if(!_0x30943d['where']['id'])_0x30943d['where']['id']=[];_0xd08f7b[_0x514fa1][_0xf7a9('0x9')][_0xf7a9('0x9d')](function(_0x575a16){_0x30943d[_0xf7a9('0x7d')]['id'][_0xf7a9('0x89')](_0x575a16);});}}}if(!_[_0xf7a9('0x87')](_0x26996b)){_0x30943d['where']=_['merge'](_0x30943d[_0xf7a9('0x7d')],{'$and':{'$or':_0x26996b}});}_0x30943d=_[_0xf7a9('0x9b')]({},_0x30943d,_0x358a45[_0xf7a9('0x9e')]);if(_0x4771d0&&!_0x4771d0[_0xf7a9('0x90')]&&_0x35c6e7[_0xf7a9('0x12')]===_0xf7a9('0xe')){if(_0x358a45[_0xf7a9('0x80')]['includeAll']){_0x30943d['include']=[{'all':!![]}];}return _0x116c4e[_0x35c6e7[_0xf7a9('0x12')]][_0xf7a9('0x6')](_0x30943d)[_0xf7a9('0x7')](function(_0x35da1a){var _0x2d498b=[];_0x35da1a[_0xf7a9('0x9d')](function(_0x2df947){var _0x465d3c;switch(_0x2df947[_0xf7a9('0x9f')]){case _0xf7a9('0xa0'):_0x465d3c=_[_0xf7a9('0x8b')](_0x4771d0[_0xf7a9('0x9')],function(_0x287fbb){return _0x287fbb['id']===_0x2df947[_0xf7a9('0xa1')]&&_0x287fbb['type']===_0xf7a9('0xa2');});break;case _0xf7a9('0xa3'):_0x465d3c=_['find'](_0x4771d0['associatedResources'],function(_0x2ddb74){return _0x2ddb74['id']===_0x2df947[_0xf7a9('0xa1')]&&_0x2ddb74[_0xf7a9('0x10')]==='CustomReports';});break;}if(_0x465d3c)_0x2d498b['push'](_0x2df947);});_0x226071[_0xf7a9('0xa4')]=_0x2d498b[_0xf7a9('0x88')];_0x226071[_0xf7a9('0xa5')]=_0x2d498b;return _0x226071;});}else{if(!_[_0xf7a9('0x87')](_0x358a45[_0xf7a9('0x80')][_0xf7a9('0xa6')])){_0x30943d[_0xf7a9('0x7d')]['id']=_0x30943d['where']['id']?_[_0xf7a9('0x92')](_0x30943d[_0xf7a9('0x7d')]['id'],_0x358a45[_0xf7a9('0x80')][_0xf7a9('0xa6')]):_0x358a45['query'][_0xf7a9('0xa6')];if(_0x358a45[_0xf7a9('0x80')][_0xf7a9('0xa7')]){_0x30943d[_0xf7a9('0x98')]=_0x358a45[_0xf7a9('0x80')][_0xf7a9('0xa7')];}}if(_0x358a45[_0xf7a9('0x80')][_0xf7a9('0xa8')]){_0x30943d['where']=_[_0xf7a9('0x9b')](_0x30943d['where'],{'$and':_0x358a45['query'][_0xf7a9('0xa8')]});}return _0x116c4e[_0x35c6e7[_0xf7a9('0x12')]][_0xf7a9('0xa4')]({'where':_0x30943d[_0xf7a9('0x7d')]})[_0xf7a9('0x7')](function(_0x2b2cc1){_0x226071[_0xf7a9('0xa4')]=_0x2b2cc1;if(_0x358a45[_0xf7a9('0x80')][_0xf7a9('0xa9')]){if(_0x35c6e7['childModel']==='CmContact'){_0x30943d[_0xf7a9('0xaa')]=[{'model':_0x116c4e['Tag'],'as':_0xf7a9('0xab'),'attributes':['id',_0xf7a9('0xb'),_0xf7a9('0xac')],'required':_0x358a45[_0xf7a9('0x80')][_0xf7a9('0xad')]?!![]:![]},{'model':_0x116c4e[_0xf7a9('0x6b')],'as':_0xf7a9('0xae'),'attributes':['id',_0xf7a9('0xb'),'color'],'through':_0x358a45[_0xf7a9('0x80')][_0xf7a9('0xad')]?{'attributes':[],'where':{'TagId':_0x358a45['query'][_0xf7a9('0xad')]||undefined}}:{},'required':_0x358a45[_0xf7a9('0x80')]['tag']?!![]:![]}];}else{_0x30943d['include']=[{'all':!![]}];}}return _0x116c4e[_0x35c6e7[_0xf7a9('0x12')]][_0xf7a9('0x6')](_0x30943d);})[_0xf7a9('0x7')](function(_0x1c3e4f){_0x226071['rows']=_0x1c3e4f;if(_0xbd4554===_0xf7a9('0x33')&&_0x358a45[_0xf7a9('0x80')][_0xf7a9('0xaf')]===_0xf7a9('0xb0')){var _0x554af8=[];for(var _0x21a90f=0x0;_0x21a90f<_0x226071[_0xf7a9('0xa5')][_0xf7a9('0x88')];_0x21a90f++){_0x554af8[_0xf7a9('0x89')](_0x5b0514(_0xf7a9('0xb1'),_0x226071[_0xf7a9('0xa5')][_0x21a90f][_0xf7a9('0xb2')]));_0x554af8['push'](_0x5b0514('sms',_0x226071[_0xf7a9('0xa5')][_0x21a90f]['dataValues']));_0x554af8['push'](_0x5b0514('fax',_0x226071[_0xf7a9('0xa5')][_0x21a90f][_0xf7a9('0xb2')]));_0x554af8[_0xf7a9('0x89')](_0x5b0514(_0xf7a9('0xb3'),_0x226071[_0xf7a9('0xa5')][_0x21a90f][_0xf7a9('0xb2')]));_0x554af8[_0xf7a9('0x89')](_0x5b0514('openchannel',_0x226071[_0xf7a9('0xa5')][_0x21a90f][_0xf7a9('0xb2')]));_0x554af8['push'](_0x5b0514('whatsapp',_0x226071[_0xf7a9('0xa5')][_0x21a90f][_0xf7a9('0xb2')]));}return Promise[_0xf7a9('0x8d')](_0x554af8)[_0xf7a9('0x7')](function(){return _0x226071;});}return _0x226071;});}});}}});};