FIX: Show Privacy Policy or ToS when they exist (#21771)

Privacy Policy and Terms of Service topics are no longer created by
default for communities that have not set a company name. For this
reason, some URLs were pointing to 404 page.
This commit is contained in:
Bianca Nenciu
2023-05-30 16:38:14 +02:00
committed by GitHub
parent 6491be9f2b
commit c3d51e9c0a
8 changed files with 66 additions and 33 deletions

View File

@ -6,14 +6,18 @@ module ConfigurableUrls
end
def tos_path
SiteSetting.tos_url.blank? ? "#{Discourse.base_path}/tos" : SiteSetting.tos_url
if SiteSetting.tos_url.present?
SiteSetting.tos_url
elsif SiteSetting.tos_topic_id > 0 && Topic.exists?(id: SiteSetting.tos_topic_id)
"#{Discourse.base_path}/tos"
end
end
def privacy_path
if SiteSetting.privacy_policy_url.blank?
"#{Discourse.base_path}/privacy"
else
if SiteSetting.privacy_policy_url.present?
SiteSetting.privacy_policy_url
elsif SiteSetting.privacy_topic_id > 0 && Topic.exists?(id: SiteSetting.privacy_topic_id)
"#{Discourse.base_path}/privacy"
end
end
end