The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/lib/server/startup/settingsOnLoadCdnPrefix.js

35 lines
1.3 KiB

import { Meteor } from 'meteor/meteor';
import { WebAppInternals } from 'meteor/webapp';
import _ from 'underscore';
import { settings } from '../../../settings';
function testWebAppInternals(fn) {
typeof WebAppInternals !== 'undefined' && fn(WebAppInternals);
}
settings.onload('CDN_PREFIX', function(key, value) {
const useForAll = settings.get('CDN_PREFIX_ALL');
if (_.isString(value) && value.trim() && useForAll) {
return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(value));
}
});
settings.onload('CDN_JSCSS_PREFIX', function(key, value) {
const useForAll = settings.get('CDN_PREFIX_ALL');
if (_.isString(value) && value.trim() && !useForAll) {
return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(value));
}
});
Meteor.startup(function() {
const cdnValue = settings.get('CDN_PREFIX');
const useForAll = settings.get('CDN_PREFIX_ALL');
const cdnJsCss = settings.get('CDN_JSCSS_PREFIX');
if (_.isString(cdnValue) && cdnValue.trim()) {
if (useForAll) {
return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(cdnValue));
} if (_.isString(cdnJsCss) && cdnJsCss.trim()) {
return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(cdnJsCss));
}
}
});