Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / api / userProfileSection / userProfileSection.controller.js
index add0f34..64e50f2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x83b6=['crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','status','end','json','offset','limit','undefined','count','Content-Range','apply','reject','update','then','destroy','sendStatus','error','stack','name','index','map','UserProfileSection','rawAttributes','key','query','keys','intersection','model','attributes','fields','hasOwnProperty','nolimit','sort','filters','filter','where','merge','VIRTUAL','options','findAll','rows','catch','show','params','include','find','create','body','describe','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','ejs','fs-extra','lodash'];(function(_0x2ea087,_0x17f324){var _0x23ebac=function(_0x5575d8){while(--_0x5575d8){_0x2ea087['push'](_0x2ea087['shift']());}};_0x23ebac(++_0x17f324);}(_0x83b6,0x83));var _0x683b=function(_0x24ec78,_0x5c40e5){_0x24ec78=_0x24ec78-0x0;var _0x297a11=_0x83b6[_0x24ec78];return _0x297a11;};'use strict';var emlformat=require(_0x683b('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x683b('0x1'));var jsonpatch=require(_0x683b('0x2'));var rp=require(_0x683b('0x3'));var moment=require(_0x683b('0x4'));var BPromise=require(_0x683b('0x5'));var Mustache=require('mustache');var util=require(_0x683b('0x6'));var path=require('path');var sox=require(_0x683b('0x7'));var csv=require('to-csv');var ejs=require(_0x683b('0x8'));var fs=require('fs');var fs_extra=require(_0x683b('0x9'));var _=require(_0x683b('0xa'));var squel=require('squel');var crypto=require(_0x683b('0xb'));var jsforce=require(_0x683b('0xc'));var deskjs=require(_0x683b('0xd'));var toCsv=require(_0x683b('0xe'));var querystring=require(_0x683b('0xf'));var Papa=require('papaparse');var Redis=require(_0x683b('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x683b('0x11'));var as=require(_0x683b('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x683b('0x13'))(_0x683b('0x14'));var utils=require(_0x683b('0x15'));var config=require(_0x683b('0x16'));var licenseUtil=require(_0x683b('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4af4fd,_0x376345){_0x376345=_0x376345||0xcc;return function(_0x5bba5a){if(_0x5bba5a){return _0x4af4fd['sendStatus'](_0x376345);}return _0x4af4fd[_0x683b('0x18')](_0x376345)[_0x683b('0x19')]();};}function respondWithResult(_0x3afaed,_0x32e0a6){_0x32e0a6=_0x32e0a6||0xc8;return function(_0x5dbeda){if(_0x5dbeda){return _0x3afaed[_0x683b('0x18')](_0x32e0a6)[_0x683b('0x1a')](_0x5dbeda);}};}function respondWithFilteredResult(_0x535bfd,_0x15f679){return function(_0x385791){if(_0x385791){var _0x252e99=typeof _0x15f679[_0x683b('0x1b')]==='undefined'&&typeof _0x15f679[_0x683b('0x1c')]===_0x683b('0x1d');var _0x338384=_0x385791[_0x683b('0x1e')];var _0x2a01e8=_0x252e99?0x0:_0x15f679[_0x683b('0x1b')];var _0x518188=_0x252e99?_0x385791[_0x683b('0x1e')]:_0x15f679[_0x683b('0x1b')]+_0x15f679[_0x683b('0x1c')];var _0x705988;if(_0x518188>=_0x338384){_0x518188=_0x338384;_0x705988=0xc8;}else{_0x705988=0xce;}_0x535bfd[_0x683b('0x18')](_0x705988);return _0x535bfd['set'](_0x683b('0x1f'),_0x2a01e8+'-'+_0x518188+'/'+_0x338384)[_0x683b('0x1a')](_0x385791);}return null;};}function patchUpdates(_0xf51c7b){return function(_0x1b6c13){try{jsonpatch[_0x683b('0x20')](_0x1b6c13,_0xf51c7b,!![]);}catch(_0x3fcfb0){return BPromise[_0x683b('0x21')](_0x3fcfb0);}return _0x1b6c13['save']();};}function saveUpdates(_0x3f16c5,_0x5696a7){return function(_0xb96967){if(_0xb96967){return _0xb96967[_0x683b('0x22')](_0x3f16c5)[_0x683b('0x23')](function(_0x2e2746){return _0x2e2746;});}return null;};}function removeEntity(_0x45a8ab,_0x2db209){return function(_0x3aa0b0){if(_0x3aa0b0){return _0x3aa0b0[_0x683b('0x24')]()[_0x683b('0x23')](function(){_0x45a8ab[_0x683b('0x18')](0xcc)[_0x683b('0x19')]();});}};}function handleEntityNotFound(_0x26369b,_0x309470){return function(_0x497044){if(!_0x497044){_0x26369b[_0x683b('0x25')](0x194);}return _0x497044;};}function handleError(_0x297b9c,_0xdef040){_0xdef040=_0xdef040||0x1f4;return function(_0x10ccde){logger[_0x683b('0x26')](_0x10ccde[_0x683b('0x27')]);if(_0x10ccde[_0x683b('0x28')]){delete _0x10ccde[_0x683b('0x28')];}_0x297b9c[_0x683b('0x18')](_0xdef040)['send'](_0x10ccde);};}exports[_0x683b('0x29')]=function(_0x33830a,_0x3dfca4){var _0x197de0={},_0x2da44e={},_0x13bce3={'count':0x0,'rows':[]};var _0x4dae71=_[_0x683b('0x2a')](db[_0x683b('0x2b')][_0x683b('0x2c')],function(_0xa7b1eb){return{'name':_0xa7b1eb['fieldName'],'type':_0xa7b1eb['type'][_0x683b('0x2d')]};});_0x2da44e['model']=_[_0x683b('0x2a')](_0x4dae71,'name');_0x2da44e[_0x683b('0x2e')]=_[_0x683b('0x2f')](_0x33830a[_0x683b('0x2e')]);_0x2da44e['filters']=_[_0x683b('0x30')](_0x2da44e[_0x683b('0x31')],_0x2da44e[_0x683b('0x2e')]);_0x197de0[_0x683b('0x32')]=_[_0x683b('0x30')](_0x2da44e[_0x683b('0x31')],qs[_0x683b('0x33')](_0x33830a[_0x683b('0x2e')][_0x683b('0x33')]));_0x197de0['attributes']=_0x197de0[_0x683b('0x32')]['length']?_0x197de0['attributes']:_0x2da44e['model'];if(!_0x33830a[_0x683b('0x2e')][_0x683b('0x34')](_0x683b('0x35'))){_0x197de0['limit']=qs['limit'](_0x33830a[_0x683b('0x2e')][_0x683b('0x1c')]);_0x197de0[_0x683b('0x1b')]=qs[_0x683b('0x1b')](_0x33830a['query'][_0x683b('0x1b')]);}_0x197de0['order']=qs['sort'](_0x33830a['query'][_0x683b('0x36')]);_0x197de0['where']=qs[_0x683b('0x37')](_['pick'](_0x33830a[_0x683b('0x2e')],_0x2da44e['filters']),_0x4dae71);if(_0x33830a[_0x683b('0x2e')][_0x683b('0x38')]){_0x197de0[_0x683b('0x39')]=_[_0x683b('0x3a')](_0x197de0[_0x683b('0x39')],{'$or':_['map'](_0x4dae71,function(_0x4c3922){if(_0x4c3922['type']!==_0x683b('0x3b')){var _0x370e0c={};_0x370e0c[_0x4c3922[_0x683b('0x28')]]={'$like':'%'+_0x33830a[_0x683b('0x2e')]['filter']+'%'};return _0x370e0c;}})});}_0x197de0=_[_0x683b('0x3a')]({},_0x197de0,_0x33830a[_0x683b('0x3c')]);var _0x42921e={'where':_0x197de0['where']};return db[_0x683b('0x2b')]['count'](_0x42921e)[_0x683b('0x23')](function(_0x3331ec){_0x13bce3[_0x683b('0x1e')]=_0x3331ec;if(_0x33830a[_0x683b('0x2e')]['includeAll']){_0x197de0['include']=[{'all':!![]}];}return db['UserProfileSection'][_0x683b('0x3d')](_0x197de0);})[_0x683b('0x23')](function(_0x240160){_0x13bce3[_0x683b('0x3e')]=_0x240160;return _0x13bce3;})[_0x683b('0x23')](respondWithFilteredResult(_0x3dfca4,_0x197de0))[_0x683b('0x3f')](handleError(_0x3dfca4,null));};exports[_0x683b('0x40')]=function(_0x5ee4e8,_0x1a0b28){var _0x5bea08={'raw':![],'where':{'id':_0x5ee4e8[_0x683b('0x41')]['id']}},_0x1d5cab={};_0x1d5cab[_0x683b('0x31')]=_[_0x683b('0x2f')](db[_0x683b('0x2b')][_0x683b('0x2c')]);_0x1d5cab[_0x683b('0x2e')]=_[_0x683b('0x2f')](_0x5ee4e8[_0x683b('0x2e')]);_0x1d5cab[_0x683b('0x37')]=_[_0x683b('0x30')](_0x1d5cab[_0x683b('0x31')],_0x1d5cab[_0x683b('0x2e')]);_0x5bea08['attributes']=_['intersection'](_0x1d5cab['model'],qs[_0x683b('0x33')](_0x5ee4e8[_0x683b('0x2e')][_0x683b('0x33')]));_0x5bea08[_0x683b('0x32')]=_0x5bea08[_0x683b('0x32')]['length']?_0x5bea08['attributes']:_0x1d5cab[_0x683b('0x31')];if(_0x5ee4e8['query']['includeAll']){_0x5bea08[_0x683b('0x42')]=[{'all':!![]}];}_0x5bea08=_[_0x683b('0x3a')]({},_0x5bea08,_0x5ee4e8[_0x683b('0x3c')]);return db[_0x683b('0x2b')][_0x683b('0x43')](_0x5bea08)[_0x683b('0x23')](handleEntityNotFound(_0x1a0b28,null))[_0x683b('0x23')](respondWithResult(_0x1a0b28,null))[_0x683b('0x3f')](handleError(_0x1a0b28,null));};exports[_0x683b('0x44')]=function(_0xf66cd6,_0x22c8e8){return db[_0x683b('0x2b')][_0x683b('0x44')](_0xf66cd6[_0x683b('0x45')],{})[_0x683b('0x23')](respondWithResult(_0x22c8e8,0xc9))[_0x683b('0x3f')](handleError(_0x22c8e8,null));};exports[_0x683b('0x22')]=function(_0x2fda57,_0x438f73){if(_0x2fda57[_0x683b('0x45')]['id']){delete _0x2fda57[_0x683b('0x45')]['id'];}return db[_0x683b('0x2b')][_0x683b('0x43')]({'where':{'id':_0x2fda57[_0x683b('0x41')]['id']}})[_0x683b('0x23')](handleEntityNotFound(_0x438f73,null))[_0x683b('0x23')](saveUpdates(_0x2fda57[_0x683b('0x45')],null))[_0x683b('0x23')](respondWithResult(_0x438f73,null))['catch'](handleError(_0x438f73,null));};exports[_0x683b('0x24')]=function(_0x10f972,_0x3d9a04){return db['UserProfileSection']['find']({'where':{'id':_0x10f972['params']['id']}})[_0x683b('0x23')](handleEntityNotFound(_0x3d9a04,null))['then'](removeEntity(_0x3d9a04,null))[_0x683b('0x3f')](handleError(_0x3d9a04,null));};exports[_0x683b('0x46')]=function(_0x28ec6b,_0x102694){return db[_0x683b('0x2b')][_0x683b('0x46')]()[_0x683b('0x23')](respondWithResult(_0x102694,null))['catch'](handleError(_0x102694,null));};
\ No newline at end of file
+var _0x78e9=['error','name','send','index','rawAttributes','type','key','map','query','filters','intersection','model','attributes','fields','length','nolimit','order','sort','where','filter','VIRTUAL','merge','options','includeAll','include','UserProfileSection','rows','show','params','keys','find','catch','create','body','describe','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','undefined','limit','count','offset','set','Content-Range','json','save','update','destroy','then'];(function(_0x10d3c2,_0x1f5142){var _0x4208aa=function(_0x2e1ff9){while(--_0x2e1ff9){_0x10d3c2['push'](_0x10d3c2['shift']());}};_0x4208aa(++_0x1f5142);}(_0x78e9,0x190));var _0x978e=function(_0x8cfaba,_0x207ffb){_0x8cfaba=_0x8cfaba-0x0;var _0x2dc0db=_0x78e9[_0x8cfaba];return _0x2dc0db;};'use strict';var emlformat=require(_0x978e('0x0'));var rimraf=require(_0x978e('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x978e('0x2'));var rp=require(_0x978e('0x3'));var moment=require(_0x978e('0x4'));var BPromise=require(_0x978e('0x5'));var Mustache=require(_0x978e('0x6'));var util=require(_0x978e('0x7'));var path=require(_0x978e('0x8'));var sox=require(_0x978e('0x9'));var csv=require(_0x978e('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x978e('0xb'));var squel=require(_0x978e('0xc'));var crypto=require(_0x978e('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x978e('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x978e('0xf'));var Redis=require(_0x978e('0x10'));var authService=require(_0x978e('0x11'));var qs=require(_0x978e('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x978e('0x13'));var logger=require(_0x978e('0x14'))('api');var utils=require(_0x978e('0x15'));var config=require(_0x978e('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x978e('0x17'))['db'];function respondWithStatusCode(_0x5ec496,_0x5163c8){_0x5163c8=_0x5163c8||0xcc;return function(_0x4f123c){if(_0x4f123c){return _0x5ec496[_0x978e('0x18')](_0x5163c8);}return _0x5ec496[_0x978e('0x19')](_0x5163c8)[_0x978e('0x1a')]();};}function respondWithResult(_0x4301d0,_0x23dde1){_0x23dde1=_0x23dde1||0xc8;return function(_0x574ad8){if(_0x574ad8){return _0x4301d0[_0x978e('0x19')](_0x23dde1)['json'](_0x574ad8);}};}function respondWithFilteredResult(_0x5b2771,_0x202a23){return function(_0x9a35fb){if(_0x9a35fb){var _0x9653b4=typeof _0x202a23['offset']===_0x978e('0x1b')&&typeof _0x202a23[_0x978e('0x1c')]==='undefined';var _0x1bd8de=_0x9a35fb[_0x978e('0x1d')];var _0x4f9e84=_0x9653b4?0x0:_0x202a23[_0x978e('0x1e')];var _0x51ca13=_0x9653b4?_0x9a35fb[_0x978e('0x1d')]:_0x202a23[_0x978e('0x1e')]+_0x202a23['limit'];var _0x5943a8;if(_0x51ca13>=_0x1bd8de){_0x51ca13=_0x1bd8de;_0x5943a8=0xc8;}else{_0x5943a8=0xce;}_0x5b2771[_0x978e('0x19')](_0x5943a8);return _0x5b2771[_0x978e('0x1f')](_0x978e('0x20'),_0x4f9e84+'-'+_0x51ca13+'/'+_0x1bd8de)[_0x978e('0x21')](_0x9a35fb);}return null;};}function patchUpdates(_0x1329e1){return function(_0x4ce4e8){try{jsonpatch['apply'](_0x4ce4e8,_0x1329e1,!![]);}catch(_0x5b0d98){return BPromise['reject'](_0x5b0d98);}return _0x4ce4e8[_0x978e('0x22')]();};}function saveUpdates(_0x328c66,_0x1025c8){return function(_0x7915f7){if(_0x7915f7){return _0x7915f7[_0x978e('0x23')](_0x328c66)['then'](function(_0x4ad091){return _0x4ad091;});}return null;};}function removeEntity(_0x37e3ca,_0x2d43b2){return function(_0x448b60){if(_0x448b60){return _0x448b60[_0x978e('0x24')]()[_0x978e('0x25')](function(){_0x37e3ca[_0x978e('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4f8cde,_0x3d6fba){return function(_0x564aaa){if(!_0x564aaa){_0x4f8cde[_0x978e('0x18')](0x194);}return _0x564aaa;};}function handleError(_0x1ec313,_0x57cacd){_0x57cacd=_0x57cacd||0x1f4;return function(_0x525c18){logger[_0x978e('0x26')](_0x525c18['stack']);if(_0x525c18[_0x978e('0x27')]){delete _0x525c18[_0x978e('0x27')];}_0x1ec313[_0x978e('0x19')](_0x57cacd)[_0x978e('0x28')](_0x525c18);};}exports[_0x978e('0x29')]=function(_0x482793,_0x544e36){var _0x56b4b0={},_0x247483={},_0x327fff={'count':0x0,'rows':[]};var _0x89a50a=_['map'](db['UserProfileSection'][_0x978e('0x2a')],function(_0xdebb81){return{'name':_0xdebb81['fieldName'],'type':_0xdebb81[_0x978e('0x2b')][_0x978e('0x2c')]};});_0x247483['model']=_[_0x978e('0x2d')](_0x89a50a,_0x978e('0x27'));_0x247483['query']=_['keys'](_0x482793[_0x978e('0x2e')]);_0x247483[_0x978e('0x2f')]=_[_0x978e('0x30')](_0x247483[_0x978e('0x31')],_0x247483[_0x978e('0x2e')]);_0x56b4b0[_0x978e('0x32')]=_[_0x978e('0x30')](_0x247483[_0x978e('0x31')],qs[_0x978e('0x33')](_0x482793[_0x978e('0x2e')][_0x978e('0x33')]));_0x56b4b0['attributes']=_0x56b4b0[_0x978e('0x32')][_0x978e('0x34')]?_0x56b4b0[_0x978e('0x32')]:_0x247483[_0x978e('0x31')];if(!_0x482793['query']['hasOwnProperty'](_0x978e('0x35'))){_0x56b4b0[_0x978e('0x1c')]=qs[_0x978e('0x1c')](_0x482793[_0x978e('0x2e')][_0x978e('0x1c')]);_0x56b4b0['offset']=qs['offset'](_0x482793[_0x978e('0x2e')][_0x978e('0x1e')]);}_0x56b4b0[_0x978e('0x36')]=qs[_0x978e('0x37')](_0x482793[_0x978e('0x2e')][_0x978e('0x37')]);_0x56b4b0[_0x978e('0x38')]=qs[_0x978e('0x2f')](_['pick'](_0x482793[_0x978e('0x2e')],_0x247483[_0x978e('0x2f')]),_0x89a50a);if(_0x482793[_0x978e('0x2e')][_0x978e('0x39')]){_0x56b4b0[_0x978e('0x38')]=_['merge'](_0x56b4b0[_0x978e('0x38')],{'$or':_[_0x978e('0x2d')](_0x89a50a,function(_0x3accbd){if(_0x3accbd['type']!==_0x978e('0x3a')){var _0x1a8737={};_0x1a8737[_0x3accbd[_0x978e('0x27')]]={'$like':'%'+_0x482793['query']['filter']+'%'};return _0x1a8737;}})});}_0x56b4b0=_[_0x978e('0x3b')]({},_0x56b4b0,_0x482793[_0x978e('0x3c')]);var _0x12e1e8={'where':_0x56b4b0[_0x978e('0x38')]};return db['UserProfileSection'][_0x978e('0x1d')](_0x12e1e8)[_0x978e('0x25')](function(_0x37e7ac){_0x327fff['count']=_0x37e7ac;if(_0x482793['query'][_0x978e('0x3d')]){_0x56b4b0[_0x978e('0x3e')]=[{'all':!![]}];}return db[_0x978e('0x3f')]['findAll'](_0x56b4b0);})[_0x978e('0x25')](function(_0x10beee){_0x327fff[_0x978e('0x40')]=_0x10beee;return _0x327fff;})[_0x978e('0x25')](respondWithFilteredResult(_0x544e36,_0x56b4b0))['catch'](handleError(_0x544e36,null));};exports[_0x978e('0x41')]=function(_0x41c3e9,_0x119700){var _0x52403a={'raw':![],'where':{'id':_0x41c3e9[_0x978e('0x42')]['id']}},_0x58b8e3={};_0x58b8e3[_0x978e('0x31')]=_['keys'](db[_0x978e('0x3f')][_0x978e('0x2a')]);_0x58b8e3[_0x978e('0x2e')]=_[_0x978e('0x43')](_0x41c3e9[_0x978e('0x2e')]);_0x58b8e3[_0x978e('0x2f')]=_['intersection'](_0x58b8e3[_0x978e('0x31')],_0x58b8e3[_0x978e('0x2e')]);_0x52403a[_0x978e('0x32')]=_[_0x978e('0x30')](_0x58b8e3['model'],qs[_0x978e('0x33')](_0x41c3e9[_0x978e('0x2e')]['fields']));_0x52403a['attributes']=_0x52403a[_0x978e('0x32')][_0x978e('0x34')]?_0x52403a[_0x978e('0x32')]:_0x58b8e3['model'];if(_0x41c3e9['query'][_0x978e('0x3d')]){_0x52403a[_0x978e('0x3e')]=[{'all':!![]}];}_0x52403a=_[_0x978e('0x3b')]({},_0x52403a,_0x41c3e9[_0x978e('0x3c')]);return db[_0x978e('0x3f')][_0x978e('0x44')](_0x52403a)[_0x978e('0x25')](handleEntityNotFound(_0x119700,null))[_0x978e('0x25')](respondWithResult(_0x119700,null))[_0x978e('0x45')](handleError(_0x119700,null));};exports[_0x978e('0x46')]=function(_0x790dc5,_0x2b9d33){return db[_0x978e('0x3f')][_0x978e('0x46')](_0x790dc5['body'],{})['then'](respondWithResult(_0x2b9d33,0xc9))[_0x978e('0x45')](handleError(_0x2b9d33,null));};exports[_0x978e('0x23')]=function(_0x58ae5d,_0x30c2a5){if(_0x58ae5d[_0x978e('0x47')]['id']){delete _0x58ae5d[_0x978e('0x47')]['id'];}return db[_0x978e('0x3f')][_0x978e('0x44')]({'where':{'id':_0x58ae5d[_0x978e('0x42')]['id']}})[_0x978e('0x25')](handleEntityNotFound(_0x30c2a5,null))[_0x978e('0x25')](saveUpdates(_0x58ae5d['body'],null))['then'](respondWithResult(_0x30c2a5,null))['catch'](handleError(_0x30c2a5,null));};exports[_0x978e('0x24')]=function(_0x58f02d,_0x579368){return db[_0x978e('0x3f')][_0x978e('0x44')]({'where':{'id':_0x58f02d[_0x978e('0x42')]['id']}})[_0x978e('0x25')](handleEntityNotFound(_0x579368,null))['then'](removeEntity(_0x579368,null))[_0x978e('0x45')](handleError(_0x579368,null));};exports['describe']=function(_0x583b9c,_0xe8d551){return db[_0x978e('0x3f')][_0x978e('0x48')]()[_0x978e('0x25')](respondWithResult(_0xe8d551,null))[_0x978e('0x45')](handleError(_0xe8d551,null));};
\ No newline at end of file