10b38377d35201436806a566e5eca88de76a58e3
[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 _0xc1fd=['customSorting','extraQueryConditions','CmContact','Tag','Tags','ThroughTags','color','tag','openTabs','true','dataValues','fax','openchannel','whatsapp','all','lodash','../../components/parsers/qs','squel','exports','models','filter','findAll','then','associatedResources','catch','field','value','map','name','UserProfileResource','resourceId','type','toLowerCase','squareprojects','childModel','SquareProject','SquareOdbc','squarerecordings','SquareRecording','SquareProjects','projects','parentSections','Lists','ListId','lists','CmList','companies','CmCompany','globalcustomfields','CmCustomField','chatqueues','chatwebsites','ChatWebsite','FaxQueue','faxaccounts','FaxAccount','inboundroutes','internalroutes','outboundroutes','VoiceExtension','VoiceContext','voicemails','voicerecordings','VoiceRecording','membername','role','agent','Telephones','User','telephone','VoiceQueues','VoiceQueue','QueueCampaigns','queue','musiconholds','VoiceMusicOnHold','chanspies','VoiceChanSpy','voiceprefixes','ivrcampaigns','mailqueues','MailQueue','MailAccount','mailsubstatuses','openchannelqueues','smsqueues','SmsQueue','smsaccounts','SmsAccount','whatsappqueues','whatsappaccounts','WhatsappAccount','Team','voicequeues','queuecampaigns','admin','Agents','zendeskaccounts','ZendeskAccount','salesforceaccounts','freshdeskaccounts','FreshdeskAccount','sugarcrmaccounts','SugarcrmAccount','deskaccounts','DeskAccount','zohoaccounts','ZohoAccount','vtigeraccounts','cannedanswers','CannedAnswer','dispositions','Disposition','customdashboards','Dashboard','intervals','pauses','Pause','scheduler','Schedule','Sound','tags','templates','triggers','trunks','Trunk','variables','Variable','plugins','Plugin','extractedreports','AnalyticExtractedReport','Reports','reportId','AnalyticMetric','toUpperCase','slice','Sequelize','QueryTypes','SELECT','select','ui.','InteractionId','from','user_has_','_interactions','where','ui.UserId\x20=\x20?','sequelize','query','toString','OpenTabs','define','user_profiles','raw','section','Invalid\x20section\x20\x27','isEmpty','length','push','UserProfileSection','find','params','ignore','union','autoAssociation','rawAttributes','keys','filters','model','attributes','intersection','fields','hasOwnProperty','nolimit','limit','offset','order','sort','pick','merge','key','VIRTUAL','foreignKey','forEach','options','includeAll','include','reportType','default','DefaultReports','custom','CustomReports','count','rows','ids'];(function(_0x34e5c3,_0x2e2b9b){var _0x175897=function(_0x18c00b){while(--_0x18c00b){_0x34e5c3['push'](_0x34e5c3['shift']());}};_0x175897(++_0x2e2b9b);}(_0xc1fd,0xd3));var _0xdc1f=function(_0x5c56ca,_0x10f0a9){_0x5c56ca=_0x5c56ca-0x0;var _0x3bdfcd=_0xc1fd[_0x5c56ca];return _0x3bdfcd;};'use strict';var _=require(_0xdc1f('0x0'));var attributes=require('./userProfile.attributes');var qs=require(_0xdc1f('0x1'));var squel=require(_0xdc1f('0x2'));module[_0xdc1f('0x3')]=function(_0x3f469f){var _0x422a39=_0x3f469f[_0xdc1f('0x4')];function _0x76e1b6(_0x231194,_0x16d46f){return new Promise(function(_0x526024,_0x146559){if(!_0x16d46f)return _0x526024(null);var _0x3d51e1=_0x16d46f[_0xdc1f('0x5')]?{[_0x16d46f[_0xdc1f('0x5')]['field']]:_0x16d46f[_0xdc1f('0x5')]['value']}:undefined;return _0x422a39[_0x231194][_0xdc1f('0x6')]({'where':_0x3d51e1,'raw':!![]})[_0xdc1f('0x7')](function(_0x1d44bd){_0x16d46f[_0xdc1f('0x8')]=_['map'](_0x1d44bd,'id');_0x526024(_0x16d46f);})[_0xdc1f('0x9')](function(_0x5cac53){_0x146559(_0x5cac53);});});}function _0x440759(_0x176d32,_0x3b261e){return new Promise(function(_0x562fe5,_0x4f4884){var _0x1fa827=_0x176d32[_0xdc1f('0x5')]?{[_0x176d32['filter'][_0xdc1f('0xa')]]:_0x176d32[_0xdc1f('0x5')][_0xdc1f('0xb')]}:undefined;return _0x422a39[_0x176d32['model']][_0xdc1f('0x6')]({'where':_0x1fa827,'raw':!![]})[_0xdc1f('0x7')](function(_0x464993){_0x3b261e[_0xdc1f('0x8')]=_[_0xdc1f('0xc')](_0x464993,function(_0x420609){return _0x420609[_0xdc1f('0xd')];});_0x562fe5(_0x3b261e);})[_0xdc1f('0x9')](function(_0xbabb57){_0x4f4884(_0xbabb57);});});}function _0x1cea5f(_0x49321b,_0x1d8b4e,_0x5e8453){if(!_0x1d8b4e)return Promise['resolve'](null);return new Promise(function(_0x9ce4bd,_0x502080){return _0x422a39[_0xdc1f('0xe')][_0xdc1f('0x6')]({'where':{'sectionId':_0x1d8b4e['id']},'raw':!![]})[_0xdc1f('0x7')](function(_0x28760c){if(_0x49321b['field']&&_0x49321b[_0xdc1f('0xa')]!=='id'){_0x1d8b4e['associatedResources']=_[_0xdc1f('0xc')](_0x28760c,function(_0x1e66a0){return _0x1e66a0[_0x49321b[_0xdc1f('0xa')]];});}else{if(_0x5e8453==='AnalyticExtractedReport'){_0x1d8b4e['associatedResources']=_[_0xdc1f('0xc')](_0x28760c,function(_0x530d6d){return{'id':_0x530d6d[_0xdc1f('0xf')],'type':_0x530d6d[_0xdc1f('0x10')]};});}else{_0x1d8b4e[_0xdc1f('0x8')]=_[_0xdc1f('0xc')](_0x28760c,function(_0x3f7ccb){return _0x3f7ccb[_0xdc1f('0xf')];});}}_0x9ce4bd(_0x1d8b4e);})[_0xdc1f('0x9')](function(_0xefaab){_0x502080(_0xefaab);});});}function _0x720800(_0xaf7ce3,_0x430c6f){var _0x456d69={'parentSections':[]};switch(_0xaf7ce3[_0xdc1f('0x11')]()){case _0xdc1f('0x12'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x14');break;case'odbc':_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x15');break;case _0xdc1f('0x16'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x17');_0x456d69['parentSections']=[{'name':_0xdc1f('0x18'),'field':_0xdc1f('0xd'),'foreignKey':'projectName'}];break;case _0xdc1f('0x19'):_0x456d69[_0xdc1f('0x13')]='JscriptyProject';break;case'contacts':_0x456d69[_0xdc1f('0x13')]='CmContact';_0x456d69[_0xdc1f('0x1a')]=[{'name':_0xdc1f('0x1b'),'field':'id','foreignKey':_0xdc1f('0x1c')}];break;case _0xdc1f('0x1d'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x1e');break;case _0xdc1f('0x1f'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x20');break;case _0xdc1f('0x21'):_0x456d69['childModel']=_0xdc1f('0x22');break;case _0xdc1f('0x23'):_0x456d69['childModel']='ChatQueue';break;case _0xdc1f('0x24'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x25');break;case'faxqueues':_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x26');break;case _0xdc1f('0x27'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x28');break;case _0xdc1f('0x29'):case _0xdc1f('0x2a'):case _0xdc1f('0x2b'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x2c');break;case'contexts':_0x456d69['childModel']=_0xdc1f('0x2d');break;case _0xdc1f('0x2e'):_0x456d69[_0xdc1f('0x13')]='VoiceMail';break;case _0xdc1f('0x2f'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x30');_0x456d69[_0xdc1f('0x1a')]=[{'name':'Agents','field':_0xdc1f('0xd'),'foreignKey':_0xdc1f('0x31'),'model':'User','filter':{'field':_0xdc1f('0x32'),'value':[_0xdc1f('0x33')]}},{'name':_0xdc1f('0x34'),'field':_0xdc1f('0xd'),'foreignKey':'membername','model':_0xdc1f('0x35'),'filter':{'field':'role','value':[_0xdc1f('0x36')]}},{'name':_0xdc1f('0x37'),'field':'name','foreignKey':'queue','model':_0xdc1f('0x38'),'filter':{'field':_0xdc1f('0x10'),'value':['inbound']}},{'name':_0xdc1f('0x39'),'field':_0xdc1f('0xd'),'foreignKey':_0xdc1f('0x3a'),'model':_0xdc1f('0x38'),'filter':{'field':_0xdc1f('0x10'),'value':['outbound']}}];break;case _0xdc1f('0x3b'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x3c');break;case _0xdc1f('0x3d'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x3e');break;case _0xdc1f('0x3f'):_0x456d69[_0xdc1f('0x13')]='VoicePrefix';break;case _0xdc1f('0x40'):_0x456d69[_0xdc1f('0x13')]='Campaign';break;case _0xdc1f('0x41'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x42');break;case'mailaccounts':_0x456d69['childModel']=_0xdc1f('0x43');break;case _0xdc1f('0x44'):_0x456d69['childModel']='MailSubstatus';break;case _0xdc1f('0x45'):_0x456d69[_0xdc1f('0x13')]='OpenchannelQueue';break;case'openchannelaccounts':_0x456d69[_0xdc1f('0x13')]='OpenchannelAccount';break;case _0xdc1f('0x46'):_0x456d69['childModel']=_0xdc1f('0x47');break;case _0xdc1f('0x48'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x49');break;case _0xdc1f('0x4a'):_0x456d69[_0xdc1f('0x13')]='WhatsappQueue';break;case _0xdc1f('0x4b'):_0x456d69['childModel']=_0xdc1f('0x4c');break;case'teams':_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x4d');break;case _0xdc1f('0x4e'):case _0xdc1f('0x4f'):_0x456d69[_0xdc1f('0x13')]='VoiceQueue';if(_0x430c6f){_0x456d69[_0xdc1f('0x1a')]=[{'name':_0xdc1f('0x37')},{'name':_0xdc1f('0x39')}];}break;case'users':case'agents':case'telephones':_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x35');if(_0x430c6f){_0x456d69['parentSections']=[{'name':'Users','filter':{'field':'role','value':[_0xdc1f('0x50'),'user']},'ignore':!![]},{'name':_0xdc1f('0x51')},{'name':_0xdc1f('0x34')}];}break;case _0xdc1f('0x52'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x53');break;case _0xdc1f('0x54'):_0x456d69[_0xdc1f('0x13')]='SalesforceAccount';break;case _0xdc1f('0x55'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x56');break;case _0xdc1f('0x57'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x58');break;case _0xdc1f('0x59'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x5a');break;case _0xdc1f('0x5b'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x5c');break;case _0xdc1f('0x5d'):_0x456d69[_0xdc1f('0x13')]='User';break;case _0xdc1f('0x5e'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x5f');break;case _0xdc1f('0x60'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x61');break;case _0xdc1f('0x62'):_0x456d69['childModel']=_0xdc1f('0x63');break;case _0xdc1f('0x64'):_0x456d69[_0xdc1f('0x13')]='Interval';break;case _0xdc1f('0x65'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x66');break;case _0xdc1f('0x67'):_0x456d69['childModel']=_0xdc1f('0x68');break;case'sounds':_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x69');break;case _0xdc1f('0x6a'):_0x456d69['childModel']='Tag';break;case _0xdc1f('0x6b'):_0x456d69['childModel']='Template';break;case _0xdc1f('0x6c'):_0x456d69[_0xdc1f('0x13')]='Trigger';break;case _0xdc1f('0x6d'):_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x6e');break;case _0xdc1f('0x6f'):_0x456d69['childModel']=_0xdc1f('0x70');break;case _0xdc1f('0x71'):_0x456d69['childModel']=_0xdc1f('0x72');break;case _0xdc1f('0x73'):_0x456d69['childModel']=_0xdc1f('0x74');_0x456d69['parentSections']=[{'name':_0xdc1f('0x75'),'field':'id','foreignKey':_0xdc1f('0x76')}];break;case'metrics':_0x456d69[_0xdc1f('0x13')]=_0xdc1f('0x77');break;}return _0x456d69;}function _0xb38e39(_0xc8e79c,_0x47a293){var _0x5475a9=_0xc8e79c['charAt'](0x0)[_0xdc1f('0x78')]()+_0xc8e79c[_0xdc1f('0x79')](0x1);var _0x277df0={'type':_0x422a39[_0xdc1f('0x7a')][_0xdc1f('0x7b')][_0xdc1f('0x7c')],'raw':!![]};return new Promise(function(_0x41a955,_0x4843fe){var _0x3133e1=squel[_0xdc1f('0x7d')]()[_0xdc1f('0xa')](_0xdc1f('0x7e')+_0x5475a9+_0xdc1f('0x7f'),'id')[_0xdc1f('0xa')]('ui.createdAt')[_0xdc1f('0x80')](_0xdc1f('0x81')+_0xc8e79c+_0xdc1f('0x82'),'ui')[_0xdc1f('0x83')](_0xdc1f('0x84'),_0x47a293['id']);return _0x422a39[_0xdc1f('0x85')][_0xdc1f('0x86')](_0x3133e1[_0xdc1f('0x87')](),_0x277df0)[_0xdc1f('0x7')](function(_0x4bac3a){_0x47a293[_0x5475a9+_0xdc1f('0x88')]=_0x4bac3a;_0x41a955(_0x4bac3a);})[_0xdc1f('0x9')](function(_0x1b34a7){_0x4843fe(_0x1b34a7);});});}return _0x3f469f[_0xdc1f('0x89')]('UserProfile',attributes,{'tableName':_0xdc1f('0x8a'),'paranoid':![],'indexes':[],'timestamps':!![],'classMethods':{'getResources':function(_0x305e70){var _0x55d6ff={'raw':_0x305e70[_0xdc1f('0x86')][_0xdc1f('0x8b')],'where':{}};var _0x37bc18={};var _0xce1f23={'count':0x0,'rows':[]};var _0x545c5d=_0x305e70[_0xdc1f('0x86')][_0xdc1f('0x8c')];var _0xe40f2=_0x305e70[_0xdc1f('0x86')]['mergeResources']||![];var _0x2346bf=_0x720800(_0x545c5d,_0xe40f2);if(!_0x2346bf[_0xdc1f('0x13')])throw new Error(_0xdc1f('0x8d')+_0x545c5d+'\x27');var _0x3b2b19=[{'name':_0x545c5d}];if(!_[_0xdc1f('0x8e')](_0x2346bf[_0xdc1f('0x1a')]))_0x3b2b19=_0x2346bf['parentSections'];var _0x3eace4=[];for(var _0x3a5733=0x0;_0x3a5733<_0x3b2b19[_0xdc1f('0x8f')];_0x3a5733++){_0x3eace4[_0xdc1f('0x90')](_0x422a39[_0xdc1f('0x91')][_0xdc1f('0x92')]({'where':{'userProfileId':_0x305e70[_0xdc1f('0x93')]['id'],'name':_0x3b2b19[_0x3a5733][_0xdc1f('0xd')]},'raw':!![]}));}return Promise['all'](_0x3eace4)[_0xdc1f('0x7')](function(_0x1b94ef){var _0x21c199=_['filter'](_0x1b94ef,function(_0x1ee071){return _0x1ee071?_0x1ee071:undefined;});var _0x544c45=_[_0xdc1f('0x5')](_0x3b2b19,[_0xdc1f('0x94'),!![]]);var _0x48b9c3=_[_0xdc1f('0x8e')](_0x21c199)&&_[_0xdc1f('0x8e')](_0x544c45)?null:_[_0xdc1f('0x95')](_0x544c45,_0x21c199);if(!_0x48b9c3)return null;var _0x31ac26=[];for(var _0x41a9b8=0x0;_0x41a9b8<_0x48b9c3[_0xdc1f('0x8f')];_0x41a9b8++){var _0x3e05a6=_['find'](_0x3b2b19,function(_0x231a2f){return _0x48b9c3[_0x41a9b8]?_0x231a2f[_0xdc1f('0xd')]===_0x48b9c3[_0x41a9b8][_0xdc1f('0xd')]:null;});if(_0x3e05a6){if(_0x48b9c3[_0x41a9b8][_0xdc1f('0x94')]){_0x31ac26[_0xdc1f('0x90')](_0x76e1b6(_0x2346bf[_0xdc1f('0x13')],_0x48b9c3[_0x41a9b8]));}else{if(!_0x48b9c3[_0x41a9b8][_0xdc1f('0x96')]){_0x31ac26[_0xdc1f('0x90')](_0x1cea5f(_0x3e05a6,_0x48b9c3[_0x41a9b8],_0x2346bf[_0xdc1f('0x13')]));}else{if(_0x3e05a6['model']){_0x31ac26['push'](_0x440759(_0x3e05a6,_0x48b9c3[_0x41a9b8]));}}}}}return Promise['all'](_0x31ac26);})[_0xdc1f('0x7')](function(_0x5b9a3c){var _0x5a0172=_0x5b9a3c;var _0x16b2a3=null;if(_0x5a0172){_0x16b2a3=_0x5a0172[_0xdc1f('0x8f')]===0x1?_0x5a0172[0x0]:null;}if(!_0x16b2a3&&!_0x5a0172)return _0xce1f23;var _0x404a3e=_0x422a39[_0x2346bf[_0xdc1f('0x13')]][_0xdc1f('0x97')];_0x37bc18['model']=_[_0xdc1f('0x98')](_0x404a3e);_0x37bc18[_0xdc1f('0x86')]=_[_0xdc1f('0x98')](_0x305e70[_0xdc1f('0x86')]);_0x37bc18[_0xdc1f('0x99')]=_['intersection'](_0x37bc18[_0xdc1f('0x9a')],_0x37bc18['query']);_0x55d6ff[_0xdc1f('0x9b')]=_[_0xdc1f('0x9c')](_0x37bc18[_0xdc1f('0x9a')],qs[_0xdc1f('0x9d')](_0x305e70[_0xdc1f('0x86')][_0xdc1f('0x9d')]));_0x55d6ff[_0xdc1f('0x9b')]=_0x55d6ff['attributes']['length']?_0x55d6ff[_0xdc1f('0x9b')]:_0x37bc18[_0xdc1f('0x9a')];if(!_0x305e70['query'][_0xdc1f('0x9e')](_0xdc1f('0x9f'))){_0x55d6ff[_0xdc1f('0xa0')]=qs[_0xdc1f('0xa0')](_0x305e70[_0xdc1f('0x86')][_0xdc1f('0xa0')]);_0x55d6ff[_0xdc1f('0xa1')]=qs[_0xdc1f('0xa1')](_0x305e70[_0xdc1f('0x86')][_0xdc1f('0xa1')]);}_0x55d6ff[_0xdc1f('0xa2')]=qs[_0xdc1f('0xa3')](_0x305e70['query'][_0xdc1f('0xa3')]);_0x55d6ff[_0xdc1f('0x83')]=qs['filters'](_[_0xdc1f('0xa4')](_0x305e70[_0xdc1f('0x86')],_0x37bc18[_0xdc1f('0x99')]));if(_0x305e70['query'][_0xdc1f('0x5')]){_0x55d6ff[_0xdc1f('0x83')]=_[_0xdc1f('0xa5')](_0x55d6ff[_0xdc1f('0x83')],{'$or':_[_0xdc1f('0xc')](_0x404a3e,function(_0x4e0f20){if(_0x4e0f20[_0xdc1f('0x10')][_0xdc1f('0xa6')]!==_0xdc1f('0xa7')){var _0x591c75={};_0x591c75[_0x4e0f20['field']]={'$like':'%'+_0x305e70[_0xdc1f('0x86')]['filter']+'%'};return _0x591c75;}})});}var _0x460d05=[];var _0x266c77=null;var _0x470b55={};if(_0x16b2a3){_0x266c77=_[_0xdc1f('0x92')](_0x3b2b19,[_0xdc1f('0xd'),_0x16b2a3['name']]);if(_0x266c77[_0xdc1f('0xa')]){_0x470b55={};if(_0x2346bf[_0xdc1f('0x13')]==='AnalyticExtractedReport'){_0x470b55[_0x266c77[_0xdc1f('0xa8')]]=_['map'](_0x16b2a3[_0xdc1f('0x8')],'id');}else{_0x470b55[_0x266c77[_0xdc1f('0xa8')]]=_0x16b2a3[_0xdc1f('0x8')];}_0x460d05['push'](_0x470b55);}else{_0x55d6ff[_0xdc1f('0x83')]['id']=_0x16b2a3['associatedResources'];}}else{for(var _0x2b609e=0x0;_0x2b609e<_0x5a0172[_0xdc1f('0x8f')];_0x2b609e++){_0x266c77=_[_0xdc1f('0x92')](_0x3b2b19,[_0xdc1f('0xd'),_0x5a0172[_0x2b609e][_0xdc1f('0xd')]]);if(_0x266c77[_0xdc1f('0xa')]){_0x470b55={};_0x470b55[_0x266c77[_0xdc1f('0xa8')]]=_0x5a0172[_0x2b609e][_0xdc1f('0x8')];_0x460d05[_0xdc1f('0x90')](_0x470b55);}else{if(!_0x55d6ff['where']['id'])_0x55d6ff[_0xdc1f('0x83')]['id']=[];_0x5a0172[_0x2b609e][_0xdc1f('0x8')][_0xdc1f('0xa9')](function(_0x490129){_0x55d6ff[_0xdc1f('0x83')]['id'][_0xdc1f('0x90')](_0x490129);});}}}if(!_[_0xdc1f('0x8e')](_0x460d05)){_0x55d6ff[_0xdc1f('0x83')]=_[_0xdc1f('0xa5')](_0x55d6ff[_0xdc1f('0x83')],{'$and':{'$or':_0x460d05}});}_0x55d6ff=_[_0xdc1f('0xa5')]({},_0x55d6ff,_0x305e70[_0xdc1f('0xaa')]);if(_0x16b2a3&&!_0x16b2a3[_0xdc1f('0x96')]&&_0x2346bf[_0xdc1f('0x13')]===_0xdc1f('0x74')){if(_0x305e70['query'][_0xdc1f('0xab')]){_0x55d6ff[_0xdc1f('0xac')]=[{'all':!![]}];}return _0x422a39[_0x2346bf[_0xdc1f('0x13')]][_0xdc1f('0x6')](_0x55d6ff)[_0xdc1f('0x7')](function(_0x2990af){var _0x3f216e=[];_0x2990af[_0xdc1f('0xa9')](function(_0x5a1bd8){var _0x2f4fb3;switch(_0x5a1bd8[_0xdc1f('0xad')]){case _0xdc1f('0xae'):_0x2f4fb3=_[_0xdc1f('0x92')](_0x16b2a3[_0xdc1f('0x8')],function(_0x1e8e13){return _0x1e8e13['id']===_0x5a1bd8[_0xdc1f('0x76')]&&_0x1e8e13[_0xdc1f('0x10')]===_0xdc1f('0xaf');});break;case _0xdc1f('0xb0'):_0x2f4fb3=_[_0xdc1f('0x92')](_0x16b2a3[_0xdc1f('0x8')],function(_0x7c3148){return _0x7c3148['id']===_0x5a1bd8[_0xdc1f('0x76')]&&_0x7c3148['type']===_0xdc1f('0xb1');});break;}if(_0x2f4fb3)_0x3f216e[_0xdc1f('0x90')](_0x5a1bd8);});_0xce1f23[_0xdc1f('0xb2')]=_0x3f216e['length'];_0xce1f23[_0xdc1f('0xb3')]=_0x3f216e;return _0xce1f23;});}else{if(!_['isEmpty'](_0x305e70['query']['ids'])){_0x55d6ff['where']['id']=_0x55d6ff[_0xdc1f('0x83')]['id']?_[_0xdc1f('0x9c')](_0x55d6ff[_0xdc1f('0x83')]['id'],_0x305e70[_0xdc1f('0x86')][_0xdc1f('0xb4')]):_0x305e70['query']['ids'];if(_0x305e70[_0xdc1f('0x86')][_0xdc1f('0xb5')]){_0x55d6ff[_0xdc1f('0xa2')]=_0x305e70[_0xdc1f('0x86')][_0xdc1f('0xb5')];}}if(_0x305e70['query'][_0xdc1f('0xb6')]){_0x55d6ff['where']=_[_0xdc1f('0xa5')](_0x55d6ff[_0xdc1f('0x83')],{'$and':_0x305e70[_0xdc1f('0x86')]['extraQueryConditions']});}return _0x422a39[_0x2346bf[_0xdc1f('0x13')]][_0xdc1f('0xb2')]({'where':_0x55d6ff[_0xdc1f('0x83')]})['then'](function(_0x5cd56f){_0xce1f23[_0xdc1f('0xb2')]=_0x5cd56f;if(_0x305e70[_0xdc1f('0x86')][_0xdc1f('0xab')]){if(_0x2346bf[_0xdc1f('0x13')]===_0xdc1f('0xb7')){_0x55d6ff[_0xdc1f('0xac')]=[{'model':_0x422a39[_0xdc1f('0xb8')],'as':_0xdc1f('0xb9'),'attributes':['id',_0xdc1f('0xd'),'color'],'required':_0x305e70[_0xdc1f('0x86')]['tag']?!![]:![]},{'model':_0x422a39['Tag'],'as':_0xdc1f('0xba'),'attributes':['id',_0xdc1f('0xd'),_0xdc1f('0xbb')],'through':_0x305e70['query'][_0xdc1f('0xbc')]?{'attributes':[],'where':{'TagId':_0x305e70[_0xdc1f('0x86')]['tag']||undefined}}:{},'required':_0x305e70['query'][_0xdc1f('0xbc')]?!![]:![]}];}else{_0x55d6ff[_0xdc1f('0xac')]=[{'all':!![]}];}}return _0x422a39[_0x2346bf['childModel']]['findAll'](_0x55d6ff);})['then'](function(_0x425264){_0xce1f23['rows']=_0x425264;if(_0x545c5d==='Agents'&&_0x305e70['query'][_0xdc1f('0xbd')]===_0xdc1f('0xbe')){var _0x2185a7=[];for(var _0x4eb63e=0x0;_0x4eb63e<_0xce1f23[_0xdc1f('0xb3')][_0xdc1f('0x8f')];_0x4eb63e++){_0x2185a7[_0xdc1f('0x90')](_0xb38e39('chat',_0xce1f23['rows'][_0x4eb63e]['dataValues']));_0x2185a7[_0xdc1f('0x90')](_0xb38e39('sms',_0xce1f23[_0xdc1f('0xb3')][_0x4eb63e][_0xdc1f('0xbf')]));_0x2185a7[_0xdc1f('0x90')](_0xb38e39(_0xdc1f('0xc0'),_0xce1f23[_0xdc1f('0xb3')][_0x4eb63e][_0xdc1f('0xbf')]));_0x2185a7[_0xdc1f('0x90')](_0xb38e39('mail',_0xce1f23[_0xdc1f('0xb3')][_0x4eb63e]['dataValues']));_0x2185a7['push'](_0xb38e39(_0xdc1f('0xc1'),_0xce1f23[_0xdc1f('0xb3')][_0x4eb63e]['dataValues']));_0x2185a7[_0xdc1f('0x90')](_0xb38e39(_0xdc1f('0xc2'),_0xce1f23[_0xdc1f('0xb3')][_0x4eb63e][_0xdc1f('0xbf')]));}return Promise[_0xdc1f('0xc3')](_0x2185a7)[_0xdc1f('0x7')](function(){return _0xce1f23;});}return _0xce1f23;});}});}}});};