FIX: Fix narrative bot settings in multisites (#12380)

after_initialize is not called for each multisite database, but just
for first (default) database.
This commit is contained in:
Bianca Nenciu 2021-03-17 17:41:31 +02:00 committed by GitHub
parent 16b5fa030b
commit 50f8782def
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -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'