Built motion from commit 10af8726.|2.6.34
[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 _0xa3a0=['name','projectName','projects','JscriptyProject','contacts','Lists','ListId','lists','CmList','companies','CmCompany','CmCustomField','chatqueues','ChatQueue','faxqueues','FaxAccount','internalroutes','outboundroutes','contexts','VoiceMail','voicerecordings','VoiceRecording','membername','role','agent','Telephones','User','telephone','queue','inbound','QueueCampaigns','outbound','musiconholds','VoiceMusicOnHold','chanspies','VoiceChanSpy','voiceprefixes','VoicePrefix','Campaign','mailqueues','MailQueue','mailaccounts','MailAccount','mailsubstatuses','MailSubstatus','OpenchannelQueue','openchannelaccounts','OpenchannelAccount','smsqueues','SmsQueue','smsaccounts','SmsAccount','whatsappqueues','WhatsappQueue','WhatsappAccount','teams','Team','voicequeues','queuecampaigns','VoiceQueues','users','agents','telephones','admin','user','Agents','zendeskaccounts','ZendeskAccount','salesforceaccounts','SalesforceAccount','freshdeskaccounts','FreshdeskAccount','sugarcrmaccounts','SugarcrmAccount','deskaccounts','zohoaccounts','ZohoAccount','cannedanswers','CannedAnswer','dispositions','Disposition','customdashboards','Dashboard','intervals','Interval','pauses','Pause','scheduler','Schedule','sounds','tags','triggers','Trigger','Trunk','variables','Variable','plugins','Plugin','extractedreports','Reports','reportId','metrics','charAt','toUpperCase','Sequelize','QueryTypes','SELECT','select','ui.','InteractionId','ui.createdAt','from','user_has_','_interactions','where','ui.UserId\x20=\x20?','sequelize','query','OpenTabs','UserProfile','user_profiles','../../components/parsers/qs','raw','section','isEmpty','length','push','UserProfileSection','find','all','autoAssociation','rawAttributes','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','limit','offset','order','sort','merge','key','VIRTUAL','foreignKey','forEach','reportType','DefaultReports','custom','CustomReports','count','ids','customSorting','extraQueryConditions','includeAll','CmContact','include','Tag','Tags','color','tag','ThroughTags','rows','openTabs','true','sms','dataValues','fax','whatsapp','./userProfile.attributes','squel','models','field','associatedResources','filter','value','model','then','catch','findAll','map','AnalyticExtractedReport','type','toLowerCase','childModel','SquareOdbc','squarerecordings','SquareRecording','parentSections','SquareProjects'];(function(_0x2400db,_0x31c4c6){var _0x262af1=function(_0x10514e){while(--_0x10514e){_0x2400db['push'](_0x2400db['shift']());}};_0x262af1(++_0x31c4c6);}(_0xa3a0,0x16b));var _0x0a3a=function(_0x1e9946,_0x16a118){_0x1e9946=_0x1e9946-0x0;var _0x1122cc=_0xa3a0[_0x1e9946];return _0x1122cc;};'use strict';var _=require('lodash');var attributes=require(_0x0a3a('0x0'));var squel=require(_0x0a3a('0x1'));module['exports']=function(_0x20f4ed){var _0xdeabed=_0x20f4ed[_0x0a3a('0x2')];function _0x4f27cb(_0xea26a4,_0x5e05ef){return new Promise(function(_0x122bc3,_0x1b91a6){if(!_0x5e05ef)return _0x122bc3(null);var _0xddfcf9=_0x5e05ef['filter']?{[_0x5e05ef['filter'][_0x0a3a('0x3')]]:_0x5e05ef['filter']['value']}:undefined;return _0xdeabed[_0xea26a4]['findAll']({'where':_0xddfcf9,'raw':!![]})['then'](function(_0x22192b){_0x5e05ef[_0x0a3a('0x4')]=_['map'](_0x22192b,'id');_0x122bc3(_0x5e05ef);})['catch'](function(_0x2555f3){_0x1b91a6(_0x2555f3);});});}function _0x426eaa(_0x4c75fc,_0x2d85bb){return new Promise(function(_0x557d3a,_0x102250){var _0x2581a7=_0x4c75fc[_0x0a3a('0x5')]?{[_0x4c75fc['filter'][_0x0a3a('0x3')]]:_0x4c75fc[_0x0a3a('0x5')][_0x0a3a('0x6')]}:undefined;return _0xdeabed[_0x4c75fc[_0x0a3a('0x7')]]['findAll']({'where':_0x2581a7,'raw':!![]})[_0x0a3a('0x8')](function(_0x1a06ad){_0x2d85bb[_0x0a3a('0x4')]=_['map'](_0x1a06ad,function(_0x271451){return _0x271451['name'];});_0x557d3a(_0x2d85bb);})[_0x0a3a('0x9')](function(_0x3c4d32){_0x102250(_0x3c4d32);});});}function _0x3ee697(_0x39691d,_0x9405a3,_0x71ae45){if(!_0x9405a3)return Promise['resolve'](null);return new Promise(function(_0x100b6a,_0x1b85d7){return _0xdeabed['UserProfileResource'][_0x0a3a('0xa')]({'where':{'sectionId':_0x9405a3['id']},'raw':!![]})[_0x0a3a('0x8')](function(_0x3d5ce7){if(_0x39691d[_0x0a3a('0x3')]&&_0x39691d[_0x0a3a('0x3')]!=='id'){_0x9405a3['associatedResources']=_[_0x0a3a('0xb')](_0x3d5ce7,function(_0x5b4189){return _0x5b4189[_0x39691d['field']];});}else{if(_0x71ae45===_0x0a3a('0xc')){_0x9405a3[_0x0a3a('0x4')]=_[_0x0a3a('0xb')](_0x3d5ce7,function(_0x4f31b8){return{'id':_0x4f31b8['resourceId'],'type':_0x4f31b8[_0x0a3a('0xd')]};});}else{_0x9405a3['associatedResources']=_[_0x0a3a('0xb')](_0x3d5ce7,function(_0x55cefc){return _0x55cefc['resourceId'];});}}_0x100b6a(_0x9405a3);})[_0x0a3a('0x9')](function(_0x5ce565){_0x1b85d7(_0x5ce565);});});}function _0x26d943(_0x1d7a79,_0x3ff2af){var _0x310e4a={'parentSections':[]};switch(_0x1d7a79[_0x0a3a('0xe')]()){case'squareprojects':_0x310e4a[_0x0a3a('0xf')]='SquareProject';break;case'odbc':_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x10');break;case _0x0a3a('0x11'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x12');_0x310e4a[_0x0a3a('0x13')]=[{'name':_0x0a3a('0x14'),'field':_0x0a3a('0x15'),'foreignKey':_0x0a3a('0x16')}];break;case _0x0a3a('0x17'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x18');break;case _0x0a3a('0x19'):_0x310e4a['childModel']='CmContact';_0x310e4a[_0x0a3a('0x13')]=[{'name':_0x0a3a('0x1a'),'field':'id','foreignKey':_0x0a3a('0x1b')}];break;case _0x0a3a('0x1c'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x1d');break;case _0x0a3a('0x1e'):_0x310e4a['childModel']=_0x0a3a('0x1f');break;case'globalcustomfields':_0x310e4a['childModel']=_0x0a3a('0x20');break;case _0x0a3a('0x21'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x22');break;case'chatwebsites':_0x310e4a[_0x0a3a('0xf')]='ChatWebsite';break;case _0x0a3a('0x23'):_0x310e4a[_0x0a3a('0xf')]='FaxQueue';break;case'faxaccounts':_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x24');break;case'inboundroutes':case _0x0a3a('0x25'):case _0x0a3a('0x26'):_0x310e4a['childModel']='VoiceExtension';break;case _0x0a3a('0x27'):_0x310e4a[_0x0a3a('0xf')]='VoiceContext';break;case'voicemails':_0x310e4a['childModel']=_0x0a3a('0x28');break;case _0x0a3a('0x29'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x2a');_0x310e4a[_0x0a3a('0x13')]=[{'name':'Agents','field':_0x0a3a('0x15'),'foreignKey':_0x0a3a('0x2b'),'model':'User','filter':{'field':_0x0a3a('0x2c'),'value':[_0x0a3a('0x2d')]}},{'name':_0x0a3a('0x2e'),'field':'name','foreignKey':_0x0a3a('0x2b'),'model':_0x0a3a('0x2f'),'filter':{'field':_0x0a3a('0x2c'),'value':[_0x0a3a('0x30')]}},{'name':'VoiceQueues','field':_0x0a3a('0x15'),'foreignKey':_0x0a3a('0x31'),'model':'VoiceQueue','filter':{'field':'type','value':[_0x0a3a('0x32')]}},{'name':_0x0a3a('0x33'),'field':_0x0a3a('0x15'),'foreignKey':_0x0a3a('0x31'),'model':'VoiceQueue','filter':{'field':_0x0a3a('0xd'),'value':[_0x0a3a('0x34')]}}];break;case _0x0a3a('0x35'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x36');break;case _0x0a3a('0x37'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x38');break;case _0x0a3a('0x39'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x3a');break;case'ivrcampaigns':_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x3b');break;case _0x0a3a('0x3c'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x3d');break;case _0x0a3a('0x3e'):_0x310e4a['childModel']=_0x0a3a('0x3f');break;case _0x0a3a('0x40'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x41');break;case'openchannelqueues':_0x310e4a['childModel']=_0x0a3a('0x42');break;case _0x0a3a('0x43'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x44');break;case _0x0a3a('0x45'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x46');break;case _0x0a3a('0x47'):_0x310e4a['childModel']=_0x0a3a('0x48');break;case _0x0a3a('0x49'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x4a');break;case'whatsappaccounts':_0x310e4a['childModel']=_0x0a3a('0x4b');break;case _0x0a3a('0x4c'):_0x310e4a['childModel']=_0x0a3a('0x4d');break;case _0x0a3a('0x4e'):case _0x0a3a('0x4f'):_0x310e4a[_0x0a3a('0xf')]='VoiceQueue';if(_0x3ff2af){_0x310e4a[_0x0a3a('0x13')]=[{'name':_0x0a3a('0x50')},{'name':_0x0a3a('0x33')}];}break;case _0x0a3a('0x51'):case _0x0a3a('0x52'):case _0x0a3a('0x53'):_0x310e4a['childModel']=_0x0a3a('0x2f');if(_0x3ff2af){_0x310e4a[_0x0a3a('0x13')]=[{'name':'Users','filter':{'field':'role','value':[_0x0a3a('0x54'),_0x0a3a('0x55')]},'ignore':!![]},{'name':_0x0a3a('0x56')},{'name':_0x0a3a('0x2e')}];}break;case _0x0a3a('0x57'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x58');break;case _0x0a3a('0x59'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x5a');break;case _0x0a3a('0x5b'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x5c');break;case _0x0a3a('0x5d'):_0x310e4a['childModel']=_0x0a3a('0x5e');break;case _0x0a3a('0x5f'):_0x310e4a[_0x0a3a('0xf')]='DeskAccount';break;case _0x0a3a('0x60'):_0x310e4a['childModel']=_0x0a3a('0x61');break;case'vtigeraccounts':_0x310e4a[_0x0a3a('0xf')]='User';break;case _0x0a3a('0x62'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x63');break;case _0x0a3a('0x64'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x65');break;case _0x0a3a('0x66'):_0x310e4a['childModel']=_0x0a3a('0x67');break;case _0x0a3a('0x68'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x69');break;case _0x0a3a('0x6a'):_0x310e4a['childModel']=_0x0a3a('0x6b');break;case _0x0a3a('0x6c'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x6d');break;case _0x0a3a('0x6e'):_0x310e4a[_0x0a3a('0xf')]='Sound';break;case _0x0a3a('0x6f'):_0x310e4a[_0x0a3a('0xf')]='Tag';break;case'templates':_0x310e4a[_0x0a3a('0xf')]='Template';break;case _0x0a3a('0x70'):_0x310e4a['childModel']=_0x0a3a('0x71');break;case'trunks':_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x72');break;case _0x0a3a('0x73'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x74');break;case _0x0a3a('0x75'):_0x310e4a[_0x0a3a('0xf')]=_0x0a3a('0x76');break;case _0x0a3a('0x77'):_0x310e4a['childModel']=_0x0a3a('0xc');_0x310e4a[_0x0a3a('0x13')]=[{'name':_0x0a3a('0x78'),'field':'id','foreignKey':_0x0a3a('0x79')}];break;case _0x0a3a('0x7a'):_0x310e4a[_0x0a3a('0xf')]='AnalyticMetric';break;}return _0x310e4a;}function _0x5bfb98(_0x23997a,_0x561dc7){var _0x1f7164=_0x23997a[_0x0a3a('0x7b')](0x0)[_0x0a3a('0x7c')]()+_0x23997a['slice'](0x1);var _0x169e22={'type':_0xdeabed[_0x0a3a('0x7d')][_0x0a3a('0x7e')][_0x0a3a('0x7f')],'raw':!![]};return new Promise(function(_0x54df99,_0x73fbaa){var _0x187d9d=squel[_0x0a3a('0x80')]()[_0x0a3a('0x3')](_0x0a3a('0x81')+_0x1f7164+_0x0a3a('0x82'),'id')[_0x0a3a('0x3')](_0x0a3a('0x83'))[_0x0a3a('0x84')](_0x0a3a('0x85')+_0x23997a+_0x0a3a('0x86'),'ui')[_0x0a3a('0x87')](_0x0a3a('0x88'),_0x561dc7['id']);return _0xdeabed[_0x0a3a('0x89')][_0x0a3a('0x8a')](_0x187d9d['toString'](),_0x169e22)[_0x0a3a('0x8')](function(_0xe9b4da){_0x561dc7[_0x1f7164+_0x0a3a('0x8b')]=_0xe9b4da;_0x54df99(_0xe9b4da);})[_0x0a3a('0x9')](function(_0x44a8b0){_0x73fbaa(_0x44a8b0);});});}return _0x20f4ed['define'](_0x0a3a('0x8c'),attributes,{'tableName':_0x0a3a('0x8d'),'paranoid':![],'indexes':[],'timestamps':!![],'classMethods':{'getResources':function(_0x15a45e){var _0x4f4ec5=require(_0x0a3a('0x8e'));var _0x353ee3={'raw':_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0x8f')],'where':{}};var _0x10f1ce={};var _0x1e0b4a={'count':0x0,'rows':[]};var _0x1cb733=_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0x90')];var _0x84e9a8=_0x15a45e[_0x0a3a('0x8a')]['mergeResources']||![];var _0x44aef1=_0x26d943(_0x1cb733,_0x84e9a8);if(!_0x44aef1[_0x0a3a('0xf')])throw new Error('Invalid\x20section\x20\x27'+_0x1cb733+'\x27');var _0x19ece4=[{'name':_0x1cb733}];if(!_[_0x0a3a('0x91')](_0x44aef1[_0x0a3a('0x13')]))_0x19ece4=_0x44aef1['parentSections'];var _0x56dd3a=[];for(var _0x5806bf=0x0;_0x5806bf<_0x19ece4[_0x0a3a('0x92')];_0x5806bf++){_0x56dd3a[_0x0a3a('0x93')](_0xdeabed[_0x0a3a('0x94')][_0x0a3a('0x95')]({'where':{'userProfileId':_0x15a45e['params']['id'],'name':_0x19ece4[_0x5806bf]['name']},'raw':!![]}));}return Promise[_0x0a3a('0x96')](_0x56dd3a)['then'](function(_0x32ffd9){var _0x325195=_[_0x0a3a('0x5')](_0x32ffd9,function(_0x4740f3){return _0x4740f3?_0x4740f3:undefined;});var _0x5d065c=_['filter'](_0x19ece4,['ignore',!![]]);var _0x4d138f=_['isEmpty'](_0x325195)&&_[_0x0a3a('0x91')](_0x5d065c)?null:_['union'](_0x5d065c,_0x325195);if(!_0x4d138f)return null;var _0x3086d8=[];for(var _0x130377=0x0;_0x130377<_0x4d138f[_0x0a3a('0x92')];_0x130377++){var _0x546a70=_[_0x0a3a('0x95')](_0x19ece4,function(_0x3df681){return _0x4d138f[_0x130377]?_0x3df681[_0x0a3a('0x15')]===_0x4d138f[_0x130377]['name']:null;});if(_0x546a70){if(_0x4d138f[_0x130377]['ignore']){_0x3086d8[_0x0a3a('0x93')](_0x4f27cb(_0x44aef1[_0x0a3a('0xf')],_0x4d138f[_0x130377]));}else{if(!_0x4d138f[_0x130377][_0x0a3a('0x97')]){_0x3086d8[_0x0a3a('0x93')](_0x3ee697(_0x546a70,_0x4d138f[_0x130377],_0x44aef1['childModel']));}else{if(_0x546a70[_0x0a3a('0x7')]){_0x3086d8[_0x0a3a('0x93')](_0x426eaa(_0x546a70,_0x4d138f[_0x130377]));}}}}}return Promise[_0x0a3a('0x96')](_0x3086d8);})[_0x0a3a('0x8')](function(_0x1f7c3f){var _0x56ead6=_0x1f7c3f;var _0x56017d=null;if(_0x56ead6){_0x56017d=_0x56ead6[_0x0a3a('0x92')]===0x1?_0x56ead6[0x0]:null;}if(!_0x56017d&&!_0x56ead6)return _0x1e0b4a;var _0x35305d=_0xdeabed[_0x44aef1[_0x0a3a('0xf')]][_0x0a3a('0x98')];_0x10f1ce[_0x0a3a('0x7')]=_['keys'](_0x35305d);_0x10f1ce[_0x0a3a('0x8a')]=_[_0x0a3a('0x99')](_0x15a45e[_0x0a3a('0x8a')]);_0x10f1ce[_0x0a3a('0x9a')]=_['intersection'](_0x10f1ce[_0x0a3a('0x7')],_0x10f1ce[_0x0a3a('0x8a')]);_0x353ee3[_0x0a3a('0x9b')]=_[_0x0a3a('0x9c')](_0x10f1ce[_0x0a3a('0x7')],_0x4f4ec5[_0x0a3a('0x9d')](_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0x9d')]));_0x353ee3[_0x0a3a('0x9b')]=_0x353ee3[_0x0a3a('0x9b')][_0x0a3a('0x92')]?_0x353ee3[_0x0a3a('0x9b')]:_0x10f1ce['model'];if(!_0x15a45e['query'][_0x0a3a('0x9e')](_0x0a3a('0x9f'))){_0x353ee3[_0x0a3a('0xa0')]=_0x4f4ec5['limit'](_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0xa0')]);_0x353ee3['offset']=_0x4f4ec5[_0x0a3a('0xa1')](_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0xa1')]);}_0x353ee3[_0x0a3a('0xa2')]=_0x4f4ec5[_0x0a3a('0xa3')](_0x15a45e[_0x0a3a('0x8a')]['sort']);_0x353ee3[_0x0a3a('0x87')]=_0x4f4ec5[_0x0a3a('0x9a')](_['pick'](_0x15a45e['query'],_0x10f1ce['filters']));if(_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0x5')]){_0x353ee3[_0x0a3a('0x87')]=_[_0x0a3a('0xa4')](_0x353ee3[_0x0a3a('0x87')],{'$or':_[_0x0a3a('0xb')](_0x35305d,function(_0x53d2a6){if(_0x53d2a6[_0x0a3a('0xd')][_0x0a3a('0xa5')]!==_0x0a3a('0xa6')){var _0x1c1a70={};_0x1c1a70[_0x53d2a6['field']]={'$like':'%'+_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0x5')]+'%'};return _0x1c1a70;}})});}var _0x10bfba=[];var _0x3af674=null;var _0x4b173a={};if(_0x56017d){_0x3af674=_['find'](_0x19ece4,[_0x0a3a('0x15'),_0x56017d[_0x0a3a('0x15')]]);if(_0x3af674[_0x0a3a('0x3')]){_0x4b173a={};if(_0x44aef1[_0x0a3a('0xf')]==='AnalyticExtractedReport'){_0x4b173a[_0x3af674[_0x0a3a('0xa7')]]=_[_0x0a3a('0xb')](_0x56017d['associatedResources'],'id');}else{_0x4b173a[_0x3af674[_0x0a3a('0xa7')]]=_0x56017d[_0x0a3a('0x4')];}_0x10bfba[_0x0a3a('0x93')](_0x4b173a);}else{_0x353ee3[_0x0a3a('0x87')]['id']=_0x56017d[_0x0a3a('0x4')];}}else{for(var _0x128872=0x0;_0x128872<_0x56ead6[_0x0a3a('0x92')];_0x128872++){_0x3af674=_[_0x0a3a('0x95')](_0x19ece4,[_0x0a3a('0x15'),_0x56ead6[_0x128872]['name']]);if(_0x3af674[_0x0a3a('0x3')]){_0x4b173a={};_0x4b173a[_0x3af674[_0x0a3a('0xa7')]]=_0x56ead6[_0x128872]['associatedResources'];_0x10bfba['push'](_0x4b173a);}else{if(!_0x353ee3[_0x0a3a('0x87')]['id'])_0x353ee3['where']['id']=[];_0x56ead6[_0x128872][_0x0a3a('0x4')][_0x0a3a('0xa8')](function(_0x3780cf){_0x353ee3[_0x0a3a('0x87')]['id'][_0x0a3a('0x93')](_0x3780cf);});}}}if(!_[_0x0a3a('0x91')](_0x10bfba)){_0x353ee3[_0x0a3a('0x87')]=_[_0x0a3a('0xa4')](_0x353ee3['where'],{'$and':{'$or':_0x10bfba}});}_0x353ee3=_[_0x0a3a('0xa4')]({},_0x353ee3,_0x15a45e['options']);if(_0x56017d&&!_0x56017d[_0x0a3a('0x97')]&&_0x44aef1[_0x0a3a('0xf')]===_0x0a3a('0xc')){if(_0x15a45e[_0x0a3a('0x8a')]['includeAll']){_0x353ee3['include']=[{'all':!![]}];}return _0xdeabed[_0x44aef1[_0x0a3a('0xf')]]['findAll'](_0x353ee3)[_0x0a3a('0x8')](function(_0x3279c9){var _0x3bb1af=[];_0x3279c9[_0x0a3a('0xa8')](function(_0x31ce91){var _0x17384b;switch(_0x31ce91[_0x0a3a('0xa9')]){case'default':_0x17384b=_[_0x0a3a('0x95')](_0x56017d['associatedResources'],function(_0x453ace){return _0x453ace['id']===_0x31ce91['reportId']&&_0x453ace[_0x0a3a('0xd')]===_0x0a3a('0xaa');});break;case _0x0a3a('0xab'):_0x17384b=_[_0x0a3a('0x95')](_0x56017d['associatedResources'],function(_0x15237c){return _0x15237c['id']===_0x31ce91[_0x0a3a('0x79')]&&_0x15237c[_0x0a3a('0xd')]===_0x0a3a('0xac');});break;}if(_0x17384b)_0x3bb1af['push'](_0x31ce91);});_0x1e0b4a[_0x0a3a('0xad')]=_0x3bb1af['length'];_0x1e0b4a['rows']=_0x3bb1af;return _0x1e0b4a;});}else{if(!_[_0x0a3a('0x91')](_0x15a45e[_0x0a3a('0x8a')]['ids'])){_0x353ee3['where']['id']=_0x353ee3['where']['id']?_[_0x0a3a('0x9c')](_0x353ee3['where']['id'],_0x15a45e['query'][_0x0a3a('0xae')]):_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0xae')];if(_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0xaf')]){_0x353ee3['order']=_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0xaf')];}}if(_0x15a45e['query'][_0x0a3a('0xb0')]){_0x353ee3[_0x0a3a('0x87')]=_['merge'](_0x353ee3[_0x0a3a('0x87')],{'$and':_0x15a45e['query']['extraQueryConditions']});}return _0xdeabed[_0x44aef1[_0x0a3a('0xf')]][_0x0a3a('0xad')]({'where':_0x353ee3['where']})[_0x0a3a('0x8')](function(_0x38411a){_0x1e0b4a[_0x0a3a('0xad')]=_0x38411a;if(_0x15a45e['query'][_0x0a3a('0xb1')]){if(_0x44aef1['childModel']===_0x0a3a('0xb2')){_0x353ee3[_0x0a3a('0xb3')]=[{'model':_0xdeabed[_0x0a3a('0xb4')],'as':_0x0a3a('0xb5'),'attributes':['id','name',_0x0a3a('0xb6')],'required':_0x15a45e[_0x0a3a('0x8a')][_0x0a3a('0xb7')]?!![]:![]},{'model':_0xdeabed['Tag'],'as':_0x0a3a('0xb8'),'attributes':['id',_0x0a3a('0x15'),'color'],'through':_0x15a45e['query']['tag']?{'attributes':[],'where':{'TagId':_0x15a45e['query'][_0x0a3a('0xb7')]||undefined}}:{},'required':_0x15a45e[_0x0a3a('0x8a')]['tag']?!![]:![]}];}else{_0x353ee3['include']=[{'all':!![]}];}}return _0xdeabed[_0x44aef1[_0x0a3a('0xf')]]['findAll'](_0x353ee3);})[_0x0a3a('0x8')](function(_0x3bf3ab){_0x1e0b4a[_0x0a3a('0xb9')]=_0x3bf3ab;if(_0x1cb733===_0x0a3a('0x56')&&_0x15a45e['query'][_0x0a3a('0xba')]===_0x0a3a('0xbb')){var _0x473d78=[];for(var _0x150d2c=0x0;_0x150d2c<_0x1e0b4a[_0x0a3a('0xb9')]['length'];_0x150d2c++){_0x473d78[_0x0a3a('0x93')](_0x5bfb98('chat',_0x1e0b4a['rows'][_0x150d2c]['dataValues']));_0x473d78['push'](_0x5bfb98(_0x0a3a('0xbc'),_0x1e0b4a[_0x0a3a('0xb9')][_0x150d2c][_0x0a3a('0xbd')]));_0x473d78[_0x0a3a('0x93')](_0x5bfb98(_0x0a3a('0xbe'),_0x1e0b4a['rows'][_0x150d2c][_0x0a3a('0xbd')]));_0x473d78[_0x0a3a('0x93')](_0x5bfb98('mail',_0x1e0b4a[_0x0a3a('0xb9')][_0x150d2c]['dataValues']));_0x473d78[_0x0a3a('0x93')](_0x5bfb98('openchannel',_0x1e0b4a[_0x0a3a('0xb9')][_0x150d2c]['dataValues']));_0x473d78['push'](_0x5bfb98(_0x0a3a('0xbf'),_0x1e0b4a[_0x0a3a('0xb9')][_0x150d2c][_0x0a3a('0xbd')]));}return Promise['all'](_0x473d78)[_0x0a3a('0x8')](function(){return _0x1e0b4a;});}return _0x1e0b4a;});}});}}});};