diff --git a/core/frontend/helpers/comments.js b/core/frontend/helpers/comments.js index 4c218a88eb..8ed9f5a6d7 100644 --- a/core/frontend/helpers/comments.js +++ b/core/frontend/helpers/comments.js @@ -1,5 +1,5 @@ const {SafeString} = require('../services/handlebars'); -const {config, urlUtils, getFrontendKey, labs} = require('../services/proxy'); +const {config, urlUtils, getFrontendKey, labs, settingsCache} = require('../services/proxy'); async function comments(options) { // todo: For now check on the comment id to exclude normal pages (we probably have a better way to do this) @@ -9,6 +9,18 @@ async function comments(options) { if (!commentId) { return; } + + /** + * We need to check if comments enabled, because the theme might not be using the other available helpers to check + * if comments is enabled + the member has access + * @type {'all'|'paid'|'off'} + */ + const commentsEnabled = settingsCache.get('comments_enabled'); + const hasAccess = !!this.access; + + if (commentsEnabled === 'off' || !hasAccess) { + return; + } let colorScheme = 'auto'; if (options.hash.color_scheme === 'dark' || options.hash.color_scheme === 'light') { @@ -37,7 +49,8 @@ async function comments(options) { 'color-scheme': colorScheme, 'avatar-saturation': avatarSaturation, 'accent-color': accentColor, - 'app-version': config.get('comments:version') + 'app-version': config.get('comments:version'), + 'comments-enabled': commentsEnabled }; let dataAttributes = '';