Built motion from commit 538092ac.|2.6.10
[motion2.git] / server / api / userProfile / userProfile.controller.js
index fa9ed93..3fae7bf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x333f=['ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','./userProfile.socket','register','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','update','then','destroy','error','stack','name','send','index','map','UserProfile','rawAttributes','key','model','query','keys','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','type','VIRTUAL','options','findAll','catch','show','params','fields','includeAll','find','create','body','clone','get','createdAt','updatedAt','crudPermissions','omit','transaction','merge','each','autoAssociation','UserProfileResource','sectionId','userProfileId','UserProfileSection','Resources','describe','addSections','sequelize','push','removeSections','ids','includes','isEmpty','subsections','enabled','concat','findOne','forEach','Plugin','resourceId','addResources','bulkCreate','removeResources','Missing\x20section\x20parameter','No\x20User\x20Profile\x20found\x20for\x20id\x20','getResources','eml-format','zip-dir','request-promise','moment','bluebird','util','path','to-csv'];(function(_0x483e3a,_0x568361){var _0x43fca9=function(_0x273d7e){while(--_0x273d7e){_0x483e3a['push'](_0x483e3a['shift']());}};_0x43fca9(++_0x568361);}(_0x333f,0x1c4));var _0xf333=function(_0x5c280f,_0x169e66){_0x5c280f=_0x5c280f-0x0;var _0x6fc473=_0x333f[_0x5c280f];return _0x6fc473;};'use strict';var emlformat=require(_0xf333('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf333('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf333('0x2'));var moment=require(_0xf333('0x3'));var BPromise=require(_0xf333('0x4'));var Mustache=require('mustache');var util=require(_0xf333('0x5'));var path=require(_0xf333('0x6'));var sox=require('sox');var csv=require(_0xf333('0x7'));var ejs=require(_0xf333('0x8'));var fs=require('fs');var fs_extra=require(_0xf333('0x9'));var _=require(_0xf333('0xa'));var squel=require(_0xf333('0xb'));var crypto=require(_0xf333('0xc'));var jsforce=require(_0xf333('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xf333('0x7'));var querystring=require(_0xf333('0xe'));var Papa=require(_0xf333('0xf'));var Redis=require(_0xf333('0x10'));var authService=require(_0xf333('0x11'));var qs=require(_0xf333('0x12'));var as=require(_0xf333('0x13'));var hardwareService=require(_0xf333('0x14'));var logger=require('../../config/logger')(_0xf333('0x15'));var utils=require(_0xf333('0x16'));var config=require(_0xf333('0x17'));var licenseUtil=require(_0xf333('0x18'));var db=require(_0xf333('0x19'))['db'];config['redis']=_[_0xf333('0x1a')](config[_0xf333('0x1b')],{'host':_0xf333('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf333('0x1b')]));require(_0xf333('0x1d'))[_0xf333('0x1e')](socket);function respondWithStatusCode(_0x436ba2,_0x478ae0){_0x478ae0=_0x478ae0||0xcc;return function(_0x5861cf){if(_0x5861cf){return _0x436ba2[_0xf333('0x1f')](_0x478ae0);}return _0x436ba2[_0xf333('0x20')](_0x478ae0)[_0xf333('0x21')]();};}function respondWithResult(_0x2965fb,_0x1d00eb){_0x1d00eb=_0x1d00eb||0xc8;return function(_0x33f80a){if(_0x33f80a){return _0x2965fb[_0xf333('0x20')](_0x1d00eb)[_0xf333('0x22')](_0x33f80a);}};}function respondWithFilteredResult(_0x37cad6,_0x1f0aa9){return function(_0x1b3c3a){if(_0x1b3c3a){var _0x53b9b9=typeof _0x1f0aa9[_0xf333('0x23')]===_0xf333('0x24')&&typeof _0x1f0aa9['limit']===_0xf333('0x24');var _0x35a850=_0x1b3c3a[_0xf333('0x25')];var _0xc587bd=_0x53b9b9?0x0:_0x1f0aa9[_0xf333('0x23')];var _0x5a0d47=_0x53b9b9?_0x1b3c3a[_0xf333('0x25')]:_0x1f0aa9['offset']+_0x1f0aa9[_0xf333('0x26')];var _0xc827ee;if(_0x5a0d47>=_0x35a850){_0x5a0d47=_0x35a850;_0xc827ee=0xc8;}else{_0xc827ee=0xce;}_0x37cad6['status'](_0xc827ee);return _0x37cad6[_0xf333('0x27')](_0xf333('0x28'),_0xc587bd+'-'+_0x5a0d47+'/'+_0x35a850)[_0xf333('0x22')](_0x1b3c3a);}return null;};}function patchUpdates(_0xa1be98){return function(_0xda0756){try{jsonpatch['apply'](_0xda0756,_0xa1be98,!![]);}catch(_0x4e803e){return BPromise['reject'](_0x4e803e);}return _0xda0756['save']();};}function saveUpdates(_0xd04aac,_0x5bdf03){return function(_0x31ed11){if(_0x31ed11){return _0x31ed11[_0xf333('0x29')](_0xd04aac)[_0xf333('0x2a')](function(_0x17955f){return _0x17955f;});}return null;};}function removeEntity(_0xc1c605,_0x247ada){return function(_0xc997bc){if(_0xc997bc){return _0xc997bc[_0xf333('0x2b')]()[_0xf333('0x2a')](function(){_0xc1c605[_0xf333('0x20')](0xcc)['end']();});}};}function handleEntityNotFound(_0x18e0d6,_0x5d0f1d){return function(_0x54d19a){if(!_0x54d19a){_0x18e0d6['sendStatus'](0x194);}return _0x54d19a;};}function handleError(_0x45b29d,_0x22487e){_0x22487e=_0x22487e||0x1f4;return function(_0x3ec1e0){logger[_0xf333('0x2c')](_0x3ec1e0[_0xf333('0x2d')]);if(_0x3ec1e0[_0xf333('0x2e')]){delete _0x3ec1e0[_0xf333('0x2e')];}_0x45b29d['status'](_0x22487e)[_0xf333('0x2f')](_0x3ec1e0);};}exports[_0xf333('0x30')]=function(_0xc5b30b,_0x3dbd29){var _0x348823={},_0x7de265={},_0xa64933={'count':0x0,'rows':[]};var _0x3fe883=_[_0xf333('0x31')](db[_0xf333('0x32')][_0xf333('0x33')],function(_0x5ec268){return{'name':_0x5ec268['fieldName'],'type':_0x5ec268['type'][_0xf333('0x34')]};});_0x7de265[_0xf333('0x35')]=_[_0xf333('0x31')](_0x3fe883,_0xf333('0x2e'));_0x7de265[_0xf333('0x36')]=_[_0xf333('0x37')](_0xc5b30b[_0xf333('0x36')]);_0x7de265['filters']=_[_0xf333('0x38')](_0x7de265[_0xf333('0x35')],_0x7de265[_0xf333('0x36')]);_0x348823[_0xf333('0x39')]=_[_0xf333('0x38')](_0x7de265[_0xf333('0x35')],qs['fields'](_0xc5b30b[_0xf333('0x36')]['fields']));_0x348823['attributes']=_0x348823[_0xf333('0x39')][_0xf333('0x3a')]?_0x348823[_0xf333('0x39')]:_0x7de265['model'];if(!_0xc5b30b[_0xf333('0x36')][_0xf333('0x3b')](_0xf333('0x3c'))){_0x348823[_0xf333('0x26')]=qs['limit'](_0xc5b30b[_0xf333('0x36')][_0xf333('0x26')]);_0x348823['offset']=qs['offset'](_0xc5b30b[_0xf333('0x36')][_0xf333('0x23')]);}_0x348823[_0xf333('0x3d')]=qs[_0xf333('0x3e')](_0xc5b30b['query'][_0xf333('0x3e')]);_0x348823[_0xf333('0x3f')]=qs['filters'](_[_0xf333('0x40')](_0xc5b30b[_0xf333('0x36')],_0x7de265[_0xf333('0x41')]),_0x3fe883);if(_0xc5b30b['query'][_0xf333('0x42')]){_0x348823[_0xf333('0x3f')]=_['merge'](_0x348823['where'],{'$or':_[_0xf333('0x31')](_0x3fe883,function(_0x54bc01){if(_0x54bc01[_0xf333('0x43')]!==_0xf333('0x44')){var _0x4bbf2f={};_0x4bbf2f[_0x54bc01[_0xf333('0x2e')]]={'$like':'%'+_0xc5b30b['query'][_0xf333('0x42')]+'%'};return _0x4bbf2f;}})});}_0x348823=_['merge']({},_0x348823,_0xc5b30b[_0xf333('0x45')]);var _0x5d2147={'where':_0x348823[_0xf333('0x3f')]};return db[_0xf333('0x32')][_0xf333('0x25')](_0x5d2147)[_0xf333('0x2a')](function(_0x32dc73){_0xa64933[_0xf333('0x25')]=_0x32dc73;if(_0xc5b30b['query']['includeAll']){_0x348823['include']=[{'all':!![]}];}return db[_0xf333('0x32')][_0xf333('0x46')](_0x348823);})['then'](function(_0x414ac4){_0xa64933['rows']=_0x414ac4;return _0xa64933;})[_0xf333('0x2a')](respondWithFilteredResult(_0x3dbd29,_0x348823))[_0xf333('0x47')](handleError(_0x3dbd29,null));};exports[_0xf333('0x48')]=function(_0x38f315,_0x19b27f){var _0x2b029b={'raw':![],'where':{'id':_0x38f315[_0xf333('0x49')]['id']}},_0x190484={};_0x190484['model']=_[_0xf333('0x37')](db[_0xf333('0x32')][_0xf333('0x33')]);_0x190484[_0xf333('0x36')]=_[_0xf333('0x37')](_0x38f315['query']);_0x190484[_0xf333('0x41')]=_[_0xf333('0x38')](_0x190484[_0xf333('0x35')],_0x190484[_0xf333('0x36')]);_0x2b029b[_0xf333('0x39')]=_[_0xf333('0x38')](_0x190484[_0xf333('0x35')],qs[_0xf333('0x4a')](_0x38f315['query'][_0xf333('0x4a')]));_0x2b029b['attributes']=_0x2b029b[_0xf333('0x39')][_0xf333('0x3a')]?_0x2b029b['attributes']:_0x190484['model'];if(_0x38f315['query'][_0xf333('0x4b')]){_0x2b029b['include']=[{'all':!![]}];}_0x2b029b=_['merge']({},_0x2b029b,_0x38f315['options']);return db[_0xf333('0x32')][_0xf333('0x4c')](_0x2b029b)['then'](handleEntityNotFound(_0x19b27f,null))[_0xf333('0x2a')](respondWithResult(_0x19b27f,null))[_0xf333('0x47')](handleError(_0x19b27f,null));};exports[_0xf333('0x4d')]=function(_0x5d3455,_0x17ea05){return db[_0xf333('0x32')]['create'](_0x5d3455[_0xf333('0x4e')],{})[_0xf333('0x2a')](respondWithResult(_0x17ea05,0xc9))[_0xf333('0x47')](handleError(_0x17ea05,null));};exports[_0xf333('0x4f')]=function(_0x3093c5,_0x66921e){var _0x145e9d={'where':{'id':_0x3093c5[_0xf333('0x49')]['id']}},_0x243c9e={};_0x243c9e[_0xf333('0x35')]=_[_0xf333('0x37')](db[_0xf333('0x32')][_0xf333('0x33')]);_0x145e9d['attributes']=_['intersection'](_0x243c9e['model'],qs[_0xf333('0x4a')](_0x3093c5[_0xf333('0x36')][_0xf333('0x4a')]));_0x145e9d[_0xf333('0x39')]=_0x145e9d['attributes']['length']?_0x145e9d[_0xf333('0x39')]:_0x243c9e[_0xf333('0x35')];if(_0x3093c5[_0xf333('0x36')]['includeAll']){_0x145e9d['include']=[{'all':!![]}];}_0x145e9d=_['merge']({},_0x145e9d,_0x3093c5[_0xf333('0x45')]);return db['UserProfile']['find'](_0x145e9d)[_0xf333('0x2a')](handleEntityNotFound(_0x66921e,null))['then'](function(_0x476790){if(_0x476790){var _0x149220=_0x476790[_0xf333('0x50')]({'plain':!![]});_0x149220=qs['omit'](_0x149220,['id',_0xf333('0x51'),_0xf333('0x52'),_0xf333('0x53')]);_0x3093c5[_0xf333('0x4e')]=_[_0xf333('0x54')](_0x3093c5[_0xf333('0x4e')],['id',_0xf333('0x51'),_0xf333('0x52')]);return db['sequelize'][_0xf333('0x55')](function(_0x37fa68){return db[_0xf333('0x32')]['create'](_[_0xf333('0x56')](_0x149220,_0x3093c5['body']),{'include':_0x3093c5[_0xf333('0x36')][_0xf333('0x4b')]?[{'all':!![]}]:undefined,'transaction':_0x37fa68})[_0xf333('0x2a')](function(_0x4eb4e5){var _0x168ac0=_0x4eb4e5[_0xf333('0x50')]({'plain':!![]});return db['UserProfileSection'][_0xf333('0x46')]({'where':{'userProfileId':_0x3093c5[_0xf333('0x49')]['id']},'raw':!![]})[_0xf333('0x2a')](function(_0x2d5635){if(_0x2d5635){return BPromise[_0xf333('0x57')](_0x2d5635,function(_0xae58f4){return new BPromise(function(_0xb981c2,_0xab4485){if(_0xae58f4[_0xf333('0x58')]===null||_0xae58f4[_0xf333('0x58')]===0x1)_0xb981c2(null);return db[_0xf333('0x59')][_0xf333('0x46')]({'where':{'sectionId':_0xae58f4['id']},'raw':!![]})[_0xf333('0x2a')](function(_0x22c4ea){var _0x4a1523=_[_0xf333('0x31')](_0x22c4ea,function(_0x27edad){return qs[_0xf333('0x54')](_0x27edad,['id',_0xf333('0x51'),'updatedAt',_0xf333('0x5a')]);});_0xb981c2(_0x4a1523);})[_0xf333('0x47')](function(_0x4195e0){_0xab4485(_0x4195e0);});})['then'](function(_0x2f5efb){var _0x1e5ae2=qs['omit'](_0xae58f4,['id',_0xf333('0x51'),'updatedAt']);_0x1e5ae2[_0xf333('0x5b')]=_0x168ac0['id'];if(_0x2f5efb)_0x1e5ae2['Resources']=_0x2f5efb;return _0x1e5ae2;})[_0xf333('0x2a')](function(_0x2d6fe5){return db[_0xf333('0x5c')][_0xf333('0x4d')](_0x2d6fe5,{'include':[{'model':db['UserProfileResource'],'as':_0xf333('0x5d')}],'raw':!![],'transaction':_0x37fa68});});})[_0xf333('0x2a')](function(){return _0x168ac0;});}});});});}})[_0xf333('0x2a')](respondWithResult(_0x66921e,0xc9))[_0xf333('0x47')](handleError(_0x66921e,null));};exports[_0xf333('0x29')]=function(_0x284674,_0xeccbba){if(_0x284674[_0xf333('0x4e')]['id']){delete _0x284674[_0xf333('0x4e')]['id'];}return db['UserProfile']['find']({'where':{'id':_0x284674['params']['id']}})[_0xf333('0x2a')](handleEntityNotFound(_0xeccbba,null))['then'](saveUpdates(_0x284674[_0xf333('0x4e')],null))['then'](respondWithResult(_0xeccbba,null))[_0xf333('0x47')](handleError(_0xeccbba,null));};exports['destroy']=function(_0x4256eb,_0x2799be){return db[_0xf333('0x32')][_0xf333('0x4c')]({'where':{'id':_0x4256eb[_0xf333('0x49')]['id']}})[_0xf333('0x2a')](handleEntityNotFound(_0x2799be,null))['then'](removeEntity(_0x2799be,null))['catch'](handleError(_0x2799be,null));};exports[_0xf333('0x5e')]=function(_0x32fa88,_0x3b6430){return db['UserProfile'][_0xf333('0x5e')]()['then'](respondWithResult(_0x3b6430,null))['catch'](handleError(_0x3b6430,null));};exports[_0xf333('0x5f')]=function(_0x3a66d0,_0x1d3820){var _0x105054=_0x3a66d0[_0xf333('0x4e')];return db[_0xf333('0x32')][_0xf333('0x4c')]({'where':{'id':_0x3a66d0['params']['id']}})['then'](handleEntityNotFound(_0x1d3820,null))[_0xf333('0x2a')](function(_0x39dab3){if(_0x39dab3){return db[_0xf333('0x60')][_0xf333('0x55')](function(_0x1fb710){return db['UserProfileSection'][_0xf333('0x2b')]({'where':{'userProfileId':_0x3a66d0[_0xf333('0x49')]['id'],'sectionId':_['map'](_0x105054,function(_0x405745){return _0x405745['sectionId'];})},'transaction':_0x1fb710})[_0xf333('0x2a')](function(){var _0x119f78=_[_0xf333('0x31')](_0x105054,function(_0xc103c0){_0xc103c0['userProfileId']=_0x3a66d0[_0xf333('0x49')]['id'];return _0xc103c0;});var _0x5aa907=[];return BPromise[_0xf333('0x57')](_0x119f78,function(_0xfc57c9){return db[_0xf333('0x5c')][_0xf333('0x4d')](_0xfc57c9,{'include':[{'model':db[_0xf333('0x59')],'as':_0xf333('0x5d')}],'raw':!![],'transaction':_0x1fb710})[_0xf333('0x2a')](function(_0x545380){_0x5aa907[_0xf333('0x61')](_0x545380['get']({'plain':!![]}));});})['then'](function(){return _0x5aa907;});});});}})[_0xf333('0x2a')](function(_0x5475df){return _0x5475df;})[_0xf333('0x2a')](respondWithResult(_0x1d3820,null))[_0xf333('0x47')](handleError(_0x1d3820,null));};exports[_0xf333('0x62')]=function(_0x454768,_0x262fdd){var _0x1f9f65;return db['UserProfile']['find']({'where':{'id':_0x454768[_0xf333('0x49')]['id']},'attributes':['id',_0xf333('0x2e')]})[_0xf333('0x2a')](handleEntityNotFound(_0x262fdd,null))[_0xf333('0x2a')](function(_0x5b4ddc){if(_0x5b4ddc){_0x1f9f65=_0x5b4ddc;return db[_0xf333('0x5c')][_0xf333('0x2b')]({'where':{'userProfileId':_0x454768[_0xf333('0x49')]['id'],'sectionId':_0x454768[_0xf333('0x36')][_0xf333('0x63')]}});}})[_0xf333('0x2a')](function(){return _0x1f9f65;})[_0xf333('0x2a')](respondWithStatusCode(_0x262fdd,null))[_0xf333('0x47')](handleError(_0x262fdd,null));};exports['getSections']=function(_0xcf0d64,_0x443126){var _0x2bb816=[];var _0x38cd86=[];return db[_0xf333('0x5c')][_0xf333('0x46')]({'where':{'userProfileId':_0xcf0d64[_0xf333('0x49')]['id']},'raw':!![]})[_0xf333('0x2a')](function(_0x2c7ab4){_0x2bb816=_['filter'](_0x2c7ab4,function(_0x99d624){return _0x99d624['enabled']===0x1||_[_0xf333('0x64')]([0x3eb,0x709],_0x99d624['sectionId']);});if(!_[_0xf333('0x65')](_0x2bb816)){return _[_0xf333('0x31')](_0x2bb816,function(_0x583be0){return _0x583be0[_0xf333('0x5a')];});}else{return;}})[_0xf333('0x2a')](function(_0xe08cea){if(_0xe08cea)_0x38cd86=_0xe08cea;if(_[_0xf333('0x64')](_0x38cd86,0x64)){var _0x56bdaf=_['find'](_0x2bb816,{'sectionId':0x64});return hasDefaultDashboard(_0x56bdaf)[_0xf333('0x2a')](function(_0x4ab66f){return _[_0xf333('0x31')](_0x2bb816,function(_0x47513d){if(_0x47513d[_0xf333('0x5a')]===0x64){_0x47513d[_0xf333('0x66')]=_0x4ab66f;}return _0x47513d;});});}else{return;}})[_0xf333('0x2a')](function(_0x372fa5){if(_0x372fa5)_0x2bb816=_0x372fa5;if(_[_0xf333('0x64')](_0x38cd86,0x3eb)){var _0x7f0187=_[_0xf333('0x4c')](_0x2bb816,{'sectionId':0x3eb});return getCustomDashboards(_0x7f0187)['then'](function(_0xd2747d){return _[_0xf333('0x31')](_0x2bb816,function(_0x165f5a){if(_0x7f0187[_0xf333('0x67')]){if(_0x165f5a['sectionId']===0x3eb){_0x165f5a[_0xf333('0x66')]=_0xd2747d;}}else{if(_0x165f5a['sectionId']===0x64){if(!_0x165f5a[_0xf333('0x66')]){_0x165f5a[_0xf333('0x66')]=[];}_0x165f5a['subsections']=_0x165f5a[_0xf333('0x66')][_0xf333('0x68')](_0xd2747d);}}return _0x165f5a;});});}else{return;}})['then'](function(_0x92c30a){if(_0x92c30a)_0x2bb816=_0x92c30a;if(_[_0xf333('0x64')](_0x38cd86,0x709)){var _0x6de696=_[_0xf333('0x4c')](_0x2bb816,{'sectionId':0x709});return getPlugins(_0x6de696)[_0xf333('0x2a')](function(_0x237774){if(_0x6de696['enabled']){return _[_0xf333('0x31')](_0x2bb816,function(_0x338446){if(_0x338446['sectionId']===0x709){_0x338446['subsections']=_0x237774;}return _0x338446;});}else{var _0x21b7cd={'sectionId':0x76c,'enabled':0x1,'subsections':_0x237774};var _0x5ad2ed=_[_0xf333('0x31')](_0x2bb816);_0x5ad2ed['push'](_0x21b7cd);return _0x5ad2ed;}});}else{return;}})[_0xf333('0x2a')](function(_0x34d5c9){if(_0x34d5c9)_0x2bb816=_0x34d5c9;return _['filter'](_0x2bb816,[_0xf333('0x67'),0x1]);})['then'](respondWithResult(_0x443126,null))['catch'](handleError(_0x443126,null));};function hasDefaultDashboard(_0x3b129d){var _0x481b25=[0x65];return new BPromise(function(_0x124596,_0x59c54d){try{if(_0x3b129d[_0xf333('0x58')]){_0x124596(_0x481b25);}else{return db[_0xf333('0x59')][_0xf333('0x69')]({'where':{'sectionId':_0x3b129d['id']},'raw':!![]})[_0xf333('0x2a')](function(_0x2890ec){_0x2890ec?_0x124596(_0x481b25):_0x124596();});}}catch(_0x102fac){_0x59c54d(_0x102fac);}});}function getCustomDashboards(_0x1091a7){var _0x522726=[];return new BPromise(function(_0x246f57,_0x337e28){try{if(_0x1091a7[_0xf333('0x58')]){return db['Dashboard']['findAll']({'raw':!![]})[_0xf333('0x2a')](function(_0x2e8633){_0x2e8633['forEach'](function(_0x2b8e28){_0x522726[_0xf333('0x61')](_0x2b8e28['id']+0x1869f);});_0x246f57(_0x522726);});}else{return db[_0xf333('0x59')][_0xf333('0x46')]({'where':{'sectionId':_0x1091a7['id']},'raw':!![]})[_0xf333('0x2a')](function(_0x275a52){_0x275a52[_0xf333('0x6a')](function(_0xfca9b9){_0x522726[_0xf333('0x61')](_0xfca9b9['resourceId']+0x1869f);});_0x246f57(_0x522726);});}}catch(_0x5c2066){_0x337e28(_0x5c2066);}});}function getPlugins(_0x820b84){var _0x227702=[];return new BPromise(function(_0xdc57fc,_0x3330f9){try{if(_0x820b84[_0xf333('0x58')]){return db[_0xf333('0x6b')][_0xf333('0x46')]({'raw':!![]})['then'](function(_0x137793){_0x137793[_0xf333('0x6a')](function(_0x2c8584){_0x227702[_0xf333('0x61')](_0x2c8584['id']+0x15b38);});_0xdc57fc(_0x227702);});}else{return db[_0xf333('0x59')][_0xf333('0x46')]({'where':{'sectionId':_0x820b84['id']},'raw':!![]})[_0xf333('0x2a')](function(_0x3b2bd7){_0x3b2bd7['forEach'](function(_0x13e3b6){_0x227702[_0xf333('0x61')](_0x13e3b6[_0xf333('0x6c')]+0x15b38);});_0xdc57fc(_0x227702);});}}catch(_0x218b7e){_0x3330f9(_0x218b7e);}});}exports[_0xf333('0x6d')]=function(_0x409d21,_0x13d172){return db[_0xf333('0x32')]['find']({'where':{'id':_0x409d21[_0xf333('0x49')]['id']}})['then'](handleEntityNotFound(_0x13d172,null))['then'](function(_0x3c1834){if(_0x3c1834){return db[_0xf333('0x60')][_0xf333('0x55')](function(_0x3b937a){return db['UserProfileSection'][_0xf333('0x46')]({'where':{'userProfileId':_0x409d21['params']['id']},'attributes':['id'],'raw':!![]})[_0xf333('0x2a')](function(_0xd01af6){if(_0xd01af6){return db[_0xf333('0x5c')][_0xf333('0x2b')]({'where':{'userProfileId':_0x409d21['params']['id'],'id':_[_0xf333('0x31')](_0xd01af6,function(_0x527b8e){return _0x527b8e['id'];})},'transaction':_0x3b937a});}})['then'](function(_0x4d951c){var _0x4019d2=_[_0xf333('0x31')](_0x409d21[_0xf333('0x4e')],function(_0x48925d){_0x48925d[_0xf333('0x5b')]=_0x409d21[_0xf333('0x49')]['id'];return _0x48925d;});return db[_0xf333('0x5c')][_0xf333('0x6e')](_0x4019d2,{'raw':!![],'transaction':_0x3b937a});})['then'](function(_0x5967b6){var _0x5409f5=_[_0xf333('0x42')](_[_0xf333('0x31')](_0x5967b6,function(_0x41aeae){return _0x41aeae[_0xf333('0x50')]({'plain':!![]});}),{'includeAll':![]});if(_0x5409f5){return db[_0xf333('0x5c')][_0xf333('0x46')]({'where':{'userProfileId':_0x409d21[_0xf333('0x49')]['id'],'sectionId':_[_0xf333('0x31')](_0x5409f5,function(_0x808b1b){return _0x808b1b[_0xf333('0x5a')];})},'attributes':['id',_0xf333('0x5a')],'raw':!![]})['then'](function(_0x91de91){var _0x4bf241=_[_0xf333('0x31')](_0x409d21[_0xf333('0x4e')],function(_0x531655){_0x531655[_0xf333('0x5b')]=_0x409d21[_0xf333('0x49')]['id'];return _0x531655;});return db[_0xf333('0x59')][_0xf333('0x6e')](_0x4bf241,{'raw':!![],'transaction':_0x3b937a});});}})[_0xf333('0x47')](handleError(_0x13d172,null));});}})[_0xf333('0x2a')](function(_0x13bb75){var _0x595858=_[_0xf333('0x31')](_0x13bb75,function(_0x49c5ef){return _0x49c5ef['get']({'plain':!![]});});})[_0xf333('0x2a')](respondWithResult(_0x13d172,null))[_0xf333('0x47')](handleError(_0x13d172,null));};exports[_0xf333('0x6f')]=function(_0x3e76a7,_0x4f7b22,_0xc2c571){return db[_0xf333('0x32')][_0xf333('0x4c')]({'where':{'id':_0x3e76a7[_0xf333('0x49')]['id']}})['then'](handleEntityNotFound(_0x4f7b22,null))[_0xf333('0x2a')](function(_0x3f151c){if(_0x3f151c){return _0x3f151c[_0xf333('0x6f')](_0x3e76a7[_0xf333('0x36')][_0xf333('0x63')]);}})['then'](respondWithStatusCode(_0x4f7b22,null))[_0xf333('0x47')](handleError(_0x4f7b22,null));};exports['getResources']=function(_0x3164b1,_0x14c8d4){var _0x11e9a8={};if(!_0x3164b1[_0xf333('0x36')]['section'])throw new Error(_0xf333('0x70'));if(!_0x3164b1[_0xf333('0x36')][_0xf333('0x3b')](_0xf333('0x3c'))){_0x11e9a8[_0xf333('0x26')]=qs['limit'](_0x3164b1[_0xf333('0x36')]['limit']);_0x11e9a8[_0xf333('0x23')]=qs[_0xf333('0x23')](_0x3164b1[_0xf333('0x36')][_0xf333('0x23')]);}return db[_0xf333('0x32')]['find']({'where':{'id':_0x3164b1[_0xf333('0x49')]['id']}})[_0xf333('0x2a')](function(_0x34edd0){if(!_0x34edd0)throw new Error(_0xf333('0x71')+_0x3164b1[_0xf333('0x49')]['id']);return db[_0xf333('0x32')][_0xf333('0x72')](_0x3164b1);})[_0xf333('0x2a')](respondWithFilteredResult(_0x14c8d4,_0x11e9a8))[_0xf333('0x47')](handleError(_0x14c8d4,null));};
\ No newline at end of file
+var _0x1d72=['error','stack','name','index','map','rawAttributes','fieldName','type','model','query','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','merge','VIRTUAL','filter','includeAll','include','findAll','rows','catch','params','keys','UserProfile','options','find','create','clone','length','createdAt','updatedAt','crudPermissions','body','omit','sequelize','transaction','UserProfileSection','each','autoAssociation','UserProfileResource','sectionId','userProfileId','Resources','update','addSections','push','removeSections','getSections','enabled','includes','subsections','concat','findOne','Dashboard','forEach','bulkCreate','get','removeResources','ids','getResources','Missing\x20section\x20parameter','nolimit','No\x20User\x20Profile\x20found\x20for\x20id\x20','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./userProfile.socket','register','sendStatus','status','end','offset','undefined','limit','count','set','json','save','then','destroy'];(function(_0x1d2864,_0x5d90b0){var _0x110055=function(_0x6e081b){while(--_0x6e081b){_0x1d2864['push'](_0x1d2864['shift']());}};_0x110055(++_0x5d90b0);}(_0x1d72,0x11e));var _0x21d7=function(_0x5d8097,_0x3f2cc4){_0x5d8097=_0x5d8097-0x0;var _0x46c98d=_0x1d72[_0x5d8097];return _0x46c98d;};'use strict';var emlformat=require(_0x21d7('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x21d7('0x1'));var jsonpatch=require(_0x21d7('0x2'));var rp=require(_0x21d7('0x3'));var moment=require(_0x21d7('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x21d7('0x5'));var util=require('util');var path=require('path');var sox=require(_0x21d7('0x6'));var csv=require(_0x21d7('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x21d7('0x8'));var _=require(_0x21d7('0x9'));var squel=require(_0x21d7('0xa'));var crypto=require(_0x21d7('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x21d7('0xc'));var toCsv=require(_0x21d7('0x7'));var querystring=require(_0x21d7('0xd'));var Papa=require(_0x21d7('0xe'));var Redis=require('ioredis');var authService=require(_0x21d7('0xf'));var qs=require(_0x21d7('0x10'));var as=require(_0x21d7('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x21d7('0x12'))(_0x21d7('0x13'));var utils=require(_0x21d7('0x14'));var config=require(_0x21d7('0x15'));var licenseUtil=require(_0x21d7('0x16'));var db=require(_0x21d7('0x17'))['db'];config['redis']=_['defaults'](config[_0x21d7('0x18')],{'host':_0x21d7('0x19'),'port':0x18eb});var socket=require(_0x21d7('0x1a'))(new Redis(config[_0x21d7('0x18')]));require(_0x21d7('0x1b'))[_0x21d7('0x1c')](socket);function respondWithStatusCode(_0xe3e44d,_0x56e708){_0x56e708=_0x56e708||0xcc;return function(_0x1f6976){if(_0x1f6976){return _0xe3e44d[_0x21d7('0x1d')](_0x56e708);}return _0xe3e44d[_0x21d7('0x1e')](_0x56e708)[_0x21d7('0x1f')]();};}function respondWithResult(_0x36034f,_0x51803d){_0x51803d=_0x51803d||0xc8;return function(_0x2e2e2b){if(_0x2e2e2b){return _0x36034f[_0x21d7('0x1e')](_0x51803d)['json'](_0x2e2e2b);}};}function respondWithFilteredResult(_0x12207f,_0x603f62){return function(_0xc96868){if(_0xc96868){var _0x583d42=typeof _0x603f62[_0x21d7('0x20')]===_0x21d7('0x21')&&typeof _0x603f62[_0x21d7('0x22')]==='undefined';var _0x486f07=_0xc96868[_0x21d7('0x23')];var _0x52a48b=_0x583d42?0x0:_0x603f62['offset'];var _0xbab185=_0x583d42?_0xc96868[_0x21d7('0x23')]:_0x603f62[_0x21d7('0x20')]+_0x603f62[_0x21d7('0x22')];var _0xe2f608;if(_0xbab185>=_0x486f07){_0xbab185=_0x486f07;_0xe2f608=0xc8;}else{_0xe2f608=0xce;}_0x12207f[_0x21d7('0x1e')](_0xe2f608);return _0x12207f[_0x21d7('0x24')]('Content-Range',_0x52a48b+'-'+_0xbab185+'/'+_0x486f07)[_0x21d7('0x25')](_0xc96868);}return null;};}function patchUpdates(_0x27a5f2){return function(_0x11e862){try{jsonpatch['apply'](_0x11e862,_0x27a5f2,!![]);}catch(_0x4f4819){return BPromise['reject'](_0x4f4819);}return _0x11e862[_0x21d7('0x26')]();};}function saveUpdates(_0x4e3623,_0x47030e){return function(_0x222dc0){if(_0x222dc0){return _0x222dc0['update'](_0x4e3623)[_0x21d7('0x27')](function(_0x960533){return _0x960533;});}return null;};}function removeEntity(_0x2eb540,_0x30c55d){return function(_0xff331b){if(_0xff331b){return _0xff331b[_0x21d7('0x28')]()[_0x21d7('0x27')](function(){_0x2eb540[_0x21d7('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1b651c,_0x583ec3){return function(_0x2dad47){if(!_0x2dad47){_0x1b651c[_0x21d7('0x1d')](0x194);}return _0x2dad47;};}function handleError(_0x30eb2a,_0x13656e){_0x13656e=_0x13656e||0x1f4;return function(_0x59d201){logger[_0x21d7('0x29')](_0x59d201[_0x21d7('0x2a')]);if(_0x59d201['name']){delete _0x59d201[_0x21d7('0x2b')];}_0x30eb2a[_0x21d7('0x1e')](_0x13656e)['send'](_0x59d201);};}exports[_0x21d7('0x2c')]=function(_0x3ade6d,_0x48292a){var _0x3817f1={},_0x5d97ed={},_0x11f248={'count':0x0,'rows':[]};var _0x1c43b6=_[_0x21d7('0x2d')](db['UserProfile'][_0x21d7('0x2e')],function(_0x1fd5a6){return{'name':_0x1fd5a6[_0x21d7('0x2f')],'type':_0x1fd5a6[_0x21d7('0x30')]['key']};});_0x5d97ed[_0x21d7('0x31')]=_[_0x21d7('0x2d')](_0x1c43b6,_0x21d7('0x2b'));_0x5d97ed['query']=_['keys'](_0x3ade6d[_0x21d7('0x32')]);_0x5d97ed['filters']=_[_0x21d7('0x33')](_0x5d97ed['model'],_0x5d97ed[_0x21d7('0x32')]);_0x3817f1[_0x21d7('0x34')]=_[_0x21d7('0x33')](_0x5d97ed['model'],qs[_0x21d7('0x35')](_0x3ade6d[_0x21d7('0x32')]['fields']));_0x3817f1[_0x21d7('0x34')]=_0x3817f1['attributes']['length']?_0x3817f1[_0x21d7('0x34')]:_0x5d97ed[_0x21d7('0x31')];if(!_0x3ade6d[_0x21d7('0x32')][_0x21d7('0x36')]('nolimit')){_0x3817f1[_0x21d7('0x22')]=qs[_0x21d7('0x22')](_0x3ade6d[_0x21d7('0x32')][_0x21d7('0x22')]);_0x3817f1[_0x21d7('0x20')]=qs['offset'](_0x3ade6d[_0x21d7('0x32')][_0x21d7('0x20')]);}_0x3817f1[_0x21d7('0x37')]=qs[_0x21d7('0x38')](_0x3ade6d[_0x21d7('0x32')]['sort']);_0x3817f1[_0x21d7('0x39')]=qs[_0x21d7('0x3a')](_['pick'](_0x3ade6d[_0x21d7('0x32')],_0x5d97ed[_0x21d7('0x3a')]),_0x1c43b6);if(_0x3ade6d[_0x21d7('0x32')]['filter']){_0x3817f1[_0x21d7('0x39')]=_[_0x21d7('0x3b')](_0x3817f1[_0x21d7('0x39')],{'$or':_[_0x21d7('0x2d')](_0x1c43b6,function(_0x4e0366){if(_0x4e0366[_0x21d7('0x30')]!==_0x21d7('0x3c')){var _0xafe20c={};_0xafe20c[_0x4e0366[_0x21d7('0x2b')]]={'$like':'%'+_0x3ade6d[_0x21d7('0x32')][_0x21d7('0x3d')]+'%'};return _0xafe20c;}})});}_0x3817f1=_[_0x21d7('0x3b')]({},_0x3817f1,_0x3ade6d['options']);var _0x45a8c1={'where':_0x3817f1['where']};return db['UserProfile'][_0x21d7('0x23')](_0x45a8c1)['then'](function(_0x298fda){_0x11f248[_0x21d7('0x23')]=_0x298fda;if(_0x3ade6d[_0x21d7('0x32')][_0x21d7('0x3e')]){_0x3817f1[_0x21d7('0x3f')]=[{'all':!![]}];}return db['UserProfile'][_0x21d7('0x40')](_0x3817f1);})[_0x21d7('0x27')](function(_0x186413){_0x11f248[_0x21d7('0x41')]=_0x186413;return _0x11f248;})[_0x21d7('0x27')](respondWithFilteredResult(_0x48292a,_0x3817f1))[_0x21d7('0x42')](handleError(_0x48292a,null));};exports['show']=function(_0x2154ff,_0x4357a9){var _0x589d7f={'raw':![],'where':{'id':_0x2154ff[_0x21d7('0x43')]['id']}},_0x4084bb={};_0x4084bb[_0x21d7('0x31')]=_[_0x21d7('0x44')](db[_0x21d7('0x45')][_0x21d7('0x2e')]);_0x4084bb['query']=_['keys'](_0x2154ff[_0x21d7('0x32')]);_0x4084bb[_0x21d7('0x3a')]=_['intersection'](_0x4084bb[_0x21d7('0x31')],_0x4084bb[_0x21d7('0x32')]);_0x589d7f[_0x21d7('0x34')]=_[_0x21d7('0x33')](_0x4084bb['model'],qs[_0x21d7('0x35')](_0x2154ff[_0x21d7('0x32')]['fields']));_0x589d7f[_0x21d7('0x34')]=_0x589d7f[_0x21d7('0x34')]['length']?_0x589d7f['attributes']:_0x4084bb['model'];if(_0x2154ff[_0x21d7('0x32')]['includeAll']){_0x589d7f[_0x21d7('0x3f')]=[{'all':!![]}];}_0x589d7f=_[_0x21d7('0x3b')]({},_0x589d7f,_0x2154ff[_0x21d7('0x46')]);return db[_0x21d7('0x45')][_0x21d7('0x47')](_0x589d7f)['then'](handleEntityNotFound(_0x4357a9,null))[_0x21d7('0x27')](respondWithResult(_0x4357a9,null))[_0x21d7('0x42')](handleError(_0x4357a9,null));};exports[_0x21d7('0x48')]=function(_0x165f22,_0x30affe){return db[_0x21d7('0x45')][_0x21d7('0x48')](_0x165f22['body'],{})['then'](respondWithResult(_0x30affe,0xc9))['catch'](handleError(_0x30affe,null));};exports[_0x21d7('0x49')]=function(_0x49d362,_0xab387c){var _0x52d576={'where':{'id':_0x49d362[_0x21d7('0x43')]['id']}},_0x50bb84={};_0x50bb84['model']=_['keys'](db[_0x21d7('0x45')][_0x21d7('0x2e')]);_0x52d576['attributes']=_[_0x21d7('0x33')](_0x50bb84[_0x21d7('0x31')],qs[_0x21d7('0x35')](_0x49d362[_0x21d7('0x32')]['fields']));_0x52d576[_0x21d7('0x34')]=_0x52d576['attributes'][_0x21d7('0x4a')]?_0x52d576[_0x21d7('0x34')]:_0x50bb84['model'];if(_0x49d362[_0x21d7('0x32')][_0x21d7('0x3e')]){_0x52d576[_0x21d7('0x3f')]=[{'all':!![]}];}_0x52d576=_[_0x21d7('0x3b')]({},_0x52d576,_0x49d362['options']);return db[_0x21d7('0x45')]['find'](_0x52d576)[_0x21d7('0x27')](handleEntityNotFound(_0xab387c,null))[_0x21d7('0x27')](function(_0xdd02fa){if(_0xdd02fa){var _0x3b46e3=_0xdd02fa['get']({'plain':!![]});_0x3b46e3=qs['omit'](_0x3b46e3,['id',_0x21d7('0x4b'),_0x21d7('0x4c'),_0x21d7('0x4d')]);_0x49d362[_0x21d7('0x4e')]=_[_0x21d7('0x4f')](_0x49d362[_0x21d7('0x4e')],['id','createdAt','updatedAt']);return db[_0x21d7('0x50')][_0x21d7('0x51')](function(_0x55724b){return db[_0x21d7('0x45')][_0x21d7('0x48')](_['merge'](_0x3b46e3,_0x49d362[_0x21d7('0x4e')]),{'include':_0x49d362['query']['includeAll']?[{'all':!![]}]:undefined,'transaction':_0x55724b})[_0x21d7('0x27')](function(_0x2f7c49){var _0x1bff18=_0x2f7c49['get']({'plain':!![]});return db[_0x21d7('0x52')][_0x21d7('0x40')]({'where':{'userProfileId':_0x49d362[_0x21d7('0x43')]['id']},'raw':!![]})['then'](function(_0x53bebf){if(_0x53bebf){return BPromise[_0x21d7('0x53')](_0x53bebf,function(_0xdea5d5){return new BPromise(function(_0x23b1e3,_0x502868){if(_0xdea5d5[_0x21d7('0x54')]===null||_0xdea5d5[_0x21d7('0x54')]===0x1)_0x23b1e3(null);return db[_0x21d7('0x55')][_0x21d7('0x40')]({'where':{'sectionId':_0xdea5d5['id']},'raw':!![]})['then'](function(_0xd7fb92){var _0x302d7e=_[_0x21d7('0x2d')](_0xd7fb92,function(_0x44861d){return qs[_0x21d7('0x4f')](_0x44861d,['id',_0x21d7('0x4b'),_0x21d7('0x4c'),_0x21d7('0x56')]);});_0x23b1e3(_0x302d7e);})[_0x21d7('0x42')](function(_0x18caec){_0x502868(_0x18caec);});})['then'](function(_0x101aed){var _0x268107=qs[_0x21d7('0x4f')](_0xdea5d5,['id',_0x21d7('0x4b'),_0x21d7('0x4c')]);_0x268107[_0x21d7('0x57')]=_0x1bff18['id'];if(_0x101aed)_0x268107[_0x21d7('0x58')]=_0x101aed;return _0x268107;})[_0x21d7('0x27')](function(_0x3e005d){return db[_0x21d7('0x52')]['create'](_0x3e005d,{'include':[{'model':db[_0x21d7('0x55')],'as':_0x21d7('0x58')}],'raw':!![],'transaction':_0x55724b});});})[_0x21d7('0x27')](function(){return _0x1bff18;});}});});});}})[_0x21d7('0x27')](respondWithResult(_0xab387c,0xc9))[_0x21d7('0x42')](handleError(_0xab387c,null));};exports[_0x21d7('0x59')]=function(_0x507192,_0x391e7e){if(_0x507192[_0x21d7('0x4e')]['id']){delete _0x507192[_0x21d7('0x4e')]['id'];}return db[_0x21d7('0x45')]['find']({'where':{'id':_0x507192['params']['id']}})[_0x21d7('0x27')](handleEntityNotFound(_0x391e7e,null))['then'](saveUpdates(_0x507192[_0x21d7('0x4e')],null))[_0x21d7('0x27')](respondWithResult(_0x391e7e,null))[_0x21d7('0x42')](handleError(_0x391e7e,null));};exports[_0x21d7('0x28')]=function(_0x1aa5e9,_0x131be0){return db['UserProfile'][_0x21d7('0x47')]({'where':{'id':_0x1aa5e9[_0x21d7('0x43')]['id']}})[_0x21d7('0x27')](handleEntityNotFound(_0x131be0,null))[_0x21d7('0x27')](removeEntity(_0x131be0,null))[_0x21d7('0x42')](handleError(_0x131be0,null));};exports['describe']=function(_0x5e9ae9,_0x6ac745){return db['UserProfile']['describe']()['then'](respondWithResult(_0x6ac745,null))['catch'](handleError(_0x6ac745,null));};exports[_0x21d7('0x5a')]=function(_0x2b967e,_0x311647){var _0x273260=_0x2b967e[_0x21d7('0x4e')];return db[_0x21d7('0x45')]['find']({'where':{'id':_0x2b967e[_0x21d7('0x43')]['id']}})['then'](handleEntityNotFound(_0x311647,null))['then'](function(_0x5acff8){if(_0x5acff8){return db['sequelize'][_0x21d7('0x51')](function(_0x2005c9){return db[_0x21d7('0x52')]['destroy']({'where':{'userProfileId':_0x2b967e['params']['id'],'sectionId':_['map'](_0x273260,function(_0x222c76){return _0x222c76[_0x21d7('0x56')];})},'transaction':_0x2005c9})['then'](function(){var _0x21fc91=_[_0x21d7('0x2d')](_0x273260,function(_0x4aa047){_0x4aa047['userProfileId']=_0x2b967e['params']['id'];return _0x4aa047;});var _0x61bf9e=[];return BPromise[_0x21d7('0x53')](_0x21fc91,function(_0x3589be){return db['UserProfileSection'][_0x21d7('0x48')](_0x3589be,{'include':[{'model':db[_0x21d7('0x55')],'as':_0x21d7('0x58')}],'raw':!![],'transaction':_0x2005c9})[_0x21d7('0x27')](function(_0x530fde){_0x61bf9e[_0x21d7('0x5b')](_0x530fde['get']({'plain':!![]}));});})[_0x21d7('0x27')](function(){return _0x61bf9e;});});});}})[_0x21d7('0x27')](function(_0x36661b){return _0x36661b;})[_0x21d7('0x27')](respondWithResult(_0x311647,null))['catch'](handleError(_0x311647,null));};exports[_0x21d7('0x5c')]=function(_0x3563e2,_0xe4a911){var _0x3cbb89;return db[_0x21d7('0x45')][_0x21d7('0x47')]({'where':{'id':_0x3563e2[_0x21d7('0x43')]['id']},'attributes':['id',_0x21d7('0x2b')]})[_0x21d7('0x27')](handleEntityNotFound(_0xe4a911,null))[_0x21d7('0x27')](function(_0x5ba16e){if(_0x5ba16e){_0x3cbb89=_0x5ba16e;return db[_0x21d7('0x52')]['destroy']({'where':{'userProfileId':_0x3563e2[_0x21d7('0x43')]['id'],'sectionId':_0x3563e2[_0x21d7('0x32')]['ids']}});}})[_0x21d7('0x27')](function(){return _0x3cbb89;})[_0x21d7('0x27')](respondWithStatusCode(_0xe4a911,null))[_0x21d7('0x42')](handleError(_0xe4a911,null));};exports[_0x21d7('0x5d')]=function(_0x24efb4,_0x3fddd1){var _0x2a4447=[];var _0x1e560a=[];return db['UserProfileSection'][_0x21d7('0x40')]({'where':{'userProfileId':_0x24efb4[_0x21d7('0x43')]['id']},'raw':!![]})[_0x21d7('0x27')](function(_0x5da463){_0x2a4447=_[_0x21d7('0x3d')](_0x5da463,function(_0x74a875){return _0x74a875[_0x21d7('0x5e')]===0x1||_[_0x21d7('0x5f')]([0x3eb,0x709],_0x74a875[_0x21d7('0x56')]);});if(!_['isEmpty'](_0x2a4447)){return _[_0x21d7('0x2d')](_0x2a4447,function(_0x145e5a){return _0x145e5a['sectionId'];});}else{return;}})[_0x21d7('0x27')](function(_0x40f427){if(_0x40f427)_0x1e560a=_0x40f427;if(_[_0x21d7('0x5f')](_0x1e560a,0x64)){var _0x31f1de=_[_0x21d7('0x47')](_0x2a4447,{'sectionId':0x64});return hasDefaultDashboard(_0x31f1de)[_0x21d7('0x27')](function(_0x5de256){return _[_0x21d7('0x2d')](_0x2a4447,function(_0x26fc2d){if(_0x26fc2d[_0x21d7('0x56')]===0x64){_0x26fc2d[_0x21d7('0x60')]=_0x5de256;}return _0x26fc2d;});});}else{return;}})['then'](function(_0x5704b4){if(_0x5704b4)_0x2a4447=_0x5704b4;if(_[_0x21d7('0x5f')](_0x1e560a,0x3eb)){var _0x9a0236=_[_0x21d7('0x47')](_0x2a4447,{'sectionId':0x3eb});return getCustomDashboards(_0x9a0236)[_0x21d7('0x27')](function(_0x534bca){return _[_0x21d7('0x2d')](_0x2a4447,function(_0x58e948){if(_0x9a0236['enabled']){if(_0x58e948[_0x21d7('0x56')]===0x3eb){_0x58e948[_0x21d7('0x60')]=_0x534bca;}}else{if(_0x58e948[_0x21d7('0x56')]===0x64){if(!_0x58e948[_0x21d7('0x60')]){_0x58e948[_0x21d7('0x60')]=[];}_0x58e948['subsections']=_0x58e948[_0x21d7('0x60')][_0x21d7('0x61')](_0x534bca);}}return _0x58e948;});});}else{return;}})[_0x21d7('0x27')](function(_0x1103e8){if(_0x1103e8)_0x2a4447=_0x1103e8;if(_[_0x21d7('0x5f')](_0x1e560a,0x709)){var _0x20a1de=_[_0x21d7('0x47')](_0x2a4447,{'sectionId':0x709});return getPlugins(_0x20a1de)[_0x21d7('0x27')](function(_0x4a515f){if(_0x20a1de[_0x21d7('0x5e')]){return _['map'](_0x2a4447,function(_0x37d4af){if(_0x37d4af[_0x21d7('0x56')]===0x709){_0x37d4af['subsections']=_0x4a515f;}return _0x37d4af;});}else{var _0x4897d9={'sectionId':0x76c,'enabled':0x1,'subsections':_0x4a515f};var _0x2079b4=_['map'](_0x2a4447);_0x2079b4['push'](_0x4897d9);return _0x2079b4;}});}else{return;}})[_0x21d7('0x27')](function(_0x47dcbb){if(_0x47dcbb)_0x2a4447=_0x47dcbb;return _[_0x21d7('0x3d')](_0x2a4447,[_0x21d7('0x5e'),0x1]);})[_0x21d7('0x27')](respondWithResult(_0x3fddd1,null))[_0x21d7('0x42')](handleError(_0x3fddd1,null));};function hasDefaultDashboard(_0x1ecc02){var _0x2a6305=[0x65];return new BPromise(function(_0x137dc1,_0x1b2657){try{if(_0x1ecc02[_0x21d7('0x54')]){_0x137dc1(_0x2a6305);}else{return db[_0x21d7('0x55')][_0x21d7('0x62')]({'where':{'sectionId':_0x1ecc02['id']},'raw':!![]})[_0x21d7('0x27')](function(_0x166d56){_0x166d56?_0x137dc1(_0x2a6305):_0x137dc1();});}}catch(_0x4ce6bf){_0x1b2657(_0x4ce6bf);}});}function getCustomDashboards(_0x86f96b){var _0x112167=[];return new BPromise(function(_0x276c34,_0x166d68){try{if(_0x86f96b[_0x21d7('0x54')]){return db[_0x21d7('0x63')][_0x21d7('0x40')]({'raw':!![]})[_0x21d7('0x27')](function(_0x398218){_0x398218[_0x21d7('0x64')](function(_0x4bec75){_0x112167['push'](_0x4bec75['id']+0x1869f);});_0x276c34(_0x112167);});}else{return db[_0x21d7('0x55')][_0x21d7('0x40')]({'where':{'sectionId':_0x86f96b['id']},'raw':!![]})[_0x21d7('0x27')](function(_0x5821b9){_0x5821b9['forEach'](function(_0x58e563){_0x112167[_0x21d7('0x5b')](_0x58e563['resourceId']+0x1869f);});_0x276c34(_0x112167);});}}catch(_0x359676){_0x166d68(_0x359676);}});}function getPlugins(_0x455774){var _0x2e0331=[];return new BPromise(function(_0x3da2bd,_0x2d9c12){try{if(_0x455774['autoAssociation']){return db['Plugin']['findAll']({'raw':!![]})[_0x21d7('0x27')](function(_0x417ef6){_0x417ef6[_0x21d7('0x64')](function(_0xd4e6a1){_0x2e0331[_0x21d7('0x5b')](_0xd4e6a1['id']+0x15b38);});_0x3da2bd(_0x2e0331);});}else{return db[_0x21d7('0x55')][_0x21d7('0x40')]({'where':{'sectionId':_0x455774['id']},'raw':!![]})[_0x21d7('0x27')](function(_0x39d890){_0x39d890['forEach'](function(_0x22694e){_0x2e0331[_0x21d7('0x5b')](_0x22694e['resourceId']+0x15b38);});_0x3da2bd(_0x2e0331);});}}catch(_0x1b6084){_0x2d9c12(_0x1b6084);}});}exports['addResources']=function(_0x372cf3,_0x51ebfc){return db[_0x21d7('0x45')]['find']({'where':{'id':_0x372cf3[_0x21d7('0x43')]['id']}})[_0x21d7('0x27')](handleEntityNotFound(_0x51ebfc,null))[_0x21d7('0x27')](function(_0x4d934f){if(_0x4d934f){return db['sequelize'][_0x21d7('0x51')](function(_0x916ced){return db[_0x21d7('0x52')]['findAll']({'where':{'userProfileId':_0x372cf3[_0x21d7('0x43')]['id']},'attributes':['id'],'raw':!![]})['then'](function(_0x31bb32){if(_0x31bb32){return db[_0x21d7('0x52')][_0x21d7('0x28')]({'where':{'userProfileId':_0x372cf3[_0x21d7('0x43')]['id'],'id':_[_0x21d7('0x2d')](_0x31bb32,function(_0x30018a){return _0x30018a['id'];})},'transaction':_0x916ced});}})[_0x21d7('0x27')](function(_0x1b441c){var _0x250a6d=_[_0x21d7('0x2d')](_0x372cf3['body'],function(_0x1d4c89){_0x1d4c89[_0x21d7('0x57')]=_0x372cf3[_0x21d7('0x43')]['id'];return _0x1d4c89;});return db[_0x21d7('0x52')][_0x21d7('0x65')](_0x250a6d,{'raw':!![],'transaction':_0x916ced});})[_0x21d7('0x27')](function(_0xa58a04){var _0x2a638a=_[_0x21d7('0x3d')](_[_0x21d7('0x2d')](_0xa58a04,function(_0x24d37a){return _0x24d37a['get']({'plain':!![]});}),{'includeAll':![]});if(_0x2a638a){return db[_0x21d7('0x52')][_0x21d7('0x40')]({'where':{'userProfileId':_0x372cf3[_0x21d7('0x43')]['id'],'sectionId':_[_0x21d7('0x2d')](_0x2a638a,function(_0x39ddc6){return _0x39ddc6[_0x21d7('0x56')];})},'attributes':['id',_0x21d7('0x56')],'raw':!![]})[_0x21d7('0x27')](function(_0x12759a){var _0x283930=_[_0x21d7('0x2d')](_0x372cf3['body'],function(_0xa489c6){_0xa489c6[_0x21d7('0x57')]=_0x372cf3[_0x21d7('0x43')]['id'];return _0xa489c6;});return db[_0x21d7('0x55')][_0x21d7('0x65')](_0x283930,{'raw':!![],'transaction':_0x916ced});});}})['catch'](handleError(_0x51ebfc,null));});}})['then'](function(_0x3989af){var _0x53799a=_['map'](_0x3989af,function(_0x31538c){return _0x31538c[_0x21d7('0x66')]({'plain':!![]});});})[_0x21d7('0x27')](respondWithResult(_0x51ebfc,null))['catch'](handleError(_0x51ebfc,null));};exports[_0x21d7('0x67')]=function(_0x33325e,_0x21f2fe,_0x55016d){return db[_0x21d7('0x45')][_0x21d7('0x47')]({'where':{'id':_0x33325e[_0x21d7('0x43')]['id']}})[_0x21d7('0x27')](handleEntityNotFound(_0x21f2fe,null))[_0x21d7('0x27')](function(_0x324b6e){if(_0x324b6e){return _0x324b6e[_0x21d7('0x67')](_0x33325e[_0x21d7('0x32')][_0x21d7('0x68')]);}})[_0x21d7('0x27')](respondWithStatusCode(_0x21f2fe,null))[_0x21d7('0x42')](handleError(_0x21f2fe,null));};exports[_0x21d7('0x69')]=function(_0x5cc700,_0x3a6f28){var _0x44632b={};if(!_0x5cc700['query']['section'])throw new Error(_0x21d7('0x6a'));if(!_0x5cc700[_0x21d7('0x32')][_0x21d7('0x36')](_0x21d7('0x6b'))){_0x44632b[_0x21d7('0x22')]=qs[_0x21d7('0x22')](_0x5cc700[_0x21d7('0x32')]['limit']);_0x44632b[_0x21d7('0x20')]=qs['offset'](_0x5cc700[_0x21d7('0x32')][_0x21d7('0x20')]);}return db[_0x21d7('0x45')][_0x21d7('0x47')]({'where':{'id':_0x5cc700[_0x21d7('0x43')]['id']}})[_0x21d7('0x27')](function(_0x1e2918){if(!_0x1e2918)throw new Error(_0x21d7('0x6c')+_0x5cc700[_0x21d7('0x43')]['id']);return db['UserProfile'][_0x21d7('0x69')](_0x5cc700);})[_0x21d7('0x27')](respondWithFilteredResult(_0x3a6f28,_0x44632b))[_0x21d7('0x42')](handleError(_0x3a6f28,null));};
\ No newline at end of file