e29d9f7bad33cdbd88bfedfbf707209af1d3bf54
[motion2.git] / server / api / userProfile / userProfile.controller.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 _0x252f=['enabled','includes','isEmpty','subsections','concat','findOne','Dashboard','forEach','resourceId','bulkCreate','removeResources','section','Missing\x20section\x20parameter','No\x20User\x20Profile\x20found\x20for\x20id\x20','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./userProfile.socket','register','status','json','offset','undefined','limit','set','Content-Range','apply','reject','save','update','then','destroy','end','sendStatus','stack','name','send','index','map','UserProfile','rawAttributes','model','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','filters','pick','filter','where','VIRTUAL','merge','count','include','findAll','rows','catch','show','keys','includeAll','options','find','create','body','clone','params','get','omit','createdAt','updatedAt','sequelize','transaction','UserProfileSection','each','autoAssociation','sectionId','userProfileId','Resources','UserProfileResource','describe','addSections','push','removeSections','ids','getSections'];(function(_0x3ab9ee,_0x4a74b8){var _0x82ee88=function(_0x6ccc7e){while(--_0x6ccc7e){_0x3ab9ee['push'](_0x3ab9ee['shift']());}};_0x82ee88(++_0x4a74b8);}(_0x252f,0x1e2));var _0xf252=function(_0x22c597,_0x1b85f5){_0x22c597=_0x22c597-0x0;var _0x42ded4=_0x252f[_0x22c597];return _0x42ded4;};'use strict';var emlformat=require(_0xf252('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf252('0x1'));var jsonpatch=require(_0xf252('0x2'));var rp=require(_0xf252('0x3'));var moment=require(_0xf252('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xf252('0x5'));var util=require(_0xf252('0x6'));var path=require(_0xf252('0x7'));var sox=require(_0xf252('0x8'));var csv=require(_0xf252('0x9'));var ejs=require(_0xf252('0xa'));var fs=require('fs');var fs_extra=require(_0xf252('0xb'));var _=require(_0xf252('0xc'));var squel=require(_0xf252('0xd'));var crypto=require(_0xf252('0xe'));var jsforce=require(_0xf252('0xf'));var deskjs=require(_0xf252('0x10'));var toCsv=require('to-csv');var querystring=require(_0xf252('0x11'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xf252('0x12'));var qs=require(_0xf252('0x13'));var as=require(_0xf252('0x14'));var hardwareService=require(_0xf252('0x15'));var logger=require(_0xf252('0x16'))(_0xf252('0x17'));var utils=require(_0xf252('0x18'));var config=require(_0xf252('0x19'));var licenseUtil=require(_0xf252('0x1a'));var db=require(_0xf252('0x1b'))['db'];config[_0xf252('0x1c')]=_[_0xf252('0x1d')](config[_0xf252('0x1c')],{'host':_0xf252('0x1e'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf252('0x1c')]));require(_0xf252('0x1f'))[_0xf252('0x20')](socket);function respondWithStatusCode(_0x3345ce,_0x11b919){_0x11b919=_0x11b919||0xcc;return function(_0x25e48e){if(_0x25e48e){return _0x3345ce['sendStatus'](_0x11b919);}return _0x3345ce[_0xf252('0x21')](_0x11b919)['end']();};}function respondWithResult(_0x400ed8,_0x3b7efd){_0x3b7efd=_0x3b7efd||0xc8;return function(_0x19c993){if(_0x19c993){return _0x400ed8[_0xf252('0x21')](_0x3b7efd)[_0xf252('0x22')](_0x19c993);}};}function respondWithFilteredResult(_0x2f2be4,_0x54703b){return function(_0x34848b){if(_0x34848b){var _0x283ed7=typeof _0x54703b[_0xf252('0x23')]===_0xf252('0x24')&&typeof _0x54703b['limit']===_0xf252('0x24');var _0x5cea3d=_0x34848b['count'];var _0x565f23=_0x283ed7?0x0:_0x54703b[_0xf252('0x23')];var _0xa4ca7a=_0x283ed7?_0x34848b['count']:_0x54703b[_0xf252('0x23')]+_0x54703b[_0xf252('0x25')];var _0x3e0a48;if(_0xa4ca7a>=_0x5cea3d){_0xa4ca7a=_0x5cea3d;_0x3e0a48=0xc8;}else{_0x3e0a48=0xce;}_0x2f2be4['status'](_0x3e0a48);return _0x2f2be4[_0xf252('0x26')](_0xf252('0x27'),_0x565f23+'-'+_0xa4ca7a+'/'+_0x5cea3d)[_0xf252('0x22')](_0x34848b);}return null;};}function patchUpdates(_0x38136a){return function(_0x1674ce){try{jsonpatch[_0xf252('0x28')](_0x1674ce,_0x38136a,!![]);}catch(_0x5844e5){return BPromise[_0xf252('0x29')](_0x5844e5);}return _0x1674ce[_0xf252('0x2a')]();};}function saveUpdates(_0x51bd5e,_0x2a5c03){return function(_0x258cdb){if(_0x258cdb){return _0x258cdb[_0xf252('0x2b')](_0x51bd5e)[_0xf252('0x2c')](function(_0x4518c4){return _0x4518c4;});}return null;};}function removeEntity(_0x343a2a,_0x1a0bbf){return function(_0x336395){if(_0x336395){return _0x336395[_0xf252('0x2d')]()[_0xf252('0x2c')](function(){_0x343a2a[_0xf252('0x21')](0xcc)[_0xf252('0x2e')]();});}};}function handleEntityNotFound(_0x5cb67c,_0x45d2df){return function(_0x27accd){if(!_0x27accd){_0x5cb67c[_0xf252('0x2f')](0x194);}return _0x27accd;};}function handleError(_0x52a725,_0x54350d){_0x54350d=_0x54350d||0x1f4;return function(_0x2691ea){logger['error'](_0x2691ea[_0xf252('0x30')]);if(_0x2691ea[_0xf252('0x31')]){delete _0x2691ea['name'];}_0x52a725[_0xf252('0x21')](_0x54350d)[_0xf252('0x32')](_0x2691ea);};}exports[_0xf252('0x33')]=function(_0x11f018,_0x22f1e1){var _0x10c623={},_0x37b999={},_0x24d9d6={'count':0x0,'rows':[]};var _0x5bcb88=_[_0xf252('0x34')](db[_0xf252('0x35')][_0xf252('0x36')],function(_0x557b1c){return{'name':_0x557b1c['fieldName'],'type':_0x557b1c['type']['key']};});_0x37b999[_0xf252('0x37')]=_[_0xf252('0x34')](_0x5bcb88,_0xf252('0x31'));_0x37b999[_0xf252('0x38')]=_['keys'](_0x11f018[_0xf252('0x38')]);_0x37b999['filters']=_[_0xf252('0x39')](_0x37b999[_0xf252('0x37')],_0x37b999[_0xf252('0x38')]);_0x10c623[_0xf252('0x3a')]=_[_0xf252('0x39')](_0x37b999[_0xf252('0x37')],qs[_0xf252('0x3b')](_0x11f018[_0xf252('0x38')][_0xf252('0x3b')]));_0x10c623['attributes']=_0x10c623[_0xf252('0x3a')][_0xf252('0x3c')]?_0x10c623[_0xf252('0x3a')]:_0x37b999[_0xf252('0x37')];if(!_0x11f018['query'][_0xf252('0x3d')](_0xf252('0x3e'))){_0x10c623['limit']=qs['limit'](_0x11f018[_0xf252('0x38')][_0xf252('0x25')]);_0x10c623[_0xf252('0x23')]=qs[_0xf252('0x23')](_0x11f018[_0xf252('0x38')][_0xf252('0x23')]);}_0x10c623[_0xf252('0x3f')]=qs['sort'](_0x11f018['query']['sort']);_0x10c623['where']=qs[_0xf252('0x40')](_[_0xf252('0x41')](_0x11f018[_0xf252('0x38')],_0x37b999['filters']),_0x5bcb88);if(_0x11f018[_0xf252('0x38')][_0xf252('0x42')]){_0x10c623[_0xf252('0x43')]=_['merge'](_0x10c623[_0xf252('0x43')],{'$or':_[_0xf252('0x34')](_0x5bcb88,function(_0x21a438){if(_0x21a438['type']!==_0xf252('0x44')){var _0x508321={};_0x508321[_0x21a438['name']]={'$like':'%'+_0x11f018[_0xf252('0x38')][_0xf252('0x42')]+'%'};return _0x508321;}})});}_0x10c623=_[_0xf252('0x45')]({},_0x10c623,_0x11f018['options']);var _0x4790a5={'where':_0x10c623[_0xf252('0x43')]};return db['UserProfile'][_0xf252('0x46')](_0x4790a5)['then'](function(_0x52cadd){_0x24d9d6[_0xf252('0x46')]=_0x52cadd;if(_0x11f018[_0xf252('0x38')]['includeAll']){_0x10c623[_0xf252('0x47')]=[{'all':!![]}];}return db[_0xf252('0x35')][_0xf252('0x48')](_0x10c623);})[_0xf252('0x2c')](function(_0x41707a){_0x24d9d6[_0xf252('0x49')]=_0x41707a;return _0x24d9d6;})['then'](respondWithFilteredResult(_0x22f1e1,_0x10c623))[_0xf252('0x4a')](handleError(_0x22f1e1,null));};exports[_0xf252('0x4b')]=function(_0x3b80d5,_0x5cc0f4){var _0x2d5df3={'raw':![],'where':{'id':_0x3b80d5['params']['id']}},_0x4e12b9={};_0x4e12b9['model']=_[_0xf252('0x4c')](db['UserProfile'][_0xf252('0x36')]);_0x4e12b9['query']=_[_0xf252('0x4c')](_0x3b80d5['query']);_0x4e12b9[_0xf252('0x40')]=_[_0xf252('0x39')](_0x4e12b9[_0xf252('0x37')],_0x4e12b9['query']);_0x2d5df3[_0xf252('0x3a')]=_['intersection'](_0x4e12b9[_0xf252('0x37')],qs[_0xf252('0x3b')](_0x3b80d5[_0xf252('0x38')][_0xf252('0x3b')]));_0x2d5df3[_0xf252('0x3a')]=_0x2d5df3[_0xf252('0x3a')]['length']?_0x2d5df3['attributes']:_0x4e12b9[_0xf252('0x37')];if(_0x3b80d5[_0xf252('0x38')][_0xf252('0x4d')]){_0x2d5df3['include']=[{'all':!![]}];}_0x2d5df3=_[_0xf252('0x45')]({},_0x2d5df3,_0x3b80d5[_0xf252('0x4e')]);return db[_0xf252('0x35')][_0xf252('0x4f')](_0x2d5df3)[_0xf252('0x2c')](handleEntityNotFound(_0x5cc0f4,null))[_0xf252('0x2c')](respondWithResult(_0x5cc0f4,null))[_0xf252('0x4a')](handleError(_0x5cc0f4,null));};exports[_0xf252('0x50')]=function(_0xebd415,_0x5103f7){return db[_0xf252('0x35')][_0xf252('0x50')](_0xebd415[_0xf252('0x51')],{})[_0xf252('0x2c')](respondWithResult(_0x5103f7,0xc9))[_0xf252('0x4a')](handleError(_0x5103f7,null));};exports[_0xf252('0x52')]=function(_0x138176,_0x173422){var _0x2bfd98={'where':{'id':_0x138176[_0xf252('0x53')]['id']}},_0x19f95f={};_0x19f95f[_0xf252('0x37')]=_['keys'](db['UserProfile'][_0xf252('0x36')]);_0x2bfd98[_0xf252('0x3a')]=_[_0xf252('0x39')](_0x19f95f[_0xf252('0x37')],qs[_0xf252('0x3b')](_0x138176[_0xf252('0x38')][_0xf252('0x3b')]));_0x2bfd98[_0xf252('0x3a')]=_0x2bfd98['attributes'][_0xf252('0x3c')]?_0x2bfd98[_0xf252('0x3a')]:_0x19f95f[_0xf252('0x37')];if(_0x138176[_0xf252('0x38')][_0xf252('0x4d')]){_0x2bfd98[_0xf252('0x47')]=[{'all':!![]}];}_0x2bfd98=_[_0xf252('0x45')]({},_0x2bfd98,_0x138176[_0xf252('0x4e')]);return db[_0xf252('0x35')][_0xf252('0x4f')](_0x2bfd98)['then'](handleEntityNotFound(_0x173422,null))[_0xf252('0x2c')](function(_0x3c2ab3){if(_0x3c2ab3){var _0x59518e=_0x3c2ab3[_0xf252('0x54')]({'plain':!![]});_0x59518e=qs[_0xf252('0x55')](_0x59518e,['id',_0xf252('0x56'),_0xf252('0x57'),'crudPermissions']);_0x138176['body']=_['omit'](_0x138176[_0xf252('0x51')],['id',_0xf252('0x56'),_0xf252('0x57')]);return db[_0xf252('0x58')][_0xf252('0x59')](function(_0x261d0d){return db[_0xf252('0x35')]['create'](_['merge'](_0x59518e,_0x138176[_0xf252('0x51')]),{'include':_0x138176['query'][_0xf252('0x4d')]?[{'all':!![]}]:undefined,'transaction':_0x261d0d})[_0xf252('0x2c')](function(_0x103de6){var _0x12dbf5=_0x103de6['get']({'plain':!![]});return db[_0xf252('0x5a')][_0xf252('0x48')]({'where':{'userProfileId':_0x138176[_0xf252('0x53')]['id']},'raw':!![]})[_0xf252('0x2c')](function(_0x475d0c){if(_0x475d0c){return BPromise[_0xf252('0x5b')](_0x475d0c,function(_0x50442d){return new BPromise(function(_0x5b32ea,_0x1a420d){if(_0x50442d['autoAssociation']===null||_0x50442d[_0xf252('0x5c')]===0x1)_0x5b32ea(null);return db['UserProfileResource'][_0xf252('0x48')]({'where':{'sectionId':_0x50442d['id']},'raw':!![]})[_0xf252('0x2c')](function(_0x4cd33e){var _0x2f7753=_['map'](_0x4cd33e,function(_0x3e7d9d){return qs[_0xf252('0x55')](_0x3e7d9d,['id','createdAt',_0xf252('0x57'),_0xf252('0x5d')]);});_0x5b32ea(_0x2f7753);})[_0xf252('0x4a')](function(_0x48bc7e){_0x1a420d(_0x48bc7e);});})[_0xf252('0x2c')](function(_0x2c9844){var _0x2741d8=qs['omit'](_0x50442d,['id',_0xf252('0x56'),_0xf252('0x57')]);_0x2741d8[_0xf252('0x5e')]=_0x12dbf5['id'];if(_0x2c9844)_0x2741d8[_0xf252('0x5f')]=_0x2c9844;return _0x2741d8;})[_0xf252('0x2c')](function(_0x2c5080){return db[_0xf252('0x5a')][_0xf252('0x50')](_0x2c5080,{'include':[{'model':db[_0xf252('0x60')],'as':_0xf252('0x5f')}],'raw':!![],'transaction':_0x261d0d});});})[_0xf252('0x2c')](function(){return _0x12dbf5;});}});});});}})[_0xf252('0x2c')](respondWithResult(_0x173422,0xc9))[_0xf252('0x4a')](handleError(_0x173422,null));};exports[_0xf252('0x2b')]=function(_0x2a078a,_0xdfe025){if(_0x2a078a[_0xf252('0x51')]['id']){delete _0x2a078a[_0xf252('0x51')]['id'];}return db[_0xf252('0x35')][_0xf252('0x4f')]({'where':{'id':_0x2a078a[_0xf252('0x53')]['id']}})[_0xf252('0x2c')](handleEntityNotFound(_0xdfe025,null))['then'](saveUpdates(_0x2a078a[_0xf252('0x51')],null))[_0xf252('0x2c')](respondWithResult(_0xdfe025,null))['catch'](handleError(_0xdfe025,null));};exports[_0xf252('0x2d')]=function(_0xa648ba,_0x5d6bc5){return db[_0xf252('0x35')]['find']({'where':{'id':_0xa648ba[_0xf252('0x53')]['id']}})[_0xf252('0x2c')](handleEntityNotFound(_0x5d6bc5,null))[_0xf252('0x2c')](removeEntity(_0x5d6bc5,null))[_0xf252('0x4a')](handleError(_0x5d6bc5,null));};exports[_0xf252('0x61')]=function(_0x428dd6,_0x1f60c1){return db[_0xf252('0x35')]['describe']()[_0xf252('0x2c')](respondWithResult(_0x1f60c1,null))[_0xf252('0x4a')](handleError(_0x1f60c1,null));};exports[_0xf252('0x62')]=function(_0x1d060a,_0x442729){var _0xa2d70a=_0x1d060a[_0xf252('0x51')];return db[_0xf252('0x35')][_0xf252('0x4f')]({'where':{'id':_0x1d060a['params']['id']}})[_0xf252('0x2c')](handleEntityNotFound(_0x442729,null))[_0xf252('0x2c')](function(_0x15807e){if(_0x15807e){return db['sequelize'][_0xf252('0x59')](function(_0x50de5a){return db[_0xf252('0x5a')][_0xf252('0x2d')]({'where':{'userProfileId':_0x1d060a[_0xf252('0x53')]['id'],'sectionId':_[_0xf252('0x34')](_0xa2d70a,function(_0x2e7b02){return _0x2e7b02[_0xf252('0x5d')];})},'transaction':_0x50de5a})[_0xf252('0x2c')](function(){var _0x1cccbd=_['map'](_0xa2d70a,function(_0x3c8323){_0x3c8323[_0xf252('0x5e')]=_0x1d060a['params']['id'];return _0x3c8323;});var _0x47f2c7=[];return BPromise[_0xf252('0x5b')](_0x1cccbd,function(_0x45a750){return db[_0xf252('0x5a')][_0xf252('0x50')](_0x45a750,{'include':[{'model':db[_0xf252('0x60')],'as':'Resources'}],'raw':!![],'transaction':_0x50de5a})[_0xf252('0x2c')](function(_0x4f2ebb){_0x47f2c7[_0xf252('0x63')](_0x4f2ebb[_0xf252('0x54')]({'plain':!![]}));});})['then'](function(){return _0x47f2c7;});});});}})[_0xf252('0x2c')](function(_0x4bf930){return _0x4bf930;})['then'](respondWithResult(_0x442729,null))[_0xf252('0x4a')](handleError(_0x442729,null));};exports[_0xf252('0x64')]=function(_0x1bdc1e,_0x148d57){var _0x510ace;return db['UserProfile'][_0xf252('0x4f')]({'where':{'id':_0x1bdc1e['params']['id']},'attributes':['id',_0xf252('0x31')]})[_0xf252('0x2c')](handleEntityNotFound(_0x148d57,null))['then'](function(_0x10ab03){if(_0x10ab03){_0x510ace=_0x10ab03;return db[_0xf252('0x5a')][_0xf252('0x2d')]({'where':{'userProfileId':_0x1bdc1e[_0xf252('0x53')]['id'],'sectionId':_0x1bdc1e['query'][_0xf252('0x65')]}});}})['then'](function(){return _0x510ace;})[_0xf252('0x2c')](respondWithStatusCode(_0x148d57,null))[_0xf252('0x4a')](handleError(_0x148d57,null));};exports[_0xf252('0x66')]=function(_0x3191c5,_0x8a006f){var _0x51e6cc=[];var _0xeaca36=[];return db['UserProfileSection'][_0xf252('0x48')]({'where':{'userProfileId':_0x3191c5[_0xf252('0x53')]['id']},'raw':!![]})[_0xf252('0x2c')](function(_0x4c96be){_0x51e6cc=_[_0xf252('0x42')](_0x4c96be,function(_0x348ed6){return _0x348ed6[_0xf252('0x67')]===0x1||_[_0xf252('0x68')]([0x3eb,0x709],_0x348ed6['sectionId']);});if(!_[_0xf252('0x69')](_0x51e6cc)){return _[_0xf252('0x34')](_0x51e6cc,function(_0x6167cb){return _0x6167cb[_0xf252('0x5d')];});}else{return;}})[_0xf252('0x2c')](function(_0x115811){if(_0x115811)_0xeaca36=_0x115811;if(_['includes'](_0xeaca36,0x64)){var _0x37dac5=_[_0xf252('0x4f')](_0x51e6cc,{'sectionId':0x64});return hasDefaultDashboard(_0x37dac5)[_0xf252('0x2c')](function(_0x1fea3d){return _[_0xf252('0x34')](_0x51e6cc,function(_0x5c6b2b){if(_0x5c6b2b[_0xf252('0x5d')]===0x64){_0x5c6b2b['subsections']=_0x1fea3d;}return _0x5c6b2b;});});}else{return;}})[_0xf252('0x2c')](function(_0x2d43cb){if(_0x2d43cb)_0x51e6cc=_0x2d43cb;if(_[_0xf252('0x68')](_0xeaca36,0x3eb)){var _0x23000e=_[_0xf252('0x4f')](_0x51e6cc,{'sectionId':0x3eb});return getCustomDashboards(_0x23000e)[_0xf252('0x2c')](function(_0x4882c7){return _[_0xf252('0x34')](_0x51e6cc,function(_0x114374){if(_0x23000e['enabled']){if(_0x114374[_0xf252('0x5d')]===0x3eb){_0x114374[_0xf252('0x6a')]=_0x4882c7;}}else{if(_0x114374[_0xf252('0x5d')]===0x64){if(!_0x114374[_0xf252('0x6a')]){_0x114374['subsections']=[];}_0x114374[_0xf252('0x6a')]=_0x114374[_0xf252('0x6a')][_0xf252('0x6b')](_0x4882c7);}}return _0x114374;});});}else{return;}})[_0xf252('0x2c')](function(_0x22c3a8){if(_0x22c3a8)_0x51e6cc=_0x22c3a8;if(_['includes'](_0xeaca36,0x709)){var _0x357a8a=_[_0xf252('0x4f')](_0x51e6cc,{'sectionId':0x709});return getPlugins(_0x357a8a)['then'](function(_0x30425e){if(_0x357a8a[_0xf252('0x67')]){return _[_0xf252('0x34')](_0x51e6cc,function(_0x2fc33b){if(_0x2fc33b[_0xf252('0x5d')]===0x709){_0x2fc33b[_0xf252('0x6a')]=_0x30425e;}return _0x2fc33b;});}else{var _0x20c90b={'sectionId':0x76c,'enabled':0x1,'subsections':_0x30425e};var _0x301497=_[_0xf252('0x34')](_0x51e6cc);_0x301497['push'](_0x20c90b);return _0x301497;}});}else{return;}})[_0xf252('0x2c')](function(_0x1638af){if(_0x1638af)_0x51e6cc=_0x1638af;return _['filter'](_0x51e6cc,[_0xf252('0x67'),0x1]);})[_0xf252('0x2c')](respondWithResult(_0x8a006f,null))[_0xf252('0x4a')](handleError(_0x8a006f,null));};function hasDefaultDashboard(_0x4569d0){var _0xe9f759=[0x65];return new BPromise(function(_0x6decf9,_0x20f0ad){try{if(_0x4569d0[_0xf252('0x5c')]){_0x6decf9(_0xe9f759);}else{return db['UserProfileResource'][_0xf252('0x6c')]({'where':{'sectionId':_0x4569d0['id']},'raw':!![]})['then'](function(_0x54756e){_0x54756e?_0x6decf9(_0xe9f759):_0x6decf9();});}}catch(_0x46f493){_0x20f0ad(_0x46f493);}});}function getCustomDashboards(_0x510543){var _0x1238f5=[];return new BPromise(function(_0x5e5cde,_0x179647){try{if(_0x510543[_0xf252('0x5c')]){return db[_0xf252('0x6d')][_0xf252('0x48')]({'raw':!![]})[_0xf252('0x2c')](function(_0x4ddf82){_0x4ddf82[_0xf252('0x6e')](function(_0x778d7b){_0x1238f5[_0xf252('0x63')](_0x778d7b['id']+0x1869f);});_0x5e5cde(_0x1238f5);});}else{return db['UserProfileResource']['findAll']({'where':{'sectionId':_0x510543['id']},'raw':!![]})[_0xf252('0x2c')](function(_0x2c2f36){_0x2c2f36[_0xf252('0x6e')](function(_0x559019){_0x1238f5[_0xf252('0x63')](_0x559019[_0xf252('0x6f')]+0x1869f);});_0x5e5cde(_0x1238f5);});}}catch(_0x57fd97){_0x179647(_0x57fd97);}});}function getPlugins(_0x57da34){var _0x9c2ae=[];return new BPromise(function(_0x590b06,_0x137355){try{if(_0x57da34['autoAssociation']){return db['Plugin'][_0xf252('0x48')]({'raw':!![]})[_0xf252('0x2c')](function(_0x31ad7d){_0x31ad7d['forEach'](function(_0x15c68b){_0x9c2ae['push'](_0x15c68b['id']+0x15b38);});_0x590b06(_0x9c2ae);});}else{return db[_0xf252('0x60')]['findAll']({'where':{'sectionId':_0x57da34['id']},'raw':!![]})[_0xf252('0x2c')](function(_0x3bed83){_0x3bed83[_0xf252('0x6e')](function(_0x812767){_0x9c2ae[_0xf252('0x63')](_0x812767[_0xf252('0x6f')]+0x15b38);});_0x590b06(_0x9c2ae);});}}catch(_0x5e6c4f){_0x137355(_0x5e6c4f);}});}exports['addResources']=function(_0x798b04,_0x38d5bf){return db[_0xf252('0x35')][_0xf252('0x4f')]({'where':{'id':_0x798b04['params']['id']}})[_0xf252('0x2c')](handleEntityNotFound(_0x38d5bf,null))[_0xf252('0x2c')](function(_0x4627f7){if(_0x4627f7){return db[_0xf252('0x58')][_0xf252('0x59')](function(_0xa9bba3){return db['UserProfileSection'][_0xf252('0x48')]({'where':{'userProfileId':_0x798b04[_0xf252('0x53')]['id']},'attributes':['id'],'raw':!![]})[_0xf252('0x2c')](function(_0x17eead){if(_0x17eead){return db['UserProfileSection']['destroy']({'where':{'userProfileId':_0x798b04['params']['id'],'id':_[_0xf252('0x34')](_0x17eead,function(_0x438400){return _0x438400['id'];})},'transaction':_0xa9bba3});}})[_0xf252('0x2c')](function(_0x550033){var _0x519fac=_[_0xf252('0x34')](_0x798b04['body'],function(_0xb74841){_0xb74841[_0xf252('0x5e')]=_0x798b04['params']['id'];return _0xb74841;});return db['UserProfileSection'][_0xf252('0x70')](_0x519fac,{'raw':!![],'transaction':_0xa9bba3});})[_0xf252('0x2c')](function(_0x16f24e){var _0x5a149f=_[_0xf252('0x42')](_[_0xf252('0x34')](_0x16f24e,function(_0x1bd764){return _0x1bd764[_0xf252('0x54')]({'plain':!![]});}),{'includeAll':![]});if(_0x5a149f){return db[_0xf252('0x5a')][_0xf252('0x48')]({'where':{'userProfileId':_0x798b04[_0xf252('0x53')]['id'],'sectionId':_[_0xf252('0x34')](_0x5a149f,function(_0x48b103){return _0x48b103['sectionId'];})},'attributes':['id',_0xf252('0x5d')],'raw':!![]})['then'](function(_0x147c61){var _0x35c480=_[_0xf252('0x34')](_0x798b04[_0xf252('0x51')],function(_0x3bd2a5){_0x3bd2a5['userProfileId']=_0x798b04[_0xf252('0x53')]['id'];return _0x3bd2a5;});return db[_0xf252('0x60')][_0xf252('0x70')](_0x35c480,{'raw':!![],'transaction':_0xa9bba3});});}})[_0xf252('0x4a')](handleError(_0x38d5bf,null));});}})[_0xf252('0x2c')](function(_0x1d235b){var _0x1e57a9=_[_0xf252('0x34')](_0x1d235b,function(_0x4a2311){return _0x4a2311[_0xf252('0x54')]({'plain':!![]});});})[_0xf252('0x2c')](respondWithResult(_0x38d5bf,null))[_0xf252('0x4a')](handleError(_0x38d5bf,null));};exports[_0xf252('0x71')]=function(_0x1d3259,_0x294f08,_0x371c73){return db[_0xf252('0x35')][_0xf252('0x4f')]({'where':{'id':_0x1d3259[_0xf252('0x53')]['id']}})[_0xf252('0x2c')](handleEntityNotFound(_0x294f08,null))['then'](function(_0x2a4a75){if(_0x2a4a75){return _0x2a4a75[_0xf252('0x71')](_0x1d3259[_0xf252('0x38')][_0xf252('0x65')]);}})[_0xf252('0x2c')](respondWithStatusCode(_0x294f08,null))[_0xf252('0x4a')](handleError(_0x294f08,null));};exports['getResources']=function(_0x43a0d3,_0x332f7d){var _0xda39ca={};if(!_0x43a0d3[_0xf252('0x38')][_0xf252('0x72')])throw new Error(_0xf252('0x73'));if(!_0x43a0d3[_0xf252('0x38')]['hasOwnProperty'](_0xf252('0x3e'))){_0xda39ca[_0xf252('0x25')]=qs[_0xf252('0x25')](_0x43a0d3[_0xf252('0x38')][_0xf252('0x25')]);_0xda39ca[_0xf252('0x23')]=qs[_0xf252('0x23')](_0x43a0d3[_0xf252('0x38')][_0xf252('0x23')]);}return db[_0xf252('0x35')][_0xf252('0x4f')]({'where':{'id':_0x43a0d3[_0xf252('0x53')]['id']}})[_0xf252('0x2c')](function(_0x5cabec){if(!_0x5cabec)throw new Error(_0xf252('0x74')+_0x43a0d3[_0xf252('0x53')]['id']);return db['UserProfile']['getResources'](_0x43a0d3);})[_0xf252('0x2c')](respondWithFilteredResult(_0x332f7d,_0xda39ca))[_0xf252('0x4a')](handleError(_0x332f7d,null));};