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/packages/rocketchat-lib/server/startup/settingsOnLoadCdnPrefix.js

32 lines
1.3 KiB

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