mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Convert approve_new_topics_unless_trust_level to groups (#24504)
* DEV: Convert approve_new_topics_unless_trust_level to groups This change converts the `approve_new_topics_unless_trust_level` site setting to `approve_new_topics_unless_allowed_groups`. See: https://meta.discourse.org/t/283408 - Hides the old setting - Adds the new site setting - Add a deprecation warning - Updates to use the new setting - Adds a migration to fill in the new setting if the old setting was changed - Adds an entry to the site_setting.keywords section - Updates tests to account for the new change After a couple of months we will remove the `approve_new_topics_unless_trust_level` setting entirely. Internal ref: /t/115696 * add missing translation * Add keyword entry * Add migration
This commit is contained in:
@@ -97,10 +97,10 @@ class NewPostManager
|
||||
end
|
||||
|
||||
if (
|
||||
manager.args[:title].present? &&
|
||||
user.trust_level < SiteSetting.approve_new_topics_unless_trust_level.to_i
|
||||
manager.args[:title].present? && user.groups.any? &&
|
||||
!user.in_any_groups?(SiteSetting.approve_new_topics_unless_allowed_groups_map)
|
||||
)
|
||||
return :new_topics_unless_trust_level
|
||||
return :new_topics_unless_allowed_groups
|
||||
end
|
||||
|
||||
if WordWatcher.new("#{manager.args[:title]} #{manager.args[:raw]}").requires_approval?
|
||||
@@ -205,9 +205,13 @@ class NewPostManager
|
||||
SiteSetting.approve_post_count > 0 ||
|
||||
!(
|
||||
SiteSetting.approve_unless_allowed_groups_map.include?(Group::AUTO_GROUPS[:trust_level_0])
|
||||
) || SiteSetting.approve_new_topics_unless_trust_level.to_i > 0 ||
|
||||
SiteSetting.approve_unless_staged || WordWatcher.words_for_action_exist?(:require_approval) ||
|
||||
handlers.size > 1
|
||||
) ||
|
||||
!(
|
||||
SiteSetting.approve_new_topics_unless_allowed_groups_map.include?(
|
||||
Group::AUTO_GROUPS[:trust_level_0],
|
||||
)
|
||||
) || SiteSetting.approve_unless_staged ||
|
||||
WordWatcher.words_for_action_exist?(:require_approval) || handlers.size > 1
|
||||
end
|
||||
|
||||
def initialize(user, args)
|
||||
|
||||
@@ -12,6 +12,12 @@ module SiteSettings::DeprecatedSettings
|
||||
["shared_drafts_min_trust_level", "shared_drafts_allowed_groups", false, "3.3"],
|
||||
["min_trust_level_for_here_mention", "here_mention_allowed_groups", false, "3.3"],
|
||||
["approve_unless_trust_level", "approve_unless_allowed_groups", false, "3.3"],
|
||||
[
|
||||
"approve_new_topics_unless_trust_level",
|
||||
"approve_new_topics_unless_allowed_groups",
|
||||
false,
|
||||
"3.3",
|
||||
],
|
||||
]
|
||||
|
||||
def setup_deprecated_methods
|
||||
|
||||
Reference in New Issue
Block a user