From 50f8782def77735c9dc3e13b68b3c8af7ab6ac6b Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Wed, 17 Mar 2021 17:41:31 +0200 Subject: [PATCH] FIX: Fix narrative bot settings in multisites (#12380) after_initialize is not called for each multisite database, but just for first (default) database. --- plugins/discourse-narrative-bot/plugin.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/discourse-narrative-bot/plugin.rb b/plugins/discourse-narrative-bot/plugin.rb index 5def8979919..2a6136176ab 100644 --- a/plugins/discourse-narrative-bot/plugin.rb +++ b/plugins/discourse-narrative-bot/plugin.rb @@ -48,12 +48,16 @@ after_initialize do '../lib/discourse_narrative_bot/welcome_post_type_site_setting.rb' ].each { |path| load File.expand_path(path, __FILE__) } - # Disable welcome message because that is what the bot is supposed to replace. - SiteSetting.send_welcome_message = false if SiteSetting.send_welcome_message + RailsMultisite::ConnectionManagement.each_connection do + if SiteSetting.discourse_narrative_bot_enabled + # Disable welcome message because that is what the bot is supposed to replace. + SiteSetting.send_welcome_message = false - certificate_path = "#{Discourse.base_url}/discobot/certificate.svg" - if SiteSetting.discourse_narrative_bot_enabled && !SiteSetting.allowed_iframes.include?(certificate_path) - SiteSetting.allowed_iframes = SiteSetting.allowed_iframes.split('|').append("#{Discourse.base_url}/discobot/certificate.svg").join('|') + certificate_path = "#{Discourse.base_url}/discobot/certificate.svg" + if !SiteSetting.allowed_iframes.include?(certificate_path) + SiteSetting.allowed_iframes = SiteSetting.allowed_iframes.split('|').append(certificate_path).join('|') + end + end end require_dependency 'plugin_store'