cf014f69297eb40adca90841815785b79b7b3ffd
[motion-next.git] / server / api / setting / setting.controller.js
1 const a538_0x25be=['defaultFavicon','loginLogo','securePassword','fieldName','filters','send','merge','offset','getLogoLogin','addLogo','intersection','\x20not\x20found','default_favicon.ico','status','order','name','findAll','upperFirst','custom','default_preferred.png','../../mysqldb','keys','where','filename','lodash','limit','../../config/logger','then','favicon','like','defaultPreferred','undefined','includeAll','index','attributes','../../config/environment','body','map','sendStatus','options','addFavicon','path','Sequelize','defaultLoginLogo','default_loginLogo.svg','fields','sort','show','getLogo','Content-Range','../../config/license/util','getLicense','download','api','addPreferred','set','toLower','update','model','logo','default_logo.svg','catch','defaultLogo','ValidationError','params','json','sequelize','files/images/logos','type','length','nolimit','error','preferred','file','Setting','query','rawAttributes','root','count','join','findOne','addLogoLogin','existsSync','getFavicon','include','default','getPreferred','key'];(function(_0x4a5ccc,_0x25bead){const _0x3e75e3=function(_0x4baf3d){while(--_0x4baf3d){_0x4a5ccc['push'](_0x4a5ccc['shift']());}};_0x3e75e3(++_0x25bead);}(a538_0x25be,0x77));const a538_0x3e75=function(_0x4a5ccc,_0x25bead){_0x4a5ccc=_0x4a5ccc-0x0;let _0x3e75e3=a538_0x25be[_0x4a5ccc];return _0x3e75e3;};const _0x30d8af=a538_0x3e75;'use strict';const path=require(_0x30d8af('0xa')),fs=require('fs'),_=require(_0x30d8af('0x51')),qs=require('../../components/parsers/qs'),logger=require(_0x30d8af('0x53'))(_0x30d8af('0x16')),config=require(_0x30d8af('0x4')),db=require(_0x30d8af('0x4d'))['db'],{Op}=require(_0x30d8af('0x23')),utilLicense=require(_0x30d8af('0x13'));function respondWithResult(_0x4baf3d,_0x5e84fb){return _0x5e84fb=_0x5e84fb||0xc8,function(_0x364cb2){const _0xa4a68=a538_0x3e75;if(_0x364cb2)return _0x4baf3d[_0xa4a68('0x46')](_0x5e84fb)['json'](_0x364cb2);};}function respondWithFilteredResult(_0x411ef9,_0x26c13b){return function(_0x371a06){const _0x13df6a=a538_0x3e75;if(_0x371a06){const _0x5aa773=_0x371a06[_0x13df6a('0x2f')],_0x31d42f=_0x26c13b[_0x13df6a('0x40')];let _0x18287f=_0x26c13b[_0x13df6a('0x40')]+_0x26c13b[_0x13df6a('0x52')],_0x20e193;return _0x18287f>=_0x5aa773?(_0x18287f=_0x5aa773,_0x20e193=0xc8):_0x20e193=0xce,_0x411ef9[_0x13df6a('0x46')](_0x20e193),_0x411ef9[_0x13df6a('0x18')](_0x13df6a('0x12'),_0x31d42f+'-'+_0x18287f+'/'+_0x5aa773)[_0x13df6a('0x22')](_0x371a06);}return null;};}function saveUpdates(_0x4a3c94){return function(_0x8c59b2){const _0x3d7d60=a538_0x3e75;if(_0x8c59b2)return _0x8c59b2[_0x3d7d60('0x1a')](_0x4a3c94)[_0x3d7d60('0x54')](function(_0x1de39a){return _0x1de39a;});return null;};}function handleEntityNotFound(_0x5585c9){return function(_0x1b8af7){const _0x20957e=a538_0x3e75;return!_0x1b8af7&&_0x5585c9[_0x20957e('0x7')](0x194),_0x1b8af7;};}function handleError(_0x44f8f8,_0x35ba1b){return _0x35ba1b=_0x35ba1b||0x1f4,function(_0x35781b){const _0x208428=a538_0x3e75;logger[_0x208428('0x28')](_0x35781b['stack']),_0x35781b[_0x208428('0x48')]&&delete _0x35781b[_0x208428('0x48')],_0x44f8f8[_0x208428('0x46')](_0x35ba1b)[_0x208428('0x3e')](_0x35781b);};}exports[_0x30d8af('0x2')]=function(_0x2b1155,_0x2a976e){const _0x1db677=_0x30d8af;let _0x58eb91={};const _0x367b18={},_0x18bc7a={'count':0x0,'rows':[]},_0x47cf0=_['map'](db[_0x1db677('0x2b')][_0x1db677('0x2d')],function(_0x16a9f4){const _0x50f5ae=_0x1db677;return{'name':_0x16a9f4[_0x50f5ae('0x3c')],'type':_0x16a9f4['type'][_0x50f5ae('0x38')]};});_0x367b18['model']=_[_0x1db677('0x6')](_0x47cf0,_0x1db677('0x48')),_0x367b18['query']=_[_0x1db677('0x4e')](_0x2b1155[_0x1db677('0x2c')]),_0x367b18[_0x1db677('0x3d')]=_[_0x1db677('0x43')](_0x367b18[_0x1db677('0x1b')],_0x367b18[_0x1db677('0x2c')]),_0x58eb91[_0x1db677('0x3')]=_[_0x1db677('0x43')](_0x367b18['model'],qs[_0x1db677('0xe')](_0x2b1155[_0x1db677('0x2c')][_0x1db677('0xe')])),_0x58eb91['attributes']=_0x58eb91[_0x1db677('0x3')][_0x1db677('0x26')]?_0x58eb91['attributes']:_0x367b18[_0x1db677('0x1b')];typeof _0x2b1155[_0x1db677('0x2c')][_0x1db677('0x27')]===_0x1db677('0x0')&&(_0x58eb91[_0x1db677('0x52')]=qs[_0x1db677('0x52')](_0x2b1155[_0x1db677('0x2c')][_0x1db677('0x52')]),_0x58eb91['offset']=qs[_0x1db677('0x40')](_0x2b1155['query'][_0x1db677('0x40')]));_0x58eb91[_0x1db677('0x47')]=qs[_0x1db677('0xf')](_0x2b1155['query'][_0x1db677('0xf')]),_0x58eb91[_0x1db677('0x4f')]=qs['filters'](_['pick'](_0x2b1155[_0x1db677('0x2c')],_0x367b18[_0x1db677('0x3d')]),_0x47cf0);_0x2b1155[_0x1db677('0x2c')]['filter']&&(_0x58eb91['where']=_['merge'](_0x58eb91[_0x1db677('0x4f')],{[Op['or']]:_[_0x1db677('0x6')](_0x47cf0,function(_0x3c7c86){const _0x336e23=_0x1db677;if(_0x3c7c86[_0x336e23('0x25')]!=='VIRTUAL'){const _0x1430fb={};return _0x1430fb[_0x3c7c86[_0x336e23('0x48')]]={[Op[_0x336e23('0x56')]]:'%'+_0x2b1155[_0x336e23('0x2c')]['filter']+'%'},_0x1430fb;}})}));_0x58eb91=_[_0x1db677('0x3f')]({},_0x58eb91,_0x2b1155[_0x1db677('0x8')]);const _0xe882f3={'where':_0x58eb91[_0x1db677('0x4f')]};return db['Setting'][_0x1db677('0x2f')](_0xe882f3)['then'](function(_0x35fce8){const _0x140c3a=_0x1db677;return _0x18bc7a['count']=_0x35fce8,_0x2b1155[_0x140c3a('0x2c')][_0x140c3a('0x1')]&&(_0x58eb91[_0x140c3a('0x35')]=[{'all':!![]}]),db['Setting'][_0x140c3a('0x49')](_0x58eb91);})['then'](function(_0x22e4e1){return _0x18bc7a['rows']=_0x22e4e1,_0x18bc7a;})[_0x1db677('0x54')](respondWithFilteredResult(_0x2a976e,_0x58eb91))[_0x1db677('0x1e')](handleError(_0x2a976e,null));},exports[_0x30d8af('0x10')]=function(_0x5f3b69,_0x362221){const _0x30da1c=_0x30d8af;let _0x2390fb={'raw':![],'where':{'id':_0x5f3b69[_0x30da1c('0x21')]['id']}};const _0x22957e={};return _0x22957e['model']=_[_0x30da1c('0x4e')](db['Setting']['rawAttributes']),_0x22957e[_0x30da1c('0x2c')]=_[_0x30da1c('0x4e')](_0x5f3b69['query']),_0x22957e[_0x30da1c('0x3d')]=_[_0x30da1c('0x43')](_0x22957e['model'],_0x22957e[_0x30da1c('0x2c')]),_0x2390fb['attributes']=_[_0x30da1c('0x43')](_0x22957e[_0x30da1c('0x1b')],qs[_0x30da1c('0xe')](_0x5f3b69['query'][_0x30da1c('0xe')])),_0x2390fb['attributes']=_0x2390fb[_0x30da1c('0x3')][_0x30da1c('0x26')]?_0x2390fb['attributes']:_0x22957e[_0x30da1c('0x1b')],_0x5f3b69['query'][_0x30da1c('0x1')]&&(_0x2390fb[_0x30da1c('0x35')]=[{'all':!![]}]),_0x2390fb=_['merge']({},_0x2390fb,_0x5f3b69[_0x30da1c('0x8')]),db[_0x30da1c('0x2b')][_0x30da1c('0x31')](_0x2390fb)['then'](handleEntityNotFound(_0x362221,null))['then'](respondWithResult(_0x362221,null))[_0x30da1c('0x1e')](handleError(_0x362221,null));},exports[_0x30d8af('0x1a')]=function(_0x49fb4a,_0x19348f){const _0x5479f2=_0x30d8af;return _0x49fb4a[_0x5479f2('0x5')]['id']&&delete _0x49fb4a[_0x5479f2('0x5')]['id'],db[_0x5479f2('0x2b')][_0x5479f2('0x31')]({'where':{'id':_0x49fb4a[_0x5479f2('0x21')]['id']}})[_0x5479f2('0x54')](handleEntityNotFound(_0x19348f,null))[_0x5479f2('0x54')](saveUpdates(_0x49fb4a[_0x5479f2('0x5')],null))[_0x5479f2('0x54')](respondWithResult(_0x19348f,null))[_0x5479f2('0x1e')](handleError(_0x19348f,null));},exports[_0x30d8af('0x42')]=function(_0x412ce8,_0x150042){const _0x5010ef=_0x30d8af;return _0x412ce8['file']&&_0x412ce8[_0x5010ef('0x2a')]['filename']&&(_0x412ce8['body']['logo']=_0x412ce8['file'][_0x5010ef('0x50')]),db[_0x5010ef('0x2b')]['findOne']({'where':{'id':_0x412ce8[_0x5010ef('0x21')]['id']}})[_0x5010ef('0x54')](handleEntityNotFound(_0x150042,null))[_0x5010ef('0x54')](saveUpdates(_0x412ce8['body'],null))[_0x5010ef('0x54')](respondWithResult(_0x150042,null))[_0x5010ef('0x1e')](handleError(_0x150042,null));},exports[_0x30d8af('0x32')]=function(_0x188087,_0x14d307){const _0x267e93=_0x30d8af;return _0x188087['file']&&_0x188087[_0x267e93('0x2a')][_0x267e93('0x50')]&&(_0x188087[_0x267e93('0x5')][_0x267e93('0x3a')]=_0x188087['file'][_0x267e93('0x50')]),db[_0x267e93('0x2b')][_0x267e93('0x31')]({'where':{'id':_0x188087[_0x267e93('0x21')]['id']}})[_0x267e93('0x54')](handleEntityNotFound(_0x14d307,null))[_0x267e93('0x54')](saveUpdates(_0x188087[_0x267e93('0x5')],null))[_0x267e93('0x54')](respondWithResult(_0x14d307,null))[_0x267e93('0x1e')](handleError(_0x14d307,null));},exports[_0x30d8af('0x11')]=function(_0x2f5d28,_0x522082){const _0x1d0d14=_0x30d8af,_0x490e18=path[_0x1d0d14('0x30')](config['root'],_0x1d0d14('0x24'));let _0x39efe9={'custom':![]};return utilLicense[_0x1d0d14('0x14')]()['then'](function(_0x3295e0){const _0xd77b82=_0x1d0d14;return _0x3295e0&&(_0x39efe9=_0x3295e0),db[_0xd77b82('0x2b')]['findOne']({'where':{'id':_0x2f5d28[_0xd77b82('0x21')]['id']},'attributes':[_0xd77b82('0x1c'),'loginLogo',_0xd77b82('0x29'),_0xd77b82('0x55'),_0xd77b82('0x1f'),_0xd77b82('0xc'),'defaultPreferred',_0xd77b82('0x39')],'raw':!![]});})[_0x1d0d14('0x54')](handleEntityNotFound(_0x522082,null))['then'](function(_0x2b82fd){const _0x28c8d4=_0x1d0d14;if(_0x2b82fd){let _0x58fc06=_0x2b82fd['logo']&&fs[_0x28c8d4('0x33')](path['join'](_0x490e18,_[_0x28c8d4('0x19')](_0x2b82fd[_0x28c8d4('0x1c')])))?path[_0x28c8d4('0x30')](_0x490e18,_[_0x28c8d4('0x19')](_0x2b82fd[_0x28c8d4('0x1c')])):path[_0x28c8d4('0x30')](_0x490e18,_[_0x28c8d4('0x19')]('default_logo.svg'));const _0x52066b=_0x28c8d4('0x36')+_['upperFirst'](_0x28c8d4('0x1c'));(_0x2b82fd[_0x52066b]||!_0x39efe9[_0x28c8d4('0x4b')])&&(_0x58fc06=path['join'](_0x490e18,_['toLower'](_0x28c8d4('0x1d'))));if(!fs[_0x28c8d4('0x33')](_0x58fc06))throw new db[(_0x28c8d4('0xb'))]['ValidationError'](_['upperFirst'](_0x28c8d4('0x1c'))+_0x28c8d4('0x44'));return _0x522082[_0x28c8d4('0x15')](_0x58fc06);}})['catch'](handleError(_0x522082,null));},exports[_0x30d8af('0x41')]=function(_0x249f53,_0x2b62c7){const _0x58a196=_0x30d8af,_0x3781a0=path[_0x58a196('0x30')](config[_0x58a196('0x2e')],_0x58a196('0x24'));let _0x382955={'custom':![]};return utilLicense[_0x58a196('0x14')]()[_0x58a196('0x54')](function(_0xa51516){const _0x411d59=_0x58a196;return _0xa51516&&(_0x382955=_0xa51516),db[_0x411d59('0x2b')][_0x411d59('0x31')]({'where':{'id':_0x249f53[_0x411d59('0x21')]['id']},'attributes':[_0x411d59('0x1c'),_0x411d59('0x3a'),_0x411d59('0x29'),'favicon',_0x411d59('0x1f'),_0x411d59('0xc'),_0x411d59('0x57'),_0x411d59('0x39')],'raw':!![]});})[_0x58a196('0x54')](handleEntityNotFound(_0x2b62c7,null))[_0x58a196('0x54')](function(_0x17a2b9){const _0x376223=_0x58a196;if(_0x17a2b9){let _0x37543e=_0x17a2b9[_0x376223('0x3a')]&&fs[_0x376223('0x33')](path[_0x376223('0x30')](_0x3781a0,_[_0x376223('0x19')](_0x17a2b9[_0x376223('0x3a')])))?path[_0x376223('0x30')](_0x3781a0,_[_0x376223('0x19')](_0x17a2b9['loginLogo'])):path[_0x376223('0x30')](_0x3781a0,_['toLower'](_0x376223('0xd')));const _0x4a716f=_0x376223('0x36')+_[_0x376223('0x4a')](_0x376223('0x3a'));(_0x17a2b9[_0x4a716f]||!_0x382955['custom'])&&(_0x37543e=path[_0x376223('0x30')](_0x3781a0,_[_0x376223('0x19')](_0x376223('0xd'))));if(!fs[_0x376223('0x33')](_0x37543e))throw new db[(_0x376223('0xb'))][(_0x376223('0x20'))](_[_0x376223('0x4a')](_0x376223('0x3a'))+'\x20not\x20found');return _0x2b62c7[_0x376223('0x15')](_0x37543e);}})['catch'](handleError(_0x2b62c7,null));},exports['gdpr']=function(_0x411e6a,_0x30ec14){const _0x36011d=_0x30d8af;return db[_0x36011d('0x2b')][_0x36011d('0x31')]({'where':{'id':_0x411e6a['params']['id']},'attributes':[_0x36011d('0x3b')]})[_0x36011d('0x54')](respondWithResult(_0x30ec14,null))[_0x36011d('0x1e')](handleError(_0x30ec14,null));},exports[_0x30d8af('0x17')]=function(_0x3fb0fe,_0xe0ccdf){const _0x371964=_0x30d8af;return _0x3fb0fe[_0x371964('0x2a')]&&_0x3fb0fe[_0x371964('0x2a')][_0x371964('0x50')]&&(_0x3fb0fe[_0x371964('0x5')][_0x371964('0x29')]=_0x3fb0fe[_0x371964('0x2a')][_0x371964('0x50')]),db[_0x371964('0x2b')][_0x371964('0x31')]({'where':{'id':_0x3fb0fe[_0x371964('0x21')]['id']}})['then'](handleEntityNotFound(_0xe0ccdf,null))[_0x371964('0x54')](saveUpdates(_0x3fb0fe['body'],null))[_0x371964('0x54')](respondWithResult(_0xe0ccdf,null))[_0x371964('0x1e')](handleError(_0xe0ccdf,null));},exports[_0x30d8af('0x37')]=function(_0x37a240,_0x5c606e){const _0x3dc867=_0x30d8af,_0x542779=path[_0x3dc867('0x30')](config[_0x3dc867('0x2e')],_0x3dc867('0x24'));let _0x48b646={'custom':![]};return utilLicense[_0x3dc867('0x14')]()['then'](function(_0x57e3d9){const _0x2cb284=_0x3dc867;return _0x57e3d9&&(_0x48b646=_0x57e3d9),db[_0x2cb284('0x2b')][_0x2cb284('0x31')]({'where':{'id':_0x37a240[_0x2cb284('0x21')]['id']},'attributes':[_0x2cb284('0x1c'),'loginLogo',_0x2cb284('0x29'),_0x2cb284('0x55'),_0x2cb284('0x1f'),'defaultLoginLogo','defaultPreferred',_0x2cb284('0x39')],'raw':!![]});})[_0x3dc867('0x54')](handleEntityNotFound(_0x5c606e,null))[_0x3dc867('0x54')](function(_0x198667){const _0x6d994d=_0x3dc867;if(_0x198667){let _0x10802d=_0x198667[_0x6d994d('0x29')]&&fs[_0x6d994d('0x33')](path[_0x6d994d('0x30')](_0x542779,_['toLower'](_0x198667['preferred'])))?path[_0x6d994d('0x30')](_0x542779,_[_0x6d994d('0x19')](_0x198667['preferred'])):path['join'](_0x542779,_[_0x6d994d('0x19')](_0x6d994d('0x4c')));const _0x63ef12=_0x6d994d('0x36')+_[_0x6d994d('0x4a')](_0x6d994d('0x29'));(_0x198667[_0x63ef12]||!_0x48b646[_0x6d994d('0x4b')]||!_0x48b646[_0x6d994d('0x29')])&&(_0x10802d=path[_0x6d994d('0x30')](_0x542779,_[_0x6d994d('0x19')](_0x6d994d('0x4c'))));if(!fs[_0x6d994d('0x33')](_0x10802d))throw new db[(_0x6d994d('0xb'))]['ValidationError'](_[_0x6d994d('0x4a')](_0x6d994d('0x29'))+_0x6d994d('0x44'));return _0x5c606e[_0x6d994d('0x15')](_0x10802d);}})[_0x3dc867('0x1e')](handleError(_0x5c606e,null));},exports[_0x30d8af('0x9')]=function(_0x54c3a9,_0x5b1907){const _0x52d026=_0x30d8af;return _0x54c3a9[_0x52d026('0x2a')]&&_0x54c3a9[_0x52d026('0x2a')]['filename']&&(_0x54c3a9['body']['favicon']=_0x54c3a9['file'][_0x52d026('0x50')]),db[_0x52d026('0x2b')]['findOne']({'where':{'id':_0x54c3a9[_0x52d026('0x21')]['id']}})[_0x52d026('0x54')](handleEntityNotFound(_0x5b1907,null))[_0x52d026('0x54')](saveUpdates(_0x54c3a9[_0x52d026('0x5')],null))[_0x52d026('0x54')](respondWithResult(_0x5b1907,null))['catch'](handleError(_0x5b1907,null));},exports[_0x30d8af('0x34')]=function(_0x2a0aae,_0x1be4fb){const _0xc0482d=_0x30d8af,_0x579766=path[_0xc0482d('0x30')](config[_0xc0482d('0x2e')],_0xc0482d('0x24'));let _0x51a114={'custom':![]};return utilLicense[_0xc0482d('0x14')]()['then'](function(_0xbad2e7){const _0x325190=_0xc0482d;return _0xbad2e7&&(_0x51a114=_0xbad2e7),db[_0x325190('0x2b')][_0x325190('0x31')]({'where':{'id':_0x2a0aae[_0x325190('0x21')]['id']},'attributes':[_0x325190('0x1c'),_0x325190('0x3a'),_0x325190('0x29'),'favicon',_0x325190('0x1f'),_0x325190('0xc'),_0x325190('0x57'),'defaultFavicon'],'raw':!![]});})[_0xc0482d('0x54')](handleEntityNotFound(_0x1be4fb,null))[_0xc0482d('0x54')](function(_0x37d173){const _0x3fe1a2=_0xc0482d;if(_0x37d173){let _0x98612b=_0x37d173[_0x3fe1a2('0x55')]&&fs[_0x3fe1a2('0x33')](path['join'](_0x579766,_[_0x3fe1a2('0x19')](_0x37d173['favicon'])))?path['join'](_0x579766,_[_0x3fe1a2('0x19')](_0x37d173[_0x3fe1a2('0x55')])):path[_0x3fe1a2('0x30')](_0x579766,_[_0x3fe1a2('0x19')]('default_favicon.ico'));const _0x3aa32a=_0x3fe1a2('0x36')+_[_0x3fe1a2('0x4a')]('favicon');(_0x37d173[_0x3aa32a]||!_0x51a114[_0x3fe1a2('0x4b')])&&(_0x98612b=path[_0x3fe1a2('0x30')](_0x579766,_[_0x3fe1a2('0x19')](_0x3fe1a2('0x45'))));if(!fs[_0x3fe1a2('0x33')](_0x98612b))throw new db[(_0x3fe1a2('0xb'))][(_0x3fe1a2('0x20'))](_[_0x3fe1a2('0x4a')](_0x3fe1a2('0x55'))+_0x3fe1a2('0x44'));return _0x1be4fb[_0x3fe1a2('0x15')](_0x98612b);}})[_0xc0482d('0x1e')](handleError(_0x1be4fb,null));};