Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / api / setting / setting.controller.js
index 4f04df7..e92b078 100644 (file)
@@ -1 +1 @@
-const a538_0x57ca=['intersection','../../mysqldb','then','Content-Range','offset','include','getPreferred','logo','upperFirst','merge','stack','type','files/images/logos','update','defaultLogo','rawAttributes','preferred','join','options','map','filters','includeAll','show','count','\x20not\x20found','getLicense','default','order','existsSync','body','status','VIRTUAL','keys','fields','Setting','set','default_loginLogo.svg','defaultLoginLogo','like','getLogoLogin','default_preferred.png','../../config/logger','query','fieldName','length','file','download','where','favicon','default_logo.svg','send','model','filename','findOne','defaultFavicon','defaultPreferred','limit','sort','name','gdpr','default_favicon.ico','toLower','getFavicon','index','custom','addPreferred','sequelize','findAll','error','pick','lodash','addLogoLogin','loginLogo','rows','../../config/license/util','addFavicon','params','json','attributes','nolimit','root','securePassword','../../config/environment','catch','key'];(function(_0x40711e,_0x57ca39){const _0x5dfe5b=function(_0xa984e2){while(--_0xa984e2){_0x40711e['push'](_0x40711e['shift']());}};_0x5dfe5b(++_0x57ca39);}(a538_0x57ca,0x17c));const a538_0x5dfe=function(_0x40711e,_0x57ca39){_0x40711e=_0x40711e-0x0;let _0x5dfe5b=a538_0x57ca[_0x40711e];return _0x5dfe5b;};const _0x1c6b3f=a538_0x5dfe;'use strict';const path=require('path'),fs=require('fs'),_=require(_0x1c6b3f('0x1e')),qs=require('../../components/parsers/qs'),logger=require(_0x1c6b3f('0x1'))('api'),config=require(_0x1c6b3f('0x2a')),db=require(_0x1c6b3f('0x2e'))['db'],{Op,ValidationError}=require(_0x1c6b3f('0x1a')),utilLicense=require(_0x1c6b3f('0x22'));function respondWithResult(_0xa984e2,_0x3eead0){return _0x3eead0=_0x3eead0||0xc8,function(_0x5dff54){const _0x989a10=a538_0x5dfe;if(_0x5dff54)return _0xa984e2[_0x989a10('0x4b')](_0x3eead0)['json'](_0x5dff54);};}function respondWithFilteredResult(_0x3a8145,_0x5645b8){return function(_0x13de54){const _0x2f573d=a538_0x5dfe;if(_0x13de54){const _0xad940b=_0x13de54[_0x2f573d('0x44')],_0x5c1b39=_0x5645b8[_0x2f573d('0x31')];let _0xb3b71a=_0x5645b8['offset']+_0x5645b8[_0x2f573d('0x10')],_0x418783;return _0xb3b71a>=_0xad940b?(_0xb3b71a=_0xad940b,_0x418783=0xc8):_0x418783=0xce,_0x3a8145[_0x2f573d('0x4b')](_0x418783),_0x3a8145[_0x2f573d('0x50')](_0x2f573d('0x30'),_0x5c1b39+'-'+_0xb3b71a+'/'+_0xad940b)[_0x2f573d('0x25')](_0x13de54);}return null;};}function saveUpdates(_0x2891c9){return function(_0x346d95){const _0x1a9911=a538_0x5dfe;if(_0x346d95)return _0x346d95[_0x1a9911('0x3a')](_0x2891c9)['then'](function(_0x3efe43){return _0x3efe43;});return null;};}function handleEntityNotFound(_0x4086a0){return function(_0x581aba){return!_0x581aba&&_0x4086a0['sendStatus'](0x194),_0x581aba;};}function handleError(_0x42564d,_0x35b512){return _0x35b512=_0x35b512||0x1f4,function(_0x26f501){const _0x4dc6bb=a538_0x5dfe;logger[_0x4dc6bb('0x1c')](_0x26f501[_0x4dc6bb('0x37')]),_0x26f501[_0x4dc6bb('0x12')]&&delete _0x26f501[_0x4dc6bb('0x12')],_0x42564d[_0x4dc6bb('0x4b')](_0x35b512)[_0x4dc6bb('0xa')](_0x26f501);};}exports[_0x1c6b3f('0x17')]=function(_0x15067d,_0x464963){const _0x5f442a=_0x1c6b3f;let _0x19c2be={};const _0x2a8e78={},_0x27c1f7={'count':0x0,'rows':[]},_0x390580=_[_0x5f442a('0x40')](db['Setting'][_0x5f442a('0x3c')],function(_0x54abad){const _0x1334dd=_0x5f442a;return{'name':_0x54abad[_0x1334dd('0x3')],'type':_0x54abad[_0x1334dd('0x38')][_0x1334dd('0x2c')]};});_0x2a8e78[_0x5f442a('0xb')]=_[_0x5f442a('0x40')](_0x390580,_0x5f442a('0x12')),_0x2a8e78[_0x5f442a('0x2')]=_[_0x5f442a('0x4d')](_0x15067d[_0x5f442a('0x2')]),_0x2a8e78['filters']=_[_0x5f442a('0x2d')](_0x2a8e78[_0x5f442a('0xb')],_0x2a8e78[_0x5f442a('0x2')]),_0x19c2be['attributes']=_['intersection'](_0x2a8e78['model'],qs[_0x5f442a('0x4e')](_0x15067d[_0x5f442a('0x2')][_0x5f442a('0x4e')])),_0x19c2be['attributes']=_0x19c2be[_0x5f442a('0x26')][_0x5f442a('0x4')]?_0x19c2be[_0x5f442a('0x26')]:_0x2a8e78['model'];typeof _0x15067d[_0x5f442a('0x2')][_0x5f442a('0x27')]==='undefined'&&(_0x19c2be[_0x5f442a('0x10')]=qs['limit'](_0x15067d['query'][_0x5f442a('0x10')]),_0x19c2be[_0x5f442a('0x31')]=qs[_0x5f442a('0x31')](_0x15067d['query'][_0x5f442a('0x31')]));_0x19c2be[_0x5f442a('0x48')]=qs[_0x5f442a('0x11')](_0x15067d[_0x5f442a('0x2')][_0x5f442a('0x11')]),_0x19c2be[_0x5f442a('0x7')]=qs[_0x5f442a('0x41')](_[_0x5f442a('0x1d')](_0x15067d[_0x5f442a('0x2')],_0x2a8e78[_0x5f442a('0x41')]),_0x390580);_0x15067d['query']['filter']&&(_0x19c2be[_0x5f442a('0x7')]=_[_0x5f442a('0x36')](_0x19c2be['where'],{[Op['or']]:_[_0x5f442a('0x40')](_0x390580,function(_0x94de0){const _0x4099b4=_0x5f442a;if(_0x94de0['type']!==_0x4099b4('0x4c')){const _0x1c9aa4={};return _0x1c9aa4[_0x94de0[_0x4099b4('0x12')]]={[Op[_0x4099b4('0x53')]]:'%'+_0x15067d['query']['filter']+'%'},_0x1c9aa4;}})}));_0x19c2be=_[_0x5f442a('0x36')]({},_0x19c2be,_0x15067d[_0x5f442a('0x3f')]);const _0x547c6d={'where':_0x19c2be[_0x5f442a('0x7')]};return db[_0x5f442a('0x4f')][_0x5f442a('0x44')](_0x547c6d)[_0x5f442a('0x2f')](function(_0x47817c){const _0x33fb51=_0x5f442a;return _0x27c1f7[_0x33fb51('0x44')]=_0x47817c,_0x15067d[_0x33fb51('0x2')][_0x33fb51('0x42')]&&(_0x19c2be[_0x33fb51('0x32')]=[{'all':!![]}]),db[_0x33fb51('0x4f')][_0x33fb51('0x1b')](_0x19c2be);})[_0x5f442a('0x2f')](function(_0x35b16a){const _0x1351df=_0x5f442a;return _0x27c1f7[_0x1351df('0x21')]=_0x35b16a,_0x27c1f7;})[_0x5f442a('0x2f')](respondWithFilteredResult(_0x464963,_0x19c2be))[_0x5f442a('0x2b')](handleError(_0x464963,null));},exports[_0x1c6b3f('0x43')]=function(_0x35fdf0,_0x76a707){const _0x3714b9=_0x1c6b3f;let _0x3ff4f2={'raw':![],'where':{'id':_0x35fdf0[_0x3714b9('0x24')]['id']}};const _0x26f71c={};return _0x26f71c['model']=_[_0x3714b9('0x4d')](db[_0x3714b9('0x4f')][_0x3714b9('0x3c')]),_0x26f71c[_0x3714b9('0x2')]=_['keys'](_0x35fdf0[_0x3714b9('0x2')]),_0x26f71c['filters']=_['intersection'](_0x26f71c[_0x3714b9('0xb')],_0x26f71c[_0x3714b9('0x2')]),_0x3ff4f2[_0x3714b9('0x26')]=_['intersection'](_0x26f71c['model'],qs['fields'](_0x35fdf0[_0x3714b9('0x2')][_0x3714b9('0x4e')])),_0x3ff4f2[_0x3714b9('0x26')]=_0x3ff4f2[_0x3714b9('0x26')][_0x3714b9('0x4')]?_0x3ff4f2[_0x3714b9('0x26')]:_0x26f71c['model'],_0x35fdf0[_0x3714b9('0x2')]['includeAll']&&(_0x3ff4f2[_0x3714b9('0x32')]=[{'all':!![]}]),_0x3ff4f2=_[_0x3714b9('0x36')]({},_0x3ff4f2,_0x35fdf0[_0x3714b9('0x3f')]),db['Setting'][_0x3714b9('0xd')](_0x3ff4f2)['then'](handleEntityNotFound(_0x76a707,null))[_0x3714b9('0x2f')](respondWithResult(_0x76a707,null))[_0x3714b9('0x2b')](handleError(_0x76a707,null));},exports[_0x1c6b3f('0x3a')]=function(_0x14ce19,_0x40d00f){const _0xcb20e9=_0x1c6b3f;return _0x14ce19[_0xcb20e9('0x4a')]['id']&&delete _0x14ce19['body']['id'],db[_0xcb20e9('0x4f')][_0xcb20e9('0xd')]({'where':{'id':_0x14ce19['params']['id']}})[_0xcb20e9('0x2f')](handleEntityNotFound(_0x40d00f,null))[_0xcb20e9('0x2f')](saveUpdates(_0x14ce19[_0xcb20e9('0x4a')],null))['then'](respondWithResult(_0x40d00f,null))[_0xcb20e9('0x2b')](handleError(_0x40d00f,null));},exports['addLogo']=function(_0x39eb4e,_0x4b8bd2){const _0x349f53=_0x1c6b3f;return _0x39eb4e['file']&&_0x39eb4e['file']['filename']&&(_0x39eb4e[_0x349f53('0x4a')][_0x349f53('0x34')]=_0x39eb4e[_0x349f53('0x5')][_0x349f53('0xc')]),db[_0x349f53('0x4f')][_0x349f53('0xd')]({'where':{'id':_0x39eb4e[_0x349f53('0x24')]['id']}})[_0x349f53('0x2f')](handleEntityNotFound(_0x4b8bd2,null))[_0x349f53('0x2f')](saveUpdates(_0x39eb4e[_0x349f53('0x4a')],null))[_0x349f53('0x2f')](respondWithResult(_0x4b8bd2,null))[_0x349f53('0x2b')](handleError(_0x4b8bd2,null));},exports[_0x1c6b3f('0x1f')]=function(_0x15511f,_0x10768f){const _0x20ac97=_0x1c6b3f;return _0x15511f[_0x20ac97('0x5')]&&_0x15511f[_0x20ac97('0x5')][_0x20ac97('0xc')]&&(_0x15511f[_0x20ac97('0x4a')][_0x20ac97('0x20')]=_0x15511f[_0x20ac97('0x5')][_0x20ac97('0xc')]),db[_0x20ac97('0x4f')][_0x20ac97('0xd')]({'where':{'id':_0x15511f[_0x20ac97('0x24')]['id']}})[_0x20ac97('0x2f')](handleEntityNotFound(_0x10768f,null))[_0x20ac97('0x2f')](saveUpdates(_0x15511f[_0x20ac97('0x4a')],null))[_0x20ac97('0x2f')](respondWithResult(_0x10768f,null))[_0x20ac97('0x2b')](handleError(_0x10768f,null));},exports['getLogo']=function(_0x58c2b9,_0x376e7f){const _0x55cfdf=_0x1c6b3f,_0x4d7537=path[_0x55cfdf('0x3e')](config[_0x55cfdf('0x28')],_0x55cfdf('0x39'));let _0x19dfbc={'custom':![]};return utilLicense[_0x55cfdf('0x46')]()[_0x55cfdf('0x2f')](function(_0x5456c5){const _0x2f470c=_0x55cfdf;return _0x5456c5&&(_0x19dfbc=_0x5456c5),db[_0x2f470c('0x4f')]['findOne']({'where':{'id':_0x58c2b9[_0x2f470c('0x24')]['id']},'attributes':[_0x2f470c('0x34'),'loginLogo',_0x2f470c('0x3d'),_0x2f470c('0x8'),_0x2f470c('0x3b'),_0x2f470c('0x52'),'defaultPreferred',_0x2f470c('0xe')],'raw':!![]});})[_0x55cfdf('0x2f')](handleEntityNotFound(_0x376e7f,null))[_0x55cfdf('0x2f')](function(_0x493d31){const _0x5ae70b=_0x55cfdf;if(_0x493d31){let _0x5d799e=_0x493d31['logo']&&fs[_0x5ae70b('0x49')](path[_0x5ae70b('0x3e')](_0x4d7537,_[_0x5ae70b('0x15')](_0x493d31[_0x5ae70b('0x34')])))?path[_0x5ae70b('0x3e')](_0x4d7537,_[_0x5ae70b('0x15')](_0x493d31[_0x5ae70b('0x34')])):path[_0x5ae70b('0x3e')](_0x4d7537,_[_0x5ae70b('0x15')]('default_logo.svg'));const _0x18e462='default'+_['upperFirst'](_0x5ae70b('0x34'));(_0x493d31[_0x18e462]||!_0x19dfbc[_0x5ae70b('0x18')])&&(_0x5d799e=path[_0x5ae70b('0x3e')](_0x4d7537,_[_0x5ae70b('0x15')](_0x5ae70b('0x9'))));if(!fs[_0x5ae70b('0x49')](_0x5d799e))throw new ValidationError(_['upperFirst'](_0x5ae70b('0x34'))+_0x5ae70b('0x45'));return _0x376e7f[_0x5ae70b('0x6')](_0x5d799e);}})[_0x55cfdf('0x2b')](handleError(_0x376e7f,null));},exports[_0x1c6b3f('0x54')]=function(_0x43df1e,_0x14d1c2){const _0x1acd28=_0x1c6b3f,_0x312a68=path['join'](config['root'],_0x1acd28('0x39'));let _0xd83ad={'custom':![]};return utilLicense[_0x1acd28('0x46')]()['then'](function(_0x5f29e2){const _0x3ebc36=_0x1acd28;return _0x5f29e2&&(_0xd83ad=_0x5f29e2),db['Setting'][_0x3ebc36('0xd')]({'where':{'id':_0x43df1e['params']['id']},'attributes':[_0x3ebc36('0x34'),_0x3ebc36('0x20'),_0x3ebc36('0x3d'),_0x3ebc36('0x8'),'defaultLogo',_0x3ebc36('0x52'),_0x3ebc36('0xf'),_0x3ebc36('0xe')],'raw':!![]});})['then'](handleEntityNotFound(_0x14d1c2,null))[_0x1acd28('0x2f')](function(_0x3c2e67){const _0x1cb9e9=_0x1acd28;if(_0x3c2e67){let _0x56a609=_0x3c2e67[_0x1cb9e9('0x20')]&&fs[_0x1cb9e9('0x49')](path[_0x1cb9e9('0x3e')](_0x312a68,_['toLower'](_0x3c2e67[_0x1cb9e9('0x20')])))?path['join'](_0x312a68,_[_0x1cb9e9('0x15')](_0x3c2e67[_0x1cb9e9('0x20')])):path[_0x1cb9e9('0x3e')](_0x312a68,_['toLower'](_0x1cb9e9('0x51')));const _0x51d140='default'+_['upperFirst']('loginLogo');(_0x3c2e67[_0x51d140]||!_0xd83ad['custom'])&&(_0x56a609=path[_0x1cb9e9('0x3e')](_0x312a68,_[_0x1cb9e9('0x15')](_0x1cb9e9('0x51'))));if(!fs['existsSync'](_0x56a609))throw new ValidationError(_['upperFirst'](_0x1cb9e9('0x20'))+'\x20not\x20found');return _0x14d1c2[_0x1cb9e9('0x6')](_0x56a609);}})[_0x1acd28('0x2b')](handleError(_0x14d1c2,null));},exports[_0x1c6b3f('0x13')]=function(_0x332c07,_0x39f630){const _0x209980=_0x1c6b3f;return db[_0x209980('0x4f')][_0x209980('0xd')]({'where':{'id':_0x332c07[_0x209980('0x24')]['id']},'attributes':[_0x209980('0x29')]})[_0x209980('0x2f')](respondWithResult(_0x39f630,null))[_0x209980('0x2b')](handleError(_0x39f630,null));},exports[_0x1c6b3f('0x19')]=function(_0x5e7185,_0xf6f469){const _0x45abde=_0x1c6b3f;return _0x5e7185[_0x45abde('0x5')]&&_0x5e7185[_0x45abde('0x5')][_0x45abde('0xc')]&&(_0x5e7185[_0x45abde('0x4a')][_0x45abde('0x3d')]=_0x5e7185['file'][_0x45abde('0xc')]),db[_0x45abde('0x4f')]['findOne']({'where':{'id':_0x5e7185[_0x45abde('0x24')]['id']}})['then'](handleEntityNotFound(_0xf6f469,null))[_0x45abde('0x2f')](saveUpdates(_0x5e7185['body'],null))[_0x45abde('0x2f')](respondWithResult(_0xf6f469,null))[_0x45abde('0x2b')](handleError(_0xf6f469,null));},exports[_0x1c6b3f('0x33')]=function(_0x1e0317,_0x740981){const _0x1cf68=_0x1c6b3f,_0x393d03=path['join'](config[_0x1cf68('0x28')],'files/images/logos');let _0x33f864={'custom':![]};return utilLicense[_0x1cf68('0x46')]()[_0x1cf68('0x2f')](function(_0x25f759){const _0x30bad1=_0x1cf68;return _0x25f759&&(_0x33f864=_0x25f759),db[_0x30bad1('0x4f')][_0x30bad1('0xd')]({'where':{'id':_0x1e0317['params']['id']},'attributes':[_0x30bad1('0x34'),_0x30bad1('0x20'),_0x30bad1('0x3d'),_0x30bad1('0x8'),_0x30bad1('0x3b'),_0x30bad1('0x52'),_0x30bad1('0xf'),_0x30bad1('0xe')],'raw':!![]});})[_0x1cf68('0x2f')](handleEntityNotFound(_0x740981,null))[_0x1cf68('0x2f')](function(_0x17c1ba){const _0x33fdb6=_0x1cf68;if(_0x17c1ba){let _0x504bf5=_0x17c1ba['preferred']&&fs[_0x33fdb6('0x49')](path[_0x33fdb6('0x3e')](_0x393d03,_[_0x33fdb6('0x15')](_0x17c1ba['preferred'])))?path[_0x33fdb6('0x3e')](_0x393d03,_[_0x33fdb6('0x15')](_0x17c1ba[_0x33fdb6('0x3d')])):path[_0x33fdb6('0x3e')](_0x393d03,_[_0x33fdb6('0x15')](_0x33fdb6('0x0')));const _0x408f9e='default'+_[_0x33fdb6('0x35')](_0x33fdb6('0x3d'));(_0x17c1ba[_0x408f9e]||!_0x33f864[_0x33fdb6('0x18')]||!_0x33f864['preferred'])&&(_0x504bf5=path[_0x33fdb6('0x3e')](_0x393d03,_[_0x33fdb6('0x15')](_0x33fdb6('0x0'))));if(!fs[_0x33fdb6('0x49')](_0x504bf5))throw new ValidationError(_[_0x33fdb6('0x35')]('preferred')+_0x33fdb6('0x45'));return _0x740981[_0x33fdb6('0x6')](_0x504bf5);}})['catch'](handleError(_0x740981,null));},exports[_0x1c6b3f('0x23')]=function(_0x80c3d6,_0x400769){const _0x560a10=_0x1c6b3f;return _0x80c3d6[_0x560a10('0x5')]&&_0x80c3d6[_0x560a10('0x5')][_0x560a10('0xc')]&&(_0x80c3d6['body'][_0x560a10('0x8')]=_0x80c3d6[_0x560a10('0x5')][_0x560a10('0xc')]),db[_0x560a10('0x4f')]['findOne']({'where':{'id':_0x80c3d6[_0x560a10('0x24')]['id']}})['then'](handleEntityNotFound(_0x400769,null))[_0x560a10('0x2f')](saveUpdates(_0x80c3d6['body'],null))['then'](respondWithResult(_0x400769,null))[_0x560a10('0x2b')](handleError(_0x400769,null));},exports[_0x1c6b3f('0x16')]=function(_0x17a7c1,_0x422d77){const _0x2f04b7=_0x1c6b3f,_0x523c42=path[_0x2f04b7('0x3e')](config['root'],_0x2f04b7('0x39'));let _0x44108b={'custom':![]};return utilLicense[_0x2f04b7('0x46')]()[_0x2f04b7('0x2f')](function(_0x4d7287){const _0x2738f2=_0x2f04b7;return _0x4d7287&&(_0x44108b=_0x4d7287),db[_0x2738f2('0x4f')][_0x2738f2('0xd')]({'where':{'id':_0x17a7c1['params']['id']},'attributes':['logo',_0x2738f2('0x20'),_0x2738f2('0x3d'),_0x2738f2('0x8'),'defaultLogo',_0x2738f2('0x52'),_0x2738f2('0xf'),_0x2738f2('0xe')],'raw':!![]});})[_0x2f04b7('0x2f')](handleEntityNotFound(_0x422d77,null))['then'](function(_0x2fddda){const _0x4f0946=_0x2f04b7;if(_0x2fddda){let _0x3eb182=_0x2fddda['favicon']&&fs[_0x4f0946('0x49')](path[_0x4f0946('0x3e')](_0x523c42,_['toLower'](_0x2fddda['favicon'])))?path[_0x4f0946('0x3e')](_0x523c42,_[_0x4f0946('0x15')](_0x2fddda[_0x4f0946('0x8')])):path['join'](_0x523c42,_['toLower'](_0x4f0946('0x14')));const _0x2d986c=_0x4f0946('0x47')+_[_0x4f0946('0x35')](_0x4f0946('0x8'));(_0x2fddda[_0x2d986c]||!_0x44108b['custom'])&&(_0x3eb182=path['join'](_0x523c42,_['toLower'](_0x4f0946('0x14'))));if(!fs[_0x4f0946('0x49')](_0x3eb182))throw new ValidationError(_['upperFirst'](_0x4f0946('0x8'))+'\x20not\x20found');return _0x422d77[_0x4f0946('0x6')](_0x3eb182);}})['catch'](handleError(_0x422d77,null));};
\ No newline at end of file
+const a538_0x883b=['default_favicon.ico','defaultLoginLogo','getLogo','favicon','addLogoLogin','existsSync','files/images/logos','pick','path','default_logo.svg','length','fields','defaultPreferred','nolimit','merge','map','../../mysqldb','default_preferred.png','then','catch','keys','name','getFavicon','intersection','getLogoLogin','Content-Range','count','type','attributes','error','params','upperFirst','download','root','sequelize','addLogo','rawAttributes','lodash','offset','where','options','send','Setting','sendStatus','default','logo','json','stack','filename','includeAll','query','addFavicon','custom','defaultFavicon','include','../../components/parsers/qs','default_loginLogo.svg','status','model','VIRTUAL','key','gdpr','file','findAll','join','limit','findOne','\x20not\x20found','undefined','filter','api','getLicense','index','update','sort','addPreferred','toLower','body','defaultLogo','filters','loginLogo','preferred','securePassword','../../config/license/util'];(function(_0x1c2e00,_0x883bd9){const _0x530d45=function(_0x57c80a){while(--_0x57c80a){_0x1c2e00['push'](_0x1c2e00['shift']());}};_0x530d45(++_0x883bd9);}(a538_0x883b,0x164));const a538_0x530d=function(_0x1c2e00,_0x883bd9){_0x1c2e00=_0x1c2e00-0x0;let _0x530d45=a538_0x883b[_0x1c2e00];return _0x530d45;};const _0x1a16fd=a538_0x530d;'use strict';const path=require(_0x1a16fd('0x48')),fs=require('fs'),_=require(_0x1a16fd('0x11')),qs=require(_0x1a16fd('0x23')),logger=require('../../config/logger')(_0x1a16fd('0x32')),config=require('../../config/environment'),db=require(_0x1a16fd('0x50'))['db'],{Op,ValidationError}=require(_0x1a16fd('0xe')),utilLicense=require(_0x1a16fd('0x3f'));function respondWithResult(_0x57c80a,_0x208f27){return _0x208f27=_0x208f27||0xc8,function(_0x1d685f){const _0x284863=a538_0x530d;if(_0x1d685f)return _0x57c80a[_0x284863('0x25')](_0x208f27)[_0x284863('0x1a')](_0x1d685f);};}function respondWithFilteredResult(_0x52237b,_0x1f467f){return function(_0x51c34b){const _0x5c4f73=a538_0x530d;if(_0x51c34b){const _0x42da32=_0x51c34b[_0x5c4f73('0x6')],_0xa1b28b=_0x1f467f['offset'];let _0x13fbfa=_0x1f467f[_0x5c4f73('0x12')]+_0x1f467f[_0x5c4f73('0x2d')],_0x5c6558;return _0x13fbfa>=_0x42da32?(_0x13fbfa=_0x42da32,_0x5c6558=0xc8):_0x5c6558=0xce,_0x52237b[_0x5c4f73('0x25')](_0x5c6558),_0x52237b['set'](_0x5c4f73('0x5'),_0xa1b28b+'-'+_0x13fbfa+'/'+_0x42da32)['json'](_0x51c34b);}return null;};}function saveUpdates(_0x532c6b){return function(_0x57cbc8){const _0x31a484=a538_0x530d;if(_0x57cbc8)return _0x57cbc8[_0x31a484('0x35')](_0x532c6b)['then'](function(_0x252b36){return _0x252b36;});return null;};}function handleEntityNotFound(_0xaea25b){return function(_0x52fb07){const _0x42f0b9=a538_0x530d;return!_0x52fb07&&_0xaea25b[_0x42f0b9('0x17')](0x194),_0x52fb07;};}function handleError(_0x2f9f68,_0x554c77){return _0x554c77=_0x554c77||0x1f4,function(_0x1fa272){const _0x15a9fc=a538_0x530d;logger[_0x15a9fc('0x9')](_0x1fa272[_0x15a9fc('0x1b')]),_0x1fa272['name']&&delete _0x1fa272[_0x15a9fc('0x1')],_0x2f9f68[_0x15a9fc('0x25')](_0x554c77)[_0x15a9fc('0x15')](_0x1fa272);};}exports[_0x1a16fd('0x34')]=function(_0x5b9371,_0x378957){const _0x376f03=_0x1a16fd;let _0x427429={};const _0x48fb05={},_0x471403={'count':0x0,'rows':[]},_0x38e27c=_[_0x376f03('0x4f')](db[_0x376f03('0x16')][_0x376f03('0x10')],function(_0x5a6293){const _0x1613e3=_0x376f03;return{'name':_0x5a6293['fieldName'],'type':_0x5a6293[_0x1613e3('0x7')][_0x1613e3('0x28')]};});_0x48fb05['model']=_['map'](_0x38e27c,_0x376f03('0x1')),_0x48fb05[_0x376f03('0x1e')]=_['keys'](_0x5b9371[_0x376f03('0x1e')]),_0x48fb05[_0x376f03('0x3b')]=_[_0x376f03('0x3')](_0x48fb05['model'],_0x48fb05[_0x376f03('0x1e')]),_0x427429[_0x376f03('0x8')]=_[_0x376f03('0x3')](_0x48fb05[_0x376f03('0x26')],qs[_0x376f03('0x4b')](_0x5b9371[_0x376f03('0x1e')]['fields'])),_0x427429[_0x376f03('0x8')]=_0x427429[_0x376f03('0x8')][_0x376f03('0x4a')]?_0x427429[_0x376f03('0x8')]:_0x48fb05[_0x376f03('0x26')];typeof _0x5b9371[_0x376f03('0x1e')][_0x376f03('0x4d')]===_0x376f03('0x30')&&(_0x427429[_0x376f03('0x2d')]=qs['limit'](_0x5b9371[_0x376f03('0x1e')]['limit']),_0x427429['offset']=qs['offset'](_0x5b9371['query'][_0x376f03('0x12')]));_0x427429['order']=qs[_0x376f03('0x36')](_0x5b9371[_0x376f03('0x1e')][_0x376f03('0x36')]),_0x427429['where']=qs[_0x376f03('0x3b')](_[_0x376f03('0x47')](_0x5b9371[_0x376f03('0x1e')],_0x48fb05['filters']),_0x38e27c);_0x5b9371[_0x376f03('0x1e')][_0x376f03('0x31')]&&(_0x427429[_0x376f03('0x13')]=_['merge'](_0x427429[_0x376f03('0x13')],{[Op['or']]:_[_0x376f03('0x4f')](_0x38e27c,function(_0x4dcfdc){const _0x11e1d6=_0x376f03;if(_0x4dcfdc['type']!==_0x11e1d6('0x27')){const _0x3322a3={};return _0x3322a3[_0x4dcfdc[_0x11e1d6('0x1')]]={[Op['like']]:'%'+_0x5b9371[_0x11e1d6('0x1e')][_0x11e1d6('0x31')]+'%'},_0x3322a3;}})}));_0x427429=_['merge']({},_0x427429,_0x5b9371[_0x376f03('0x14')]);const _0x32fb0d={'where':_0x427429[_0x376f03('0x13')]};return db[_0x376f03('0x16')][_0x376f03('0x6')](_0x32fb0d)[_0x376f03('0x52')](function(_0xf80f56){const _0x3939dd=_0x376f03;return _0x471403['count']=_0xf80f56,_0x5b9371[_0x3939dd('0x1e')][_0x3939dd('0x1d')]&&(_0x427429[_0x3939dd('0x22')]=[{'all':!![]}]),db[_0x3939dd('0x16')][_0x3939dd('0x2b')](_0x427429);})['then'](function(_0x3075bb){return _0x471403['rows']=_0x3075bb,_0x471403;})[_0x376f03('0x52')](respondWithFilteredResult(_0x378957,_0x427429))[_0x376f03('0x53')](handleError(_0x378957,null));},exports['show']=function(_0x30a8ed,_0x42cb85){const _0x2679e0=_0x1a16fd;let _0x27469a={'raw':![],'where':{'id':_0x30a8ed[_0x2679e0('0xa')]['id']}};const _0x121d65={};return _0x121d65[_0x2679e0('0x26')]=_['keys'](db[_0x2679e0('0x16')]['rawAttributes']),_0x121d65['query']=_[_0x2679e0('0x0')](_0x30a8ed[_0x2679e0('0x1e')]),_0x121d65[_0x2679e0('0x3b')]=_['intersection'](_0x121d65[_0x2679e0('0x26')],_0x121d65[_0x2679e0('0x1e')]),_0x27469a['attributes']=_['intersection'](_0x121d65[_0x2679e0('0x26')],qs[_0x2679e0('0x4b')](_0x30a8ed[_0x2679e0('0x1e')][_0x2679e0('0x4b')])),_0x27469a[_0x2679e0('0x8')]=_0x27469a[_0x2679e0('0x8')][_0x2679e0('0x4a')]?_0x27469a['attributes']:_0x121d65[_0x2679e0('0x26')],_0x30a8ed[_0x2679e0('0x1e')][_0x2679e0('0x1d')]&&(_0x27469a['include']=[{'all':!![]}]),_0x27469a=_[_0x2679e0('0x4e')]({},_0x27469a,_0x30a8ed[_0x2679e0('0x14')]),db['Setting'][_0x2679e0('0x2e')](_0x27469a)['then'](handleEntityNotFound(_0x42cb85,null))[_0x2679e0('0x52')](respondWithResult(_0x42cb85,null))[_0x2679e0('0x53')](handleError(_0x42cb85,null));},exports[_0x1a16fd('0x35')]=function(_0x2b419f,_0x4a027f){const _0x4efbe5=_0x1a16fd;return _0x2b419f['body']['id']&&delete _0x2b419f[_0x4efbe5('0x39')]['id'],db[_0x4efbe5('0x16')][_0x4efbe5('0x2e')]({'where':{'id':_0x2b419f['params']['id']}})[_0x4efbe5('0x52')](handleEntityNotFound(_0x4a027f,null))['then'](saveUpdates(_0x2b419f[_0x4efbe5('0x39')],null))[_0x4efbe5('0x52')](respondWithResult(_0x4a027f,null))[_0x4efbe5('0x53')](handleError(_0x4a027f,null));},exports[_0x1a16fd('0xf')]=function(_0x339936,_0x548fa0){const _0x499653=_0x1a16fd;return _0x339936['file']&&_0x339936[_0x499653('0x2a')][_0x499653('0x1c')]&&(_0x339936['body'][_0x499653('0x19')]=_0x339936[_0x499653('0x2a')]['filename']),db[_0x499653('0x16')][_0x499653('0x2e')]({'where':{'id':_0x339936['params']['id']}})[_0x499653('0x52')](handleEntityNotFound(_0x548fa0,null))[_0x499653('0x52')](saveUpdates(_0x339936['body'],null))[_0x499653('0x52')](respondWithResult(_0x548fa0,null))[_0x499653('0x53')](handleError(_0x548fa0,null));},exports[_0x1a16fd('0x44')]=function(_0x1984ef,_0x4e961d){const _0x3eb818=_0x1a16fd;return _0x1984ef[_0x3eb818('0x2a')]&&_0x1984ef['file'][_0x3eb818('0x1c')]&&(_0x1984ef[_0x3eb818('0x39')][_0x3eb818('0x3c')]=_0x1984ef[_0x3eb818('0x2a')]['filename']),db[_0x3eb818('0x16')]['findOne']({'where':{'id':_0x1984ef[_0x3eb818('0xa')]['id']}})[_0x3eb818('0x52')](handleEntityNotFound(_0x4e961d,null))['then'](saveUpdates(_0x1984ef['body'],null))[_0x3eb818('0x52')](respondWithResult(_0x4e961d,null))[_0x3eb818('0x53')](handleError(_0x4e961d,null));},exports[_0x1a16fd('0x42')]=function(_0x423a0c,_0x4eee21){const _0x1bfc5b=_0x1a16fd,_0xa0edf2=path[_0x1bfc5b('0x2c')](config[_0x1bfc5b('0xd')],_0x1bfc5b('0x46'));let _0x24f66a={'custom':![]};return utilLicense[_0x1bfc5b('0x33')]()[_0x1bfc5b('0x52')](function(_0x43462c){const _0xc4815e=_0x1bfc5b;return _0x43462c&&(_0x24f66a=_0x43462c),db[_0xc4815e('0x16')]['findOne']({'where':{'id':_0x423a0c['params']['id']},'attributes':['logo','loginLogo',_0xc4815e('0x3d'),_0xc4815e('0x43'),'defaultLogo',_0xc4815e('0x41'),_0xc4815e('0x4c'),_0xc4815e('0x21')],'raw':!![]});})[_0x1bfc5b('0x52')](handleEntityNotFound(_0x4eee21,null))['then'](function(_0xe7134b){const _0x35fee6=_0x1bfc5b;if(_0xe7134b){let _0x131c78=_0xe7134b[_0x35fee6('0x19')]&&fs[_0x35fee6('0x45')](path[_0x35fee6('0x2c')](_0xa0edf2,_[_0x35fee6('0x38')](_0xe7134b[_0x35fee6('0x19')])))?path[_0x35fee6('0x2c')](_0xa0edf2,_[_0x35fee6('0x38')](_0xe7134b['logo'])):path[_0x35fee6('0x2c')](_0xa0edf2,_[_0x35fee6('0x38')](_0x35fee6('0x49')));const _0x5e7833='default'+_[_0x35fee6('0xb')](_0x35fee6('0x19'));(_0xe7134b[_0x5e7833]||!_0x24f66a[_0x35fee6('0x20')])&&(_0x131c78=path[_0x35fee6('0x2c')](_0xa0edf2,_[_0x35fee6('0x38')](_0x35fee6('0x49'))));if(!fs[_0x35fee6('0x45')](_0x131c78))throw new ValidationError(_[_0x35fee6('0xb')]('logo')+_0x35fee6('0x2f'));return _0x4eee21['download'](_0x131c78);}})[_0x1bfc5b('0x53')](handleError(_0x4eee21,null));},exports[_0x1a16fd('0x4')]=function(_0x13c7f2,_0x594448){const _0x243c1f=_0x1a16fd,_0xf1e268=path[_0x243c1f('0x2c')](config[_0x243c1f('0xd')],_0x243c1f('0x46'));let _0x4379fb={'custom':![]};return utilLicense[_0x243c1f('0x33')]()[_0x243c1f('0x52')](function(_0xb8cff8){const _0x45ad2b=_0x243c1f;return _0xb8cff8&&(_0x4379fb=_0xb8cff8),db[_0x45ad2b('0x16')]['findOne']({'where':{'id':_0x13c7f2[_0x45ad2b('0xa')]['id']},'attributes':[_0x45ad2b('0x19'),'loginLogo',_0x45ad2b('0x3d'),_0x45ad2b('0x43'),_0x45ad2b('0x3a'),_0x45ad2b('0x41'),_0x45ad2b('0x4c'),'defaultFavicon'],'raw':!![]});})[_0x243c1f('0x52')](handleEntityNotFound(_0x594448,null))[_0x243c1f('0x52')](function(_0xc4bfa6){const _0x171c4b=_0x243c1f;if(_0xc4bfa6){let _0x9aa09e=_0xc4bfa6[_0x171c4b('0x3c')]&&fs[_0x171c4b('0x45')](path[_0x171c4b('0x2c')](_0xf1e268,_[_0x171c4b('0x38')](_0xc4bfa6[_0x171c4b('0x3c')])))?path[_0x171c4b('0x2c')](_0xf1e268,_[_0x171c4b('0x38')](_0xc4bfa6[_0x171c4b('0x3c')])):path[_0x171c4b('0x2c')](_0xf1e268,_[_0x171c4b('0x38')](_0x171c4b('0x24')));const _0xbb13bf=_0x171c4b('0x18')+_['upperFirst']('loginLogo');(_0xc4bfa6[_0xbb13bf]||!_0x4379fb[_0x171c4b('0x20')])&&(_0x9aa09e=path[_0x171c4b('0x2c')](_0xf1e268,_[_0x171c4b('0x38')](_0x171c4b('0x24'))));if(!fs[_0x171c4b('0x45')](_0x9aa09e))throw new ValidationError(_[_0x171c4b('0xb')](_0x171c4b('0x3c'))+_0x171c4b('0x2f'));return _0x594448[_0x171c4b('0xc')](_0x9aa09e);}})[_0x243c1f('0x53')](handleError(_0x594448,null));},exports[_0x1a16fd('0x29')]=function(_0x5946a7,_0x1b3590){const _0x51e356=_0x1a16fd;return db[_0x51e356('0x16')][_0x51e356('0x2e')]({'where':{'id':_0x5946a7['params']['id']},'attributes':[_0x51e356('0x3e')]})[_0x51e356('0x52')](respondWithResult(_0x1b3590,null))[_0x51e356('0x53')](handleError(_0x1b3590,null));},exports[_0x1a16fd('0x37')]=function(_0x3109f4,_0x25658a){const _0x9b324=_0x1a16fd;return _0x3109f4['file']&&_0x3109f4[_0x9b324('0x2a')][_0x9b324('0x1c')]&&(_0x3109f4['body']['preferred']=_0x3109f4['file'][_0x9b324('0x1c')]),db[_0x9b324('0x16')][_0x9b324('0x2e')]({'where':{'id':_0x3109f4[_0x9b324('0xa')]['id']}})[_0x9b324('0x52')](handleEntityNotFound(_0x25658a,null))[_0x9b324('0x52')](saveUpdates(_0x3109f4[_0x9b324('0x39')],null))['then'](respondWithResult(_0x25658a,null))[_0x9b324('0x53')](handleError(_0x25658a,null));},exports['getPreferred']=function(_0x486dba,_0x212a2a){const _0x4b6341=_0x1a16fd,_0x4700b7=path[_0x4b6341('0x2c')](config[_0x4b6341('0xd')],_0x4b6341('0x46'));let _0x462dc4={'custom':![]};return utilLicense[_0x4b6341('0x33')]()[_0x4b6341('0x52')](function(_0x315f45){const _0x496aea=_0x4b6341;return _0x315f45&&(_0x462dc4=_0x315f45),db[_0x496aea('0x16')]['findOne']({'where':{'id':_0x486dba['params']['id']},'attributes':[_0x496aea('0x19'),_0x496aea('0x3c'),_0x496aea('0x3d'),_0x496aea('0x43'),'defaultLogo',_0x496aea('0x41'),_0x496aea('0x4c'),'defaultFavicon'],'raw':!![]});})['then'](handleEntityNotFound(_0x212a2a,null))[_0x4b6341('0x52')](function(_0x13d16b){const _0x567252=_0x4b6341;if(_0x13d16b){let _0x548b5a=_0x13d16b[_0x567252('0x3d')]&&fs['existsSync'](path[_0x567252('0x2c')](_0x4700b7,_[_0x567252('0x38')](_0x13d16b[_0x567252('0x3d')])))?path[_0x567252('0x2c')](_0x4700b7,_[_0x567252('0x38')](_0x13d16b['preferred'])):path[_0x567252('0x2c')](_0x4700b7,_[_0x567252('0x38')](_0x567252('0x51')));const _0x8d17b=_0x567252('0x18')+_[_0x567252('0xb')](_0x567252('0x3d'));(_0x13d16b[_0x8d17b]||!_0x462dc4['custom']||!_0x462dc4[_0x567252('0x3d')])&&(_0x548b5a=path[_0x567252('0x2c')](_0x4700b7,_[_0x567252('0x38')](_0x567252('0x51'))));if(!fs[_0x567252('0x45')](_0x548b5a))throw new ValidationError(_[_0x567252('0xb')](_0x567252('0x3d'))+_0x567252('0x2f'));return _0x212a2a[_0x567252('0xc')](_0x548b5a);}})[_0x4b6341('0x53')](handleError(_0x212a2a,null));},exports[_0x1a16fd('0x1f')]=function(_0x1a5db4,_0x3980cd){const _0xb92c9b=_0x1a16fd;return _0x1a5db4[_0xb92c9b('0x2a')]&&_0x1a5db4[_0xb92c9b('0x2a')][_0xb92c9b('0x1c')]&&(_0x1a5db4[_0xb92c9b('0x39')][_0xb92c9b('0x43')]=_0x1a5db4[_0xb92c9b('0x2a')][_0xb92c9b('0x1c')]),db[_0xb92c9b('0x16')][_0xb92c9b('0x2e')]({'where':{'id':_0x1a5db4[_0xb92c9b('0xa')]['id']}})['then'](handleEntityNotFound(_0x3980cd,null))[_0xb92c9b('0x52')](saveUpdates(_0x1a5db4[_0xb92c9b('0x39')],null))[_0xb92c9b('0x52')](respondWithResult(_0x3980cd,null))[_0xb92c9b('0x53')](handleError(_0x3980cd,null));},exports[_0x1a16fd('0x2')]=function(_0xddcfb4,_0x1eedaa){const _0x36f930=_0x1a16fd,_0x27687e=path[_0x36f930('0x2c')](config['root'],'files/images/logos');let _0x505f83={'custom':![]};return utilLicense[_0x36f930('0x33')]()[_0x36f930('0x52')](function(_0x3a9be6){const _0xda727e=_0x36f930;return _0x3a9be6&&(_0x505f83=_0x3a9be6),db['Setting'][_0xda727e('0x2e')]({'where':{'id':_0xddcfb4['params']['id']},'attributes':[_0xda727e('0x19'),_0xda727e('0x3c'),_0xda727e('0x3d'),_0xda727e('0x43'),_0xda727e('0x3a'),_0xda727e('0x41'),_0xda727e('0x4c'),_0xda727e('0x21')],'raw':!![]});})['then'](handleEntityNotFound(_0x1eedaa,null))[_0x36f930('0x52')](function(_0x25cc83){const _0x2d956b=_0x36f930;if(_0x25cc83){let _0x32997f=_0x25cc83[_0x2d956b('0x43')]&&fs[_0x2d956b('0x45')](path[_0x2d956b('0x2c')](_0x27687e,_[_0x2d956b('0x38')](_0x25cc83[_0x2d956b('0x43')])))?path[_0x2d956b('0x2c')](_0x27687e,_[_0x2d956b('0x38')](_0x25cc83['favicon'])):path[_0x2d956b('0x2c')](_0x27687e,_['toLower'](_0x2d956b('0x40')));const _0x3c7ee0=_0x2d956b('0x18')+_[_0x2d956b('0xb')]('favicon');(_0x25cc83[_0x3c7ee0]||!_0x505f83[_0x2d956b('0x20')])&&(_0x32997f=path[_0x2d956b('0x2c')](_0x27687e,_['toLower'](_0x2d956b('0x40'))));if(!fs[_0x2d956b('0x45')](_0x32997f))throw new ValidationError(_[_0x2d956b('0xb')](_0x2d956b('0x43'))+_0x2d956b('0x2f'));return _0x1eedaa[_0x2d956b('0xc')](_0x32997f);}})['catch'](handleError(_0x1eedaa,null));};
\ No newline at end of file