689213c703681d7ea79d432e91cb960725ec49e7
[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 _0xdd4f=['Schedule','sounds','tags','Tag','templates','Template','triggers','trunks','variables','Plugin','extractedreports','Reports','reportId','metrics','toUpperCase','slice','Sequelize','QueryTypes','ui.','InteractionId','ui.createdAt','user_has_','_interactions','where','ui.UserId\x20=\x20?','sequelize','query','toString','define','UserProfile','user_profiles','raw','section','mergeResources','length','push','UserProfileSection','find','params','all','ignore','isEmpty','union','rawAttributes','keys','intersection','attributes','fields','nolimit','limit','offset','order','sort','filters','pick','merge','key','VIRTUAL','foreignKey','forEach','options','includeAll','include','reportType','default','DefaultReports','CustomReports','count','ids','color','tag','ThroughTags','rows','openTabs','chat','dataValues','fax','mail','openchannel','whatsapp','lodash','exports','models','filter','findAll','then','map','field','model','associatedResources','name','catch','resolve','UserProfileResource','AnalyticExtractedReport','resourceId','toLowerCase','squareprojects','SquareProject','odbc','childModel','SquareOdbc','squarerecordings','SquareRecording','parentSections','SquareProjects','projectName','projects','JscriptyProject','CmContact','Lists','ListId','CmList','companies','CmCompany','CmCustomField','chatqueues','ChatQueue','ChatWebsite','FaxQueue','faxaccounts','inboundroutes','internalroutes','outboundroutes','VoiceExtension','contexts','VoiceContext','voicemails','VoiceMail','voicerecordings','VoiceRecording','Agents','membername','User','role','agent','Telephones','VoiceQueues','queue','VoiceQueue','type','inbound','outbound','musiconholds','VoiceMusicOnHold','chanspies','VoiceChanSpy','voiceprefixes','VoicePrefix','ivrcampaigns','Campaign','MailQueue','mailaccounts','mailsubstatuses','MailSubstatus','openchannelqueues','openchannelaccounts','OpenchannelAccount','smsqueues','SmsQueue','smsaccounts','SmsAccount','WhatsappQueue','whatsappaccounts','teams','voicequeues','queuecampaigns','users','agents','telephones','admin','user','zendeskaccounts','ZendeskAccount','salesforceaccounts','SalesforceAccount','freshdeskaccounts','FreshdeskAccount','SugarcrmAccount','deskaccounts','DeskAccount','ZohoAccount','CannedAnswer','dispositions','Disposition','customdashboards','intervals','Interval','pauses','Pause','scheduler'];(function(_0xad57ee,_0x2823a6){var _0x3eaea9=function(_0x185650){while(--_0x185650){_0xad57ee['push'](_0xad57ee['shift']());}};_0x3eaea9(++_0x2823a6);}(_0xdd4f,0x1ce));var _0xfdd4=function(_0x19ce91,_0x5154f3){_0x19ce91=_0x19ce91-0x0;var _0x4ab182=_0xdd4f[_0x19ce91];return _0x4ab182;};'use strict';var _=require(_0xfdd4('0x0'));var attributes=require('./userProfile.attributes');var qs=require('../../components/parsers/qs');var squel=require('squel');module[_0xfdd4('0x1')]=function(_0x19cda7){var _0x5918d1=_0x19cda7[_0xfdd4('0x2')];function _0x3175f6(_0x6b2b0d,_0x554e44){return new Promise(function(_0x398015,_0x43cbcf){if(!_0x554e44)return _0x398015(null);var _0x30e080=_0x554e44[_0xfdd4('0x3')]?{[_0x554e44[_0xfdd4('0x3')]['field']]:_0x554e44[_0xfdd4('0x3')]['value']}:undefined;return _0x5918d1[_0x6b2b0d][_0xfdd4('0x4')]({'where':_0x30e080,'raw':!![]})[_0xfdd4('0x5')](function(_0x1e823e){_0x554e44['associatedResources']=_[_0xfdd4('0x6')](_0x1e823e,'id');_0x398015(_0x554e44);})['catch'](function(_0x27a9f3){_0x43cbcf(_0x27a9f3);});});}function _0x3ce77a(_0x210c7d,_0x382350){return new Promise(function(_0x35e22d,_0xc9fcf1){var _0x1e21ca=_0x210c7d[_0xfdd4('0x3')]?{[_0x210c7d[_0xfdd4('0x3')][_0xfdd4('0x7')]]:_0x210c7d[_0xfdd4('0x3')]['value']}:undefined;return _0x5918d1[_0x210c7d[_0xfdd4('0x8')]][_0xfdd4('0x4')]({'where':_0x1e21ca,'raw':!![]})[_0xfdd4('0x5')](function(_0x57b21f){_0x382350[_0xfdd4('0x9')]=_['map'](_0x57b21f,function(_0x467824){return _0x467824[_0xfdd4('0xa')];});_0x35e22d(_0x382350);})[_0xfdd4('0xb')](function(_0x431255){_0xc9fcf1(_0x431255);});});}function _0x37b05f(_0x52cf2c,_0x47ed1d,_0x559c77){if(!_0x47ed1d)return Promise[_0xfdd4('0xc')](null);return new Promise(function(_0x216c7e,_0x2eb174){return _0x5918d1[_0xfdd4('0xd')][_0xfdd4('0x4')]({'where':{'sectionId':_0x47ed1d['id']},'raw':!![]})[_0xfdd4('0x5')](function(_0x1746e1){if(_0x52cf2c[_0xfdd4('0x7')]&&_0x52cf2c[_0xfdd4('0x7')]!=='id'){_0x47ed1d['associatedResources']=_[_0xfdd4('0x6')](_0x1746e1,function(_0x3e8eac){return _0x3e8eac[_0x52cf2c[_0xfdd4('0x7')]];});}else{if(_0x559c77===_0xfdd4('0xe')){_0x47ed1d[_0xfdd4('0x9')]=_[_0xfdd4('0x6')](_0x1746e1,function(_0x452afb){return{'id':_0x452afb[_0xfdd4('0xf')],'type':_0x452afb['type']};});}else{_0x47ed1d[_0xfdd4('0x9')]=_[_0xfdd4('0x6')](_0x1746e1,function(_0x2a24e8){return _0x2a24e8[_0xfdd4('0xf')];});}}_0x216c7e(_0x47ed1d);})[_0xfdd4('0xb')](function(_0x144acd){_0x2eb174(_0x144acd);});});}function _0x451767(_0x277ec1,_0x538b00){var _0x1e14da={'parentSections':[]};switch(_0x277ec1[_0xfdd4('0x10')]()){case _0xfdd4('0x11'):_0x1e14da['childModel']=_0xfdd4('0x12');break;case _0xfdd4('0x13'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x15');break;case _0xfdd4('0x16'):_0x1e14da['childModel']=_0xfdd4('0x17');_0x1e14da[_0xfdd4('0x18')]=[{'name':_0xfdd4('0x19'),'field':_0xfdd4('0xa'),'foreignKey':_0xfdd4('0x1a')}];break;case _0xfdd4('0x1b'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x1c');break;case'contacts':_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x1d');_0x1e14da[_0xfdd4('0x18')]=[{'name':_0xfdd4('0x1e'),'field':'id','foreignKey':_0xfdd4('0x1f')}];break;case'lists':_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x20');break;case _0xfdd4('0x21'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x22');break;case'globalcustomfields':_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x23');break;case _0xfdd4('0x24'):_0x1e14da['childModel']=_0xfdd4('0x25');break;case'chatwebsites':_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x26');break;case'faxqueues':_0x1e14da['childModel']=_0xfdd4('0x27');break;case _0xfdd4('0x28'):_0x1e14da['childModel']='FaxAccount';break;case _0xfdd4('0x29'):case _0xfdd4('0x2a'):case _0xfdd4('0x2b'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x2c');break;case _0xfdd4('0x2d'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x2e');break;case _0xfdd4('0x2f'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x30');break;case _0xfdd4('0x31'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x32');_0x1e14da[_0xfdd4('0x18')]=[{'name':_0xfdd4('0x33'),'field':_0xfdd4('0xa'),'foreignKey':_0xfdd4('0x34'),'model':_0xfdd4('0x35'),'filter':{'field':_0xfdd4('0x36'),'value':[_0xfdd4('0x37')]}},{'name':_0xfdd4('0x38'),'field':_0xfdd4('0xa'),'foreignKey':_0xfdd4('0x34'),'model':_0xfdd4('0x35'),'filter':{'field':_0xfdd4('0x36'),'value':['telephone']}},{'name':_0xfdd4('0x39'),'field':_0xfdd4('0xa'),'foreignKey':_0xfdd4('0x3a'),'model':_0xfdd4('0x3b'),'filter':{'field':_0xfdd4('0x3c'),'value':[_0xfdd4('0x3d')]}},{'name':'QueueCampaigns','field':_0xfdd4('0xa'),'foreignKey':'queue','model':_0xfdd4('0x3b'),'filter':{'field':_0xfdd4('0x3c'),'value':[_0xfdd4('0x3e')]}}];break;case _0xfdd4('0x3f'):_0x1e14da['childModel']=_0xfdd4('0x40');break;case _0xfdd4('0x41'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x42');break;case _0xfdd4('0x43'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x44');break;case _0xfdd4('0x45'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x46');break;case'mailqueues':_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x47');break;case _0xfdd4('0x48'):_0x1e14da[_0xfdd4('0x14')]='MailAccount';break;case _0xfdd4('0x49'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x4a');break;case _0xfdd4('0x4b'):_0x1e14da[_0xfdd4('0x14')]='OpenchannelQueue';break;case _0xfdd4('0x4c'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x4d');break;case _0xfdd4('0x4e'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x4f');break;case _0xfdd4('0x50'):_0x1e14da['childModel']=_0xfdd4('0x51');break;case'whatsappqueues':_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x52');break;case _0xfdd4('0x53'):_0x1e14da[_0xfdd4('0x14')]='WhatsappAccount';break;case _0xfdd4('0x54'):_0x1e14da[_0xfdd4('0x14')]='Team';break;case _0xfdd4('0x55'):case _0xfdd4('0x56'):_0x1e14da['childModel']=_0xfdd4('0x3b');if(_0x538b00){_0x1e14da['parentSections']=[{'name':'VoiceQueues'},{'name':'QueueCampaigns'}];}break;case _0xfdd4('0x57'):case _0xfdd4('0x58'):case _0xfdd4('0x59'):_0x1e14da['childModel']=_0xfdd4('0x35');if(_0x538b00){_0x1e14da[_0xfdd4('0x18')]=[{'name':'Users','filter':{'field':_0xfdd4('0x36'),'value':[_0xfdd4('0x5a'),_0xfdd4('0x5b')]},'ignore':!![]},{'name':_0xfdd4('0x33')},{'name':_0xfdd4('0x38')}];}break;case _0xfdd4('0x5c'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x5d');break;case _0xfdd4('0x5e'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x5f');break;case _0xfdd4('0x60'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x61');break;case'sugarcrmaccounts':_0x1e14da['childModel']=_0xfdd4('0x62');break;case _0xfdd4('0x63'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x64');break;case'zohoaccounts':_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x65');break;case'vtigeraccounts':_0x1e14da['childModel']='User';break;case'cannedanswers':_0x1e14da['childModel']=_0xfdd4('0x66');break;case _0xfdd4('0x67'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x68');break;case _0xfdd4('0x69'):_0x1e14da[_0xfdd4('0x14')]='Dashboard';break;case _0xfdd4('0x6a'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x6b');break;case _0xfdd4('0x6c'):_0x1e14da['childModel']=_0xfdd4('0x6d');break;case _0xfdd4('0x6e'):_0x1e14da['childModel']=_0xfdd4('0x6f');break;case _0xfdd4('0x70'):_0x1e14da['childModel']='Sound';break;case _0xfdd4('0x71'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x72');break;case _0xfdd4('0x73'):_0x1e14da[_0xfdd4('0x14')]=_0xfdd4('0x74');break;case _0xfdd4('0x75'):_0x1e14da[_0xfdd4('0x14')]='Trigger';break;case _0xfdd4('0x76'):_0x1e14da['childModel']='Trunk';break;case _0xfdd4('0x77'):_0x1e14da[_0xfdd4('0x14')]='Variable';break;case'plugins':_0x1e14da['childModel']=_0xfdd4('0x78');break;case _0xfdd4('0x79'):_0x1e14da['childModel']=_0xfdd4('0xe');_0x1e14da[_0xfdd4('0x18')]=[{'name':_0xfdd4('0x7a'),'field':'id','foreignKey':_0xfdd4('0x7b')}];break;case _0xfdd4('0x7c'):_0x1e14da['childModel']='AnalyticMetric';break;}return _0x1e14da;}function _0x483942(_0x5d0136,_0x3e5cb0){var _0x14d07e=_0x5d0136['charAt'](0x0)[_0xfdd4('0x7d')]()+_0x5d0136[_0xfdd4('0x7e')](0x1);var _0x4d4304={'type':_0x5918d1[_0xfdd4('0x7f')][_0xfdd4('0x80')]['SELECT'],'raw':!![]};return new Promise(function(_0x1497ff,_0x2b7081){var _0xd4e5e4=squel['select']()[_0xfdd4('0x7')](_0xfdd4('0x81')+_0x14d07e+_0xfdd4('0x82'),'id')[_0xfdd4('0x7')](_0xfdd4('0x83'))['from'](_0xfdd4('0x84')+_0x5d0136+_0xfdd4('0x85'),'ui')[_0xfdd4('0x86')](_0xfdd4('0x87'),_0x3e5cb0['id']);return _0x5918d1[_0xfdd4('0x88')][_0xfdd4('0x89')](_0xd4e5e4[_0xfdd4('0x8a')](),_0x4d4304)[_0xfdd4('0x5')](function(_0x38b58b){_0x3e5cb0[_0x14d07e+'OpenTabs']=_0x38b58b;_0x1497ff(_0x38b58b);})[_0xfdd4('0xb')](function(_0x2799b2){_0x2b7081(_0x2799b2);});});}return _0x19cda7[_0xfdd4('0x8b')](_0xfdd4('0x8c'),attributes,{'tableName':_0xfdd4('0x8d'),'paranoid':![],'indexes':[],'timestamps':!![],'classMethods':{'getResources':function(_0x593f5c){var _0x46e7eb={'raw':_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0x8e')],'where':{}};var _0x12e917={};var _0x383175={'count':0x0,'rows':[]};var _0x2be970=_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0x8f')];var _0x35c7ab=_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0x90')]||![];var _0x2792c4=_0x451767(_0x2be970,_0x35c7ab);if(!_0x2792c4[_0xfdd4('0x14')])throw new Error('Invalid\x20section\x20\x27'+_0x2be970+'\x27');var _0xb9d86a=[{'name':_0x2be970}];if(!_['isEmpty'](_0x2792c4[_0xfdd4('0x18')]))_0xb9d86a=_0x2792c4[_0xfdd4('0x18')];var _0x393e11=[];for(var _0x36843c=0x0;_0x36843c<_0xb9d86a[_0xfdd4('0x91')];_0x36843c++){_0x393e11[_0xfdd4('0x92')](_0x5918d1[_0xfdd4('0x93')][_0xfdd4('0x94')]({'where':{'userProfileId':_0x593f5c[_0xfdd4('0x95')]['id'],'name':_0xb9d86a[_0x36843c][_0xfdd4('0xa')]},'raw':!![]}));}return Promise[_0xfdd4('0x96')](_0x393e11)[_0xfdd4('0x5')](function(_0x50e984){var _0x4bac59=_['filter'](_0x50e984,function(_0x3feda6){return _0x3feda6?_0x3feda6:undefined;});var _0x2fcfe4=_['filter'](_0xb9d86a,[_0xfdd4('0x97'),!![]]);var _0x3f027b=_[_0xfdd4('0x98')](_0x4bac59)&&_[_0xfdd4('0x98')](_0x2fcfe4)?null:_[_0xfdd4('0x99')](_0x2fcfe4,_0x4bac59);if(!_0x3f027b)return null;var _0x4b14bf=[];for(var _0x150537=0x0;_0x150537<_0x3f027b[_0xfdd4('0x91')];_0x150537++){var _0x3958cd=_['find'](_0xb9d86a,function(_0x366f1c){return _0x3f027b[_0x150537]?_0x366f1c['name']===_0x3f027b[_0x150537][_0xfdd4('0xa')]:null;});if(_0x3958cd){if(_0x3f027b[_0x150537][_0xfdd4('0x97')]){_0x4b14bf[_0xfdd4('0x92')](_0x3175f6(_0x2792c4[_0xfdd4('0x14')],_0x3f027b[_0x150537]));}else{if(!_0x3f027b[_0x150537]['autoAssociation']){_0x4b14bf[_0xfdd4('0x92')](_0x37b05f(_0x3958cd,_0x3f027b[_0x150537],_0x2792c4[_0xfdd4('0x14')]));}else{if(_0x3958cd['model']){_0x4b14bf[_0xfdd4('0x92')](_0x3ce77a(_0x3958cd,_0x3f027b[_0x150537]));}}}}}return Promise[_0xfdd4('0x96')](_0x4b14bf);})[_0xfdd4('0x5')](function(_0x53c8ac){var _0x1a1028=_0x53c8ac;var _0x26c0ac=null;if(_0x1a1028){_0x26c0ac=_0x1a1028[_0xfdd4('0x91')]===0x1?_0x1a1028[0x0]:null;}if(!_0x26c0ac&&!_0x1a1028)return _0x383175;var _0x535b07=_0x5918d1[_0x2792c4[_0xfdd4('0x14')]][_0xfdd4('0x9a')];_0x12e917[_0xfdd4('0x8')]=_[_0xfdd4('0x9b')](_0x535b07);_0x12e917[_0xfdd4('0x89')]=_[_0xfdd4('0x9b')](_0x593f5c[_0xfdd4('0x89')]);_0x12e917['filters']=_[_0xfdd4('0x9c')](_0x12e917[_0xfdd4('0x8')],_0x12e917[_0xfdd4('0x89')]);_0x46e7eb[_0xfdd4('0x9d')]=_[_0xfdd4('0x9c')](_0x12e917[_0xfdd4('0x8')],qs[_0xfdd4('0x9e')](_0x593f5c[_0xfdd4('0x89')]['fields']));_0x46e7eb[_0xfdd4('0x9d')]=_0x46e7eb['attributes']['length']?_0x46e7eb[_0xfdd4('0x9d')]:_0x12e917['model'];if(!_0x593f5c[_0xfdd4('0x89')]['hasOwnProperty'](_0xfdd4('0x9f'))){_0x46e7eb[_0xfdd4('0xa0')]=qs[_0xfdd4('0xa0')](_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xa0')]);_0x46e7eb[_0xfdd4('0xa1')]=qs[_0xfdd4('0xa1')](_0x593f5c['query']['offset']);}_0x46e7eb[_0xfdd4('0xa2')]=qs['sort'](_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xa3')]);_0x46e7eb[_0xfdd4('0x86')]=qs[_0xfdd4('0xa4')](_[_0xfdd4('0xa5')](_0x593f5c[_0xfdd4('0x89')],_0x12e917[_0xfdd4('0xa4')]));if(_0x593f5c['query']['filter']){_0x46e7eb[_0xfdd4('0x86')]=_[_0xfdd4('0xa6')](_0x46e7eb[_0xfdd4('0x86')],{'$or':_[_0xfdd4('0x6')](_0x535b07,function(_0x1deacd){if(_0x1deacd[_0xfdd4('0x3c')][_0xfdd4('0xa7')]!==_0xfdd4('0xa8')){var _0xf78c69={};_0xf78c69[_0x1deacd[_0xfdd4('0x7')]]={'$like':'%'+_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0x3')]+'%'};return _0xf78c69;}})});}var _0x256ce8=[];var _0x48c480=null;var _0x4bb814={};if(_0x26c0ac){_0x48c480=_[_0xfdd4('0x94')](_0xb9d86a,[_0xfdd4('0xa'),_0x26c0ac['name']]);if(_0x48c480['field']){_0x4bb814={};if(_0x2792c4[_0xfdd4('0x14')]===_0xfdd4('0xe')){_0x4bb814[_0x48c480['foreignKey']]=_[_0xfdd4('0x6')](_0x26c0ac[_0xfdd4('0x9')],'id');}else{_0x4bb814[_0x48c480[_0xfdd4('0xa9')]]=_0x26c0ac[_0xfdd4('0x9')];}_0x256ce8[_0xfdd4('0x92')](_0x4bb814);}else{_0x46e7eb[_0xfdd4('0x86')]['id']=_0x26c0ac['associatedResources'];}}else{for(var _0x3924c7=0x0;_0x3924c7<_0x1a1028[_0xfdd4('0x91')];_0x3924c7++){_0x48c480=_[_0xfdd4('0x94')](_0xb9d86a,[_0xfdd4('0xa'),_0x1a1028[_0x3924c7][_0xfdd4('0xa')]]);if(_0x48c480[_0xfdd4('0x7')]){_0x4bb814={};_0x4bb814[_0x48c480[_0xfdd4('0xa9')]]=_0x1a1028[_0x3924c7][_0xfdd4('0x9')];_0x256ce8['push'](_0x4bb814);}else{if(!_0x46e7eb['where']['id'])_0x46e7eb[_0xfdd4('0x86')]['id']=[];_0x1a1028[_0x3924c7]['associatedResources'][_0xfdd4('0xaa')](function(_0x1b4f61){_0x46e7eb[_0xfdd4('0x86')]['id'][_0xfdd4('0x92')](_0x1b4f61);});}}}if(!_[_0xfdd4('0x98')](_0x256ce8)){_0x46e7eb['where']=_['merge'](_0x46e7eb[_0xfdd4('0x86')],{'$and':{'$or':_0x256ce8}});}_0x46e7eb=_['merge']({},_0x46e7eb,_0x593f5c[_0xfdd4('0xab')]);if(_0x26c0ac&&!_0x26c0ac['autoAssociation']&&_0x2792c4[_0xfdd4('0x14')]===_0xfdd4('0xe')){if(_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xac')]){_0x46e7eb[_0xfdd4('0xad')]=[{'all':!![]}];}return _0x5918d1[_0x2792c4[_0xfdd4('0x14')]][_0xfdd4('0x4')](_0x46e7eb)[_0xfdd4('0x5')](function(_0x3d23df){var _0x1ce2d7=[];_0x3d23df[_0xfdd4('0xaa')](function(_0x4a25bb){var _0xf15402;switch(_0x4a25bb[_0xfdd4('0xae')]){case _0xfdd4('0xaf'):_0xf15402=_[_0xfdd4('0x94')](_0x26c0ac[_0xfdd4('0x9')],function(_0x33a5a0){return _0x33a5a0['id']===_0x4a25bb[_0xfdd4('0x7b')]&&_0x33a5a0[_0xfdd4('0x3c')]===_0xfdd4('0xb0');});break;case'custom':_0xf15402=_['find'](_0x26c0ac[_0xfdd4('0x9')],function(_0x244d6d){return _0x244d6d['id']===_0x4a25bb[_0xfdd4('0x7b')]&&_0x244d6d['type']===_0xfdd4('0xb1');});break;}if(_0xf15402)_0x1ce2d7[_0xfdd4('0x92')](_0x4a25bb);});_0x383175[_0xfdd4('0xb2')]=_0x1ce2d7[_0xfdd4('0x91')];_0x383175['rows']=_0x1ce2d7;return _0x383175;});}else{if(!_['isEmpty'](_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xb3')])){_0x46e7eb[_0xfdd4('0x86')]['id']=_0x46e7eb['where']['id']?_[_0xfdd4('0x9c')](_0x46e7eb[_0xfdd4('0x86')]['id'],_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xb3')]):_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xb3')];}return _0x5918d1[_0x2792c4['childModel']]['count']({'where':_0x46e7eb[_0xfdd4('0x86')]})[_0xfdd4('0x5')](function(_0x6a1410){_0x383175[_0xfdd4('0xb2')]=_0x6a1410;if(_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xac')]){if(_0x2792c4[_0xfdd4('0x14')]===_0xfdd4('0x1d')){_0x46e7eb['include']=[{'model':_0x5918d1[_0xfdd4('0x72')],'as':'Tags','attributes':['id',_0xfdd4('0xa'),_0xfdd4('0xb4')],'required':_0x593f5c['query'][_0xfdd4('0xb5')]?!![]:![]},{'model':_0x5918d1[_0xfdd4('0x72')],'as':_0xfdd4('0xb6'),'attributes':['id',_0xfdd4('0xa'),_0xfdd4('0xb4')],'through':_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xb5')]?{'attributes':[],'where':{'TagId':_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xb5')]||undefined}}:{},'required':_0x593f5c['query'][_0xfdd4('0xb5')]?!![]:![]}];}else{_0x46e7eb['include']=[{'all':!![]}];}}return _0x5918d1[_0x2792c4[_0xfdd4('0x14')]]['findAll'](_0x46e7eb);})['then'](function(_0x43d22e){_0x383175[_0xfdd4('0xb7')]=_0x43d22e;if(_0x2be970===_0xfdd4('0x33')&&_0x593f5c[_0xfdd4('0x89')][_0xfdd4('0xb8')]==='true'){var _0x45dccd=[];for(var _0x1fad79=0x0;_0x1fad79<_0x383175[_0xfdd4('0xb7')][_0xfdd4('0x91')];_0x1fad79++){_0x45dccd[_0xfdd4('0x92')](_0x483942(_0xfdd4('0xb9'),_0x383175['rows'][_0x1fad79][_0xfdd4('0xba')]));_0x45dccd[_0xfdd4('0x92')](_0x483942('sms',_0x383175['rows'][_0x1fad79][_0xfdd4('0xba')]));_0x45dccd[_0xfdd4('0x92')](_0x483942(_0xfdd4('0xbb'),_0x383175['rows'][_0x1fad79]['dataValues']));_0x45dccd[_0xfdd4('0x92')](_0x483942(_0xfdd4('0xbc'),_0x383175[_0xfdd4('0xb7')][_0x1fad79]['dataValues']));_0x45dccd['push'](_0x483942(_0xfdd4('0xbd'),_0x383175[_0xfdd4('0xb7')][_0x1fad79][_0xfdd4('0xba')]));_0x45dccd['push'](_0x483942(_0xfdd4('0xbe'),_0x383175['rows'][_0x1fad79][_0xfdd4('0xba')]));}return Promise[_0xfdd4('0x96')](_0x45dccd)[_0xfdd4('0x5')](function(){return _0x383175;});}return _0x383175;});}});}}});};