Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / setting / setting.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 _0x4cdd=['type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','filter','where','merge','options','include','findAll','show','length','includeAll','body','find','params','file','filename','catch','getLogo','getLicense','logo','loginLogo','preferred','defaultLogo','defaultLoginLogo','defaultPreferred','defaultFavicon','existsSync','join','root','toLower','upperFirst','custom','Sequelize','\x20not\x20found','download','getLogoLogin','server/files/images/logos','default','default_loginLogo.svg','ValidationError','gdpr','securePassword','addPreferred','favicon','default_preferred.png','addFavicon','getFavicon','default_favicon.ico','getDate','utcOffset','now','format','YYYY-MM-DD\x20HH:mm:ss:SSS','eml-format','rimraf','request-promise','moment','bluebird','mustache','util','path','sox','lodash','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/license/util','../../mysqldb','http','request\x20sent','debug','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code','Setting,\x20%s,\x20%s','message','info','result','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','stack','name','send','index','map','Setting','rawAttributes','fieldName'];(function(_0x32e580,_0x4c6b0d){var _0x12e8e5=function(_0x6abb){while(--_0x6abb){_0x32e580['push'](_0x32e580['shift']());}};_0x12e8e5(++_0x4c6b0d);}(_0x4cdd,0x1a5));var _0xd4cd=function(_0x109a08,_0x51905c){_0x109a08=_0x109a08-0x0;var _0x2a42a3=_0x4cdd[_0x109a08];return _0x2a42a3;};'use strict';var emlformat=require(_0xd4cd('0x0'));var rimraf=require(_0xd4cd('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xd4cd('0x2'));var moment=require(_0xd4cd('0x3'));var BPromise=require(_0xd4cd('0x4'));var Mustache=require(_0xd4cd('0x5'));var util=require(_0xd4cd('0x6'));var path=require(_0xd4cd('0x7'));var sox=require(_0xd4cd('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xd4cd('0x9'));var squel=require('squel');var crypto=require(_0xd4cd('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xd4cd('0xb'));var toCsv=require(_0xd4cd('0xc'));var querystring=require(_0xd4cd('0xd'));var Papa=require(_0xd4cd('0xe'));var Redis=require(_0xd4cd('0xf'));var authService=require(_0xd4cd('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xd4cd('0x11'));var hardwareService=require(_0xd4cd('0x12'));var logger=require(_0xd4cd('0x13'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xd4cd('0x14'));var db=require(_0xd4cd('0x15'))['db'];var jayson=require('jayson/promise');var client=jayson['client'][_0xd4cd('0x16')]({'port':0x232a});function respondWithRpcPromise(_0x313af1,_0x5d1b49,_0x4e11a4,_0x5aa418){return new BPromise(function(_0x8bdf6f,_0x2bf761){var _0x54cf5d=_0x5aa418||client;return _0x54cf5d['request'](_0x313af1,_0x4e11a4)['then'](function(_0x35e30c){logger['info']('Setting,\x20%s,\x20%s',_0x5d1b49,_0xd4cd('0x17'));logger[_0xd4cd('0x18')](_0xd4cd('0x19'),_0x5d1b49,_0xd4cd('0x17'),JSON[_0xd4cd('0x1a')](_0x35e30c));if(_0x35e30c['error']){if(_0x35e30c[_0xd4cd('0x1b')][_0xd4cd('0x1c')]===0x1f4){logger['error'](_0xd4cd('0x1d'),_0x5d1b49,_0x35e30c[_0xd4cd('0x1b')]['message']);return _0x2bf761(_0x35e30c[_0xd4cd('0x1b')][_0xd4cd('0x1e')]);}logger[_0xd4cd('0x1b')](_0xd4cd('0x1d'),_0x5d1b49,_0x35e30c[_0xd4cd('0x1b')]['message']);return _0x8bdf6f(_0x35e30c['error'][_0xd4cd('0x1e')]);}else{logger[_0xd4cd('0x1f')](_0xd4cd('0x1d'),_0x5d1b49,_0xd4cd('0x17'));_0x8bdf6f(_0x35e30c[_0xd4cd('0x20')][_0xd4cd('0x1e')]);}})['catch'](function(_0x244ee3){logger[_0xd4cd('0x1b')]('Setting,\x20%s,\x20%s',_0x5d1b49,_0x244ee3);_0x2bf761(_0x244ee3);});});}function respondWithStatusCode(_0x282fd3,_0x2e2dbf){_0x2e2dbf=_0x2e2dbf||0xcc;return function(_0x4b370f){if(_0x4b370f){return _0x282fd3[_0xd4cd('0x21')](_0x2e2dbf);}return _0x282fd3['status'](_0x2e2dbf)['end']();};}function respondWithResult(_0x49ce20,_0x27bbe8){_0x27bbe8=_0x27bbe8||0xc8;return function(_0x230eea){if(_0x230eea){return _0x49ce20[_0xd4cd('0x22')](_0x27bbe8)[_0xd4cd('0x23')](_0x230eea);}};}function respondWithFilteredResult(_0x43efdd,_0x3897e3){return function(_0x443f9e){if(_0x443f9e){var _0x371ccf=typeof _0x3897e3[_0xd4cd('0x24')]===_0xd4cd('0x25')&&typeof _0x3897e3[_0xd4cd('0x26')]===_0xd4cd('0x25');var _0x29918d=_0x443f9e['count'];var _0xae194c=_0x371ccf?0x0:_0x3897e3[_0xd4cd('0x24')];var _0x5c8b1f=_0x371ccf?_0x443f9e[_0xd4cd('0x27')]:_0x3897e3[_0xd4cd('0x24')]+_0x3897e3['limit'];var _0x3a892b;if(_0x5c8b1f>=_0x29918d){_0x5c8b1f=_0x29918d;_0x3a892b=0xc8;}else{_0x3a892b=0xce;}_0x43efdd[_0xd4cd('0x22')](_0x3a892b);return _0x43efdd[_0xd4cd('0x28')](_0xd4cd('0x29'),_0xae194c+'-'+_0x5c8b1f+'/'+_0x29918d)[_0xd4cd('0x23')](_0x443f9e);}return null;};}function patchUpdates(_0x40ab61){return function(_0x484ec6){try{jsonpatch['apply'](_0x484ec6,_0x40ab61,!![]);}catch(_0x1bae67){return BPromise[_0xd4cd('0x2a')](_0x1bae67);}return _0x484ec6[_0xd4cd('0x2b')]();};}function saveUpdates(_0x27a1ea,_0x4e860f){return function(_0x1c788f){if(_0x1c788f){return _0x1c788f[_0xd4cd('0x2c')](_0x27a1ea)[_0xd4cd('0x2d')](function(_0x4a49ce){return _0x4a49ce;});}return null;};}function removeEntity(_0x1dbfa5,_0x5efa56){return function(_0x30c2b2){if(_0x30c2b2){return _0x30c2b2[_0xd4cd('0x2e')]()[_0xd4cd('0x2d')](function(){_0x1dbfa5[_0xd4cd('0x22')](0xcc)['end']();});}};}function handleEntityNotFound(_0x11f93e,_0x310542){return function(_0x42f7da){if(!_0x42f7da){_0x11f93e[_0xd4cd('0x21')](0x194);}return _0x42f7da;};}function handleError(_0x5dc549,_0x3ab62d){_0x3ab62d=_0x3ab62d||0x1f4;return function(_0xf2f5ab){logger[_0xd4cd('0x1b')](_0xf2f5ab[_0xd4cd('0x2f')]);if(_0xf2f5ab[_0xd4cd('0x30')]){delete _0xf2f5ab['name'];}_0x5dc549[_0xd4cd('0x22')](_0x3ab62d)[_0xd4cd('0x31')](_0xf2f5ab);};}exports[_0xd4cd('0x32')]=function(_0x30492f,_0x3fd569){var _0x2f7692={},_0x18fcfc={},_0x318019={'count':0x0,'rows':[]};var _0x536ce0=_[_0xd4cd('0x33')](db[_0xd4cd('0x34')][_0xd4cd('0x35')],function(_0x153cfc){return{'name':_0x153cfc[_0xd4cd('0x36')],'type':_0x153cfc[_0xd4cd('0x37')][_0xd4cd('0x38')]};});_0x18fcfc[_0xd4cd('0x39')]=_['map'](_0x536ce0,_0xd4cd('0x30'));_0x18fcfc[_0xd4cd('0x3a')]=_[_0xd4cd('0x3b')](_0x30492f[_0xd4cd('0x3a')]);_0x18fcfc[_0xd4cd('0x3c')]=_[_0xd4cd('0x3d')](_0x18fcfc['model'],_0x18fcfc[_0xd4cd('0x3a')]);_0x2f7692[_0xd4cd('0x3e')]=_[_0xd4cd('0x3d')](_0x18fcfc[_0xd4cd('0x39')],qs[_0xd4cd('0x3f')](_0x30492f['query'][_0xd4cd('0x3f')]));_0x2f7692[_0xd4cd('0x3e')]=_0x2f7692[_0xd4cd('0x3e')]['length']?_0x2f7692[_0xd4cd('0x3e')]:_0x18fcfc[_0xd4cd('0x39')];if(!_0x30492f[_0xd4cd('0x3a')][_0xd4cd('0x40')](_0xd4cd('0x41'))){_0x2f7692[_0xd4cd('0x26')]=qs['limit'](_0x30492f[_0xd4cd('0x3a')][_0xd4cd('0x26')]);_0x2f7692[_0xd4cd('0x24')]=qs[_0xd4cd('0x24')](_0x30492f[_0xd4cd('0x3a')]['offset']);}_0x2f7692[_0xd4cd('0x42')]=qs[_0xd4cd('0x43')](_0x30492f[_0xd4cd('0x3a')][_0xd4cd('0x43')]);_0x2f7692['where']=qs['filters'](_['pick'](_0x30492f[_0xd4cd('0x3a')],_0x18fcfc[_0xd4cd('0x3c')]),_0x536ce0);if(_0x30492f[_0xd4cd('0x3a')][_0xd4cd('0x44')]){_0x2f7692[_0xd4cd('0x45')]=_[_0xd4cd('0x46')](_0x2f7692[_0xd4cd('0x45')],{'$or':_[_0xd4cd('0x33')](_0x536ce0,function(_0x5bf7fa){if(_0x5bf7fa[_0xd4cd('0x37')]!=='VIRTUAL'){var _0x33ccd1={};_0x33ccd1[_0x5bf7fa[_0xd4cd('0x30')]]={'$like':'%'+_0x30492f[_0xd4cd('0x3a')][_0xd4cd('0x44')]+'%'};return _0x33ccd1;}})});}_0x2f7692=_['merge']({},_0x2f7692,_0x30492f[_0xd4cd('0x47')]);var _0x4f7f30={'where':_0x2f7692['where']};return db['Setting']['count'](_0x4f7f30)[_0xd4cd('0x2d')](function(_0x1296da){_0x318019[_0xd4cd('0x27')]=_0x1296da;if(_0x30492f[_0xd4cd('0x3a')]['includeAll']){_0x2f7692[_0xd4cd('0x48')]=[{'all':!![]}];}return db['Setting'][_0xd4cd('0x49')](_0x2f7692);})[_0xd4cd('0x2d')](function(_0x391e51){_0x318019['rows']=_0x391e51;return _0x318019;})[_0xd4cd('0x2d')](respondWithFilteredResult(_0x3fd569,_0x2f7692))['catch'](handleError(_0x3fd569,null));};exports[_0xd4cd('0x4a')]=function(_0x559fc6,_0x48a196){var _0x7d070c={'raw':![],'where':{'id':_0x559fc6['params']['id']}},_0x1a337d={};_0x1a337d[_0xd4cd('0x39')]=_[_0xd4cd('0x3b')](db[_0xd4cd('0x34')]['rawAttributes']);_0x1a337d[_0xd4cd('0x3a')]=_[_0xd4cd('0x3b')](_0x559fc6['query']);_0x1a337d[_0xd4cd('0x3c')]=_[_0xd4cd('0x3d')](_0x1a337d[_0xd4cd('0x39')],_0x1a337d[_0xd4cd('0x3a')]);_0x7d070c[_0xd4cd('0x3e')]=_[_0xd4cd('0x3d')](_0x1a337d[_0xd4cd('0x39')],qs['fields'](_0x559fc6[_0xd4cd('0x3a')]['fields']));_0x7d070c[_0xd4cd('0x3e')]=_0x7d070c[_0xd4cd('0x3e')][_0xd4cd('0x4b')]?_0x7d070c[_0xd4cd('0x3e')]:_0x1a337d[_0xd4cd('0x39')];if(_0x559fc6['query'][_0xd4cd('0x4c')]){_0x7d070c['include']=[{'all':!![]}];}_0x7d070c=_[_0xd4cd('0x46')]({},_0x7d070c,_0x559fc6['options']);return db[_0xd4cd('0x34')]['find'](_0x7d070c)[_0xd4cd('0x2d')](handleEntityNotFound(_0x48a196,null))[_0xd4cd('0x2d')](respondWithResult(_0x48a196,null))['catch'](handleError(_0x48a196,null));};exports[_0xd4cd('0x2c')]=function(_0x4c666e,_0x2d43b5){if(_0x4c666e['body']['id']){delete _0x4c666e[_0xd4cd('0x4d')]['id'];}return db[_0xd4cd('0x34')][_0xd4cd('0x4e')]({'where':{'id':_0x4c666e[_0xd4cd('0x4f')]['id']}})[_0xd4cd('0x2d')](handleEntityNotFound(_0x2d43b5,null))[_0xd4cd('0x2d')](saveUpdates(_0x4c666e[_0xd4cd('0x4d')],null))[_0xd4cd('0x2d')](respondWithResult(_0x2d43b5,null))['catch'](handleError(_0x2d43b5,null));};exports['addLogo']=function(_0x4ef4c0,_0x3cd4be,_0xed37ef){if(_0x4ef4c0[_0xd4cd('0x50')]&&_0x4ef4c0['file'][_0xd4cd('0x51')]){_0x4ef4c0[_0xd4cd('0x4d')]['logo']=_0x4ef4c0[_0xd4cd('0x50')][_0xd4cd('0x51')];}return db['Setting'][_0xd4cd('0x4e')]({'where':{'id':_0x4ef4c0[_0xd4cd('0x4f')]['id']}})[_0xd4cd('0x2d')](handleEntityNotFound(_0x3cd4be,null))[_0xd4cd('0x2d')](saveUpdates(_0x4ef4c0[_0xd4cd('0x4d')],null))[_0xd4cd('0x2d')](respondWithResult(_0x3cd4be,null))[_0xd4cd('0x52')](handleError(_0x3cd4be,null));};exports['addLogoLogin']=function(_0x423af1,_0x3f5553,_0x28017f){if(_0x423af1[_0xd4cd('0x50')]&&_0x423af1[_0xd4cd('0x50')][_0xd4cd('0x51')]){_0x423af1[_0xd4cd('0x4d')]['loginLogo']=_0x423af1[_0xd4cd('0x50')][_0xd4cd('0x51')];}return db[_0xd4cd('0x34')]['find']({'where':{'id':_0x423af1[_0xd4cd('0x4f')]['id']}})[_0xd4cd('0x2d')](handleEntityNotFound(_0x3f5553,null))[_0xd4cd('0x2d')](saveUpdates(_0x423af1['body'],null))[_0xd4cd('0x2d')](respondWithResult(_0x3f5553,null))[_0xd4cd('0x52')](handleError(_0x3f5553,null));};var utilLicense=require(_0xd4cd('0x14'));exports[_0xd4cd('0x53')]=function(_0x53b72c,_0xd60292,_0x53adbd){var _0x2b1bc1='server/files/images/logos';var _0x1eca34={'custom':![]};return utilLicense[_0xd4cd('0x54')]()[_0xd4cd('0x2d')](function(_0x1f9db4){if(_0x1f9db4){_0x1eca34=_0x1f9db4;}return db[_0xd4cd('0x34')]['find']({'where':{'id':_0x53b72c[_0xd4cd('0x4f')]['id']},'attributes':[_0xd4cd('0x55'),_0xd4cd('0x56'),_0xd4cd('0x57'),'favicon',_0xd4cd('0x58'),_0xd4cd('0x59'),_0xd4cd('0x5a'),_0xd4cd('0x5b')],'raw':!![]});})[_0xd4cd('0x2d')](handleEntityNotFound(_0xd60292,null))[_0xd4cd('0x2d')](function(_0x46e8f4){if(_0x46e8f4){var _0x4a5cd9=_0x46e8f4[_0xd4cd('0x55')]&&fs[_0xd4cd('0x5c')](path[_0xd4cd('0x5d')](config['root'],_0x2b1bc1,_['toLower'](_0x46e8f4[_0xd4cd('0x55')])))?path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0x2b1bc1,_['toLower'](_0x46e8f4[_0xd4cd('0x55')])):path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0x2b1bc1,_[_0xd4cd('0x5f')]('default_logo.svg'));var _0x4dacfc='default'+_[_0xd4cd('0x60')](_0xd4cd('0x55'));if(_0x46e8f4[_0x4dacfc]||!_0x1eca34[_0xd4cd('0x61')]){_0x4a5cd9=path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0x2b1bc1,_[_0xd4cd('0x5f')]('default_logo.svg'));}if(!fs[_0xd4cd('0x5c')](_0x4a5cd9)){throw new db[(_0xd4cd('0x62'))]['ValidationError'](_[_0xd4cd('0x60')](_0xd4cd('0x55'))+_0xd4cd('0x63'));}return _0xd60292[_0xd4cd('0x64')](_0x4a5cd9);}})[_0xd4cd('0x52')](handleError(_0xd60292,null));};var utilLicense=require(_0xd4cd('0x14'));exports[_0xd4cd('0x65')]=function(_0xe0153f,_0x121e87,_0x63341e){var _0x496cbc=_0xd4cd('0x66');var _0xbb150d={'custom':![]};return utilLicense[_0xd4cd('0x54')]()['then'](function(_0x36d1b8){if(_0x36d1b8){_0xbb150d=_0x36d1b8;}return db[_0xd4cd('0x34')][_0xd4cd('0x4e')]({'where':{'id':_0xe0153f[_0xd4cd('0x4f')]['id']},'attributes':['logo',_0xd4cd('0x56'),'preferred','favicon',_0xd4cd('0x58'),_0xd4cd('0x59'),_0xd4cd('0x5a'),_0xd4cd('0x5b')],'raw':!![]});})[_0xd4cd('0x2d')](handleEntityNotFound(_0x121e87,null))[_0xd4cd('0x2d')](function(_0x49a338){if(_0x49a338){var _0x3f87fb=_0x49a338[_0xd4cd('0x56')]&&fs[_0xd4cd('0x5c')](path[_0xd4cd('0x5d')](config['root'],_0x496cbc,_[_0xd4cd('0x5f')](_0x49a338['loginLogo'])))?path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0x496cbc,_['toLower'](_0x49a338['loginLogo'])):path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0x496cbc,_[_0xd4cd('0x5f')]('default_loginLogo.svg'));var _0x1e9f4c=_0xd4cd('0x67')+_[_0xd4cd('0x60')](_0xd4cd('0x56'));if(_0x49a338[_0x1e9f4c]||!_0xbb150d[_0xd4cd('0x61')]){_0x3f87fb=path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0x496cbc,_['toLower'](_0xd4cd('0x68')));}if(!fs[_0xd4cd('0x5c')](_0x3f87fb)){throw new db[(_0xd4cd('0x62'))][(_0xd4cd('0x69'))](_[_0xd4cd('0x60')](_0xd4cd('0x56'))+_0xd4cd('0x63'));}return _0x121e87[_0xd4cd('0x64')](_0x3f87fb);}})[_0xd4cd('0x52')](handleError(_0x121e87,null));};exports[_0xd4cd('0x6a')]=function(_0x59d9dd,_0xe69ef5){return db[_0xd4cd('0x34')][_0xd4cd('0x4e')]({'where':{'id':_0x59d9dd['params']['id']},'attributes':[_0xd4cd('0x6b')]})['then'](respondWithResult(_0xe69ef5,null))[_0xd4cd('0x52')](handleError(_0xe69ef5,null));};exports[_0xd4cd('0x6c')]=function(_0x3ad46f,_0x265fac,_0x3cc48f){if(_0x3ad46f[_0xd4cd('0x50')]&&_0x3ad46f[_0xd4cd('0x50')]['filename']){_0x3ad46f[_0xd4cd('0x4d')][_0xd4cd('0x57')]=_0x3ad46f[_0xd4cd('0x50')][_0xd4cd('0x51')];}return db[_0xd4cd('0x34')][_0xd4cd('0x4e')]({'where':{'id':_0x3ad46f['params']['id']}})['then'](handleEntityNotFound(_0x265fac,null))[_0xd4cd('0x2d')](saveUpdates(_0x3ad46f[_0xd4cd('0x4d')],null))[_0xd4cd('0x2d')](respondWithResult(_0x265fac,null))['catch'](handleError(_0x265fac,null));};var utilLicense=require(_0xd4cd('0x14'));exports['getPreferred']=function(_0x2cac96,_0x4820a8,_0x9142e){var _0xf95252=_0xd4cd('0x66');var _0x134132={'custom':![]};return utilLicense[_0xd4cd('0x54')]()[_0xd4cd('0x2d')](function(_0x59672f){if(_0x59672f){_0x134132=_0x59672f;}return db[_0xd4cd('0x34')][_0xd4cd('0x4e')]({'where':{'id':_0x2cac96['params']['id']},'attributes':[_0xd4cd('0x55'),_0xd4cd('0x56'),_0xd4cd('0x57'),_0xd4cd('0x6d'),_0xd4cd('0x58'),'defaultLoginLogo',_0xd4cd('0x5a'),'defaultFavicon'],'raw':!![]});})[_0xd4cd('0x2d')](handleEntityNotFound(_0x4820a8,null))[_0xd4cd('0x2d')](function(_0x1bd29c){if(_0x1bd29c){var _0x447ab6=_0x1bd29c[_0xd4cd('0x57')]&&fs[_0xd4cd('0x5c')](path[_0xd4cd('0x5d')](config['root'],_0xf95252,_[_0xd4cd('0x5f')](_0x1bd29c[_0xd4cd('0x57')])))?path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0xf95252,_[_0xd4cd('0x5f')](_0x1bd29c[_0xd4cd('0x57')])):path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0xf95252,_['toLower']('default_preferred.png'));var _0x2809d3=_0xd4cd('0x67')+_['upperFirst'](_0xd4cd('0x57'));if(_0x1bd29c[_0x2809d3]||!_0x134132[_0xd4cd('0x61')]||!_0x134132[_0xd4cd('0x57')]){_0x447ab6=path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0xf95252,_[_0xd4cd('0x5f')](_0xd4cd('0x6e')));}if(!fs[_0xd4cd('0x5c')](_0x447ab6)){throw new db[(_0xd4cd('0x62'))][(_0xd4cd('0x69'))](_[_0xd4cd('0x60')]('preferred')+_0xd4cd('0x63'));}return _0x4820a8[_0xd4cd('0x64')](_0x447ab6);}})[_0xd4cd('0x52')](handleError(_0x4820a8,null));};exports[_0xd4cd('0x6f')]=function(_0x4f2fde,_0x2f85aa,_0x343275){if(_0x4f2fde['file']&&_0x4f2fde['file'][_0xd4cd('0x51')]){_0x4f2fde['body'][_0xd4cd('0x6d')]=_0x4f2fde[_0xd4cd('0x50')][_0xd4cd('0x51')];}return db[_0xd4cd('0x34')][_0xd4cd('0x4e')]({'where':{'id':_0x4f2fde[_0xd4cd('0x4f')]['id']}})[_0xd4cd('0x2d')](handleEntityNotFound(_0x2f85aa,null))[_0xd4cd('0x2d')](saveUpdates(_0x4f2fde[_0xd4cd('0x4d')],null))[_0xd4cd('0x2d')](respondWithResult(_0x2f85aa,null))[_0xd4cd('0x52')](handleError(_0x2f85aa,null));};var utilLicense=require(_0xd4cd('0x14'));exports[_0xd4cd('0x70')]=function(_0x5bf7cb,_0x399ec5,_0x498f1d){var _0x7105c3=_0xd4cd('0x66');var _0x34462b={'custom':![]};return utilLicense[_0xd4cd('0x54')]()[_0xd4cd('0x2d')](function(_0x3144ff){if(_0x3144ff){_0x34462b=_0x3144ff;}return db[_0xd4cd('0x34')][_0xd4cd('0x4e')]({'where':{'id':_0x5bf7cb[_0xd4cd('0x4f')]['id']},'attributes':['logo',_0xd4cd('0x56'),_0xd4cd('0x57'),_0xd4cd('0x6d'),'defaultLogo',_0xd4cd('0x59'),_0xd4cd('0x5a'),'defaultFavicon'],'raw':!![]});})['then'](handleEntityNotFound(_0x399ec5,null))[_0xd4cd('0x2d')](function(_0x135ca3){if(_0x135ca3){var _0x16f55e=_0x135ca3['favicon']&&fs[_0xd4cd('0x5c')](path['join'](config['root'],_0x7105c3,_[_0xd4cd('0x5f')](_0x135ca3[_0xd4cd('0x6d')])))?path[_0xd4cd('0x5d')](config[_0xd4cd('0x5e')],_0x7105c3,_[_0xd4cd('0x5f')](_0x135ca3[_0xd4cd('0x6d')])):path['join'](config['root'],_0x7105c3,_[_0xd4cd('0x5f')](_0xd4cd('0x71')));var _0x53cda5=_0xd4cd('0x67')+_[_0xd4cd('0x60')](_0xd4cd('0x6d'));if(_0x135ca3[_0x53cda5]||!_0x34462b[_0xd4cd('0x61')]){_0x16f55e=path[_0xd4cd('0x5d')](config['root'],_0x7105c3,_[_0xd4cd('0x5f')](_0xd4cd('0x71')));}if(!fs['existsSync'](_0x16f55e)){throw new db[(_0xd4cd('0x62'))]['ValidationError'](_['upperFirst']('favicon')+'\x20not\x20found');}return _0x399ec5[_0xd4cd('0x64')](_0x16f55e);}})['catch'](handleError(_0x399ec5,null));};exports[_0xd4cd('0x72')]=function(_0x128d89,_0x152a01){var _0x6b10fe={'offset':moment()[_0xd4cd('0x73')]()};_0x6b10fe[_0xd4cd('0x74')]=moment()['utcOffset'](_0x6b10fe[_0xd4cd('0x24')])[_0xd4cd('0x75')](_0xd4cd('0x76'));return _0x152a01['status'](0xc8)[_0xd4cd('0x31')](_0x6b10fe);};