Built motion from commit (unavailable).|2.5.31
[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 _0xfc9f=['defaultPreferred','defaultFavicon','existsSync','join','root','toLower','default_logo.svg','default','upperFirst','custom','Sequelize','ValidationError','\x20not\x20found','download','defaultLogo','default_loginLogo.svg','gdpr','securePassword','getPreferred','preferred','default_preferred.png','addFavicon','getFavicon','default_favicon.ico','getDate','utcOffset','format','YYYY-MM-DD\x20HH:mm:ss:SSS','send','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','to-csv','ejs','fs-extra','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','request','then','info','Setting,\x20%s,\x20%s','debug','Setting,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','status','json','offset','limit','count','set','Content-Range','apply','reject','save','destroy','end','sendStatus','stack','name','render','merge','body','contact','agent','interaction','Setting','rawAttributes','fieldName','type','key','map','query','keys','filters','intersection','model','attributes','fields','length','order','sort','pick','filter','where','VIRTUAL','options','include','findAll','rows','show','params','find','update','addLogo','file','filename','logo','addLogoLogin','loginLogo','getLogo','server/files/images/logos','getLicense','favicon','defaultLoginLogo'];(function(_0x501510,_0x61caa9){var _0x1e6ee5=function(_0x32845b){while(--_0x32845b){_0x501510['push'](_0x501510['shift']());}};_0x1e6ee5(++_0x61caa9);}(_0xfc9f,0x11d));var _0xffc9=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xfc9f[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xffc9('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xffc9('0x1'));var jsonpatch=require(_0xffc9('0x2'));var rp=require(_0xffc9('0x3'));var moment=require(_0xffc9('0x4'));var BPromise=require(_0xffc9('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0xffc9('0x6'));var ejs=require(_0xffc9('0x7'));var fs=require('fs');var fs_extra=require(_0xffc9('0x8'));var _=require('lodash');var squel=require(_0xffc9('0x9'));var crypto=require(_0xffc9('0xa'));var jsforce=require(_0xffc9('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xffc9('0x6'));var querystring=require('querystring');var Papa=require(_0xffc9('0xc'));var Redis=require(_0xffc9('0xd'));var authService=require(_0xffc9('0xe'));var qs=require(_0xffc9('0xf'));var as=require(_0xffc9('0x10'));var hardwareService=require(_0xffc9('0x11'));var logger=require(_0xffc9('0x12'))(_0xffc9('0x13'));var utils=require(_0xffc9('0x14'));var config=require(_0xffc9('0x15'));var licenseUtil=require(_0xffc9('0x16'));var db=require(_0xffc9('0x17'))['db'];var jayson=require(_0xffc9('0x18'));var client=jayson[_0xffc9('0x19')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4c5789,_0x1ab080,_0x23cc59,_0x2dc1c7){return new BPromise(function(_0x625a2c,_0xc614b7){var _0x12412f=_0x2dc1c7||client;return _0x12412f[_0xffc9('0x1a')](_0x4c5789,_0x23cc59)[_0xffc9('0x1b')](function(_0x181750){logger[_0xffc9('0x1c')](_0xffc9('0x1d'),_0x1ab080,'request\x20sent');logger[_0xffc9('0x1e')](_0xffc9('0x1f'),_0x1ab080,_0xffc9('0x20'),JSON[_0xffc9('0x21')](_0x181750));if(_0x181750[_0xffc9('0x22')]){if(_0x181750[_0xffc9('0x22')][_0xffc9('0x23')]===0x1f4){logger[_0xffc9('0x22')](_0xffc9('0x1d'),_0x1ab080,_0x181750['error'][_0xffc9('0x24')]);return _0xc614b7(_0x181750[_0xffc9('0x22')]['message']);}logger[_0xffc9('0x22')](_0xffc9('0x1d'),_0x1ab080,_0x181750[_0xffc9('0x22')][_0xffc9('0x24')]);return _0x625a2c(_0x181750['error'][_0xffc9('0x24')]);}else{logger[_0xffc9('0x1c')](_0xffc9('0x1d'),_0x1ab080,_0xffc9('0x20'));_0x625a2c(_0x181750[_0xffc9('0x25')][_0xffc9('0x24')]);}})[_0xffc9('0x26')](function(_0x39f9e9){logger[_0xffc9('0x22')](_0xffc9('0x1d'),_0x1ab080,_0x39f9e9);_0xc614b7(_0x39f9e9);});});}function respondWithStatusCode(_0x2687bb,_0x53e36f){_0x53e36f=_0x53e36f||0xcc;return function(_0x28b3ef){if(_0x28b3ef){return _0x2687bb['sendStatus'](_0x53e36f);}return _0x2687bb[_0xffc9('0x27')](_0x53e36f)['end']();};}function respondWithResult(_0x5d8248,_0x4a8d90){_0x4a8d90=_0x4a8d90||0xc8;return function(_0x4488eb){if(_0x4488eb){return _0x5d8248[_0xffc9('0x27')](_0x4a8d90)[_0xffc9('0x28')](_0x4488eb);}};}function respondWithFilteredResult(_0xab17b5,_0x409cdc){return function(_0xdf6f3f){if(_0xdf6f3f){var _0x282f8f=typeof _0x409cdc[_0xffc9('0x29')]==='undefined'&&typeof _0x409cdc[_0xffc9('0x2a')]==='undefined';var _0x27a53a=_0xdf6f3f[_0xffc9('0x2b')];var _0x29c0d7=_0x282f8f?0x0:_0x409cdc[_0xffc9('0x29')];var _0x71a7a9=_0x282f8f?_0xdf6f3f['count']:_0x409cdc[_0xffc9('0x29')]+_0x409cdc['limit'];var _0xd7aea7;if(_0x71a7a9>=_0x27a53a){_0x71a7a9=_0x27a53a;_0xd7aea7=0xc8;}else{_0xd7aea7=0xce;}_0xab17b5['status'](_0xd7aea7);return _0xab17b5[_0xffc9('0x2c')](_0xffc9('0x2d'),_0x29c0d7+'-'+_0x71a7a9+'/'+_0x27a53a)[_0xffc9('0x28')](_0xdf6f3f);}return null;};}function patchUpdates(_0xfd1665){return function(_0x54c6de){try{jsonpatch[_0xffc9('0x2e')](_0x54c6de,_0xfd1665,!![]);}catch(_0x5c4630){return BPromise[_0xffc9('0x2f')](_0x5c4630);}return _0x54c6de[_0xffc9('0x30')]();};}function saveUpdates(_0x4fc9d7,_0x49f170){return function(_0x4b1361){if(_0x4b1361){return _0x4b1361['update'](_0x4fc9d7)[_0xffc9('0x1b')](function(_0x1a0818){return _0x1a0818;});}return null;};}function removeEntity(_0xba7dbf,_0x5bddfe){return function(_0x215900){if(_0x215900){return _0x215900[_0xffc9('0x31')]()[_0xffc9('0x1b')](function(){_0xba7dbf[_0xffc9('0x27')](0xcc)[_0xffc9('0x32')]();});}};}function handleEntityNotFound(_0x2fcb60,_0x449544){return function(_0x27afac){if(!_0x27afac){_0x2fcb60[_0xffc9('0x33')](0x194);}return _0x27afac;};}function handleError(_0x3844c1,_0x4c55a0){_0x4c55a0=_0x4c55a0||0x1f4;return function(_0x579c0c){logger[_0xffc9('0x22')](_0x579c0c[_0xffc9('0x34')]);if(_0x579c0c[_0xffc9('0x35')]){delete _0x579c0c[_0xffc9('0x35')];}_0x3844c1[_0xffc9('0x27')](_0x4c55a0)['send'](_0x579c0c);};}function getMustacheRender(_0xaadfde,_0x47f663){return Mustache[_0xffc9('0x36')](_0xaadfde,_[_0xffc9('0x37')](_0x47f663[_0xffc9('0x38')],{'contact':_0x47f663[_0xffc9('0x39')],'message':_0x47f663[_0xffc9('0x24')],'agent':_0x47f663[_0xffc9('0x3a')],'interaction':_0x47f663[_0xffc9('0x3b')],'account':_0x47f663['account']}))||'';}exports['index']=function(_0x5ed193,_0x32d909){var _0x1b0d06={},_0x292ecb={},_0x4fa9b7={'count':0x0,'rows':[]};var _0x533acb=_['map'](db[_0xffc9('0x3c')][_0xffc9('0x3d')],function(_0x5ac22b){return{'name':_0x5ac22b[_0xffc9('0x3e')],'type':_0x5ac22b[_0xffc9('0x3f')][_0xffc9('0x40')]};});_0x292ecb['model']=_[_0xffc9('0x41')](_0x533acb,_0xffc9('0x35'));_0x292ecb[_0xffc9('0x42')]=_[_0xffc9('0x43')](_0x5ed193[_0xffc9('0x42')]);_0x292ecb[_0xffc9('0x44')]=_[_0xffc9('0x45')](_0x292ecb[_0xffc9('0x46')],_0x292ecb[_0xffc9('0x42')]);_0x1b0d06[_0xffc9('0x47')]=_[_0xffc9('0x45')](_0x292ecb[_0xffc9('0x46')],qs[_0xffc9('0x48')](_0x5ed193[_0xffc9('0x42')][_0xffc9('0x48')]));_0x1b0d06['attributes']=_0x1b0d06[_0xffc9('0x47')][_0xffc9('0x49')]?_0x1b0d06['attributes']:_0x292ecb[_0xffc9('0x46')];if(!_0x5ed193[_0xffc9('0x42')]['hasOwnProperty']('nolimit')){_0x1b0d06['limit']=qs[_0xffc9('0x2a')](_0x5ed193[_0xffc9('0x42')][_0xffc9('0x2a')]);_0x1b0d06[_0xffc9('0x29')]=qs[_0xffc9('0x29')](_0x5ed193[_0xffc9('0x42')]['offset']);}_0x1b0d06[_0xffc9('0x4a')]=qs[_0xffc9('0x4b')](_0x5ed193[_0xffc9('0x42')][_0xffc9('0x4b')]);_0x1b0d06['where']=qs['filters'](_[_0xffc9('0x4c')](_0x5ed193[_0xffc9('0x42')],_0x292ecb[_0xffc9('0x44')]),_0x533acb);if(_0x5ed193[_0xffc9('0x42')][_0xffc9('0x4d')]){_0x1b0d06[_0xffc9('0x4e')]=_[_0xffc9('0x37')](_0x1b0d06[_0xffc9('0x4e')],{'$or':_[_0xffc9('0x41')](_0x533acb,function(_0x1f70d1){if(_0x1f70d1['type']!==_0xffc9('0x4f')){var _0x3f5b35={};_0x3f5b35[_0x1f70d1[_0xffc9('0x35')]]={'$like':'%'+_0x5ed193['query']['filter']+'%'};return _0x3f5b35;}})});}_0x1b0d06=_[_0xffc9('0x37')]({},_0x1b0d06,_0x5ed193[_0xffc9('0x50')]);var _0x50aff4={'where':_0x1b0d06['where']};return db['Setting'][_0xffc9('0x2b')](_0x50aff4)[_0xffc9('0x1b')](function(_0x39276b){_0x4fa9b7[_0xffc9('0x2b')]=_0x39276b;if(_0x5ed193[_0xffc9('0x42')]['includeAll']){_0x1b0d06[_0xffc9('0x51')]=[{'all':!![]}];}return db[_0xffc9('0x3c')][_0xffc9('0x52')](_0x1b0d06);})[_0xffc9('0x1b')](function(_0x22ab35){_0x4fa9b7[_0xffc9('0x53')]=_0x22ab35;return _0x4fa9b7;})[_0xffc9('0x1b')](respondWithFilteredResult(_0x32d909,_0x1b0d06))[_0xffc9('0x26')](handleError(_0x32d909,null));};exports[_0xffc9('0x54')]=function(_0x49d2e7,_0x2202f2){var _0x58d5c0={'raw':![],'where':{'id':_0x49d2e7[_0xffc9('0x55')]['id']}},_0x584b28={};_0x584b28[_0xffc9('0x46')]=_[_0xffc9('0x43')](db['Setting']['rawAttributes']);_0x584b28[_0xffc9('0x42')]=_[_0xffc9('0x43')](_0x49d2e7['query']);_0x584b28[_0xffc9('0x44')]=_[_0xffc9('0x45')](_0x584b28[_0xffc9('0x46')],_0x584b28['query']);_0x58d5c0[_0xffc9('0x47')]=_[_0xffc9('0x45')](_0x584b28[_0xffc9('0x46')],qs[_0xffc9('0x48')](_0x49d2e7[_0xffc9('0x42')]['fields']));_0x58d5c0['attributes']=_0x58d5c0[_0xffc9('0x47')][_0xffc9('0x49')]?_0x58d5c0['attributes']:_0x584b28['model'];if(_0x49d2e7[_0xffc9('0x42')]['includeAll']){_0x58d5c0[_0xffc9('0x51')]=[{'all':!![]}];}_0x58d5c0=_[_0xffc9('0x37')]({},_0x58d5c0,_0x49d2e7[_0xffc9('0x50')]);return db[_0xffc9('0x3c')][_0xffc9('0x56')](_0x58d5c0)['then'](handleEntityNotFound(_0x2202f2,null))[_0xffc9('0x1b')](respondWithResult(_0x2202f2,null))[_0xffc9('0x26')](handleError(_0x2202f2,null));};exports[_0xffc9('0x57')]=function(_0x56e690,_0x26da0f){if(_0x56e690[_0xffc9('0x38')]['id']){delete _0x56e690[_0xffc9('0x38')]['id'];}return db[_0xffc9('0x3c')][_0xffc9('0x56')]({'where':{'id':_0x56e690[_0xffc9('0x55')]['id']}})[_0xffc9('0x1b')](handleEntityNotFound(_0x26da0f,null))['then'](saveUpdates(_0x56e690[_0xffc9('0x38')],null))['then'](respondWithResult(_0x26da0f,null))[_0xffc9('0x26')](handleError(_0x26da0f,null));};exports[_0xffc9('0x58')]=function(_0x4fe7bc,_0x16971,_0x4c22e9){if(_0x4fe7bc[_0xffc9('0x59')]&&_0x4fe7bc[_0xffc9('0x59')][_0xffc9('0x5a')]){_0x4fe7bc[_0xffc9('0x38')][_0xffc9('0x5b')]=_0x4fe7bc['file'][_0xffc9('0x5a')];}return db['Setting'][_0xffc9('0x56')]({'where':{'id':_0x4fe7bc['params']['id']}})[_0xffc9('0x1b')](handleEntityNotFound(_0x16971,null))[_0xffc9('0x1b')](saveUpdates(_0x4fe7bc['body'],null))[_0xffc9('0x1b')](respondWithResult(_0x16971,null))[_0xffc9('0x26')](handleError(_0x16971,null));};exports[_0xffc9('0x5c')]=function(_0x54b9ab,_0x175126,_0x2ddd98){if(_0x54b9ab[_0xffc9('0x59')]&&_0x54b9ab[_0xffc9('0x59')][_0xffc9('0x5a')]){_0x54b9ab['body'][_0xffc9('0x5d')]=_0x54b9ab[_0xffc9('0x59')]['filename'];}return db[_0xffc9('0x3c')]['find']({'where':{'id':_0x54b9ab[_0xffc9('0x55')]['id']}})[_0xffc9('0x1b')](handleEntityNotFound(_0x175126,null))[_0xffc9('0x1b')](saveUpdates(_0x54b9ab[_0xffc9('0x38')],null))[_0xffc9('0x1b')](respondWithResult(_0x175126,null))[_0xffc9('0x26')](handleError(_0x175126,null));};var utilLicense=require('../../config/license/util');exports[_0xffc9('0x5e')]=function(_0x46b507,_0x55fcf6,_0x14ae18){var _0x5affd2=_0xffc9('0x5f');var _0x1aa335={'custom':![]};return utilLicense[_0xffc9('0x60')]()['then'](function(_0x414ae2){if(_0x414ae2){_0x1aa335=_0x414ae2;}return db['Setting'][_0xffc9('0x56')]({'where':{'id':_0x46b507[_0xffc9('0x55')]['id']},'attributes':['logo','loginLogo','preferred',_0xffc9('0x61'),'defaultLogo',_0xffc9('0x62'),_0xffc9('0x63'),_0xffc9('0x64')],'raw':!![]});})[_0xffc9('0x1b')](handleEntityNotFound(_0x55fcf6,null))[_0xffc9('0x1b')](function(_0x26f9d4){if(_0x26f9d4){var _0x25efc3=_0x26f9d4[_0xffc9('0x5b')]&&fs[_0xffc9('0x65')](path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x5affd2,_[_0xffc9('0x68')](_0x26f9d4[_0xffc9('0x5b')])))?path['join'](config[_0xffc9('0x67')],_0x5affd2,_[_0xffc9('0x68')](_0x26f9d4[_0xffc9('0x5b')])):path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x5affd2,_[_0xffc9('0x68')](_0xffc9('0x69')));var _0xf1f091=_0xffc9('0x6a')+_[_0xffc9('0x6b')](_0xffc9('0x5b'));if(_0x26f9d4[_0xf1f091]||!_0x1aa335[_0xffc9('0x6c')]){_0x25efc3=path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x5affd2,_['toLower']('default_logo.svg'));}if(!fs[_0xffc9('0x65')](_0x25efc3)){throw new db[(_0xffc9('0x6d'))][(_0xffc9('0x6e'))](_['upperFirst'](_0xffc9('0x5b'))+_0xffc9('0x6f'));}return _0x55fcf6[_0xffc9('0x70')](_0x25efc3);}})[_0xffc9('0x26')](handleError(_0x55fcf6,null));};var utilLicense=require(_0xffc9('0x16'));exports['getLogoLogin']=function(_0x3a1a83,_0x558a89,_0x3bb5aa){var _0x2e6e8d=_0xffc9('0x5f');var _0x29df76={'custom':![]};return utilLicense['getLicense']()[_0xffc9('0x1b')](function(_0x1ad802){if(_0x1ad802){_0x29df76=_0x1ad802;}return db[_0xffc9('0x3c')][_0xffc9('0x56')]({'where':{'id':_0x3a1a83['params']['id']},'attributes':['logo',_0xffc9('0x5d'),'preferred','favicon',_0xffc9('0x71'),_0xffc9('0x62'),_0xffc9('0x63'),_0xffc9('0x64')],'raw':!![]});})[_0xffc9('0x1b')](handleEntityNotFound(_0x558a89,null))[_0xffc9('0x1b')](function(_0x412c18){if(_0x412c18){var _0x1d4695=_0x412c18[_0xffc9('0x5d')]&&fs[_0xffc9('0x65')](path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x2e6e8d,_[_0xffc9('0x68')](_0x412c18[_0xffc9('0x5d')])))?path[_0xffc9('0x66')](config['root'],_0x2e6e8d,_['toLower'](_0x412c18[_0xffc9('0x5d')])):path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x2e6e8d,_[_0xffc9('0x68')](_0xffc9('0x72')));var _0x3c9d94=_0xffc9('0x6a')+_['upperFirst'](_0xffc9('0x5d'));if(_0x412c18[_0x3c9d94]||!_0x29df76[_0xffc9('0x6c')]){_0x1d4695=path['join'](config[_0xffc9('0x67')],_0x2e6e8d,_['toLower'](_0xffc9('0x72')));}if(!fs[_0xffc9('0x65')](_0x1d4695)){throw new db[(_0xffc9('0x6d'))][(_0xffc9('0x6e'))](_['upperFirst']('loginLogo')+_0xffc9('0x6f'));}return _0x558a89[_0xffc9('0x70')](_0x1d4695);}})[_0xffc9('0x26')](handleError(_0x558a89,null));};exports[_0xffc9('0x73')]=function(_0x4c0e48,_0x35b36e){return db['Setting'][_0xffc9('0x56')]({'where':{'id':_0x4c0e48[_0xffc9('0x55')]['id']},'attributes':[_0xffc9('0x74')]})[_0xffc9('0x1b')](respondWithResult(_0x35b36e,null))[_0xffc9('0x26')](handleError(_0x35b36e,null));};exports['addPreferred']=function(_0x1386bb,_0x360800,_0x22c488){if(_0x1386bb['file']&&_0x1386bb['file'][_0xffc9('0x5a')]){_0x1386bb[_0xffc9('0x38')]['preferred']=_0x1386bb[_0xffc9('0x59')][_0xffc9('0x5a')];}return db[_0xffc9('0x3c')][_0xffc9('0x56')]({'where':{'id':_0x1386bb['params']['id']}})[_0xffc9('0x1b')](handleEntityNotFound(_0x360800,null))['then'](saveUpdates(_0x1386bb[_0xffc9('0x38')],null))[_0xffc9('0x1b')](respondWithResult(_0x360800,null))[_0xffc9('0x26')](handleError(_0x360800,null));};var utilLicense=require(_0xffc9('0x16'));exports[_0xffc9('0x75')]=function(_0x169ea4,_0x1399ca,_0x17b754){var _0x2728fe='server/files/images/logos';var _0x4edd91={'custom':![]};return utilLicense[_0xffc9('0x60')]()['then'](function(_0x3e9d77){if(_0x3e9d77){_0x4edd91=_0x3e9d77;}return db[_0xffc9('0x3c')]['find']({'where':{'id':_0x169ea4[_0xffc9('0x55')]['id']},'attributes':[_0xffc9('0x5b'),'loginLogo',_0xffc9('0x76'),_0xffc9('0x61'),'defaultLogo',_0xffc9('0x62'),_0xffc9('0x63'),_0xffc9('0x64')],'raw':!![]});})[_0xffc9('0x1b')](handleEntityNotFound(_0x1399ca,null))[_0xffc9('0x1b')](function(_0x22c776){if(_0x22c776){var _0x245b50=_0x22c776[_0xffc9('0x76')]&&fs[_0xffc9('0x65')](path['join'](config[_0xffc9('0x67')],_0x2728fe,_[_0xffc9('0x68')](_0x22c776[_0xffc9('0x76')])))?path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x2728fe,_['toLower'](_0x22c776[_0xffc9('0x76')])):path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x2728fe,_[_0xffc9('0x68')]('default_preferred.png'));var _0x9976df=_0xffc9('0x6a')+_[_0xffc9('0x6b')](_0xffc9('0x76'));if(_0x22c776[_0x9976df]||!_0x4edd91['custom']||!_0x4edd91[_0xffc9('0x76')]){_0x245b50=path[_0xffc9('0x66')](config['root'],_0x2728fe,_[_0xffc9('0x68')](_0xffc9('0x77')));}if(!fs[_0xffc9('0x65')](_0x245b50)){throw new db[(_0xffc9('0x6d'))][(_0xffc9('0x6e'))](_[_0xffc9('0x6b')](_0xffc9('0x76'))+_0xffc9('0x6f'));}return _0x1399ca[_0xffc9('0x70')](_0x245b50);}})[_0xffc9('0x26')](handleError(_0x1399ca,null));};exports[_0xffc9('0x78')]=function(_0x446bd5,_0x4524f9,_0x25cb0d){if(_0x446bd5[_0xffc9('0x59')]&&_0x446bd5['file'][_0xffc9('0x5a')]){_0x446bd5[_0xffc9('0x38')]['favicon']=_0x446bd5[_0xffc9('0x59')]['filename'];}return db[_0xffc9('0x3c')][_0xffc9('0x56')]({'where':{'id':_0x446bd5[_0xffc9('0x55')]['id']}})['then'](handleEntityNotFound(_0x4524f9,null))[_0xffc9('0x1b')](saveUpdates(_0x446bd5[_0xffc9('0x38')],null))[_0xffc9('0x1b')](respondWithResult(_0x4524f9,null))[_0xffc9('0x26')](handleError(_0x4524f9,null));};var utilLicense=require('../../config/license/util');exports[_0xffc9('0x79')]=function(_0x3303ad,_0x59923b,_0x15832a){var _0x139219=_0xffc9('0x5f');var _0x624a58={'custom':![]};return utilLicense[_0xffc9('0x60')]()[_0xffc9('0x1b')](function(_0x220618){if(_0x220618){_0x624a58=_0x220618;}return db[_0xffc9('0x3c')][_0xffc9('0x56')]({'where':{'id':_0x3303ad[_0xffc9('0x55')]['id']},'attributes':[_0xffc9('0x5b'),_0xffc9('0x5d'),'preferred',_0xffc9('0x61'),'defaultLogo','defaultLoginLogo',_0xffc9('0x63'),_0xffc9('0x64')],'raw':!![]});})[_0xffc9('0x1b')](handleEntityNotFound(_0x59923b,null))[_0xffc9('0x1b')](function(_0x1e6d20){if(_0x1e6d20){var _0x3d1ccd=_0x1e6d20['favicon']&&fs[_0xffc9('0x65')](path['join'](config['root'],_0x139219,_['toLower'](_0x1e6d20[_0xffc9('0x61')])))?path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x139219,_['toLower'](_0x1e6d20[_0xffc9('0x61')])):path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x139219,_[_0xffc9('0x68')](_0xffc9('0x7a')));var _0x85278c='default'+_[_0xffc9('0x6b')](_0xffc9('0x61'));if(_0x1e6d20[_0x85278c]||!_0x624a58['custom']){_0x3d1ccd=path[_0xffc9('0x66')](config[_0xffc9('0x67')],_0x139219,_[_0xffc9('0x68')](_0xffc9('0x7a')));}if(!fs[_0xffc9('0x65')](_0x3d1ccd)){throw new db[(_0xffc9('0x6d'))]['ValidationError'](_[_0xffc9('0x6b')](_0xffc9('0x61'))+_0xffc9('0x6f'));}return _0x59923b[_0xffc9('0x70')](_0x3d1ccd);}})[_0xffc9('0x26')](handleError(_0x59923b,null));};exports[_0xffc9('0x7b')]=function(_0x2448ac,_0x2c1ff5){var _0x35d252={'offset':moment()[_0xffc9('0x7c')]()};_0x35d252['now']=moment()['utcOffset'](_0x35d252[_0xffc9('0x29')])[_0xffc9('0x7d')](_0xffc9('0x7e'));return _0x2c1ff5['status'](0xc8)[_0xffc9('0x7f')](_0x35d252);};