Built motion from commit a8c4dd89.|2.6.33
[motion2.git] / server / api / userProfile / userProfile.controller.js
index 1b060ae..d8689e1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x329f=['body','clone','params','get','omit','updatedAt','crudPermissions','sequelize','transaction','UserProfileSection','each','autoAssociation','UserProfileResource','createdAt','sectionId','userProfileId','Resources','update','describe','addSections','push','removeSections','getSections','enabled','includes','subsections','concat','findOne','Dashboard','forEach','resourceId','addResources','bulkCreate','removeResources','ids','getResources','section','rimraf','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./userProfile.socket','register','status','end','offset','undefined','limit','count','set','Content-Range','reject','then','destroy','error','stack','send','map','UserProfile','fieldName','model','name','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','type','VIRTUAL','options','include','findAll','show','rawAttributes','includeAll','find','catch','create'];(function(_0x3f2f03,_0x288d96){var _0x219656=function(_0x343594){while(--_0x343594){_0x3f2f03['push'](_0x3f2f03['shift']());}};_0x219656(++_0x288d96);}(_0x329f,0x1d1));var _0xf329=function(_0x29f2d2,_0x34b451){_0x29f2d2=_0x29f2d2-0x0;var _0xc6ad58=_0x329f[_0x29f2d2];return _0xc6ad58;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf329('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xf329('0x1'));var BPromise=require(_0xf329('0x2'));var Mustache=require(_0xf329('0x3'));var util=require('util');var path=require(_0xf329('0x4'));var sox=require('sox');var csv=require(_0xf329('0x5'));var ejs=require(_0xf329('0x6'));var fs=require('fs');var fs_extra=require(_0xf329('0x7'));var _=require('lodash');var squel=require(_0xf329('0x8'));var crypto=require(_0xf329('0x9'));var jsforce=require(_0xf329('0xa'));var deskjs=require('desk.js');var toCsv=require(_0xf329('0x5'));var querystring=require(_0xf329('0xb'));var Papa=require(_0xf329('0xc'));var Redis=require('ioredis');var authService=require(_0xf329('0xd'));var qs=require(_0xf329('0xe'));var as=require(_0xf329('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xf329('0x10'));var utils=require(_0xf329('0x11'));var config=require(_0xf329('0x12'));var licenseUtil=require('../../config/license/util');var db=require(_0xf329('0x13'))['db'];config['redis']=_[_0xf329('0x14')](config[_0xf329('0x15')],{'host':_0xf329('0x16'),'port':0x18eb});var socket=require(_0xf329('0x17'))(new Redis(config['redis']));require(_0xf329('0x18'))[_0xf329('0x19')](socket);function respondWithStatusCode(_0x23f365,_0x455aae){_0x455aae=_0x455aae||0xcc;return function(_0x54377c){if(_0x54377c){return _0x23f365['sendStatus'](_0x455aae);}return _0x23f365[_0xf329('0x1a')](_0x455aae)[_0xf329('0x1b')]();};}function respondWithResult(_0x313a1f,_0x33d247){_0x33d247=_0x33d247||0xc8;return function(_0x281905){if(_0x281905){return _0x313a1f['status'](_0x33d247)['json'](_0x281905);}};}function respondWithFilteredResult(_0x5270ba,_0x549e60){return function(_0xd4ca0e){if(_0xd4ca0e){var _0x2aad37=typeof _0x549e60[_0xf329('0x1c')]===_0xf329('0x1d')&&typeof _0x549e60[_0xf329('0x1e')]===_0xf329('0x1d');var _0x4bfa3e=_0xd4ca0e[_0xf329('0x1f')];var _0x5e350a=_0x2aad37?0x0:_0x549e60[_0xf329('0x1c')];var _0x3b0746=_0x2aad37?_0xd4ca0e[_0xf329('0x1f')]:_0x549e60['offset']+_0x549e60[_0xf329('0x1e')];var _0xe4e8f9;if(_0x3b0746>=_0x4bfa3e){_0x3b0746=_0x4bfa3e;_0xe4e8f9=0xc8;}else{_0xe4e8f9=0xce;}_0x5270ba[_0xf329('0x1a')](_0xe4e8f9);return _0x5270ba[_0xf329('0x20')](_0xf329('0x21'),_0x5e350a+'-'+_0x3b0746+'/'+_0x4bfa3e)['json'](_0xd4ca0e);}return null;};}function patchUpdates(_0x1e4588){return function(_0x4331b7){try{jsonpatch['apply'](_0x4331b7,_0x1e4588,!![]);}catch(_0x3bb3d1){return BPromise[_0xf329('0x22')](_0x3bb3d1);}return _0x4331b7['save']();};}function saveUpdates(_0x2aacfc,_0x324b5a){return function(_0x47d0e8){if(_0x47d0e8){return _0x47d0e8['update'](_0x2aacfc)[_0xf329('0x23')](function(_0x5612c8){return _0x5612c8;});}return null;};}function removeEntity(_0x80f9c9,_0x26d240){return function(_0x48b56e){if(_0x48b56e){return _0x48b56e[_0xf329('0x24')]()[_0xf329('0x23')](function(){_0x80f9c9[_0xf329('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1bdbdc,_0x3ff12e){return function(_0x13f605){if(!_0x13f605){_0x1bdbdc['sendStatus'](0x194);}return _0x13f605;};}function handleError(_0x4b80,_0x194de6){_0x194de6=_0x194de6||0x1f4;return function(_0x907f65){logger[_0xf329('0x25')](_0x907f65[_0xf329('0x26')]);if(_0x907f65['name']){delete _0x907f65['name'];}_0x4b80[_0xf329('0x1a')](_0x194de6)[_0xf329('0x27')](_0x907f65);};}exports['index']=function(_0x47c8ce,_0x460140){var _0x55cfb1={},_0x6da880={},_0x3d2054={'count':0x0,'rows':[]};var _0x1b98e6=_[_0xf329('0x28')](db[_0xf329('0x29')]['rawAttributes'],function(_0x161b86){return{'name':_0x161b86[_0xf329('0x2a')],'type':_0x161b86['type']['key']};});_0x6da880[_0xf329('0x2b')]=_[_0xf329('0x28')](_0x1b98e6,_0xf329('0x2c'));_0x6da880[_0xf329('0x2d')]=_[_0xf329('0x2e')](_0x47c8ce[_0xf329('0x2d')]);_0x6da880[_0xf329('0x2f')]=_[_0xf329('0x30')](_0x6da880[_0xf329('0x2b')],_0x6da880['query']);_0x55cfb1[_0xf329('0x31')]=_['intersection'](_0x6da880[_0xf329('0x2b')],qs[_0xf329('0x32')](_0x47c8ce['query'][_0xf329('0x32')]));_0x55cfb1['attributes']=_0x55cfb1[_0xf329('0x31')][_0xf329('0x33')]?_0x55cfb1[_0xf329('0x31')]:_0x6da880[_0xf329('0x2b')];if(!_0x47c8ce[_0xf329('0x2d')][_0xf329('0x34')](_0xf329('0x35'))){_0x55cfb1[_0xf329('0x1e')]=qs[_0xf329('0x1e')](_0x47c8ce[_0xf329('0x2d')][_0xf329('0x1e')]);_0x55cfb1['offset']=qs[_0xf329('0x1c')](_0x47c8ce['query'][_0xf329('0x1c')]);}_0x55cfb1['order']=qs['sort'](_0x47c8ce['query'][_0xf329('0x36')]);_0x55cfb1[_0xf329('0x37')]=qs[_0xf329('0x2f')](_[_0xf329('0x38')](_0x47c8ce['query'],_0x6da880[_0xf329('0x2f')]),_0x1b98e6);if(_0x47c8ce[_0xf329('0x2d')][_0xf329('0x39')]){_0x55cfb1[_0xf329('0x37')]=_[_0xf329('0x3a')](_0x55cfb1['where'],{'$or':_['map'](_0x1b98e6,function(_0x1e5ee0){if(_0x1e5ee0[_0xf329('0x3b')]!==_0xf329('0x3c')){var _0x253ab9={};_0x253ab9[_0x1e5ee0['name']]={'$like':'%'+_0x47c8ce[_0xf329('0x2d')]['filter']+'%'};return _0x253ab9;}})});}_0x55cfb1=_['merge']({},_0x55cfb1,_0x47c8ce[_0xf329('0x3d')]);var _0x8c0d6={'where':_0x55cfb1[_0xf329('0x37')]};return db[_0xf329('0x29')][_0xf329('0x1f')](_0x8c0d6)[_0xf329('0x23')](function(_0xe6a24b){_0x3d2054[_0xf329('0x1f')]=_0xe6a24b;if(_0x47c8ce[_0xf329('0x2d')]['includeAll']){_0x55cfb1[_0xf329('0x3e')]=[{'all':!![]}];}return db['UserProfile'][_0xf329('0x3f')](_0x55cfb1);})[_0xf329('0x23')](function(_0x17906a){_0x3d2054['rows']=_0x17906a;return _0x3d2054;})['then'](respondWithFilteredResult(_0x460140,_0x55cfb1))['catch'](handleError(_0x460140,null));};exports[_0xf329('0x40')]=function(_0xe7566e,_0x2c9d6e){var _0xb1d742={'raw':![],'where':{'id':_0xe7566e['params']['id']}},_0x168233={};_0x168233[_0xf329('0x2b')]=_[_0xf329('0x2e')](db[_0xf329('0x29')][_0xf329('0x41')]);_0x168233[_0xf329('0x2d')]=_[_0xf329('0x2e')](_0xe7566e[_0xf329('0x2d')]);_0x168233[_0xf329('0x2f')]=_['intersection'](_0x168233[_0xf329('0x2b')],_0x168233[_0xf329('0x2d')]);_0xb1d742[_0xf329('0x31')]=_[_0xf329('0x30')](_0x168233['model'],qs[_0xf329('0x32')](_0xe7566e[_0xf329('0x2d')][_0xf329('0x32')]));_0xb1d742[_0xf329('0x31')]=_0xb1d742[_0xf329('0x31')]['length']?_0xb1d742[_0xf329('0x31')]:_0x168233[_0xf329('0x2b')];if(_0xe7566e[_0xf329('0x2d')][_0xf329('0x42')]){_0xb1d742['include']=[{'all':!![]}];}_0xb1d742=_['merge']({},_0xb1d742,_0xe7566e['options']);return db[_0xf329('0x29')][_0xf329('0x43')](_0xb1d742)[_0xf329('0x23')](handleEntityNotFound(_0x2c9d6e,null))[_0xf329('0x23')](respondWithResult(_0x2c9d6e,null))[_0xf329('0x44')](handleError(_0x2c9d6e,null));};exports[_0xf329('0x45')]=function(_0xa4865,_0x10aaac){return db[_0xf329('0x29')]['create'](_0xa4865[_0xf329('0x46')],{})['then'](respondWithResult(_0x10aaac,0xc9))[_0xf329('0x44')](handleError(_0x10aaac,null));};exports[_0xf329('0x47')]=function(_0x5dadd5,_0x2d6f0d){var _0x49c86a={'where':{'id':_0x5dadd5[_0xf329('0x48')]['id']}},_0x333c6d={};_0x333c6d[_0xf329('0x2b')]=_[_0xf329('0x2e')](db[_0xf329('0x29')]['rawAttributes']);_0x49c86a[_0xf329('0x31')]=_[_0xf329('0x30')](_0x333c6d[_0xf329('0x2b')],qs[_0xf329('0x32')](_0x5dadd5[_0xf329('0x2d')][_0xf329('0x32')]));_0x49c86a['attributes']=_0x49c86a['attributes'][_0xf329('0x33')]?_0x49c86a[_0xf329('0x31')]:_0x333c6d[_0xf329('0x2b')];if(_0x5dadd5[_0xf329('0x2d')][_0xf329('0x42')]){_0x49c86a['include']=[{'all':!![]}];}_0x49c86a=_[_0xf329('0x3a')]({},_0x49c86a,_0x5dadd5[_0xf329('0x3d')]);return db[_0xf329('0x29')][_0xf329('0x43')](_0x49c86a)['then'](handleEntityNotFound(_0x2d6f0d,null))[_0xf329('0x23')](function(_0x2156e4){if(_0x2156e4){var _0x591ec5=_0x2156e4[_0xf329('0x49')]({'plain':!![]});_0x591ec5=qs[_0xf329('0x4a')](_0x591ec5,['id','createdAt',_0xf329('0x4b'),_0xf329('0x4c')]);_0x5dadd5[_0xf329('0x46')]=_[_0xf329('0x4a')](_0x5dadd5[_0xf329('0x46')],['id','createdAt',_0xf329('0x4b')]);return db[_0xf329('0x4d')][_0xf329('0x4e')](function(_0x54fd02){return db[_0xf329('0x29')][_0xf329('0x45')](_[_0xf329('0x3a')](_0x591ec5,_0x5dadd5['body']),{'include':_0x5dadd5[_0xf329('0x2d')][_0xf329('0x42')]?[{'all':!![]}]:undefined,'transaction':_0x54fd02})[_0xf329('0x23')](function(_0x3b6929){var _0x1acb0c=_0x3b6929[_0xf329('0x49')]({'plain':!![]});return db[_0xf329('0x4f')][_0xf329('0x3f')]({'where':{'userProfileId':_0x5dadd5[_0xf329('0x48')]['id']},'raw':!![]})[_0xf329('0x23')](function(_0x3e0caf){if(_0x3e0caf){return BPromise[_0xf329('0x50')](_0x3e0caf,function(_0x59ab20){return new BPromise(function(_0x4ddf9b,_0x3edb54){if(_0x59ab20[_0xf329('0x51')]===null||_0x59ab20[_0xf329('0x51')]===0x1)_0x4ddf9b(null);return db[_0xf329('0x52')]['findAll']({'where':{'sectionId':_0x59ab20['id']},'raw':!![]})[_0xf329('0x23')](function(_0x19b56a){var _0x9d49b8=_[_0xf329('0x28')](_0x19b56a,function(_0x22f417){return qs[_0xf329('0x4a')](_0x22f417,['id',_0xf329('0x53'),_0xf329('0x4b'),_0xf329('0x54')]);});_0x4ddf9b(_0x9d49b8);})[_0xf329('0x44')](function(_0x434a69){_0x3edb54(_0x434a69);});})[_0xf329('0x23')](function(_0x1f453a){var _0x2d7e9a=qs['omit'](_0x59ab20,['id',_0xf329('0x53'),_0xf329('0x4b')]);_0x2d7e9a[_0xf329('0x55')]=_0x1acb0c['id'];if(_0x1f453a)_0x2d7e9a[_0xf329('0x56')]=_0x1f453a;return _0x2d7e9a;})[_0xf329('0x23')](function(_0x43ddd1){return db[_0xf329('0x4f')][_0xf329('0x45')](_0x43ddd1,{'include':[{'model':db[_0xf329('0x52')],'as':_0xf329('0x56')}],'raw':!![],'transaction':_0x54fd02});});})['then'](function(){return _0x1acb0c;});}});});});}})[_0xf329('0x23')](respondWithResult(_0x2d6f0d,0xc9))[_0xf329('0x44')](handleError(_0x2d6f0d,null));};exports[_0xf329('0x57')]=function(_0x599345,_0x4842cb){if(_0x599345['body']['id']){delete _0x599345[_0xf329('0x46')]['id'];}return db[_0xf329('0x29')][_0xf329('0x43')]({'where':{'id':_0x599345['params']['id']}})[_0xf329('0x23')](handleEntityNotFound(_0x4842cb,null))[_0xf329('0x23')](saveUpdates(_0x599345[_0xf329('0x46')],null))[_0xf329('0x23')](respondWithResult(_0x4842cb,null))[_0xf329('0x44')](handleError(_0x4842cb,null));};exports[_0xf329('0x24')]=function(_0x517e20,_0x3175d9){return db[_0xf329('0x29')][_0xf329('0x43')]({'where':{'id':_0x517e20[_0xf329('0x48')]['id']}})['then'](handleEntityNotFound(_0x3175d9,null))[_0xf329('0x23')](removeEntity(_0x3175d9,null))[_0xf329('0x44')](handleError(_0x3175d9,null));};exports['describe']=function(_0x3089d1,_0x3459c5){return db[_0xf329('0x29')][_0xf329('0x58')]()['then'](respondWithResult(_0x3459c5,null))['catch'](handleError(_0x3459c5,null));};exports[_0xf329('0x59')]=function(_0xb06ef7,_0x5a3941){var _0x37f7a0=_0xb06ef7[_0xf329('0x46')];return db[_0xf329('0x29')][_0xf329('0x43')]({'where':{'id':_0xb06ef7[_0xf329('0x48')]['id']}})['then'](handleEntityNotFound(_0x5a3941,null))[_0xf329('0x23')](function(_0x24809f){if(_0x24809f){return db['sequelize']['transaction'](function(_0x4110e8){return db['UserProfileSection']['destroy']({'where':{'userProfileId':_0xb06ef7[_0xf329('0x48')]['id'],'sectionId':_['map'](_0x37f7a0,function(_0x3d87bf){return _0x3d87bf['sectionId'];})},'transaction':_0x4110e8})['then'](function(){var _0x22556a=_['map'](_0x37f7a0,function(_0x493cd8){_0x493cd8[_0xf329('0x55')]=_0xb06ef7[_0xf329('0x48')]['id'];return _0x493cd8;});var _0x4121a4=[];return BPromise[_0xf329('0x50')](_0x22556a,function(_0x45594a){return db[_0xf329('0x4f')][_0xf329('0x45')](_0x45594a,{'include':[{'model':db[_0xf329('0x52')],'as':_0xf329('0x56')}],'raw':!![],'transaction':_0x4110e8})[_0xf329('0x23')](function(_0x261031){_0x4121a4[_0xf329('0x5a')](_0x261031[_0xf329('0x49')]({'plain':!![]}));});})['then'](function(){return _0x4121a4;});});});}})[_0xf329('0x23')](function(_0x3a6eb5){return _0x3a6eb5;})[_0xf329('0x23')](respondWithResult(_0x5a3941,null))[_0xf329('0x44')](handleError(_0x5a3941,null));};exports[_0xf329('0x5b')]=function(_0x283b06,_0x565acb){var _0x342046;return db[_0xf329('0x29')]['find']({'where':{'id':_0x283b06['params']['id']},'attributes':['id',_0xf329('0x2c')]})[_0xf329('0x23')](handleEntityNotFound(_0x565acb,null))[_0xf329('0x23')](function(_0x2a0357){if(_0x2a0357){_0x342046=_0x2a0357;return db[_0xf329('0x4f')][_0xf329('0x24')]({'where':{'userProfileId':_0x283b06[_0xf329('0x48')]['id'],'sectionId':_0x283b06[_0xf329('0x2d')]['ids']}});}})[_0xf329('0x23')](function(){return _0x342046;})[_0xf329('0x23')](respondWithStatusCode(_0x565acb,null))['catch'](handleError(_0x565acb,null));};exports[_0xf329('0x5c')]=function(_0x391c8a,_0xae62d7){var _0x1961af=[];var _0x698d0b=[];return db[_0xf329('0x4f')][_0xf329('0x3f')]({'where':{'userProfileId':_0x391c8a['params']['id']},'raw':!![]})['then'](function(_0x4414b1){_0x1961af=_[_0xf329('0x39')](_0x4414b1,function(_0x1f0ef5){return _0x1f0ef5[_0xf329('0x5d')]===0x1||_[_0xf329('0x5e')]([0x3eb,0x709],_0x1f0ef5[_0xf329('0x54')]);});if(!_['isEmpty'](_0x1961af)){return _[_0xf329('0x28')](_0x1961af,function(_0x3dac6a){return _0x3dac6a[_0xf329('0x54')];});}else{return;}})[_0xf329('0x23')](function(_0x3afcee){if(_0x3afcee)_0x698d0b=_0x3afcee;if(_[_0xf329('0x5e')](_0x698d0b,0x64)){var _0x48928a=_[_0xf329('0x43')](_0x1961af,{'sectionId':0x64});return hasDefaultDashboard(_0x48928a)[_0xf329('0x23')](function(_0xe76eeb){return _[_0xf329('0x28')](_0x1961af,function(_0x5bb5b8){if(_0x5bb5b8[_0xf329('0x54')]===0x64){_0x5bb5b8[_0xf329('0x5f')]=_0xe76eeb;}return _0x5bb5b8;});});}else{return;}})[_0xf329('0x23')](function(_0x56b8bb){if(_0x56b8bb)_0x1961af=_0x56b8bb;if(_[_0xf329('0x5e')](_0x698d0b,0x3eb)){var _0x11f47c=_[_0xf329('0x43')](_0x1961af,{'sectionId':0x3eb});return getCustomDashboards(_0x11f47c)[_0xf329('0x23')](function(_0x34884c){return _[_0xf329('0x28')](_0x1961af,function(_0x1ae43a){if(_0x11f47c[_0xf329('0x5d')]){if(_0x1ae43a[_0xf329('0x54')]===0x3eb){_0x1ae43a['subsections']=_0x34884c;}}else{if(_0x1ae43a[_0xf329('0x54')]===0x64){if(!_0x1ae43a[_0xf329('0x5f')]){_0x1ae43a[_0xf329('0x5f')]=[];}_0x1ae43a[_0xf329('0x5f')]=_0x1ae43a[_0xf329('0x5f')][_0xf329('0x60')](_0x34884c);}}return _0x1ae43a;});});}else{return;}})[_0xf329('0x23')](function(_0x486608){if(_0x486608)_0x1961af=_0x486608;if(_[_0xf329('0x5e')](_0x698d0b,0x709)){var _0x3fe830=_[_0xf329('0x43')](_0x1961af,{'sectionId':0x709});return getPlugins(_0x3fe830)[_0xf329('0x23')](function(_0x443e76){if(_0x3fe830[_0xf329('0x5d')]){return _[_0xf329('0x28')](_0x1961af,function(_0x3f7fb7){if(_0x3f7fb7['sectionId']===0x709){_0x3f7fb7[_0xf329('0x5f')]=_0x443e76;}return _0x3f7fb7;});}else{var _0x3a139a={'sectionId':0x76c,'enabled':0x1,'subsections':_0x443e76};var _0x8577fe=_[_0xf329('0x28')](_0x1961af);_0x8577fe['push'](_0x3a139a);return _0x8577fe;}});}else{return;}})['then'](function(_0x3e7125){if(_0x3e7125)_0x1961af=_0x3e7125;return _[_0xf329('0x39')](_0x1961af,['enabled',0x1]);})[_0xf329('0x23')](respondWithResult(_0xae62d7,null))[_0xf329('0x44')](handleError(_0xae62d7,null));};function hasDefaultDashboard(_0x470da1){var _0x352a0e=[0x65];return new BPromise(function(_0x1d4898,_0x3182ee){try{if(_0x470da1[_0xf329('0x51')]){_0x1d4898(_0x352a0e);}else{return db[_0xf329('0x52')][_0xf329('0x61')]({'where':{'sectionId':_0x470da1['id']},'raw':!![]})['then'](function(_0x33fb56){_0x33fb56?_0x1d4898(_0x352a0e):_0x1d4898();});}}catch(_0x369f41){_0x3182ee(_0x369f41);}});}function getCustomDashboards(_0x175289){var _0x1e3325=[];return new BPromise(function(_0x55055a,_0x37e1ab){try{if(_0x175289['autoAssociation']){return db[_0xf329('0x62')]['findAll']({'raw':!![]})[_0xf329('0x23')](function(_0x42024f){_0x42024f['forEach'](function(_0xfadf67){_0x1e3325[_0xf329('0x5a')](_0xfadf67['id']+0x1869f);});_0x55055a(_0x1e3325);});}else{return db['UserProfileResource'][_0xf329('0x3f')]({'where':{'sectionId':_0x175289['id']},'raw':!![]})[_0xf329('0x23')](function(_0x2d3761){_0x2d3761[_0xf329('0x63')](function(_0x208dfe){_0x1e3325['push'](_0x208dfe['resourceId']+0x1869f);});_0x55055a(_0x1e3325);});}}catch(_0x533a8d){_0x37e1ab(_0x533a8d);}});}function getPlugins(_0x5753a4){var _0x596209=[];return new BPromise(function(_0x22e6ae,_0x3846e1){try{if(_0x5753a4[_0xf329('0x51')]){return db['Plugin'][_0xf329('0x3f')]({'raw':!![]})['then'](function(_0xa357){_0xa357[_0xf329('0x63')](function(_0x2d4fda){_0x596209[_0xf329('0x5a')](_0x2d4fda['id']+0x15b38);});_0x22e6ae(_0x596209);});}else{return db[_0xf329('0x52')][_0xf329('0x3f')]({'where':{'sectionId':_0x5753a4['id']},'raw':!![]})['then'](function(_0x5a2b86){_0x5a2b86[_0xf329('0x63')](function(_0xe7581a){_0x596209[_0xf329('0x5a')](_0xe7581a[_0xf329('0x64')]+0x15b38);});_0x22e6ae(_0x596209);});}}catch(_0x18c19e){_0x3846e1(_0x18c19e);}});}exports[_0xf329('0x65')]=function(_0x2b3587,_0x46fec9){return db[_0xf329('0x29')]['find']({'where':{'id':_0x2b3587[_0xf329('0x48')]['id']}})[_0xf329('0x23')](handleEntityNotFound(_0x46fec9,null))['then'](function(_0x353c52){if(_0x353c52){return db[_0xf329('0x4d')][_0xf329('0x4e')](function(_0x9da24a){return db['UserProfileSection'][_0xf329('0x3f')]({'where':{'userProfileId':_0x2b3587[_0xf329('0x48')]['id']},'attributes':['id'],'raw':!![]})['then'](function(_0x2827e4){if(_0x2827e4){return db[_0xf329('0x4f')][_0xf329('0x24')]({'where':{'userProfileId':_0x2b3587[_0xf329('0x48')]['id'],'id':_[_0xf329('0x28')](_0x2827e4,function(_0x4a037b){return _0x4a037b['id'];})},'transaction':_0x9da24a});}})[_0xf329('0x23')](function(_0xa279ac){var _0x1ea594=_['map'](_0x2b3587[_0xf329('0x46')],function(_0x557b38){_0x557b38[_0xf329('0x55')]=_0x2b3587[_0xf329('0x48')]['id'];return _0x557b38;});return db[_0xf329('0x4f')]['bulkCreate'](_0x1ea594,{'raw':!![],'transaction':_0x9da24a});})[_0xf329('0x23')](function(_0xd0520e){var _0x392a4f=_[_0xf329('0x39')](_['map'](_0xd0520e,function(_0x3fc3d2){return _0x3fc3d2[_0xf329('0x49')]({'plain':!![]});}),{'includeAll':![]});if(_0x392a4f){return db[_0xf329('0x4f')]['findAll']({'where':{'userProfileId':_0x2b3587[_0xf329('0x48')]['id'],'sectionId':_[_0xf329('0x28')](_0x392a4f,function(_0x3a0f30){return _0x3a0f30[_0xf329('0x54')];})},'attributes':['id',_0xf329('0x54')],'raw':!![]})[_0xf329('0x23')](function(_0x2f8fba){var _0xccd93f=_['map'](_0x2b3587[_0xf329('0x46')],function(_0x25f626){_0x25f626[_0xf329('0x55')]=_0x2b3587[_0xf329('0x48')]['id'];return _0x25f626;});return db[_0xf329('0x52')][_0xf329('0x66')](_0xccd93f,{'raw':!![],'transaction':_0x9da24a});});}})[_0xf329('0x44')](handleError(_0x46fec9,null));});}})[_0xf329('0x23')](function(_0x3a256e){var _0x3e473b=_[_0xf329('0x28')](_0x3a256e,function(_0x1e1bbd){return _0x1e1bbd[_0xf329('0x49')]({'plain':!![]});});})[_0xf329('0x23')](respondWithResult(_0x46fec9,null))[_0xf329('0x44')](handleError(_0x46fec9,null));};exports[_0xf329('0x67')]=function(_0x18feb6,_0x586cd6,_0x5539df){return db['UserProfile'][_0xf329('0x43')]({'where':{'id':_0x18feb6[_0xf329('0x48')]['id']}})[_0xf329('0x23')](handleEntityNotFound(_0x586cd6,null))[_0xf329('0x23')](function(_0x19fb24){if(_0x19fb24){return _0x19fb24[_0xf329('0x67')](_0x18feb6['query'][_0xf329('0x68')]);}})[_0xf329('0x23')](respondWithStatusCode(_0x586cd6,null))['catch'](handleError(_0x586cd6,null));};exports[_0xf329('0x69')]=function(_0x355115,_0x2f52f4){var _0x5788a8={};if(!_0x355115[_0xf329('0x2d')][_0xf329('0x6a')])throw new Error('Missing\x20section\x20parameter');if(!_0x355115[_0xf329('0x2d')][_0xf329('0x34')]('nolimit')){_0x5788a8[_0xf329('0x1e')]=qs[_0xf329('0x1e')](_0x355115['query']['limit']);_0x5788a8[_0xf329('0x1c')]=qs['offset'](_0x355115[_0xf329('0x2d')][_0xf329('0x1c')]);}return db[_0xf329('0x29')][_0xf329('0x43')]({'where':{'id':_0x355115[_0xf329('0x48')]['id']}})[_0xf329('0x23')](function(_0x385ec1){if(!_0x385ec1)throw new Error('No\x20User\x20Profile\x20found\x20for\x20id\x20'+_0x355115[_0xf329('0x48')]['id']);return db[_0xf329('0x29')][_0xf329('0x69')](_0x355115);})[_0xf329('0x23')](respondWithFilteredResult(_0x2f52f4,_0x5788a8))[_0xf329('0x44')](handleError(_0x2f52f4,null));};
\ No newline at end of file
+var _0x311a=['util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','status','end','offset','limit','count','set','Content-Range','json','apply','reject','save','update','then','sendStatus','name','send','index','map','rawAttributes','fieldName','type','keys','filters','intersection','model','attributes','fields','query','length','order','sort','where','pick','filter','VIRTUAL','merge','UserProfile','includeAll','findAll','rows','show','params','include','options','find','catch','create','body','clone','get','omit','createdAt','crudPermissions','updatedAt','sequelize','each','autoAssociation','UserProfileResource','sectionId','userProfileId','Resources','UserProfileSection','destroy','describe','transaction','push','ids','getSections','enabled','includes','subsections','concat','findOne','Dashboard','forEach','resourceId','Plugin','addResources','bulkCreate','removeResources','section','hasOwnProperty','No\x20User\x20Profile\x20found\x20for\x20id\x20','getResources','rimraf','zip-dir','moment','bluebird','mustache'];(function(_0x252295,_0x4bc665){var _0x27f24e=function(_0x513615){while(--_0x513615){_0x252295['push'](_0x252295['shift']());}};_0x27f24e(++_0x4bc665);}(_0x311a,0x6e));var _0xa311=function(_0x58a3c0,_0x4bdb75){_0x58a3c0=_0x58a3c0-0x0;var _0x49bf1f=_0x311a[_0x58a3c0];return _0x49bf1f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xa311('0x0'));var zipdir=require(_0xa311('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xa311('0x2'));var BPromise=require(_0xa311('0x3'));var Mustache=require(_0xa311('0x4'));var util=require(_0xa311('0x5'));var path=require(_0xa311('0x6'));var sox=require(_0xa311('0x7'));var csv=require(_0xa311('0x8'));var ejs=require(_0xa311('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa311('0xa'));var squel=require(_0xa311('0xb'));var crypto=require(_0xa311('0xc'));var jsforce=require(_0xa311('0xd'));var deskjs=require(_0xa311('0xe'));var toCsv=require(_0xa311('0x8'));var querystring=require('querystring');var Papa=require(_0xa311('0xf'));var Redis=require(_0xa311('0x10'));var authService=require(_0xa311('0x11'));var qs=require(_0xa311('0x12'));var as=require(_0xa311('0x13'));var hardwareService=require(_0xa311('0x14'));var logger=require(_0xa311('0x15'))('api');var utils=require(_0xa311('0x16'));var config=require(_0xa311('0x17'));var licenseUtil=require(_0xa311('0x18'));var db=require(_0xa311('0x19'))['db'];config[_0xa311('0x1a')]=_[_0xa311('0x1b')](config['redis'],{'host':_0xa311('0x1c'),'port':0x18eb});var socket=require(_0xa311('0x1d'))(new Redis(config['redis']));require('./userProfile.socket')[_0xa311('0x1e')](socket);function respondWithStatusCode(_0x3d0f8f,_0x4b0975){_0x4b0975=_0x4b0975||0xcc;return function(_0x46a758){if(_0x46a758){return _0x3d0f8f['sendStatus'](_0x4b0975);}return _0x3d0f8f[_0xa311('0x1f')](_0x4b0975)[_0xa311('0x20')]();};}function respondWithResult(_0x103985,_0x1d67c9){_0x1d67c9=_0x1d67c9||0xc8;return function(_0x4c9339){if(_0x4c9339){return _0x103985[_0xa311('0x1f')](_0x1d67c9)['json'](_0x4c9339);}};}function respondWithFilteredResult(_0x4efbbe,_0x42a219){return function(_0x427167){if(_0x427167){var _0xa1292=typeof _0x42a219[_0xa311('0x21')]==='undefined'&&typeof _0x42a219[_0xa311('0x22')]==='undefined';var _0x1239f6=_0x427167[_0xa311('0x23')];var _0xd1f116=_0xa1292?0x0:_0x42a219['offset'];var _0xdb9486=_0xa1292?_0x427167[_0xa311('0x23')]:_0x42a219[_0xa311('0x21')]+_0x42a219[_0xa311('0x22')];var _0x2900cd;if(_0xdb9486>=_0x1239f6){_0xdb9486=_0x1239f6;_0x2900cd=0xc8;}else{_0x2900cd=0xce;}_0x4efbbe[_0xa311('0x1f')](_0x2900cd);return _0x4efbbe[_0xa311('0x24')](_0xa311('0x25'),_0xd1f116+'-'+_0xdb9486+'/'+_0x1239f6)[_0xa311('0x26')](_0x427167);}return null;};}function patchUpdates(_0x51ccb3){return function(_0x539c9c){try{jsonpatch[_0xa311('0x27')](_0x539c9c,_0x51ccb3,!![]);}catch(_0x2a3096){return BPromise[_0xa311('0x28')](_0x2a3096);}return _0x539c9c[_0xa311('0x29')]();};}function saveUpdates(_0x51b786,_0x51a13c){return function(_0x6d177){if(_0x6d177){return _0x6d177[_0xa311('0x2a')](_0x51b786)[_0xa311('0x2b')](function(_0x43d6f4){return _0x43d6f4;});}return null;};}function removeEntity(_0x564773,_0x10c704){return function(_0x13b0c5){if(_0x13b0c5){return _0x13b0c5['destroy']()[_0xa311('0x2b')](function(){_0x564773[_0xa311('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x12b033,_0x5cdf2a){return function(_0x1962a4){if(!_0x1962a4){_0x12b033[_0xa311('0x2c')](0x194);}return _0x1962a4;};}function handleError(_0x583748,_0x45c1e6){_0x45c1e6=_0x45c1e6||0x1f4;return function(_0x21556e){logger['error'](_0x21556e['stack']);if(_0x21556e['name']){delete _0x21556e[_0xa311('0x2d')];}_0x583748['status'](_0x45c1e6)[_0xa311('0x2e')](_0x21556e);};}exports[_0xa311('0x2f')]=function(_0x5a7422,_0x12daa4){var _0x1294d6={},_0x4dbda2={},_0x12fa42={'count':0x0,'rows':[]};var _0x22f6d9=_[_0xa311('0x30')](db['UserProfile'][_0xa311('0x31')],function(_0x3e0326){return{'name':_0x3e0326[_0xa311('0x32')],'type':_0x3e0326[_0xa311('0x33')]['key']};});_0x4dbda2['model']=_['map'](_0x22f6d9,_0xa311('0x2d'));_0x4dbda2['query']=_[_0xa311('0x34')](_0x5a7422['query']);_0x4dbda2[_0xa311('0x35')]=_[_0xa311('0x36')](_0x4dbda2[_0xa311('0x37')],_0x4dbda2['query']);_0x1294d6[_0xa311('0x38')]=_[_0xa311('0x36')](_0x4dbda2['model'],qs[_0xa311('0x39')](_0x5a7422[_0xa311('0x3a')][_0xa311('0x39')]));_0x1294d6[_0xa311('0x38')]=_0x1294d6['attributes'][_0xa311('0x3b')]?_0x1294d6[_0xa311('0x38')]:_0x4dbda2[_0xa311('0x37')];if(!_0x5a7422[_0xa311('0x3a')]['hasOwnProperty']('nolimit')){_0x1294d6['limit']=qs['limit'](_0x5a7422[_0xa311('0x3a')][_0xa311('0x22')]);_0x1294d6['offset']=qs[_0xa311('0x21')](_0x5a7422[_0xa311('0x3a')][_0xa311('0x21')]);}_0x1294d6[_0xa311('0x3c')]=qs[_0xa311('0x3d')](_0x5a7422[_0xa311('0x3a')][_0xa311('0x3d')]);_0x1294d6[_0xa311('0x3e')]=qs[_0xa311('0x35')](_[_0xa311('0x3f')](_0x5a7422[_0xa311('0x3a')],_0x4dbda2[_0xa311('0x35')]),_0x22f6d9);if(_0x5a7422[_0xa311('0x3a')][_0xa311('0x40')]){_0x1294d6[_0xa311('0x3e')]=_['merge'](_0x1294d6[_0xa311('0x3e')],{'$or':_[_0xa311('0x30')](_0x22f6d9,function(_0x560823){if(_0x560823[_0xa311('0x33')]!==_0xa311('0x41')){var _0x2de197={};_0x2de197[_0x560823[_0xa311('0x2d')]]={'$like':'%'+_0x5a7422['query'][_0xa311('0x40')]+'%'};return _0x2de197;}})});}_0x1294d6=_[_0xa311('0x42')]({},_0x1294d6,_0x5a7422['options']);var _0x13c39a={'where':_0x1294d6[_0xa311('0x3e')]};return db[_0xa311('0x43')]['count'](_0x13c39a)[_0xa311('0x2b')](function(_0x557a04){_0x12fa42[_0xa311('0x23')]=_0x557a04;if(_0x5a7422[_0xa311('0x3a')][_0xa311('0x44')]){_0x1294d6['include']=[{'all':!![]}];}return db[_0xa311('0x43')][_0xa311('0x45')](_0x1294d6);})[_0xa311('0x2b')](function(_0x262d44){_0x12fa42[_0xa311('0x46')]=_0x262d44;return _0x12fa42;})['then'](respondWithFilteredResult(_0x12daa4,_0x1294d6))['catch'](handleError(_0x12daa4,null));};exports[_0xa311('0x47')]=function(_0x58564c,_0x1dbe97){var _0x39dddc={'raw':![],'where':{'id':_0x58564c[_0xa311('0x48')]['id']}},_0x3d81ae={};_0x3d81ae['model']=_[_0xa311('0x34')](db[_0xa311('0x43')][_0xa311('0x31')]);_0x3d81ae['query']=_[_0xa311('0x34')](_0x58564c[_0xa311('0x3a')]);_0x3d81ae[_0xa311('0x35')]=_[_0xa311('0x36')](_0x3d81ae[_0xa311('0x37')],_0x3d81ae[_0xa311('0x3a')]);_0x39dddc[_0xa311('0x38')]=_[_0xa311('0x36')](_0x3d81ae[_0xa311('0x37')],qs[_0xa311('0x39')](_0x58564c[_0xa311('0x3a')][_0xa311('0x39')]));_0x39dddc[_0xa311('0x38')]=_0x39dddc[_0xa311('0x38')][_0xa311('0x3b')]?_0x39dddc[_0xa311('0x38')]:_0x3d81ae[_0xa311('0x37')];if(_0x58564c['query'][_0xa311('0x44')]){_0x39dddc[_0xa311('0x49')]=[{'all':!![]}];}_0x39dddc=_[_0xa311('0x42')]({},_0x39dddc,_0x58564c[_0xa311('0x4a')]);return db[_0xa311('0x43')][_0xa311('0x4b')](_0x39dddc)[_0xa311('0x2b')](handleEntityNotFound(_0x1dbe97,null))['then'](respondWithResult(_0x1dbe97,null))[_0xa311('0x4c')](handleError(_0x1dbe97,null));};exports[_0xa311('0x4d')]=function(_0x2785c7,_0x55bc94){return db[_0xa311('0x43')]['create'](_0x2785c7[_0xa311('0x4e')],{})['then'](respondWithResult(_0x55bc94,0xc9))[_0xa311('0x4c')](handleError(_0x55bc94,null));};exports[_0xa311('0x4f')]=function(_0x53b15d,_0x5e89a2){var _0x525935={'where':{'id':_0x53b15d['params']['id']}},_0xd53a20={};_0xd53a20[_0xa311('0x37')]=_[_0xa311('0x34')](db[_0xa311('0x43')][_0xa311('0x31')]);_0x525935['attributes']=_[_0xa311('0x36')](_0xd53a20[_0xa311('0x37')],qs['fields'](_0x53b15d[_0xa311('0x3a')]['fields']));_0x525935[_0xa311('0x38')]=_0x525935['attributes']['length']?_0x525935['attributes']:_0xd53a20[_0xa311('0x37')];if(_0x53b15d[_0xa311('0x3a')]['includeAll']){_0x525935[_0xa311('0x49')]=[{'all':!![]}];}_0x525935=_[_0xa311('0x42')]({},_0x525935,_0x53b15d[_0xa311('0x4a')]);return db[_0xa311('0x43')][_0xa311('0x4b')](_0x525935)[_0xa311('0x2b')](handleEntityNotFound(_0x5e89a2,null))['then'](function(_0xb1a0fa){if(_0xb1a0fa){var _0x251090=_0xb1a0fa[_0xa311('0x50')]({'plain':!![]});_0x251090=qs[_0xa311('0x51')](_0x251090,['id',_0xa311('0x52'),'updatedAt',_0xa311('0x53')]);_0x53b15d[_0xa311('0x4e')]=_['omit'](_0x53b15d['body'],['id','createdAt',_0xa311('0x54')]);return db[_0xa311('0x55')]['transaction'](function(_0x439fcf){return db['UserProfile'][_0xa311('0x4d')](_[_0xa311('0x42')](_0x251090,_0x53b15d[_0xa311('0x4e')]),{'include':_0x53b15d[_0xa311('0x3a')]['includeAll']?[{'all':!![]}]:undefined,'transaction':_0x439fcf})[_0xa311('0x2b')](function(_0x4dd80f){var _0x45e30a=_0x4dd80f[_0xa311('0x50')]({'plain':!![]});return db['UserProfileSection'][_0xa311('0x45')]({'where':{'userProfileId':_0x53b15d['params']['id']},'raw':!![]})[_0xa311('0x2b')](function(_0x385c2){if(_0x385c2){return BPromise[_0xa311('0x56')](_0x385c2,function(_0x3d8f91){return new BPromise(function(_0x5ad1ee,_0x84170d){if(_0x3d8f91['autoAssociation']===null||_0x3d8f91[_0xa311('0x57')]===0x1)_0x5ad1ee(null);return db[_0xa311('0x58')]['findAll']({'where':{'sectionId':_0x3d8f91['id']},'raw':!![]})[_0xa311('0x2b')](function(_0x44d3b7){var _0x568be6=_['map'](_0x44d3b7,function(_0x104956){return qs['omit'](_0x104956,['id','createdAt',_0xa311('0x54'),_0xa311('0x59')]);});_0x5ad1ee(_0x568be6);})['catch'](function(_0x5dbfcc){_0x84170d(_0x5dbfcc);});})[_0xa311('0x2b')](function(_0x4ca057){var _0x2dd27c=qs['omit'](_0x3d8f91,['id',_0xa311('0x52'),'updatedAt']);_0x2dd27c[_0xa311('0x5a')]=_0x45e30a['id'];if(_0x4ca057)_0x2dd27c[_0xa311('0x5b')]=_0x4ca057;return _0x2dd27c;})[_0xa311('0x2b')](function(_0x2568fd){return db[_0xa311('0x5c')][_0xa311('0x4d')](_0x2568fd,{'include':[{'model':db[_0xa311('0x58')],'as':_0xa311('0x5b')}],'raw':!![],'transaction':_0x439fcf});});})[_0xa311('0x2b')](function(){return _0x45e30a;});}});});});}})['then'](respondWithResult(_0x5e89a2,0xc9))[_0xa311('0x4c')](handleError(_0x5e89a2,null));};exports[_0xa311('0x2a')]=function(_0x5a6668,_0x3fec4e){if(_0x5a6668[_0xa311('0x4e')]['id']){delete _0x5a6668[_0xa311('0x4e')]['id'];}return db[_0xa311('0x43')][_0xa311('0x4b')]({'where':{'id':_0x5a6668[_0xa311('0x48')]['id']}})[_0xa311('0x2b')](handleEntityNotFound(_0x3fec4e,null))['then'](saveUpdates(_0x5a6668[_0xa311('0x4e')],null))[_0xa311('0x2b')](respondWithResult(_0x3fec4e,null))['catch'](handleError(_0x3fec4e,null));};exports[_0xa311('0x5d')]=function(_0x488a1f,_0x596f3b){return db[_0xa311('0x43')][_0xa311('0x4b')]({'where':{'id':_0x488a1f[_0xa311('0x48')]['id']}})['then'](handleEntityNotFound(_0x596f3b,null))['then'](removeEntity(_0x596f3b,null))[_0xa311('0x4c')](handleError(_0x596f3b,null));};exports[_0xa311('0x5e')]=function(_0x24a7a0,_0x21c52b){return db[_0xa311('0x43')][_0xa311('0x5e')]()[_0xa311('0x2b')](respondWithResult(_0x21c52b,null))['catch'](handleError(_0x21c52b,null));};exports['addSections']=function(_0x54fe14,_0x2b9382){var _0x48a2c7=_0x54fe14[_0xa311('0x4e')];return db[_0xa311('0x43')][_0xa311('0x4b')]({'where':{'id':_0x54fe14[_0xa311('0x48')]['id']}})[_0xa311('0x2b')](handleEntityNotFound(_0x2b9382,null))[_0xa311('0x2b')](function(_0x5dc827){if(_0x5dc827){return db['sequelize'][_0xa311('0x5f')](function(_0x2ad5c9){return db[_0xa311('0x5c')][_0xa311('0x5d')]({'where':{'userProfileId':_0x54fe14['params']['id'],'sectionId':_[_0xa311('0x30')](_0x48a2c7,function(_0xfc29e3){return _0xfc29e3[_0xa311('0x59')];})},'transaction':_0x2ad5c9})[_0xa311('0x2b')](function(){var _0x5354d6=_['map'](_0x48a2c7,function(_0x6953b){_0x6953b[_0xa311('0x5a')]=_0x54fe14[_0xa311('0x48')]['id'];return _0x6953b;});var _0x1b5406=[];return BPromise[_0xa311('0x56')](_0x5354d6,function(_0x476b5c){return db['UserProfileSection']['create'](_0x476b5c,{'include':[{'model':db[_0xa311('0x58')],'as':_0xa311('0x5b')}],'raw':!![],'transaction':_0x2ad5c9})[_0xa311('0x2b')](function(_0x2234fc){_0x1b5406[_0xa311('0x60')](_0x2234fc[_0xa311('0x50')]({'plain':!![]}));});})[_0xa311('0x2b')](function(){return _0x1b5406;});});});}})['then'](function(_0x510287){return _0x510287;})[_0xa311('0x2b')](respondWithResult(_0x2b9382,null))['catch'](handleError(_0x2b9382,null));};exports['removeSections']=function(_0x904dd5,_0x393235){var _0x1b279c;return db['UserProfile']['find']({'where':{'id':_0x904dd5[_0xa311('0x48')]['id']},'attributes':['id',_0xa311('0x2d')]})[_0xa311('0x2b')](handleEntityNotFound(_0x393235,null))['then'](function(_0x37ccd2){if(_0x37ccd2){_0x1b279c=_0x37ccd2;return db[_0xa311('0x5c')][_0xa311('0x5d')]({'where':{'userProfileId':_0x904dd5[_0xa311('0x48')]['id'],'sectionId':_0x904dd5[_0xa311('0x3a')][_0xa311('0x61')]}});}})[_0xa311('0x2b')](function(){return _0x1b279c;})[_0xa311('0x2b')](respondWithStatusCode(_0x393235,null))[_0xa311('0x4c')](handleError(_0x393235,null));};exports[_0xa311('0x62')]=function(_0x5a885a,_0xc9f540){var _0x497b3c=[];var _0x585cc2=[];return db[_0xa311('0x5c')][_0xa311('0x45')]({'where':{'userProfileId':_0x5a885a[_0xa311('0x48')]['id']},'raw':!![]})['then'](function(_0x4c4c5e){_0x497b3c=_[_0xa311('0x40')](_0x4c4c5e,function(_0x8f37c7){return _0x8f37c7[_0xa311('0x63')]===0x1||_[_0xa311('0x64')]([0x3eb,0x709],_0x8f37c7[_0xa311('0x59')]);});if(!_['isEmpty'](_0x497b3c)){return _[_0xa311('0x30')](_0x497b3c,function(_0x528c85){return _0x528c85['sectionId'];});}else{return;}})[_0xa311('0x2b')](function(_0x537ca3){if(_0x537ca3)_0x585cc2=_0x537ca3;if(_[_0xa311('0x64')](_0x585cc2,0x64)){var _0x17c703=_[_0xa311('0x4b')](_0x497b3c,{'sectionId':0x64});return hasDefaultDashboard(_0x17c703)[_0xa311('0x2b')](function(_0x3a6e27){return _['map'](_0x497b3c,function(_0x17823d){if(_0x17823d[_0xa311('0x59')]===0x64){_0x17823d[_0xa311('0x65')]=_0x3a6e27;}return _0x17823d;});});}else{return;}})['then'](function(_0xc336be){if(_0xc336be)_0x497b3c=_0xc336be;if(_[_0xa311('0x64')](_0x585cc2,0x3eb)){var _0x5bd7f1=_['find'](_0x497b3c,{'sectionId':0x3eb});return getCustomDashboards(_0x5bd7f1)[_0xa311('0x2b')](function(_0x3ed316){return _[_0xa311('0x30')](_0x497b3c,function(_0x24bfab){if(_0x5bd7f1[_0xa311('0x63')]){if(_0x24bfab[_0xa311('0x59')]===0x3eb){_0x24bfab['subsections']=_0x3ed316;}}else{if(_0x24bfab['sectionId']===0x64){if(!_0x24bfab[_0xa311('0x65')]){_0x24bfab['subsections']=[];}_0x24bfab['subsections']=_0x24bfab[_0xa311('0x65')][_0xa311('0x66')](_0x3ed316);}}return _0x24bfab;});});}else{return;}})[_0xa311('0x2b')](function(_0x317666){if(_0x317666)_0x497b3c=_0x317666;if(_[_0xa311('0x64')](_0x585cc2,0x709)){var _0x25ff3a=_[_0xa311('0x4b')](_0x497b3c,{'sectionId':0x709});return getPlugins(_0x25ff3a)[_0xa311('0x2b')](function(_0x30a102){if(_0x25ff3a[_0xa311('0x63')]){return _['map'](_0x497b3c,function(_0xf04ae3){if(_0xf04ae3['sectionId']===0x709){_0xf04ae3[_0xa311('0x65')]=_0x30a102;}return _0xf04ae3;});}else{var _0x23b1f6={'sectionId':0x76c,'enabled':0x1,'subsections':_0x30a102};var _0x2b1750=_[_0xa311('0x30')](_0x497b3c);_0x2b1750['push'](_0x23b1f6);return _0x2b1750;}});}else{return;}})[_0xa311('0x2b')](function(_0x491559){if(_0x491559)_0x497b3c=_0x491559;return _[_0xa311('0x40')](_0x497b3c,[_0xa311('0x63'),0x1]);})[_0xa311('0x2b')](respondWithResult(_0xc9f540,null))[_0xa311('0x4c')](handleError(_0xc9f540,null));};function hasDefaultDashboard(_0x1f0e74){var _0x35cc94=[0x65];return new BPromise(function(_0x5b89d1,_0x109001){try{if(_0x1f0e74['autoAssociation']){_0x5b89d1(_0x35cc94);}else{return db['UserProfileResource'][_0xa311('0x67')]({'where':{'sectionId':_0x1f0e74['id']},'raw':!![]})[_0xa311('0x2b')](function(_0x471564){_0x471564?_0x5b89d1(_0x35cc94):_0x5b89d1();});}}catch(_0x2fd742){_0x109001(_0x2fd742);}});}function getCustomDashboards(_0xc2b38d){var _0x4ccfc8=[];return new BPromise(function(_0x3c3c21,_0x294500){try{if(_0xc2b38d[_0xa311('0x57')]){return db[_0xa311('0x68')][_0xa311('0x45')]({'raw':!![]})['then'](function(_0x4f54b7){_0x4f54b7[_0xa311('0x69')](function(_0x346ab2){_0x4ccfc8[_0xa311('0x60')](_0x346ab2['id']+0x1869f);});_0x3c3c21(_0x4ccfc8);});}else{return db[_0xa311('0x58')]['findAll']({'where':{'sectionId':_0xc2b38d['id']},'raw':!![]})[_0xa311('0x2b')](function(_0x211388){_0x211388['forEach'](function(_0x1e5147){_0x4ccfc8[_0xa311('0x60')](_0x1e5147[_0xa311('0x6a')]+0x1869f);});_0x3c3c21(_0x4ccfc8);});}}catch(_0x373a2c){_0x294500(_0x373a2c);}});}function getPlugins(_0xe0a57c){var _0x1dfebc=[];return new BPromise(function(_0x1de443,_0x21220c){try{if(_0xe0a57c[_0xa311('0x57')]){return db[_0xa311('0x6b')][_0xa311('0x45')]({'raw':!![]})[_0xa311('0x2b')](function(_0x524172){_0x524172[_0xa311('0x69')](function(_0x75686b){_0x1dfebc['push'](_0x75686b['id']+0x15b38);});_0x1de443(_0x1dfebc);});}else{return db[_0xa311('0x58')]['findAll']({'where':{'sectionId':_0xe0a57c['id']},'raw':!![]})[_0xa311('0x2b')](function(_0x44f988){_0x44f988['forEach'](function(_0x5e3933){_0x1dfebc[_0xa311('0x60')](_0x5e3933['resourceId']+0x15b38);});_0x1de443(_0x1dfebc);});}}catch(_0x540f6c){_0x21220c(_0x540f6c);}});}exports[_0xa311('0x6c')]=function(_0x49de11,_0x6bedb7){return db[_0xa311('0x43')][_0xa311('0x4b')]({'where':{'id':_0x49de11[_0xa311('0x48')]['id']}})[_0xa311('0x2b')](handleEntityNotFound(_0x6bedb7,null))[_0xa311('0x2b')](function(_0xf7ce1){if(_0xf7ce1){return db['sequelize']['transaction'](function(_0x3a3e8a){return db[_0xa311('0x5c')]['findAll']({'where':{'userProfileId':_0x49de11[_0xa311('0x48')]['id']},'attributes':['id'],'raw':!![]})[_0xa311('0x2b')](function(_0x19d74b){if(_0x19d74b){return db[_0xa311('0x5c')][_0xa311('0x5d')]({'where':{'userProfileId':_0x49de11['params']['id'],'id':_[_0xa311('0x30')](_0x19d74b,function(_0xdc5e75){return _0xdc5e75['id'];})},'transaction':_0x3a3e8a});}})[_0xa311('0x2b')](function(_0x501a36){var _0x3e6c15=_[_0xa311('0x30')](_0x49de11[_0xa311('0x4e')],function(_0x514a5c){_0x514a5c[_0xa311('0x5a')]=_0x49de11[_0xa311('0x48')]['id'];return _0x514a5c;});return db[_0xa311('0x5c')][_0xa311('0x6d')](_0x3e6c15,{'raw':!![],'transaction':_0x3a3e8a});})['then'](function(_0x414b44){var _0x1507e7=_['filter'](_[_0xa311('0x30')](_0x414b44,function(_0x23c77c){return _0x23c77c[_0xa311('0x50')]({'plain':!![]});}),{'includeAll':![]});if(_0x1507e7){return db[_0xa311('0x5c')][_0xa311('0x45')]({'where':{'userProfileId':_0x49de11[_0xa311('0x48')]['id'],'sectionId':_[_0xa311('0x30')](_0x1507e7,function(_0x496347){return _0x496347[_0xa311('0x59')];})},'attributes':['id',_0xa311('0x59')],'raw':!![]})[_0xa311('0x2b')](function(_0x4b5efa){var _0x43e5aa=_['map'](_0x49de11['body'],function(_0x9fa865){_0x9fa865[_0xa311('0x5a')]=_0x49de11[_0xa311('0x48')]['id'];return _0x9fa865;});return db[_0xa311('0x58')][_0xa311('0x6d')](_0x43e5aa,{'raw':!![],'transaction':_0x3a3e8a});});}})[_0xa311('0x4c')](handleError(_0x6bedb7,null));});}})[_0xa311('0x2b')](function(_0x444630){var _0x4cad6c=_[_0xa311('0x30')](_0x444630,function(_0x39b6dd){return _0x39b6dd[_0xa311('0x50')]({'plain':!![]});});})['then'](respondWithResult(_0x6bedb7,null))[_0xa311('0x4c')](handleError(_0x6bedb7,null));};exports[_0xa311('0x6e')]=function(_0x3ada33,_0x61a723,_0x16597c){return db[_0xa311('0x43')][_0xa311('0x4b')]({'where':{'id':_0x3ada33[_0xa311('0x48')]['id']}})[_0xa311('0x2b')](handleEntityNotFound(_0x61a723,null))[_0xa311('0x2b')](function(_0x4675c7){if(_0x4675c7){return _0x4675c7[_0xa311('0x6e')](_0x3ada33[_0xa311('0x3a')][_0xa311('0x61')]);}})[_0xa311('0x2b')](respondWithStatusCode(_0x61a723,null))[_0xa311('0x4c')](handleError(_0x61a723,null));};exports['getResources']=function(_0x32150e,_0x2a1432){var _0x20977d={};if(!_0x32150e['query'][_0xa311('0x6f')])throw new Error('Missing\x20section\x20parameter');if(!_0x32150e[_0xa311('0x3a')][_0xa311('0x70')]('nolimit')){_0x20977d[_0xa311('0x22')]=qs[_0xa311('0x22')](_0x32150e[_0xa311('0x3a')][_0xa311('0x22')]);_0x20977d[_0xa311('0x21')]=qs[_0xa311('0x21')](_0x32150e['query'][_0xa311('0x21')]);}return db[_0xa311('0x43')][_0xa311('0x4b')]({'where':{'id':_0x32150e[_0xa311('0x48')]['id']}})[_0xa311('0x2b')](function(_0x41401d){if(!_0x41401d)throw new Error(_0xa311('0x71')+_0x32150e[_0xa311('0x48')]['id']);return db[_0xa311('0x43')][_0xa311('0x72')](_0x32150e);})[_0xa311('0x2b')](respondWithFilteredResult(_0x2a1432,_0x20977d))[_0xa311('0x4c')](handleError(_0x2a1432,null));};
\ No newline at end of file