Built motion from commit b0a9a629.|2.6.33
[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 _0x9884=['name','send','map','rawAttributes','fieldName','type','key','query','filters','intersection','model','attributes','fields','hasOwnProperty','limit','order','sort','where','filter','merge','VIRTUAL','UserProfile','then','includeAll','include','findAll','rows','catch','show','params','keys','length','find','create','body','clone','options','get','omit','createdAt','updatedAt','crudPermissions','sequelize','UserProfileSection','each','autoAssociation','userProfileId','Resources','UserProfileResource','destroy','describe','addSections','sectionId','push','enabled','isEmpty','includes','subsections','concat','findOne','Dashboard','forEach','resourceId','Plugin','addResources','transaction','bulkCreate','removeResources','ids','getResources','Missing\x20section\x20parameter','No\x20User\x20Profile\x20found\x20for\x20id\x20','rimraf','zip-dir','fast-json-patch','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./userProfile.socket','end','status','json','offset','undefined','count','set','Content-Range','apply','reject','update','sendStatus','error','stack'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0x9884,0x12c));var _0x4988=function(_0x38209d,_0x282138){_0x38209d=_0x38209d-0x0;var _0x578b0d=_0x9884[_0x38209d];return _0x578b0d;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x4988('0x0'));var zipdir=require(_0x4988('0x1'));var jsonpatch=require(_0x4988('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x4988('0x3'));var Mustache=require(_0x4988('0x4'));var util=require('util');var path=require('path');var sox=require(_0x4988('0x5'));var csv=require(_0x4988('0x6'));var ejs=require(_0x4988('0x7'));var fs=require('fs');var fs_extra=require(_0x4988('0x8'));var _=require(_0x4988('0x9'));var squel=require(_0x4988('0xa'));var crypto=require(_0x4988('0xb'));var jsforce=require(_0x4988('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x4988('0x6'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x4988('0xd'));var authService=require(_0x4988('0xe'));var qs=require(_0x4988('0xf'));var as=require(_0x4988('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x4988('0x11'))(_0x4988('0x12'));var utils=require(_0x4988('0x13'));var config=require(_0x4988('0x14'));var licenseUtil=require(_0x4988('0x15'));var db=require(_0x4988('0x16'))['db'];config[_0x4988('0x17')]=_[_0x4988('0x18')](config[_0x4988('0x17')],{'host':_0x4988('0x19'),'port':0x18eb});var socket=require(_0x4988('0x1a'))(new Redis(config['redis']));require(_0x4988('0x1b'))['register'](socket);function respondWithStatusCode(_0x364ad2,_0x3a35d2){_0x3a35d2=_0x3a35d2||0xcc;return function(_0x4d55ee){if(_0x4d55ee){return _0x364ad2['sendStatus'](_0x3a35d2);}return _0x364ad2['status'](_0x3a35d2)[_0x4988('0x1c')]();};}function respondWithResult(_0x568068,_0x26bc3e){_0x26bc3e=_0x26bc3e||0xc8;return function(_0x313f42){if(_0x313f42){return _0x568068[_0x4988('0x1d')](_0x26bc3e)[_0x4988('0x1e')](_0x313f42);}};}function respondWithFilteredResult(_0x1fe9ed,_0x31845b){return function(_0xfba2d3){if(_0xfba2d3){var _0x5de256=typeof _0x31845b[_0x4988('0x1f')]===_0x4988('0x20')&&typeof _0x31845b['limit']===_0x4988('0x20');var _0x5167eb=_0xfba2d3[_0x4988('0x21')];var _0x199cab=_0x5de256?0x0:_0x31845b[_0x4988('0x1f')];var _0xc3712=_0x5de256?_0xfba2d3['count']:_0x31845b[_0x4988('0x1f')]+_0x31845b['limit'];var _0x39c98d;if(_0xc3712>=_0x5167eb){_0xc3712=_0x5167eb;_0x39c98d=0xc8;}else{_0x39c98d=0xce;}_0x1fe9ed[_0x4988('0x1d')](_0x39c98d);return _0x1fe9ed[_0x4988('0x22')](_0x4988('0x23'),_0x199cab+'-'+_0xc3712+'/'+_0x5167eb)[_0x4988('0x1e')](_0xfba2d3);}return null;};}function patchUpdates(_0x10f945){return function(_0x36399b){try{jsonpatch[_0x4988('0x24')](_0x36399b,_0x10f945,!![]);}catch(_0x53901b){return BPromise[_0x4988('0x25')](_0x53901b);}return _0x36399b['save']();};}function saveUpdates(_0x24d636,_0x5e212e){return function(_0x1b5ec7){if(_0x1b5ec7){return _0x1b5ec7[_0x4988('0x26')](_0x24d636)['then'](function(_0x4a79b9){return _0x4a79b9;});}return null;};}function removeEntity(_0x5b05cd,_0x521846){return function(_0x49a0f0){if(_0x49a0f0){return _0x49a0f0['destroy']()['then'](function(){_0x5b05cd[_0x4988('0x1d')](0xcc)[_0x4988('0x1c')]();});}};}function handleEntityNotFound(_0x43034e,_0x14b0a5){return function(_0x5715b9){if(!_0x5715b9){_0x43034e[_0x4988('0x27')](0x194);}return _0x5715b9;};}function handleError(_0x951945,_0x568a29){_0x568a29=_0x568a29||0x1f4;return function(_0x1bf6b2){logger[_0x4988('0x28')](_0x1bf6b2[_0x4988('0x29')]);if(_0x1bf6b2[_0x4988('0x2a')]){delete _0x1bf6b2[_0x4988('0x2a')];}_0x951945[_0x4988('0x1d')](_0x568a29)[_0x4988('0x2b')](_0x1bf6b2);};}exports['index']=function(_0x55346e,_0x55a135){var _0x3dec26={},_0x49888f={},_0x10a05c={'count':0x0,'rows':[]};var _0x2e5c63=_[_0x4988('0x2c')](db['UserProfile'][_0x4988('0x2d')],function(_0x454fa3){return{'name':_0x454fa3[_0x4988('0x2e')],'type':_0x454fa3[_0x4988('0x2f')][_0x4988('0x30')]};});_0x49888f['model']=_[_0x4988('0x2c')](_0x2e5c63,_0x4988('0x2a'));_0x49888f[_0x4988('0x31')]=_['keys'](_0x55346e[_0x4988('0x31')]);_0x49888f[_0x4988('0x32')]=_[_0x4988('0x33')](_0x49888f[_0x4988('0x34')],_0x49888f['query']);_0x3dec26[_0x4988('0x35')]=_[_0x4988('0x33')](_0x49888f[_0x4988('0x34')],qs[_0x4988('0x36')](_0x55346e[_0x4988('0x31')][_0x4988('0x36')]));_0x3dec26[_0x4988('0x35')]=_0x3dec26['attributes']['length']?_0x3dec26['attributes']:_0x49888f[_0x4988('0x34')];if(!_0x55346e['query'][_0x4988('0x37')]('nolimit')){_0x3dec26[_0x4988('0x38')]=qs[_0x4988('0x38')](_0x55346e[_0x4988('0x31')]['limit']);_0x3dec26[_0x4988('0x1f')]=qs['offset'](_0x55346e[_0x4988('0x31')][_0x4988('0x1f')]);}_0x3dec26[_0x4988('0x39')]=qs[_0x4988('0x3a')](_0x55346e[_0x4988('0x31')][_0x4988('0x3a')]);_0x3dec26[_0x4988('0x3b')]=qs['filters'](_['pick'](_0x55346e[_0x4988('0x31')],_0x49888f[_0x4988('0x32')]),_0x2e5c63);if(_0x55346e[_0x4988('0x31')][_0x4988('0x3c')]){_0x3dec26['where']=_[_0x4988('0x3d')](_0x3dec26['where'],{'$or':_[_0x4988('0x2c')](_0x2e5c63,function(_0xc31f09){if(_0xc31f09['type']!==_0x4988('0x3e')){var _0x458da5={};_0x458da5[_0xc31f09[_0x4988('0x2a')]]={'$like':'%'+_0x55346e[_0x4988('0x31')][_0x4988('0x3c')]+'%'};return _0x458da5;}})});}_0x3dec26=_['merge']({},_0x3dec26,_0x55346e['options']);var _0x4216be={'where':_0x3dec26['where']};return db[_0x4988('0x3f')]['count'](_0x4216be)[_0x4988('0x40')](function(_0x46889b){_0x10a05c['count']=_0x46889b;if(_0x55346e[_0x4988('0x31')][_0x4988('0x41')]){_0x3dec26[_0x4988('0x42')]=[{'all':!![]}];}return db[_0x4988('0x3f')][_0x4988('0x43')](_0x3dec26);})['then'](function(_0x394b3b){_0x10a05c[_0x4988('0x44')]=_0x394b3b;return _0x10a05c;})['then'](respondWithFilteredResult(_0x55a135,_0x3dec26))[_0x4988('0x45')](handleError(_0x55a135,null));};exports[_0x4988('0x46')]=function(_0x30bd42,_0x47d43d){var _0x736fff={'raw':![],'where':{'id':_0x30bd42[_0x4988('0x47')]['id']}},_0x427d7b={};_0x427d7b[_0x4988('0x34')]=_[_0x4988('0x48')](db['UserProfile'][_0x4988('0x2d')]);_0x427d7b[_0x4988('0x31')]=_['keys'](_0x30bd42[_0x4988('0x31')]);_0x427d7b[_0x4988('0x32')]=_[_0x4988('0x33')](_0x427d7b[_0x4988('0x34')],_0x427d7b['query']);_0x736fff[_0x4988('0x35')]=_['intersection'](_0x427d7b[_0x4988('0x34')],qs['fields'](_0x30bd42[_0x4988('0x31')][_0x4988('0x36')]));_0x736fff[_0x4988('0x35')]=_0x736fff[_0x4988('0x35')][_0x4988('0x49')]?_0x736fff[_0x4988('0x35')]:_0x427d7b['model'];if(_0x30bd42[_0x4988('0x31')][_0x4988('0x41')]){_0x736fff[_0x4988('0x42')]=[{'all':!![]}];}_0x736fff=_[_0x4988('0x3d')]({},_0x736fff,_0x30bd42['options']);return db[_0x4988('0x3f')][_0x4988('0x4a')](_0x736fff)['then'](handleEntityNotFound(_0x47d43d,null))[_0x4988('0x40')](respondWithResult(_0x47d43d,null))[_0x4988('0x45')](handleError(_0x47d43d,null));};exports['create']=function(_0x3bf9b1,_0x46f74d){return db['UserProfile'][_0x4988('0x4b')](_0x3bf9b1[_0x4988('0x4c')],{})['then'](respondWithResult(_0x46f74d,0xc9))[_0x4988('0x45')](handleError(_0x46f74d,null));};exports[_0x4988('0x4d')]=function(_0x9a81ec,_0x23c05b){var _0x2a0928={'where':{'id':_0x9a81ec['params']['id']}},_0x24ec5d={};_0x24ec5d[_0x4988('0x34')]=_[_0x4988('0x48')](db[_0x4988('0x3f')][_0x4988('0x2d')]);_0x2a0928[_0x4988('0x35')]=_['intersection'](_0x24ec5d[_0x4988('0x34')],qs[_0x4988('0x36')](_0x9a81ec[_0x4988('0x31')]['fields']));_0x2a0928[_0x4988('0x35')]=_0x2a0928['attributes'][_0x4988('0x49')]?_0x2a0928[_0x4988('0x35')]:_0x24ec5d[_0x4988('0x34')];if(_0x9a81ec[_0x4988('0x31')][_0x4988('0x41')]){_0x2a0928[_0x4988('0x42')]=[{'all':!![]}];}_0x2a0928=_['merge']({},_0x2a0928,_0x9a81ec[_0x4988('0x4e')]);return db[_0x4988('0x3f')]['find'](_0x2a0928)[_0x4988('0x40')](handleEntityNotFound(_0x23c05b,null))[_0x4988('0x40')](function(_0x55454a){if(_0x55454a){var _0x40750c=_0x55454a[_0x4988('0x4f')]({'plain':!![]});_0x40750c=qs[_0x4988('0x50')](_0x40750c,['id',_0x4988('0x51'),_0x4988('0x52'),_0x4988('0x53')]);_0x9a81ec[_0x4988('0x4c')]=_['omit'](_0x9a81ec['body'],['id',_0x4988('0x51'),'updatedAt']);return db[_0x4988('0x54')]['transaction'](function(_0x167dee){return db[_0x4988('0x3f')][_0x4988('0x4b')](_[_0x4988('0x3d')](_0x40750c,_0x9a81ec[_0x4988('0x4c')]),{'include':_0x9a81ec['query'][_0x4988('0x41')]?[{'all':!![]}]:undefined,'transaction':_0x167dee})['then'](function(_0xb3e11c){var _0xbb3552=_0xb3e11c[_0x4988('0x4f')]({'plain':!![]});return db[_0x4988('0x55')][_0x4988('0x43')]({'where':{'userProfileId':_0x9a81ec['params']['id']},'raw':!![]})[_0x4988('0x40')](function(_0x267e29){if(_0x267e29){return BPromise[_0x4988('0x56')](_0x267e29,function(_0x459ac7){return new BPromise(function(_0x4f6f1e,_0x5b8f9f){if(_0x459ac7[_0x4988('0x57')]===null||_0x459ac7[_0x4988('0x57')]===0x1)_0x4f6f1e(null);return db['UserProfileResource'][_0x4988('0x43')]({'where':{'sectionId':_0x459ac7['id']},'raw':!![]})[_0x4988('0x40')](function(_0x514a94){var _0x3012cc=_[_0x4988('0x2c')](_0x514a94,function(_0x31bdcc){return qs['omit'](_0x31bdcc,['id','createdAt','updatedAt','sectionId']);});_0x4f6f1e(_0x3012cc);})[_0x4988('0x45')](function(_0x2a9d3f){_0x5b8f9f(_0x2a9d3f);});})[_0x4988('0x40')](function(_0x312100){var _0x497a78=qs[_0x4988('0x50')](_0x459ac7,['id',_0x4988('0x51'),_0x4988('0x52')]);_0x497a78[_0x4988('0x58')]=_0xbb3552['id'];if(_0x312100)_0x497a78[_0x4988('0x59')]=_0x312100;return _0x497a78;})['then'](function(_0x5a7f6f){return db['UserProfileSection'][_0x4988('0x4b')](_0x5a7f6f,{'include':[{'model':db[_0x4988('0x5a')],'as':_0x4988('0x59')}],'raw':!![],'transaction':_0x167dee});});})[_0x4988('0x40')](function(){return _0xbb3552;});}});});});}})[_0x4988('0x40')](respondWithResult(_0x23c05b,0xc9))[_0x4988('0x45')](handleError(_0x23c05b,null));};exports[_0x4988('0x26')]=function(_0x19c378,_0x153804){if(_0x19c378[_0x4988('0x4c')]['id']){delete _0x19c378[_0x4988('0x4c')]['id'];}return db['UserProfile']['find']({'where':{'id':_0x19c378[_0x4988('0x47')]['id']}})[_0x4988('0x40')](handleEntityNotFound(_0x153804,null))['then'](saveUpdates(_0x19c378[_0x4988('0x4c')],null))[_0x4988('0x40')](respondWithResult(_0x153804,null))[_0x4988('0x45')](handleError(_0x153804,null));};exports[_0x4988('0x5b')]=function(_0x5ed3e0,_0x35fdb6){return db[_0x4988('0x3f')]['find']({'where':{'id':_0x5ed3e0[_0x4988('0x47')]['id']}})[_0x4988('0x40')](handleEntityNotFound(_0x35fdb6,null))[_0x4988('0x40')](removeEntity(_0x35fdb6,null))['catch'](handleError(_0x35fdb6,null));};exports['describe']=function(_0x463db9,_0x2b8cf8){return db[_0x4988('0x3f')][_0x4988('0x5c')]()['then'](respondWithResult(_0x2b8cf8,null))[_0x4988('0x45')](handleError(_0x2b8cf8,null));};exports[_0x4988('0x5d')]=function(_0x12b0e8,_0x26ce38){var _0x3d793a=_0x12b0e8[_0x4988('0x4c')];return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x12b0e8[_0x4988('0x47')]['id']}})[_0x4988('0x40')](handleEntityNotFound(_0x26ce38,null))[_0x4988('0x40')](function(_0x58db84){if(_0x58db84){return db['sequelize']['transaction'](function(_0x6db8f4){return db[_0x4988('0x55')][_0x4988('0x5b')]({'where':{'userProfileId':_0x12b0e8['params']['id'],'sectionId':_['map'](_0x3d793a,function(_0x2dfef9){return _0x2dfef9[_0x4988('0x5e')];})},'transaction':_0x6db8f4})['then'](function(){var _0x556722=_['map'](_0x3d793a,function(_0x352e9d){_0x352e9d[_0x4988('0x58')]=_0x12b0e8[_0x4988('0x47')]['id'];return _0x352e9d;});var _0x23d3e1=[];return BPromise['each'](_0x556722,function(_0x269a73){return db['UserProfileSection'][_0x4988('0x4b')](_0x269a73,{'include':[{'model':db[_0x4988('0x5a')],'as':'Resources'}],'raw':!![],'transaction':_0x6db8f4})[_0x4988('0x40')](function(_0x447156){_0x23d3e1[_0x4988('0x5f')](_0x447156[_0x4988('0x4f')]({'plain':!![]}));});})[_0x4988('0x40')](function(){return _0x23d3e1;});});});}})[_0x4988('0x40')](function(_0xa036f4){return _0xa036f4;})[_0x4988('0x40')](respondWithResult(_0x26ce38,null))[_0x4988('0x45')](handleError(_0x26ce38,null));};exports['removeSections']=function(_0x40ed1e,_0x26bd3b){var _0x2611b7;return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x40ed1e[_0x4988('0x47')]['id']},'attributes':['id',_0x4988('0x2a')]})[_0x4988('0x40')](handleEntityNotFound(_0x26bd3b,null))[_0x4988('0x40')](function(_0x239248){if(_0x239248){_0x2611b7=_0x239248;return db[_0x4988('0x55')][_0x4988('0x5b')]({'where':{'userProfileId':_0x40ed1e['params']['id'],'sectionId':_0x40ed1e[_0x4988('0x31')]['ids']}});}})[_0x4988('0x40')](function(){return _0x2611b7;})[_0x4988('0x40')](respondWithStatusCode(_0x26bd3b,null))[_0x4988('0x45')](handleError(_0x26bd3b,null));};exports['getSections']=function(_0x441277,_0x118b39){var _0x361218=[];var _0x31f7b1=[];return db['UserProfileSection'][_0x4988('0x43')]({'where':{'userProfileId':_0x441277[_0x4988('0x47')]['id']},'raw':!![]})['then'](function(_0x3bd5a9){_0x361218=_[_0x4988('0x3c')](_0x3bd5a9,function(_0x4967ee){return _0x4967ee[_0x4988('0x60')]===0x1||_['includes']([0x3eb,0x709],_0x4967ee[_0x4988('0x5e')]);});if(!_[_0x4988('0x61')](_0x361218)){return _[_0x4988('0x2c')](_0x361218,function(_0x22100b){return _0x22100b['sectionId'];});}else{return;}})[_0x4988('0x40')](function(_0xe4fdf9){if(_0xe4fdf9)_0x31f7b1=_0xe4fdf9;if(_[_0x4988('0x62')](_0x31f7b1,0x64)){var _0x4e05c3=_[_0x4988('0x4a')](_0x361218,{'sectionId':0x64});return hasDefaultDashboard(_0x4e05c3)[_0x4988('0x40')](function(_0x3ede66){return _[_0x4988('0x2c')](_0x361218,function(_0x45870e){if(_0x45870e[_0x4988('0x5e')]===0x64){_0x45870e[_0x4988('0x63')]=_0x3ede66;}return _0x45870e;});});}else{return;}})[_0x4988('0x40')](function(_0x4c7010){if(_0x4c7010)_0x361218=_0x4c7010;if(_[_0x4988('0x62')](_0x31f7b1,0x3eb)){var _0x3863b0=_[_0x4988('0x4a')](_0x361218,{'sectionId':0x3eb});return getCustomDashboards(_0x3863b0)[_0x4988('0x40')](function(_0x2913a6){return _[_0x4988('0x2c')](_0x361218,function(_0x63cdcb){if(_0x3863b0[_0x4988('0x60')]){if(_0x63cdcb[_0x4988('0x5e')]===0x3eb){_0x63cdcb[_0x4988('0x63')]=_0x2913a6;}}else{if(_0x63cdcb[_0x4988('0x5e')]===0x64){if(!_0x63cdcb[_0x4988('0x63')]){_0x63cdcb[_0x4988('0x63')]=[];}_0x63cdcb[_0x4988('0x63')]=_0x63cdcb[_0x4988('0x63')][_0x4988('0x64')](_0x2913a6);}}return _0x63cdcb;});});}else{return;}})[_0x4988('0x40')](function(_0x42e06a){if(_0x42e06a)_0x361218=_0x42e06a;if(_['includes'](_0x31f7b1,0x709)){var _0x4a112f=_[_0x4988('0x4a')](_0x361218,{'sectionId':0x709});return getPlugins(_0x4a112f)[_0x4988('0x40')](function(_0x39e87){if(_0x4a112f['enabled']){return _[_0x4988('0x2c')](_0x361218,function(_0x5bb1da){if(_0x5bb1da[_0x4988('0x5e')]===0x709){_0x5bb1da['subsections']=_0x39e87;}return _0x5bb1da;});}else{var _0x5b6a9c={'sectionId':0x76c,'enabled':0x1,'subsections':_0x39e87};var _0x2b904d=_[_0x4988('0x2c')](_0x361218);_0x2b904d[_0x4988('0x5f')](_0x5b6a9c);return _0x2b904d;}});}else{return;}})[_0x4988('0x40')](function(_0x535714){if(_0x535714)_0x361218=_0x535714;return _[_0x4988('0x3c')](_0x361218,[_0x4988('0x60'),0x1]);})[_0x4988('0x40')](respondWithResult(_0x118b39,null))[_0x4988('0x45')](handleError(_0x118b39,null));};function hasDefaultDashboard(_0x4ba4ed){var _0x4c41f7=[0x65];return new BPromise(function(_0x4f7668,_0x56d28f){try{if(_0x4ba4ed[_0x4988('0x57')]){_0x4f7668(_0x4c41f7);}else{return db[_0x4988('0x5a')][_0x4988('0x65')]({'where':{'sectionId':_0x4ba4ed['id']},'raw':!![]})[_0x4988('0x40')](function(_0x4bdf37){_0x4bdf37?_0x4f7668(_0x4c41f7):_0x4f7668();});}}catch(_0x2a0a93){_0x56d28f(_0x2a0a93);}});}function getCustomDashboards(_0x75d20d){var _0x3790ab=[];return new BPromise(function(_0x45a212,_0x1a3819){try{if(_0x75d20d[_0x4988('0x57')]){return db[_0x4988('0x66')][_0x4988('0x43')]({'raw':!![]})[_0x4988('0x40')](function(_0x2d1773){_0x2d1773[_0x4988('0x67')](function(_0x3d482e){_0x3790ab[_0x4988('0x5f')](_0x3d482e['id']+0x1869f);});_0x45a212(_0x3790ab);});}else{return db[_0x4988('0x5a')][_0x4988('0x43')]({'where':{'sectionId':_0x75d20d['id']},'raw':!![]})[_0x4988('0x40')](function(_0x199459){_0x199459[_0x4988('0x67')](function(_0x37734a){_0x3790ab['push'](_0x37734a[_0x4988('0x68')]+0x1869f);});_0x45a212(_0x3790ab);});}}catch(_0x5e7651){_0x1a3819(_0x5e7651);}});}function getPlugins(_0x3bd70b){var _0x19f278=[];return new BPromise(function(_0x29edf9,_0x2507df){try{if(_0x3bd70b['autoAssociation']){return db[_0x4988('0x69')]['findAll']({'raw':!![]})['then'](function(_0x4e7be3){_0x4e7be3[_0x4988('0x67')](function(_0x837db3){_0x19f278[_0x4988('0x5f')](_0x837db3['id']+0x15b38);});_0x29edf9(_0x19f278);});}else{return db[_0x4988('0x5a')][_0x4988('0x43')]({'where':{'sectionId':_0x3bd70b['id']},'raw':!![]})[_0x4988('0x40')](function(_0x54298e){_0x54298e[_0x4988('0x67')](function(_0x1ad655){_0x19f278[_0x4988('0x5f')](_0x1ad655[_0x4988('0x68')]+0x15b38);});_0x29edf9(_0x19f278);});}}catch(_0x1bee3f){_0x2507df(_0x1bee3f);}});}exports[_0x4988('0x6a')]=function(_0x2e4879,_0x3f3898){return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x2e4879[_0x4988('0x47')]['id']}})[_0x4988('0x40')](handleEntityNotFound(_0x3f3898,null))['then'](function(_0x5ef26d){if(_0x5ef26d){return db[_0x4988('0x54')][_0x4988('0x6b')](function(_0x437123){return db[_0x4988('0x55')][_0x4988('0x43')]({'where':{'userProfileId':_0x2e4879[_0x4988('0x47')]['id']},'attributes':['id'],'raw':!![]})[_0x4988('0x40')](function(_0x2ba21c){if(_0x2ba21c){return db['UserProfileSection'][_0x4988('0x5b')]({'where':{'userProfileId':_0x2e4879[_0x4988('0x47')]['id'],'id':_[_0x4988('0x2c')](_0x2ba21c,function(_0x38c4e4){return _0x38c4e4['id'];})},'transaction':_0x437123});}})['then'](function(_0xa8d16a){var _0xccbfa4=_[_0x4988('0x2c')](_0x2e4879[_0x4988('0x4c')],function(_0xc0256c){_0xc0256c[_0x4988('0x58')]=_0x2e4879[_0x4988('0x47')]['id'];return _0xc0256c;});return db[_0x4988('0x55')][_0x4988('0x6c')](_0xccbfa4,{'raw':!![],'transaction':_0x437123});})[_0x4988('0x40')](function(_0x499ba8){var _0xd78998=_[_0x4988('0x3c')](_['map'](_0x499ba8,function(_0x2718f5){return _0x2718f5['get']({'plain':!![]});}),{'includeAll':![]});if(_0xd78998){return db[_0x4988('0x55')][_0x4988('0x43')]({'where':{'userProfileId':_0x2e4879['params']['id'],'sectionId':_[_0x4988('0x2c')](_0xd78998,function(_0x2c02d7){return _0x2c02d7[_0x4988('0x5e')];})},'attributes':['id','sectionId'],'raw':!![]})[_0x4988('0x40')](function(_0x2fb910){var _0x4b60a5=_[_0x4988('0x2c')](_0x2e4879[_0x4988('0x4c')],function(_0x5990ca){_0x5990ca[_0x4988('0x58')]=_0x2e4879[_0x4988('0x47')]['id'];return _0x5990ca;});return db[_0x4988('0x5a')][_0x4988('0x6c')](_0x4b60a5,{'raw':!![],'transaction':_0x437123});});}})['catch'](handleError(_0x3f3898,null));});}})[_0x4988('0x40')](function(_0x5d0af7){var _0x44a7de=_[_0x4988('0x2c')](_0x5d0af7,function(_0x34a101){return _0x34a101[_0x4988('0x4f')]({'plain':!![]});});})[_0x4988('0x40')](respondWithResult(_0x3f3898,null))[_0x4988('0x45')](handleError(_0x3f3898,null));};exports[_0x4988('0x6d')]=function(_0x3d44bc,_0x357ba0,_0x2e49da){return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x3d44bc[_0x4988('0x47')]['id']}})['then'](handleEntityNotFound(_0x357ba0,null))['then'](function(_0x6b37ad){if(_0x6b37ad){return _0x6b37ad['removeResources'](_0x3d44bc['query'][_0x4988('0x6e')]);}})[_0x4988('0x40')](respondWithStatusCode(_0x357ba0,null))[_0x4988('0x45')](handleError(_0x357ba0,null));};exports[_0x4988('0x6f')]=function(_0x2d7d56,_0x12d897){var _0x418ab4={};if(!_0x2d7d56[_0x4988('0x31')]['section'])throw new Error(_0x4988('0x70'));if(!_0x2d7d56[_0x4988('0x31')][_0x4988('0x37')]('nolimit')){_0x418ab4[_0x4988('0x38')]=qs['limit'](_0x2d7d56[_0x4988('0x31')]['limit']);_0x418ab4[_0x4988('0x1f')]=qs[_0x4988('0x1f')](_0x2d7d56[_0x4988('0x31')][_0x4988('0x1f')]);}return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x2d7d56[_0x4988('0x47')]['id']}})[_0x4988('0x40')](function(_0x207351){if(!_0x207351)throw new Error(_0x4988('0x71')+_0x2d7d56[_0x4988('0x47')]['id']);return db[_0x4988('0x3f')]['getResources'](_0x2d7d56);})[_0x4988('0x40')](respondWithFilteredResult(_0x12d897,_0x418ab4))[_0x4988('0x45')](handleError(_0x12d897,null));};