Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / squareProject / squareProject.controller.js
index deb1207..46327e4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x46e7=['json','reject','save','update','destroy','get','SquareProjects','UserProfileResource','then','error','name','send','SquareProject','rawAttributes','fieldName','type','key','model','map','keys','query','filters','intersection','fields','attributes','length','nolimit','order','sort','where','VIRTUAL','filter','merge','options','includeAll','include','findAll','catch','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','body','addUsers','ids','omit','removeUsers','isArray','emit','userSquareProject:remove','getUsers','findOne','User','pick','hasOwnProperty','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','util','path','sox','to-csv','ejs','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./squareProject.socket','register','sendStatus','end','status','count','offset','limit','set','Content-Range'];(function(_0x4b055c,_0x4b870b){var _0x4b62bb=function(_0x4884c2){while(--_0x4884c2){_0x4b055c['push'](_0x4b055c['shift']());}};_0x4b62bb(++_0x4b870b);}(_0x46e7,0x15e));var _0x746e=function(_0x1e60ff,_0x2ac8bb){_0x1e60ff=_0x1e60ff-0x0;var _0x6ba891=_0x46e7[_0x1e60ff];return _0x6ba891;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x746e('0x0'));var rimraf=require(_0x746e('0x1'));var zipdir=require(_0x746e('0x2'));var jsonpatch=require(_0x746e('0x3'));var rp=require(_0x746e('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x746e('0x5'));var path=require(_0x746e('0x6'));var sox=require(_0x746e('0x7'));var csv=require(_0x746e('0x8'));var ejs=require(_0x746e('0x9'));var fs=require('fs');var _=require(_0x746e('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x746e('0xb'));var deskjs=require(_0x746e('0xc'));var toCsv=require(_0x746e('0x8'));var querystring=require(_0x746e('0xd'));var Papa=require(_0x746e('0xe'));var Redis=require(_0x746e('0xf'));var authService=require(_0x746e('0x10'));var qs=require(_0x746e('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x746e('0x12'));var logger=require(_0x746e('0x13'))(_0x746e('0x14'));var utils=require(_0x746e('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x746e('0x16'));var db=require(_0x746e('0x17'))['db'];config[_0x746e('0x18')]=_[_0x746e('0x19')](config['redis'],{'host':_0x746e('0x1a'),'port':0x18eb});var socket=require(_0x746e('0x1b'))(new Redis(config[_0x746e('0x18')]));require(_0x746e('0x1c'))[_0x746e('0x1d')](socket);function respondWithStatusCode(_0x5acd95,_0x4ccc56){_0x4ccc56=_0x4ccc56||0xcc;return function(_0x5821da){if(_0x5821da){return _0x5acd95[_0x746e('0x1e')](_0x4ccc56);}return _0x5acd95['status'](_0x4ccc56)[_0x746e('0x1f')]();};}function respondWithResult(_0x54bc44,_0x30bfab){_0x30bfab=_0x30bfab||0xc8;return function(_0x54677f){if(_0x54677f){return _0x54bc44[_0x746e('0x20')](_0x30bfab)['json'](_0x54677f);}};}function respondWithFilteredResult(_0x257cf5,_0x2d497a){return function(_0x1c2fa2){if(_0x1c2fa2){var _0x1fd6f3=_0x1c2fa2[_0x746e('0x21')],_0x18dcad=_0x2d497a[_0x746e('0x22')],_0x4cf9f7=_0x2d497a[_0x746e('0x22')]+_0x2d497a[_0x746e('0x23')],_0x4948bc;if(_0x4cf9f7>=_0x1fd6f3){_0x4cf9f7=_0x1fd6f3;_0x4948bc=0xc8;}else{_0x4948bc=0xce;}_0x257cf5['status'](_0x4948bc);return _0x257cf5[_0x746e('0x24')](_0x746e('0x25'),_0x18dcad+'-'+_0x4cf9f7+'/'+_0x1fd6f3)[_0x746e('0x26')](_0x1c2fa2);}return null;};}function patchUpdates(_0x2bfa0b){return function(_0x4126af){try{jsonpatch['apply'](_0x4126af,_0x2bfa0b,!![]);}catch(_0x2eadeb){return BPromise[_0x746e('0x27')](_0x2eadeb);}return _0x4126af[_0x746e('0x28')]();};}function saveUpdates(_0xfc6b48,_0xdd5b2e){return function(_0x7f6fd2){if(_0x7f6fd2){return _0x7f6fd2[_0x746e('0x29')](_0xfc6b48)['then'](function(_0x4153de){return _0x4153de;});}return null;};}function removeEntity(_0x2711bf,_0x13e970){return function(_0x13b872){if(_0x13b872){return _0x13b872[_0x746e('0x2a')]()['then'](function(){var _0x592334=_0x13b872[_0x746e('0x2b')]({'plain':!![]});var _0xec9748=_0x746e('0x2c');return db[_0x746e('0x2d')][_0x746e('0x2a')]({'where':{'type':_0xec9748,'resourceId':_0x592334['id']}})[_0x746e('0x2e')](function(){return _0x13b872;});})['then'](function(){_0x2711bf[_0x746e('0x20')](0xcc)[_0x746e('0x1f')]();});}};}function handleEntityNotFound(_0x58bba4,_0x8a6312){return function(_0x2ab46c){if(!_0x2ab46c){_0x58bba4['sendStatus'](0x194);}return _0x2ab46c;};}function handleError(_0x37c72c,_0x10a990){_0x10a990=_0x10a990||0x1f4;return function(_0x582a47){logger[_0x746e('0x2f')](_0x582a47['stack']);if(_0x582a47[_0x746e('0x30')]){delete _0x582a47[_0x746e('0x30')];}_0x37c72c[_0x746e('0x20')](_0x10a990)[_0x746e('0x31')](_0x582a47);};}exports['index']=function(_0x111591,_0x1d0000){var _0x52e578={},_0x521c59={},_0x6a132d={'count':0x0,'rows':[]};var _0x37f87d=_['map'](db[_0x746e('0x32')][_0x746e('0x33')],function(_0x109b24){return{'name':_0x109b24[_0x746e('0x34')],'type':_0x109b24[_0x746e('0x35')][_0x746e('0x36')]};});_0x521c59[_0x746e('0x37')]=_[_0x746e('0x38')](_0x37f87d,'name');_0x521c59['query']=_[_0x746e('0x39')](_0x111591[_0x746e('0x3a')]);_0x521c59[_0x746e('0x3b')]=_[_0x746e('0x3c')](_0x521c59[_0x746e('0x37')],_0x521c59[_0x746e('0x3a')]);_0x52e578['attributes']=_[_0x746e('0x3c')](_0x521c59['model'],qs[_0x746e('0x3d')](_0x111591['query'][_0x746e('0x3d')]));_0x52e578['attributes']=_0x52e578[_0x746e('0x3e')][_0x746e('0x3f')]?_0x52e578[_0x746e('0x3e')]:_0x521c59[_0x746e('0x37')];if(!_0x111591[_0x746e('0x3a')]['hasOwnProperty'](_0x746e('0x40'))){_0x52e578[_0x746e('0x23')]=qs['limit'](_0x111591[_0x746e('0x3a')][_0x746e('0x23')]);_0x52e578['offset']=qs[_0x746e('0x22')](_0x111591['query']['offset']);}_0x52e578[_0x746e('0x41')]=qs[_0x746e('0x42')](_0x111591[_0x746e('0x3a')][_0x746e('0x42')]);_0x52e578[_0x746e('0x43')]=qs['filters'](_['pick'](_0x111591['query'],_0x521c59[_0x746e('0x3b')]),_0x37f87d);if(_0x111591[_0x746e('0x3a')]['filter']){_0x52e578[_0x746e('0x43')]=_['merge'](_0x52e578[_0x746e('0x43')],{'$or':_[_0x746e('0x38')](_0x37f87d,function(_0x465c04){if(_0x465c04[_0x746e('0x35')]!==_0x746e('0x44')){var _0x2f648a={};_0x2f648a[_0x465c04[_0x746e('0x30')]]={'$like':'%'+_0x111591[_0x746e('0x3a')][_0x746e('0x45')]+'%'};return _0x2f648a;}})});}_0x52e578=_[_0x746e('0x46')]({},_0x52e578,_0x111591[_0x746e('0x47')]);var _0x17d6d8={'where':_0x52e578['where']};return db['SquareProject']['count'](_0x17d6d8)['then'](function(_0x36b488){_0x6a132d[_0x746e('0x21')]=_0x36b488;if(_0x111591[_0x746e('0x3a')][_0x746e('0x48')]){_0x52e578[_0x746e('0x49')]=[{'all':!![]}];}return db['SquareProject'][_0x746e('0x4a')](_0x52e578);})[_0x746e('0x2e')](function(_0x2f2cdc){_0x6a132d['rows']=_0x2f2cdc;return _0x6a132d;})[_0x746e('0x2e')](respondWithFilteredResult(_0x1d0000,_0x52e578))[_0x746e('0x4b')](handleError(_0x1d0000,null));};exports['show']=function(_0x5547c9,_0x327d0b){var _0x104dff={'raw':![],'where':{'id':_0x5547c9['params']['id']}},_0x5c9001={};_0x5c9001[_0x746e('0x37')]=_[_0x746e('0x39')](db[_0x746e('0x32')][_0x746e('0x33')]);_0x5c9001[_0x746e('0x3a')]=_[_0x746e('0x39')](_0x5547c9[_0x746e('0x3a')]);_0x5c9001[_0x746e('0x3b')]=_[_0x746e('0x3c')](_0x5c9001['model'],_0x5c9001[_0x746e('0x3a')]);_0x104dff[_0x746e('0x3e')]=_[_0x746e('0x3c')](_0x5c9001[_0x746e('0x37')],qs[_0x746e('0x3d')](_0x5547c9['query'][_0x746e('0x3d')]));_0x104dff[_0x746e('0x3e')]=_0x104dff[_0x746e('0x3e')][_0x746e('0x3f')]?_0x104dff['attributes']:_0x5c9001[_0x746e('0x37')];if(_0x5547c9['query']['includeAll']){_0x104dff[_0x746e('0x49')]=[{'all':!![]}];}_0x104dff=_[_0x746e('0x46')]({},_0x104dff,_0x5547c9['options']);return db[_0x746e('0x32')]['find'](_0x104dff)[_0x746e('0x2e')](handleEntityNotFound(_0x327d0b,null))[_0x746e('0x2e')](respondWithResult(_0x327d0b,null))[_0x746e('0x4b')](handleError(_0x327d0b,null));};exports['create']=function(_0x403c7d,_0x3c16ea){return db[_0x746e('0x32')][_0x746e('0x4c')](_0x403c7d['body'],{})['then'](function(_0x3dce43){var _0x34b30e=_0x403c7d[_0x746e('0x4d')][_0x746e('0x2b')]({'plain':!![]});if(!_0x34b30e)throw new Error(_0x746e('0x4e'));if(_0x34b30e['role']===_0x746e('0x4d')){var _0x1f467c=_0x3dce43['get']({'plain':!![]});var _0x5180d3='SquareProjects';return db[_0x746e('0x4f')][_0x746e('0x50')]({'where':{'name':_0x5180d3,'userProfileId':_0x34b30e['userProfileId']},'raw':!![]})[_0x746e('0x2e')](function(_0x215ccc){if(_0x215ccc&&_0x215ccc[_0x746e('0x51')]===0x0){return db[_0x746e('0x2d')][_0x746e('0x4c')]({'name':_0x1f467c[_0x746e('0x30')],'resourceId':_0x1f467c['id'],'type':_0x215ccc[_0x746e('0x30')],'sectionId':_0x215ccc['id']},{})['then'](function(){return _0x3dce43;});}else{return _0x3dce43;}})[_0x746e('0x4b')](function(_0x84af41){logger[_0x746e('0x2f')](_0x746e('0x52'),_0x84af41);throw _0x84af41;});}return _0x3dce43;})[_0x746e('0x2e')](respondWithResult(_0x3c16ea,0xc9))['catch'](handleError(_0x3c16ea,null));};exports[_0x746e('0x29')]=function(_0x3c4e2b,_0x54ee10){if(_0x3c4e2b['body']['id']){delete _0x3c4e2b['body']['id'];}return db['SquareProject'][_0x746e('0x50')]({'where':{'id':_0x3c4e2b[_0x746e('0x53')]['id']}})[_0x746e('0x2e')](handleEntityNotFound(_0x54ee10,null))[_0x746e('0x2e')](saveUpdates(_0x3c4e2b[_0x746e('0x54')],null))['then'](respondWithResult(_0x54ee10,null))[_0x746e('0x4b')](handleError(_0x54ee10,null));};exports[_0x746e('0x2a')]=function(_0x21ff0,_0x345c04){return db['SquareProject'][_0x746e('0x50')]({'where':{'id':_0x21ff0[_0x746e('0x53')]['id']}})[_0x746e('0x2e')](handleEntityNotFound(_0x345c04,null))[_0x746e('0x2e')](removeEntity(_0x345c04,null))[_0x746e('0x4b')](handleError(_0x345c04,null));};exports['addUsers']=function(_0x4404fd,_0x50a383,_0x58fefc){return db[_0x746e('0x32')][_0x746e('0x50')]({'where':{'id':_0x4404fd['params']['id']}})['then'](handleEntityNotFound(_0x50a383,null))['then'](function(_0x4f090d){if(_0x4f090d){return _0x4f090d[_0x746e('0x55')](_0x4404fd['body'][_0x746e('0x56')],_[_0x746e('0x57')](_0x4404fd[_0x746e('0x54')],[_0x746e('0x56'),'id'])||{});}})['then'](respondWithResult(_0x50a383,null))['catch'](handleError(_0x50a383,null));};exports[_0x746e('0x58')]=function(_0x4d2893,_0x81fbd6,_0x46d530){return db[_0x746e('0x32')][_0x746e('0x50')]({'where':{'id':_0x4d2893[_0x746e('0x53')]['id']}})[_0x746e('0x2e')](handleEntityNotFound(_0x81fbd6,null))[_0x746e('0x2e')](function(_0x5e5b4f){if(_0x5e5b4f){return _0x5e5b4f['removeUsers'](_0x4d2893[_0x746e('0x3a')][_0x746e('0x56')])['then'](function(){if(_[_0x746e('0x59')](_0x4d2893[_0x746e('0x3a')][_0x746e('0x56')])){for(var _0x2f6e28=0x0;_0x2f6e28<_0x4d2893[_0x746e('0x3a')][_0x746e('0x56')][_0x746e('0x3f')];_0x2f6e28+=0x1){socket[_0x746e('0x5a')](_0x746e('0x5b'),{'UserId':Number(_0x4d2893[_0x746e('0x3a')]['ids'][_0x2f6e28]),'SquareProjectId':Number(_0x4d2893[_0x746e('0x53')]['id'])});}}else{socket[_0x746e('0x5a')](_0x746e('0x5b'),{'UserId':Number(_0x4d2893[_0x746e('0x3a')][_0x746e('0x56')]),'SquareProjectId':Number(_0x4d2893[_0x746e('0x53')]['id'])});}});}})[_0x746e('0x2e')](respondWithStatusCode(_0x81fbd6,null))[_0x746e('0x4b')](handleError(_0x81fbd6,null));};exports[_0x746e('0x5c')]=function(_0x5ad522,_0x1c2605,_0x56e768){var _0x518eae={};var _0x418d43={};var _0x532b8e;var _0x16c9e8;return db[_0x746e('0x32')][_0x746e('0x5d')]({'where':{'id':_0x5ad522['params']['id']}})[_0x746e('0x2e')](handleEntityNotFound(_0x1c2605,null))[_0x746e('0x2e')](function(_0xdc20f4){if(_0xdc20f4){_0x532b8e=_0xdc20f4;_0x418d43[_0x746e('0x37')]=_[_0x746e('0x39')](db[_0x746e('0x5e')]['rawAttributes']);_0x418d43[_0x746e('0x3a')]=_[_0x746e('0x39')](_0x5ad522[_0x746e('0x3a')]);_0x418d43[_0x746e('0x3b')]=_[_0x746e('0x3c')](_0x418d43['model'],_0x418d43[_0x746e('0x3a')]);_0x518eae[_0x746e('0x3e')]=_[_0x746e('0x3c')](_0x418d43['model'],qs['fields'](_0x5ad522[_0x746e('0x3a')]['fields']));_0x518eae['attributes']=_0x518eae[_0x746e('0x3e')][_0x746e('0x3f')]?_0x518eae[_0x746e('0x3e')]:_0x418d43[_0x746e('0x37')];_0x518eae[_0x746e('0x41')]=qs[_0x746e('0x42')](_0x5ad522[_0x746e('0x3a')][_0x746e('0x42')]);_0x518eae['where']=qs[_0x746e('0x3b')](_[_0x746e('0x5f')](_0x5ad522[_0x746e('0x3a')],_0x418d43[_0x746e('0x3b')]));if(_0x5ad522[_0x746e('0x3a')][_0x746e('0x45')]){_0x518eae[_0x746e('0x43')]=_[_0x746e('0x46')](_0x518eae['where'],{'$or':_[_0x746e('0x38')](_0x518eae[_0x746e('0x3e')],function(_0x286663){var _0x4263a9={};_0x4263a9[_0x286663]={'$like':'%'+_0x5ad522[_0x746e('0x3a')]['filter']+'%'};return _0x4263a9;})});}_0x518eae=_[_0x746e('0x46')]({},_0x518eae,_0x5ad522[_0x746e('0x47')]);return _0x532b8e[_0x746e('0x5c')](_0x518eae);}})['then'](function(_0x52264e){if(_0x52264e){_0x16c9e8=_0x52264e['length'];if(!_0x5ad522[_0x746e('0x3a')][_0x746e('0x60')](_0x746e('0x40'))){_0x518eae['limit']=qs['limit'](_0x5ad522[_0x746e('0x3a')][_0x746e('0x23')]);_0x518eae[_0x746e('0x22')]=qs['offset'](_0x5ad522[_0x746e('0x3a')][_0x746e('0x22')]);}return _0x532b8e[_0x746e('0x5c')](_0x518eae);}})[_0x746e('0x2e')](function(_0xab72d8){if(_0xab72d8){return _0xab72d8?{'count':_0x16c9e8,'rows':_0xab72d8}:null;}})[_0x746e('0x2e')](respondWithResult(_0x1c2605,null))[_0x746e('0x4b')](handleError(_0x1c2605,null));};
\ No newline at end of file
+var _0x8ad7=['attributes','intersection','length','nolimit','sort','where','pick','merge','VIRTUAL','options','count','include','findAll','rows','show','params','fields','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','production','lodash','ioredis','../../config/logger','api','../../config/environment','redis','defaults','socket.io-emitter','./squareProject.socket','register','json','offset','undefined','limit','set','Content-Range','update','then','get','SquareProjects','UserProfileResource','destroy','publish','agi','stringify','status','end','error','stack','name','index','map','SquareProject','rawAttributes','type','key','model','query','keys','filters'];(function(_0x2c1ce,_0x5728fc){var _0x56f56f=function(_0x5488de){while(--_0x5488de){_0x2c1ce['push'](_0x2c1ce['shift']());}};_0x56f56f(++_0x5728fc);}(_0x8ad7,0xa7));var _0x78ad=function(_0x26462c,_0xd20a35){_0x26462c=_0x26462c-0x0;var _0x509a42=_0x8ad7[_0x26462c];return _0x509a42;};'use strict';var _=require(_0x78ad('0x0'));var Redis=require(_0x78ad('0x1'));var qs=require('../../components/parsers/qs');var logger=require(_0x78ad('0x2'))(_0x78ad('0x3'));var config=require(_0x78ad('0x4'));var db=require('../../mysqldb')['db'];config[_0x78ad('0x5')]=_[_0x78ad('0x6')](config[_0x78ad('0x5')],{'host':'localhost','port':0x18eb});var socket=require(_0x78ad('0x7'))(new Redis(config[_0x78ad('0x5')]));require(_0x78ad('0x8'))[_0x78ad('0x9')](socket);function respondWithResult(_0xc3028,_0x1921bd){_0x1921bd=_0x1921bd||0xc8;return function(_0x2ad9dd){if(_0x2ad9dd){return _0xc3028['status'](_0x1921bd)[_0x78ad('0xa')](_0x2ad9dd);}};}function respondWithFilteredResult(_0x19a2b4,_0x3ee423){return function(_0x31c393){if(_0x31c393){var _0xc94a65=typeof _0x3ee423[_0x78ad('0xb')]===_0x78ad('0xc')&&typeof _0x3ee423[_0x78ad('0xd')]===_0x78ad('0xc');var _0x1817e4=_0x31c393['count'];var _0x3f6c56=_0xc94a65?0x0:_0x3ee423[_0x78ad('0xb')];var _0x2a9e57=_0xc94a65?_0x31c393['count']:_0x3ee423['offset']+_0x3ee423[_0x78ad('0xd')];var _0x1ac892;if(_0x2a9e57>=_0x1817e4){_0x2a9e57=_0x1817e4;_0x1ac892=0xc8;}else{_0x1ac892=0xce;}_0x19a2b4['status'](_0x1ac892);return _0x19a2b4[_0x78ad('0xe')](_0x78ad('0xf'),_0x3f6c56+'-'+_0x2a9e57+'/'+_0x1817e4)[_0x78ad('0xa')](_0x31c393);}return null;};}function saveUpdates(_0x4b8185){return function(_0x363fb7){if(_0x363fb7){return _0x363fb7[_0x78ad('0x10')](_0x4b8185)[_0x78ad('0x11')](function(_0x5bea0a){return _0x5bea0a;});}return null;};}function removeEntity(_0x3b888b){return function(_0x2d6eea){if(_0x2d6eea){return _0x2d6eea['destroy']()[_0x78ad('0x11')](function(){var _0x142cf9=_0x2d6eea[_0x78ad('0x12')]({'plain':!![]});var _0x4be0f7=_0x78ad('0x13');return db[_0x78ad('0x14')][_0x78ad('0x15')]({'where':{'type':_0x4be0f7,'resourceId':_0x142cf9['id']}})[_0x78ad('0x11')](function(){return _0x2d6eea;});})['then'](function(){var _0x11a03f=new Redis(config[_0x78ad('0x5')]);_0x11a03f[_0x78ad('0x16')](_0x78ad('0x17'),JSON[_0x78ad('0x18')]({'id':_0x2d6eea['id'],'deleted':!![]}));})['then'](function(){_0x3b888b[_0x78ad('0x19')](0xcc)[_0x78ad('0x1a')]();});}};}function handleEntityNotFound(_0x4f947e){return function(_0x3e233b){if(!_0x3e233b){_0x4f947e['sendStatus'](0x194);}return _0x3e233b;};}function handleError(_0x26a175,_0x423221){_0x423221=_0x423221||0x1f4;return function(_0xdace9b){logger[_0x78ad('0x1b')](_0xdace9b[_0x78ad('0x1c')]);if(_0xdace9b['name']){delete _0xdace9b[_0x78ad('0x1d')];}_0x26a175['status'](_0x423221)['send'](_0xdace9b);};}exports[_0x78ad('0x1e')]=function(_0x4ea2f1,_0x193906){var _0x5088e5={},_0x5c0217={},_0x58498a={'count':0x0,'rows':[]};var _0x24704b=_[_0x78ad('0x1f')](db[_0x78ad('0x20')][_0x78ad('0x21')],function(_0x19d488){return{'name':_0x19d488['fieldName'],'type':_0x19d488[_0x78ad('0x22')][_0x78ad('0x23')]};});_0x5c0217[_0x78ad('0x24')]=_[_0x78ad('0x1f')](_0x24704b,_0x78ad('0x1d'));_0x5c0217[_0x78ad('0x25')]=_[_0x78ad('0x26')](_0x4ea2f1['query']);_0x5c0217[_0x78ad('0x27')]=_['intersection'](_0x5c0217['model'],_0x5c0217['query']);_0x5088e5[_0x78ad('0x28')]=_[_0x78ad('0x29')](_0x5c0217['model'],qs['fields'](_0x4ea2f1[_0x78ad('0x25')]['fields']));_0x5088e5['attributes']=_0x5088e5[_0x78ad('0x28')][_0x78ad('0x2a')]?_0x5088e5[_0x78ad('0x28')]:_0x5c0217[_0x78ad('0x24')];if(!_0x4ea2f1[_0x78ad('0x25')]['hasOwnProperty'](_0x78ad('0x2b'))){_0x5088e5[_0x78ad('0xd')]=qs[_0x78ad('0xd')](_0x4ea2f1[_0x78ad('0x25')][_0x78ad('0xd')]);_0x5088e5[_0x78ad('0xb')]=qs[_0x78ad('0xb')](_0x4ea2f1[_0x78ad('0x25')][_0x78ad('0xb')]);}_0x5088e5['order']=qs['sort'](_0x4ea2f1['query'][_0x78ad('0x2c')]);_0x5088e5[_0x78ad('0x2d')]=qs['filters'](_[_0x78ad('0x2e')](_0x4ea2f1['query'],_0x5c0217[_0x78ad('0x27')]),_0x24704b);if(_0x4ea2f1['query']['filter']){_0x5088e5[_0x78ad('0x2d')]=_[_0x78ad('0x2f')](_0x5088e5[_0x78ad('0x2d')],{'$or':_['map'](_0x24704b,function(_0x213259){if(_0x213259[_0x78ad('0x22')]!==_0x78ad('0x30')){var _0x54dd77={};_0x54dd77[_0x213259[_0x78ad('0x1d')]]={'$like':'%'+_0x4ea2f1[_0x78ad('0x25')]['filter']+'%'};return _0x54dd77;}})});}_0x5088e5=_[_0x78ad('0x2f')]({},_0x5088e5,_0x4ea2f1[_0x78ad('0x31')]);var _0x4a5d31={'where':_0x5088e5['where']};return db[_0x78ad('0x20')][_0x78ad('0x32')](_0x4a5d31)[_0x78ad('0x11')](function(_0x2cbdf0){_0x58498a[_0x78ad('0x32')]=_0x2cbdf0;if(_0x4ea2f1[_0x78ad('0x25')]['includeAll']){_0x5088e5[_0x78ad('0x33')]=[{'all':!![]}];}return db[_0x78ad('0x20')][_0x78ad('0x34')](_0x5088e5);})[_0x78ad('0x11')](function(_0x818e4d){_0x58498a[_0x78ad('0x35')]=_0x818e4d;return _0x58498a;})['then'](respondWithFilteredResult(_0x193906,_0x5088e5))['catch'](handleError(_0x193906,null));};exports[_0x78ad('0x36')]=function(_0x14ab8d,_0x448821){var _0x5df69f={'raw':![],'where':{'id':_0x14ab8d[_0x78ad('0x37')]['id']}},_0x5e4da2={};_0x5e4da2['model']=_[_0x78ad('0x26')](db[_0x78ad('0x20')]['rawAttributes']);_0x5e4da2[_0x78ad('0x25')]=_[_0x78ad('0x26')](_0x14ab8d[_0x78ad('0x25')]);_0x5e4da2[_0x78ad('0x27')]=_[_0x78ad('0x29')](_0x5e4da2[_0x78ad('0x24')],_0x5e4da2[_0x78ad('0x25')]);_0x5df69f['attributes']=_['intersection'](_0x5e4da2[_0x78ad('0x24')],qs[_0x78ad('0x38')](_0x14ab8d[_0x78ad('0x25')][_0x78ad('0x38')]));_0x5df69f[_0x78ad('0x28')]=_0x5df69f['attributes'][_0x78ad('0x2a')]?_0x5df69f[_0x78ad('0x28')]:_0x5e4da2[_0x78ad('0x24')];if(_0x14ab8d[_0x78ad('0x25')]['includeAll']){_0x5df69f['include']=[{'all':!![]}];}_0x5df69f=_[_0x78ad('0x2f')]({},_0x5df69f,_0x14ab8d['options']);return db[_0x78ad('0x20')][_0x78ad('0x39')](_0x5df69f)[_0x78ad('0x11')](handleEntityNotFound(_0x448821,null))['then'](respondWithResult(_0x448821,null))[_0x78ad('0x3a')](handleError(_0x448821,null));};exports[_0x78ad('0x3b')]=function(_0x2dd373,_0x504730){return db[_0x78ad('0x20')][_0x78ad('0x3b')](_0x2dd373[_0x78ad('0x3c')],{})[_0x78ad('0x11')](function(_0x4e1773){var _0x198fa4=_0x2dd373[_0x78ad('0x3d')][_0x78ad('0x12')]({'plain':!![]});if(!_0x198fa4)throw new Error(_0x78ad('0x3e'));if(_0x198fa4[_0x78ad('0x3f')]===_0x78ad('0x3d')){var _0x51b125=_0x4e1773[_0x78ad('0x12')]({'plain':!![]});var _0x2bff08=_0x78ad('0x13');return db[_0x78ad('0x40')][_0x78ad('0x39')]({'where':{'name':_0x2bff08,'userProfileId':_0x198fa4[_0x78ad('0x41')]},'raw':!![]})[_0x78ad('0x11')](function(_0x134c18){if(_0x134c18&&_0x134c18[_0x78ad('0x42')]===0x0){return db[_0x78ad('0x14')][_0x78ad('0x3b')]({'name':_0x51b125['name'],'resourceId':_0x51b125['id'],'type':_0x134c18[_0x78ad('0x1d')],'sectionId':_0x134c18['id']},{})[_0x78ad('0x11')](function(){return _0x4e1773;});}else{return _0x4e1773;}})[_0x78ad('0x3a')](function(_0x561d3c){logger[_0x78ad('0x1b')](_0x78ad('0x43'),_0x561d3c);throw _0x561d3c;});}return _0x4e1773;})['then'](respondWithResult(_0x504730,0xc9))[_0x78ad('0x3a')](handleError(_0x504730,null));};exports[_0x78ad('0x10')]=function(_0x4e64f7,_0x337256){if(_0x4e64f7['body']['id']){delete _0x4e64f7[_0x78ad('0x3c')]['id'];}return db[_0x78ad('0x20')][_0x78ad('0x39')]({'where':{'id':_0x4e64f7[_0x78ad('0x37')]['id']}})[_0x78ad('0x11')](handleEntityNotFound(_0x337256,null))['then'](saveUpdates(_0x4e64f7[_0x78ad('0x3c')],null))[_0x78ad('0x11')](function(_0x55c8ea){if(!_0x55c8ea)return;var _0x424c3a=_0x55c8ea[_0x78ad('0x12')]({'plain':!![]});return _0x424c3a;})[_0x78ad('0x11')](function(_0x3e587c){var _0x4c2d86=new Redis(config[_0x78ad('0x5')]);_0x4c2d86['publish'](_0x78ad('0x17'),JSON[_0x78ad('0x18')](_[_0x78ad('0x2e')](_0x3e587c,['id',_0x78ad('0x1d'),_0x78ad('0x44')])));return _0x3e587c;})['then'](respondWithResult(_0x337256,null))['catch'](handleError(_0x337256,null));};exports['destroy']=function(_0x4a0638,_0x127ffb){return db[_0x78ad('0x20')][_0x78ad('0x39')]({'where':{'id':_0x4a0638[_0x78ad('0x37')]['id']}})[_0x78ad('0x11')](handleEntityNotFound(_0x127ffb,null))[_0x78ad('0x11')](removeEntity(_0x127ffb,null))[_0x78ad('0x3a')](handleError(_0x127ffb,null));};
\ No newline at end of file