Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove deprecated trust level access settings (#36414)

Ted Johanssond69cc299797b
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 8a114a77339..4ff1e01e2b3 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -2177,40 +2177,27 @@ en:
tl3_requires_likes_given: "The minimum number of likes that must be given in the last (tl3 time period) days to qualify for promotion to trust level 3."
tl3_requires_likes_received: "The minimum number of likes that must be received in the last (tl3 time period) days to qualify for promotion to trust level 3."
tl3_links_no_follow: "Do not remove rel=nofollow from links posted by trust level 3 users."
- tl4_delete_posts_and_topics: "Allow TL4 users to delete posts and topics created by other users. TL4 users will also be able to see deleted topics and posts."
delete_all_posts_and_topics_allowed_groups: "Groups allowed to delete posts and topics created by other users. These groups will also be able to see deleted topics and posts."
edit_all_topic_groups: "Allow users in this group to edit other users' topic titles, tags, and categories"
edit_all_post_groups: "Allow users in this group to edit other users' posts"
- min_trust_to_create_topic: "The minimum trust level required to create a new topic."
create_topic_allowed_groups: "Groups that are allowed to create new topics. Admins and moderators can always create topics."
allow_flagging_staff: "If enabled, users can flag posts from staff accounts."
- min_trust_to_edit_wiki_post: "The minimum trust level required to edit post marked as wiki."
edit_wiki_post_allowed_groups: "Groups that are allowed to edit posts marked as wiki. Admins and moderators can always edit posts marked as wiki."
- min_trust_to_edit_post: "The minimum trust level required to edit posts."
edit_post_allowed_groups: "Groups that are allowed to edit posts. Admins and moderators can always edit posts."
- min_trust_to_allow_self_wiki: "The minimum trust level required to make user's own post wiki."
self_wiki_allowed_groups: "Allow users in these groups to make their own posts wiki. Admins and moderators can always make their own posts wiki."
min_trust_to_send_messages: "DEPRECATED, use the 'personal message enabled groups' setting instead. The minimum trust level required to create new personal messages."
- min_trust_to_send_email_messages: "The minimum trust level required to send personal messages via email."
send_email_messages_allowed_groups: "Groups that are allowed to send personal messages via email. Admins and moderators can always send personal messages via email."
- min_trust_to_flag_posts: "The minimum trust level required to flag posts"
flag_post_allowed_groups: "Groups that are allowed to flag posts. Admins and moderators can always flag posts."
- min_trust_to_post_links: "The minimum trust level required to include links in posts"
post_links_allowed_groups: "Groups that are allowed to include links in posts. Admins and moderators are always allowed to post links."
- min_trust_to_post_embedded_media: "The minimum trust level required to embed media items in a post"
embedded_media_post_allowed_groups: "The users in these groups are allowed to embed media items in a post. Admins and moderators can always embed media items."
- min_trust_level_to_allow_profile_background: "The minimum trust level required to upload a profile background"
profile_background_allowed_groups: "Groups that are allowed to upload a profile background. Admins and moderators can always upload a profile background."
- min_trust_level_to_allow_user_card_background: "The minimum trust level required to upload a user card background"
user_card_background_allowed_groups: "Groups that are allowed to upload a user card background. Admins and moderators can always upload a user card background."
- min_trust_level_to_allow_invite: "The minimum trust level required to invite users"
invite_allowed_groups: "Groups that are allowed to invite users. Admins and moderators can always invite users."
- min_trust_level_to_allow_ignore: "The minimum trust level required to ignore users"
ignore_allowed_groups: "Groups that are allowed to ignore other users. Admins and moderators can always ignore other users."
allowed_link_domains: "Domains that users may link to even if they don't have the appropriate trust level to post links"
@@ -2224,7 +2211,6 @@ en:
enable_mentions: "Permits users to tag or reference each other in their posts using the '@' symbol."
here_mention: "Name used for a @mention to allow privileged users to notify up to 'max_here_mentioned' people participating in the topic. Must not be an existing username."
max_here_mentioned: "Maximum number of mentioned people by @here."
- min_trust_level_for_here_mention: "The minimum trust level allowed to mention @here."
here_mention_allowed_groups: "Groups that are allowed to mention @here. Admins and moderators can always mention @here."
create_thumbnails: "Create thumbnails and lightbox images that are too large to fit in a post."
@@ -2379,7 +2365,6 @@ en:
pop3_polling_delete_from_server: "Delete emails from server. NOTE: If you disable this you should manually clean your mail inbox"
log_mail_processing_failures: "Log all email processing failures to <a href='%{base_path}/logs' target='_blank'>/logs</a>"
email_in: "Allow users to post new topics via email. After enabling this setting, you will be able to configure incoming email addresses for groups and categories."
- email_in_min_trust: "The minimum trust level a user needs to have to be allowed to post new topics via email."
email_in_allowed_groups: "Groups that are allowed to post new topics via email. Admins and moderators can always post new topics via email."
email_in_authserv_id: "The identifier of the service doing authentication checks on incoming emails. See <a href='https://meta.discourse.org/t/134358'>https://meta.discourse.org/t/134358</a> for instructions on how to configure this."
@@ -2410,7 +2395,6 @@ en:
email_editable: "Allow users to change their e-mail address after registration."
logout_redirect: "Location to redirect browser to after logout (eg: https://example.com/logout)"
- allow_uploaded_avatars: "Allow users to upload custom profile pictures."
uploaded_avatars_allowed_groups: "Specify groups allowed to upload custom profile pictures."
default_avatars: "URLs to avatars that will be used by default for new users until they change them."
automatically_download_gravatars: "Download Gravatars for users upon account creation or email change."
@@ -2437,7 +2421,6 @@ en:
group_in_subject: "Set %%{optional_pm} in email subject to name of first group in PM, see: <a href='https://meta.discourse.org/t/customize-specific-email-templates/88323' target='_blank'>Customize subject format for standard emails</a>"
allow_anonymous_mode: "Enable the option for users to switch to anonymous mode for posting. When activated, users can opt for their identities to be hidden when creating posts or topics throughout the site. See also `allow anonymous likes`."
allow_likes_in_anonymous_mode: "Enable this setting to allow users who are browsing your site anonymously to like posts. When activated, users can opt for their identities to be hidden when liking posts or topics throughout the site. This setting requires the `allow anonymous mode` setting to be enabled."
- anonymous_posting_min_trust_level: "Minimum trust level required to enable anonymous posting. This setting requires the `allow anonymous mode` setting to be enabled."
anonymous_posting_allowed_groups: "Groups that are allowed to enable anonymous posting. This setting requires the `allow anonymous mode` setting to be enabled."
anonymous_account_duration_minutes: "To protect anonymity create a new anonymous account every N minutes for each user. Example: if set to 600, as soon as 600 minutes elapse from last post AND user switches to anon, a new anonymous account is created."
@@ -2569,9 +2552,7 @@ en:
emoji_deny_list: "These emoji will not be available to use in menus or shortcodes."
approve_post_count: "The amount of posts from a new or basic user that must be approved"
- approve_unless_trust_level: "Posts created by users below this trust level must be approved"
approve_unless_allowed_groups: "Posts created by users not in these groups must be approved. Posts created by admins and moderators are always approved."
- approve_new_topics_unless_trust_level: "New topics created by users below this trust level must be approved"
approve_new_topics_unless_allowed_groups: "New topics created by users not in these groups must be approved. Topics created by admins and moderators are always approved."
approve_unless_staged: "New topics and posts created by staged users must be approved"
notify_about_queued_posts_after: "If there are posts that have been waiting to be reviewed for more than this many hours, send a notification to all moderators. Set to 0 to disable these notifications."
@@ -2591,7 +2572,6 @@ en:
new_user_notice_tl: "Minimum trust level required to see new user post notices."
returning_user_notice_tl: "Minimum trust level required to see returning user post notices."
returning_users_days: "How many days should pass before a user is considered to be returning."
- review_media_unless_trust_level: "Staff will review posts of users with lower trust levels if they contain embedded media."
skip_review_media_groups: "Users who are not in any of these groups will have their posts sent to staff for review if the post contains embedded media. Posts created by admins and moderators are always allowed."
blur_tl0_flagged_posts_media: "Blur flagged posts images to hide potentially NSFW content."
enable_page_publishing: "Allow staff members to publish topics to new URLs with their own styling."
@@ -2656,9 +2636,6 @@ en:
revoke_api_keys_maxlife_days: "Number of days before an API key is automatically revoked (0 for never)"
allow_user_api_key_scopes: "List of scopes allowed for user API keys"
- min_trust_level_for_user_api_key: |
- Trust level required for generation of user API keys.<br>
- <b>WARNING</b>: Changing the trust level will prevent users with a lower trust level from logging in via Discourse Hub
user_api_key_allowed_groups: |
Group membership required for generation of user API keys.<br>
<b>WARNING</b>: Changing the trust level will prevent users with a lower trust level from logging in via Discourse Hub.<br>
@@ -2669,7 +2646,6 @@ en:
revoke_user_api_keys_maxlife_days: "Number of days before a user API key is automatically revoked (0 for never)"
tagging_enabled: "Enable tags on topics? See the <a href='https://meta.discourse.org/t/admin-guide-to-tags-in-discourse/121041'>Admin guide to tags on Meta</a> for more information."
- min_trust_to_create_tag: "The minimum trust level required to create a tag."
create_tag_allowed_groups: "Groups that are allowed to create tags. Admins and moderators can always create tags."
edit_tags_allowed_groups: "Groups that are allowed to edit tags, tag descriptions, and tag synonyms."
max_tags_per_topic: "The maximum tags that can be applied to a topic."
@@ -2682,7 +2658,6 @@ en:
tags_listed_by_group: "List tags by tag group on the <a href='%{base_path}/tags' target='_blank'>Tags page</a>."
tag_style: "Define the visual appearance of tag badges on the site. This setting allows you to customize how tags are visually represented across all areas of the site, enhancing layout consistency and user accessibility."
pm_tags_allowed_for_groups: "Allow members of included groups to tag any personal message"
- min_trust_level_to_tag_topics: "Minimum trust level required to tag topics"
tag_topic_allowed_groups: "Groups that are allowed to tag topics. Admins and moderators can always tag topics."
suppress_overlapping_tags_in_list: "If tags match exact words in topic titles, don't show the tag"
remove_muted_tags_from_latest: "Don't show topics tagged only with muted tags in the latest topic list."
@@ -2696,7 +2671,6 @@ en:
city_for_disputes: "Specify the city that will be used as the jurisdiction for resolving any disputes related to the use of this forum. This information is typically included in legal documents such as the forum's Terms of Service."
shared_drafts_category: "Enable the Shared Drafts feature by designating a category for topic drafts. Topics in this category will be suppressed from topic lists for staff users."
- shared_drafts_min_trust_level: "Allow users to see and edit Shared Drafts."
shared_drafts_allowed_groups: "Allow users in these groups to see and edit Shared Drafts."
push_notifications_prompt: "Show a user consent banner for push notifications. This setting triggers a prompt asking users for permission to send them push notifications. It only appears when push notifications are not already enabled, are supported by the user's device, and the user has either made a post or is using a Progressive Web App (PWA). The prompt will not be shown again if the user has already dismissed it or granted/denied permission."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 0ce64852ca4..b016498e8ec 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -1034,11 +1034,6 @@ users:
allow_likes_in_anonymous_mode:
default: false
client: true
- anonymous_posting_min_trust_level:
- default: 1
- enum: "TrustLevelSetting"
- client: true
- hidden: true
anonymous_posting_allowed_groups:
default: "1|2|11" # auto group admins, moderators and trust_level_1
type: group_list
@@ -1327,10 +1322,6 @@ posting:
type: category
default: ""
area: "posts_and_topics"
- shared_drafts_min_trust_level:
- default: "staff"
- enum: "TrustLevelAndStaffSetting"
- hidden: true
shared_drafts_allowed_groups:
default: "1|2" # auto group admins and moderators
type: group_list
@@ -1434,10 +1425,6 @@ posting:
max_here_mentioned:
default: 10
area: "posts_and_topics"
- min_trust_level_for_here_mention:
- default: "2"
- enum: "TrustLevelAndStaffSetting"
- hidden: true
here_mention_allowed_groups:
default: "1|2|12" # auto group admins, moderators, trust_level_2
mandatory_values: "1|2" # auto group admins, moderators
@@ -1569,10 +1556,6 @@ posting:
approve_post_count:
default: 0
area: "posts_and_topics"
- approve_unless_trust_level:
- default: 0
- enum: "TrustLevelSetting"
- hidden: true
approve_unless_allowed_groups:
default: "1|2|10" # auto groups admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -1580,10 +1563,6 @@ posting:
allow_any: false
refresh: true
area: "group_permissions"
- approve_new_topics_unless_trust_level:
- default: 0
- enum: "TrustLevelSetting"
- hidden: true
approve_new_topics_unless_allowed_groups:
default: "1|2|10" # auto groups admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -1678,10 +1657,6 @@ posting:
default: 120
max: 36500
area: "posts_and_topics"
- review_media_unless_trust_level:
- default: 0
- enum: "TrustLevelSetting"
- hidden: true
skip_review_media_groups:
default: "1|2|10" # auto groups admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -1892,10 +1867,6 @@ email:
default: false
client: true
area: "email"
- email_in_min_trust:
- default: 2
- enum: "TrustLevelSetting"
- hidden: true
email_in_allowed_groups:
default: "1|2|12" # auto group admins, moderators, trust_level_2
mandatory_values: "1|2" # auto group admins, moderators
@@ -2283,11 +2254,6 @@ files:
client: true
default: true
automatically_download_gravatars: true
- allow_uploaded_avatars:
- client: true
- default: "0"
- enum: "TrustLevelAndStaffAndDisabledSetting"
- hidden: true
uploaded_avatars_allowed_groups:
default: "10"
type: group_list
@@ -2445,10 +2411,6 @@ trust:
default: 1
enum: "TrustLevelSetting"
area: "trust_levels"
- min_trust_to_create_topic:
- default: 0
- enum: "TrustLevelSetting"
- hidden: true
create_topic_allowed_groups:
default: "1|2|10" # auto group admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -2456,10 +2418,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_to_edit_wiki_post:
- default: 1
- enum: "TrustLevelSetting"
- hidden: true
edit_wiki_post_allowed_groups:
default: "1|2|11" # auto group admins, moderators, trust_level_1
mandatory_values: "1|2" # auto group admins, moderators
@@ -2467,10 +2425,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_to_edit_post:
- default: 0
- enum: "TrustLevelSetting"
- hidden: true
edit_post_allowed_groups:
default: "1|2|10" # auto group admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -2478,10 +2432,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_to_allow_self_wiki:
- default: 3
- enum: "TrustLevelSetting"
- hidden: true
self_wiki_allowed_groups:
default: "1|2|13" # auto group admins, moderators, trust_level_3
mandatory_values: "1|2" # auto group admins, moderators
@@ -2489,10 +2439,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_to_send_email_messages:
- default: "4"
- enum: "TrustLevelAndStaffSetting"
- hidden: true
send_email_messages_allowed_groups:
default: "1|2|14" # auto group admins, moderators, trust_level_4
mandatory_values: "1|2" # auto group admins, moderators
@@ -2500,10 +2446,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_to_flag_posts:
- default: 1
- enum: "TrustLevelSetting"
- hidden: true
flag_post_allowed_groups:
default: "1|2|11" # auto group admins, moderators, trust_level_1
mandatory_values: "1|2" # auto group admins, moderators
@@ -2519,10 +2461,6 @@ trust:
default: ""
area: "flags"
client: true
- min_trust_to_post_links:
- default: 0
- enum: "TrustLevelSetting"
- hidden: true
post_links_allowed_groups:
default: "1|2|10" # auto group admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -2530,10 +2468,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_to_post_embedded_media:
- default: 0
- enum: "TrustLevelSetting"
- hidden: true
embedded_media_post_allowed_groups:
default: "1|2|10" # auto group admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -2541,11 +2475,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_level_to_allow_profile_background:
- default: 0
- client: true
- enum: "TrustLevelSetting"
- hidden: true
profile_background_allowed_groups:
default: "1|2|10" # auto group admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -2553,11 +2482,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_level_to_allow_user_card_background:
- default: 0
- client: true
- enum: "TrustLevelSetting"
- hidden: true
user_card_background_allowed_groups:
default: "1|2|10" # auto group admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -2565,10 +2489,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_level_to_allow_invite:
- default: 2
- enum: "TrustLevelSetting"
- hidden: true
invite_allowed_groups:
default: "1|2|12" # auto group admins, moderators, trust_level_2
mandatory_values: "1|2" # auto group admins, moderators
@@ -2576,11 +2496,6 @@ trust:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_level_to_allow_ignore:
- default: 2
- enum: "TrustLevelSetting"
- client: true
- hidden: true
ignore_allowed_groups:
default: "1|2|12" # auto group admins, moderators, trust_level_2
mandatory_values: "1|2" # auto group admins, moderators
@@ -2673,11 +2588,6 @@ trust:
default: false
client: true
area: "trust_levels"
- tl4_delete_posts_and_topics:
- default: false
- client: true
- hidden: true
- area: "trust_levels"
delete_all_posts_and_topics_allowed_groups:
default: "1|2" # auto group admins, moderators
mandatory_values: "1|2" # auto group admins, moderators
@@ -4042,10 +3952,6 @@ user_api:
push_api_secret_key:
default: ""
hidden: true
- min_trust_level_for_user_api_key:
- default: 0
- enum: "TrustLevelSetting"
- hidden: true
user_api_key_allowed_groups:
default: "1|2|10" # auto group admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
@@ -4109,11 +4015,6 @@ tags:
default: 20
client: true
area: "categories_and_tags"
- min_trust_to_create_tag:
- default: "3"
- type: enum
- enum: "TrustLevelAndStaffSetting"
- hidden: true
create_tag_allowed_groups:
default: "1|2|13" # auto group admins, moderators, trust_level_3
mandatory_values: "1|2" # auto group admins, moderators
@@ -4128,11 +4029,6 @@ tags:
allow_any: false
refresh: true
area: "group_permissions"
- min_trust_level_to_tag_topics:
- default: "0"
- enum: "TrustLevelAndStaffSetting"
- client: true
- hidden: true
tag_topic_allowed_groups:
default: "1|2|10" # auto group admins, moderators, trust_level_0
mandatory_values: "1|2" # auto group admins, moderators
diff --git a/lib/generators/site_setting_move_to_groups_migration/USAGE b/lib/generators/site_setting_move_to_groups_migration/USAGE
deleted file mode 100644
index d8b1900bbf2..00000000000
--- a/lib/generators/site_setting_move_to_groups_migration/USAGE
+++ /dev/null
@@ -1,8 +0,0 @@
-Description:
- Generates migration to move data from trust level based site setting to group based site setting. It only works when moving from TrustLevelSetting or TrustLevelAndStaffSetting.
-
-Example:
- bin/rails generate site_setting_move_to_groups_migration min_trust_to_create_topic create_topic_allowed_groups
-
- This will create:
- db/migrate/20231206041353_fill_create_topic_allowed_groups_based_on_deprecated_settings.rb
diff --git a/lib/generators/site_setting_move_to_groups_migration/site_setting_move_to_groups_migration_generator.rb b/lib/generators/site_setting_move_to_groups_migration/site_setting_move_to_groups_migration_generator.rb
deleted file mode 100644
index 0391cb23ff7..00000000000
--- a/lib/generators/site_setting_move_to_groups_migration/site_setting_move_to_groups_migration_generator.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-# frozen_string_literal: true
-
-class SiteSettingMoveToGroupsMigrationGenerator < Rails::Generators::Base
- include SiteSettingExtension
-
- argument :old_name, type: :string, banner: "old setting name", required: true
- argument :new_name, type: :string, banner: "new setting name", required: true
-
- def create_migration_file
- migration_version = ActiveRecord::Migration.next_migration_number(0)
- file_path = "db/migrate/#{migration_version}_fill_#{new_name}_based_on_deprecated_setting.rb"
- class_name = "Fill#{new_name.classify}BasedOnDeprecatedSetting"
-
- load_all_settings
- validate_setting_name!(old_name)
- validate_setting_name!(new_name)
- validate_setting_type!(old_name)
-
- create_file file_path, <<~MIGRATION_FILE if setting_type(old_name) == "TrustLevelSetting"
- # frozen_string_literal: true
-
- class #{class_name} < ActiveRecord::Migration[7.0]
- def up
- old_setting_trust_level =
- DB.query_single(
- "SELECT value FROM site_settings WHERE name = '#{old_name}' LIMIT 1",
- ).first
-
- if old_setting_trust_level.present?
- allowed_groups = "1\#\{old_setting_trust_level\}"
-
- DB.exec(
- "INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
- VALUES('#{new_name}', :setting, '20', NOW(), NOW())",
- setting: allowed_groups,
- )
- end
- end
-
- def down
- raise ActiveRecord::IrreversibleMigration
- end
- end
- MIGRATION_FILE
- if setting_type(old_name) == "TrustLevelAndStaffSetting"
- create_file file_path, <<~MIGRATION_FILE
- # frozen_string_literal: true
-
- class #{class_name} < ActiveRecord::Migration[7.0]
- def up
- old_setting_trust_level =
- DB.query_single(
- "SELECT value FROM site_settings WHERE name = '#{old_name}' LIMIT 1",
- ).first
-
- if old_setting_trust_level.present?
- allowed_groups =
- case old_setting_trust_level
- when "admin"
- "1"
- when "staff"
- "3"
- when "0"
- "10"
- when "1"
- "11"
- when "2"
- "12"
- when "3"
- "13"
- when "4"
- "14"
- end
-
- DB.exec(
- "INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
- VALUES('#{new_name}', :setting, '20', NOW(), NOW())",
- setting: allowed_groups,
- )
- end
- end
-
- def down
- raise ActiveRecord::IrreversibleMigration
- end
- end
- MIGRATION_FILE
- end
- end
-
- private
-
- def load_all_settings
- load_settings(File.join(Rails.root, "config", "site_settings.yml"))
-
- if GlobalSetting.load_plugins?
- Dir[File.join(Rails.root, "plugins", "*", "config", "settings.yml")].each do |file|
- load_settings(file, plugin: file.split("/")[-3])
- end
- end
-
- if Rails.env.test?
- load_settings(
- File.join(Rails.root, "spec", "fixtures", "site_settings", "generator_test.yml"),
- )
- end
- end
-
- def validate_setting_name!(name)
- if !self.respond_to?(name)
- say "Site setting with #{name} does not exist"
- raise ArgumentError
- end
- end
-
- def setting_type(name)
- if type_supervisor.get_type(name.to_sym) == :enum
- return type_supervisor.get_enum_class(name.to_sym).to_s
- end
-
- nil
- end
-
- def validate_setting_type!(name)
- if !%w[TrustLevelSetting TrustLevelAndStaffSetting].include?(setting_type(name))
- say "Site setting with #{name} must be TrustLevelSetting"
- raise ArgumentError
- end
- end
-end
diff --git a/lib/site_settings/deprecated_settings.rb b/lib/site_settings/deprecated_settings.rb
index cedcc5bcdbf..ab0fe7c8487 100644
--- a/lib/site_settings/deprecated_settings.rb
+++ b/lib/site_settings/deprecated_settings.rb
@@ -6,132 +6,11 @@ end
module SiteSettings::DeprecatedSettings
SETTINGS = [
# [<old setting>, <new_setting>, <override>, <version to drop>]
- ["anonymous_posting_min_trust_level", "anonymous_posting_allowed_groups", false, "3.3"],
- ["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",
- ],
- ["email_in_min_trust", "email_in_allowed_groups", false, "3.3"],
- ["min_trust_to_edit_wiki_post", "edit_wiki_post_allowed_groups", false, "3.3"],
- ["allow_uploaded_avatars", "uploaded_avatars_allowed_groups", false, "3.3"],
- ["min_trust_to_create_topic", "create_topic_allowed_groups", false, "3.3"],
- ["min_trust_to_edit_post", "edit_post_allowed_groups", false, "3.3"],
- ["min_trust_to_flag_posts", "flag_post_allowed_groups", false, "3.3"],
- ["tl4_delete_posts_and_topics", "delete_all_posts_and_topics_allowed_groups", false, "3.3"],
- [
- "min_trust_level_to_allow_user_card_background",
- "user_card_background_allowed_groups",
- false,
- "3.3",
- ],
- ["min_trust_level_to_allow_invite", "invite_allowed_groups", false, "3.3"],
- ["min_trust_level_to_allow_ignore", "ignore_allowed_groups", false, "3.3"],
- ["min_trust_to_allow_self_wiki", "self_wiki_allowed_groups", false, "3.3"],
- ["min_trust_to_create_tag", "create_tag_allowed_groups", false, "3.3"],
- ["min_trust_to_send_email_messages", "send_email_messages_allowed_groups", false, "3.3"],
- ["review_media_unless_trust_level", "skip_review_media_groups", false, "3.3"],
- ["min_trust_to_post_embedded_media", "embedded_media_post_allowed_groups", false, "3.3"],
- ["min_trust_to_post_links", "post_links_allowed_groups", false, "3.3"],
- ["min_trust_level_for_user_api_key", "user_api_key_allowed_groups", false, "3.3"],
- ["min_trust_level_to_tag_topics", "tag_topic_allowed_groups", false, "3.3"],
- [
- "min_trust_level_to_allow_profile_background",
- "profile_background_allowed_groups",
- false,
- "3.3",
- ],
["min_first_post_typing_time", "fast_typing_threshold", false, "3.4"],
["twitter_summary_large_image", "x_summary_large_image", false, "3.4"],
["external_system_avatars_enabled", "external_system_avatars_url", false, "3.5"],
]
- OVERRIDE_TL_GROUP_SETTINGS = %w[
- anonymous_posting_min_trust_level
- shared_drafts_min_trust_level
- min_trust_level_for_here_mention
- approve_unless_trust_level
- approve_new_topics_unless_trust_level
- email_in_min_trust
- min_trust_to_edit_wiki_post
- allow_uploaded_avatars
- min_trust_to_create_topic
- min_trust_to_edit_post
- min_trust_to_flag_posts
- tl4_delete_posts_and_topics
- min_trust_level_to_allow_user_card_background
- min_trust_level_to_allow_invite
- min_trust_level_to_allow_ignore
- min_trust_to_create_tag
- min_trust_to_send_email_messages
- review_media_unless_trust_level
- min_trust_to_post_embedded_media
- min_trust_to_post_links
- min_trust_level_for_user_api_key
- min_trust_level_to_tag_topics
- min_trust_level_to_allow_profile_background
- ]
-
- def group_to_tl(old_setting, new_setting)
- tl_and_staff = is_tl_and_staff_setting?(old_setting)
-
- valid_auto_groups =
- self.public_send("#{new_setting}_map") &
- # We only want auto groups, no actual groups because they cannot be
- # mapped to TLs.
- Group.auto_groups_between(tl_and_staff ? :admins : :trust_level_0, :trust_level_4)
-
- # We don't want to return nil because this could lead to permission holes;
- # so we return the max available permission in this case.
- return tl_and_staff ? "admin" : TrustLevel[4] if valid_auto_groups.empty?
-
- if tl_and_staff
- valid_auto_groups_excluding_staff_and_admins =
- valid_auto_groups -
- [Group::AUTO_GROUPS[:staff], Group::AUTO_GROUPS[:admins], Group::AUTO_GROUPS[:moderators]]
-
- if valid_auto_groups_excluding_staff_and_admins.any?
- return valid_auto_groups_excluding_staff_and_admins.min - Group::AUTO_GROUPS[:trust_level_0]
- end
-
- if valid_auto_groups.include?(Group::AUTO_GROUPS[:moderators])
- "moderator"
- elsif valid_auto_groups.include?(Group::AUTO_GROUPS[:staff])
- "staff"
- elsif valid_auto_groups.include?(Group::AUTO_GROUPS[:admins])
- "admin"
- end
- else
- valid_auto_groups.min - Group::AUTO_GROUPS[:trust_level_0]
- end
- end
-
- def tl_to_group(old_setting, val)
- tl_and_staff = is_tl_and_staff_setting?(old_setting)
-
- if val == "admin"
- Group::AUTO_GROUPS[:admins]
- elsif val == "staff"
- Group::AUTO_GROUPS[:staff]
- else
- if tl_and_staff
- "#{Group::AUTO_GROUPS[:admins]}|#{Group::AUTO_GROUPS[:staff]}|#{val.to_i + Group::AUTO_GROUPS[:trust_level_0]}"
- else
- "#{val.to_i + Group::AUTO_GROUPS[:trust_level_0]}"
- end
- end
- end
-
- def is_tl_and_staff_setting?(old_setting)
- SiteSetting.type_supervisor.get_type(old_setting.to_sym) == :enum &&
- SiteSetting.type_supervisor.get_enum_class(old_setting.to_sym).name ==
- TrustLevelAndStaffSetting.name
- end
-
def setup_deprecated_methods
SETTINGS.each { |s| setup_deprecated_method(*s) }
end
@@ -139,12 +18,6 @@ module SiteSettings::DeprecatedSettings
def setup_deprecated_method(old_setting, new_setting, override, version)
SiteSetting.singleton_class.alias_method(:"_#{old_setting}", :"#{old_setting}") if !override
- if OVERRIDE_TL_GROUP_SETTINGS.include?(old_setting)
- define_singleton_method "_group_to_tl_#{old_setting}" do |warn: true|
- group_to_tl(old_setting, new_setting)
- end
- end
-
define_singleton_method old_setting do |scoped_to = nil, warn: true|
if warn
Discourse.deprecate(
@@ -153,11 +26,7 @@ module SiteSettings::DeprecatedSettings
)
end
- if OVERRIDE_TL_GROUP_SETTINGS.include?(old_setting)
- self.public_send("_group_to_tl_#{old_setting}")
- else
- self.public_send(override ? new_setting : "_#{old_setting}", scoped_to)
- end
+ self.public_send(override ? new_setting : "_#{old_setting}", scoped_to)
end
SiteSetting.singleton_class.alias_method(:"_#{old_setting}?", :"#{old_setting}?") if !override
@@ -183,14 +52,7 @@ module SiteSettings::DeprecatedSettings
)
end
- if OVERRIDE_TL_GROUP_SETTINGS.include?(old_setting)
- # We want to set both the new group setting here to the equivalent of the
- # TL, as well as setting the TL value in the DB so they remain in sync.
- self.public_send("_#{old_setting}=", val)
- self.public_send("#{new_setting}=", tl_to_group(old_setting, val).to_s)
- else
- self.public_send("#{override ? new_setting : "_" + old_setting}=", val)
- end
+ self.public_send("#{override ? new_setting : "_" + old_setting}=", val)
end
end
end
diff --git a/plugins/discourse-post-voting/config/locales/server.en.yml b/plugins/discourse-post-voting/config/locales/server.en.yml
index a629ef1f17a..e4c91f46fc7 100644
--- a/plugins/discourse-post-voting/config/locales/server.en.yml
+++ b/plugins/discourse-post-voting/config/locales/server.en.yml
@@ -25,13 +25,9 @@ en:
post_voting_enable_likes_on_answers: "Enable like button on replies on Post Voting topics"
post_voting_undo_vote_action_window: "Number of minutes users are allowed to undo votes in Post Voting topics (enter 0 for no limit)"
post_voting_comment_limit_per_post: "Number of comments allowed on each post"
- min_trust_to_flag_posts_voting_comments: "Minimum trust level to flag a post voting comment"
flag_posts_voting_comments_allowed_groups: "Groups allowed to flag a post voting comment"
post_voting_comment_enabled: "Enable comments on Post in Post Voting topics"
- keywords:
- flag_posts_voting_comments_allowed_groups: "min_trust_to_flag_posts_voting_comments"
-
discourse_post_voting:
reviewables:
actions:
diff --git a/plugins/discourse-post-voting/config/settings.yml b/plugins/discourse-post-voting/config/settings.yml
index 05b17ac5b54..1ff9f4fab51 100644
--- a/plugins/discourse-post-voting/config/settings.yml
+++ b/plugins/discourse-post-voting/config/settings.yml
@@ -18,11 +18,6 @@ plugins:
post_voting_enable_likes_on_answers:
client: true
default: false
- min_trust_to_flag_posts_voting_comments:
- default: 1
- enum: "TrustLevelSetting"
- client: true
- hidden: true
flag_posts_voting_comments_allowed_groups:
default: "11" # auto group trust_level_1
type: group_list
diff --git a/spec/fixtures/site_settings/generator_test.yml b/spec/fixtures/site_settings/generator_test.yml
deleted file mode 100644
index cc9bf44986c..00000000000
--- a/spec/fixtures/site_settings/generator_test.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-category1:
- use_https: true
- min_trust_level_to_allow_invite:
- default: 2
- enum: "TrustLevelSetting"
- hidden: true
- min_trust_level_to_allow_invite_tl_and_staff:
- default: 2
- enum: "TrustLevelAndStaffSetting"
- hidden: true
- allow_invite_groups:
- default: "11" # auto group trust_level_1
- type: group_list
- client: true
- allow_any: false
- refresh: true
- validator: "AtLeastOneGroupValidator"
diff --git a/spec/generator/site_setting_move_to_groups_migrations_generator_spec.rb b/spec/generator/site_setting_move_to_groups_migrations_generator_spec.rb
deleted file mode 100644
index bcdadf52fee..00000000000
--- a/spec/generator/site_setting_move_to_groups_migrations_generator_spec.rb
+++ /dev/null
@@ -1,132 +0,0 @@
-# frozen_string_literal: true
-
-require "rails/generators"
-require "generators/site_setting_move_to_groups_migration/site_setting_move_to_groups_migration_generator"
-
-RSpec.describe SiteSettingMoveToGroupsMigrationGenerator, type: :generator do
- it "generates the correct migration for TrustLevelSetting" do
- freeze_time DateTime.parse("2010-01-01 12:00")
-
- silence_stdout do
- described_class.start(
- %w[min_trust_level_to_allow_invite allow_invite_groups],
- destination_root: "#{Rails.root}/tmp",
- )
- end
-
- file_path =
- "#{Rails.root}/tmp/db/migrate/20100101120000_fill_allow_invite_groups_based_on_deprecated_setting.rb"
- expected_content = <<~EXPECTED_CONTENT
- # frozen_string_literal: true
-
- class FillAllowInviteGroupBasedOnDeprecatedSetting < ActiveRecord::Migration[7.0]
- def up
- old_setting_trust_level =
- DB.query_single(
- "SELECT value FROM site_settings WHERE name = 'min_trust_level_to_allow_invite' LIMIT 1",
- ).first
-
- if old_setting_trust_level.present?
- allowed_groups = "1\#\{old_setting_trust_level\}"
-
- DB.exec(
- "INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
- VALUES('allow_invite_groups', :setting, '20', NOW(), NOW())",
- setting: allowed_groups,
- )
- end
- end
-
- def down
- raise ActiveRecord::IrreversibleMigration
- end
- end
- EXPECTED_CONTENT
-
- expect(File.read(file_path)).to eq(expected_content)
- ensure
- File.delete(file_path)
- end
-
- it "generates the correct migration for TrustLevelAndStaffSetting" do
- freeze_time DateTime.parse("2010-01-01 12:00")
-
- silence_stdout do
- described_class.start(
- %w[min_trust_level_to_allow_invite_tl_and_staff allow_invite_groups],
- destination_root: "#{Rails.root}/tmp",
- )
- end
-
- file_path =
- "#{Rails.root}/tmp/db/migrate/20100101120000_fill_allow_invite_groups_based_on_deprecated_setting.rb"
- expected_content = <<~EXPECTED_CONTENT
- # frozen_string_literal: true
-
- class FillAllowInviteGroupBasedOnDeprecatedSetting < ActiveRecord::Migration[7.0]
- def up
- old_setting_trust_level =
- DB.query_single(
- "SELECT value FROM site_settings WHERE name = 'min_trust_level_to_allow_invite_tl_and_staff' LIMIT 1",
- ).first
-
- if old_setting_trust_level.present?
- allowed_groups =
- case old_setting_trust_level
- when "admin"
- "1"
- when "staff"
- "3"
- when "0"
- "10"
- when "1"
- "11"
- when "2"
- "12"
- when "3"
- "13"
- when "4"
- "14"
- end
-
- DB.exec(
- "INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
- VALUES('allow_invite_groups', :setting, '20', NOW(), NOW())",
- setting: allowed_groups,
- )
- end
- end
-
- def down
- raise ActiveRecord::IrreversibleMigration
- end
- end
- EXPECTED_CONTENT
-
- expect(File.read(file_path)).to eq(expected_content)
- ensure
- File.delete(file_path)
- end
-
- it "raises an error when old name is incorrect" do
- silence_stdout do
- expect { described_class.start(%w[wrong_name allow_invite_groups]) }.to raise_error(
- ArgumentError,
- )
- end
- end
-
- it "raises an error when new name is incorrect" do
- silence_stdout do
- expect {
- described_class.start(%w[min_trust_level_to_allow_invite wrong_name])
- }.to raise_error(ArgumentError)
- end
- end
-
- it "raises an error when old setting is incorrect type" do
- silence_stdout do
- expect { described_class.start(%w[title allow_invite_groups]) }.to raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/lib/email/receiver_spec.rb b/spec/lib/email/receiver_spec.rb
index 967dab9e393..a22d6c0de38 100644
--- a/spec/lib/email/receiver_spec.rb
+++ b/spec/lib/email/receiver_spec.rb
@@ -993,7 +993,7 @@ RSpec.describe Email::Receiver do
user1 =
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
user_emails: [
Fabricate.build(:secondary_email, email: "[email protected]"),
Fabricate.build(:secondary_email, email: "[email protected]"),
@@ -1004,7 +1004,7 @@ RSpec.describe Email::Receiver do
user2 =
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
user_emails: [
Fabricate.build(:secondary_email, email: "[email protected]"),
Fabricate.build(:secondary_email, email: "[email protected]"),
@@ -1578,7 +1578,7 @@ RSpec.describe Email::Receiver do
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
refresh_auto_groups: true,
)
group = Fabricate(:group)
@@ -1607,7 +1607,7 @@ RSpec.describe Email::Receiver do
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
refresh_auto_groups: true,
)
expect { process(:existing_user) }.to change { Topic.count }.by(1) # Topic created
@@ -1628,7 +1628,7 @@ RSpec.describe Email::Receiver do
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
refresh_auto_groups: true,
)
expect { process(:spam_x_spam_flag) }.to change { ReviewableQueuedPost.count }.by(1)
@@ -1642,7 +1642,7 @@ RSpec.describe Email::Receiver do
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
refresh_auto_groups: true,
)
expect { process(:spam_x_spam_status) }.to change { ReviewableQueuedPost.count }.by(1)
@@ -1656,7 +1656,7 @@ RSpec.describe Email::Receiver do
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
refresh_auto_groups: true,
)
expect { process(:spam_x_ses_spam_verdict) }.to change { ReviewableQueuedPost.count }.by(1)
@@ -1670,7 +1670,7 @@ RSpec.describe Email::Receiver do
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
refresh_auto_groups: true,
)
expect { process(:dmarc_fail) }.to change { ReviewableQueuedPost.count }.by(1)
@@ -1683,7 +1683,7 @@ RSpec.describe Email::Receiver do
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
refresh_auto_groups: true,
)
expect { process(:forwarded_email_to_category) }.to change { Topic.count }.by(1) # Topic created
@@ -1718,7 +1718,7 @@ RSpec.describe Email::Receiver do
user =
Fabricate(
:user,
- trust_level: SiteSetting.email_in_min_trust,
+ trust_level: TrustLevel[2],
user_emails: [Fabricate.build(:secondary_email, email: "[email protected]")],
refresh_auto_groups: true,
)
diff --git a/spec/lib/guardian_spec.rb b/spec/lib/guardian_spec.rb
index da850e1f367..918342719cd 100644
--- a/spec/lib/guardian_spec.rb
+++ b/spec/lib/guardian_spec.rb
@@ -619,7 +619,6 @@ RSpec.describe Guardian do
end
it "is false if user has not met minimum trust level" do
- SiteSetting.min_trust_to_create_topic = 1
SiteSetting.create_topic_allowed_groups = Group::AUTO_GROUPS[:trust_level_1]
expect(
Guardian.new(Fabricate(:user, trust_level: 0)).can_create?(Topic, plain_category),
@@ -1430,7 +1429,6 @@ RSpec.describe Guardian do
end
it "returns false for user with insufficient trust level" do
- SiteSetting.min_trust_to_create_topic = 3
SiteSetting.create_topic_allowed_groups = Group::AUTO_GROUPS[:trust_level_3]
expect(Guardian.new(user).can_create_topic?(topic)).to eq(false)
end
@@ -2618,7 +2616,7 @@ RSpec.describe Guardian do
context "when post is older than post_edit_time_limit" do
let(:old_post) { Fabricate(:post, user: trust_level_2, created_at: 6.minutes.ago) }
before do
- SiteSetting.min_trust_to_allow_self_wiki = 2
+ SiteSetting.self_wiki_allowed_groups = "1|2|12"
SiteSetting.tl2_post_edit_time_limit = 5
end
@@ -3177,7 +3175,6 @@ RSpec.describe Guardian do
end
it "works with trust levels" do
- SiteSetting.min_trust_level_for_here_mention = 2
SiteSetting.here_mention_allowed_groups = Group::AUTO_GROUPS[:trust_level_2]
expect(trust_level_0.guardian.can_mention_here?).to eq(false)
@@ -3190,7 +3187,6 @@ RSpec.describe Guardian do
end
it "works with staff" do
- SiteSetting.min_trust_level_for_here_mention = "staff"
SiteSetting.here_mention_allowed_groups = Group::AUTO_GROUPS[:staff]
expect(trust_level_4.guardian.can_mention_here?).to eq(false)
@@ -3199,7 +3195,6 @@ RSpec.describe Guardian do
end
it "works with admin or moderator" do
- SiteSetting.min_trust_level_for_here_mention = "admin"
SiteSetting.here_mention_allowed_groups = Group::AUTO_GROUPS[:admins]
expect(trust_level_4.guardian.can_mention_here?).to eq(false)
diff --git a/spec/lib/new_post_manager_spec.rb b/spec/lib/new_post_manager_spec.rb
index 1d0c0a774ff..250a55be30c 100644
--- a/spec/lib/new_post_manager_spec.rb
+++ b/spec/lib/new_post_manager_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe NewPostManager do
fab!(:other_user, :user)
it "doesn't enqueue private messages" do
- SiteSetting.approve_unless_trust_level = 4
+ SiteSetting.approve_unless_allowed_groups = "1|2|14"
manager =
NewPostManager.new(
diff --git a/spec/system/admin_site_setting_search_spec.rb b/spec/system/admin_site_setting_search_spec.rb
index 7fec0b12f46..daa51871f05 100644
--- a/spec/system/admin_site_setting_search_spec.rb
+++ b/spec/system/admin_site_setting_search_spec.rb
@@ -27,10 +27,12 @@ describe "Admin Site Setting Search", type: :system do
end
describe "when searching for keywords" do
- it "finds the associated site setting" do
- settings_page.visit
- settings_page.type_in_search("anonymous_posting_min_trust_level")
- expect(settings_page).to have_search_result("anonymous_posting_allowed_groups")
+ it "finds the replacement site setting when deprecated" do
+ stub_deprecated_settings!(override: false) do
+ settings_page.visit
+ settings_page.type_in_search("old_one")
+ expect(settings_page).to have_search_result("new_one")
+ end
end
it "finds the associated site setting when many keywords" do
@@ -41,9 +43,11 @@ describe "Admin Site Setting Search", type: :system do
end
it "can search for previous site setting without underscores" do
- settings_page.visit
- settings_page.type_in_search("anonymous posting min")
- expect(settings_page).to have_search_result("anonymous_posting_allowed_groups")
+ stub_deprecated_settings!(override: false) do
+ settings_page.visit
+ settings_page.type_in_search("old one")
+ expect(settings_page).to have_search_result("new_one")
+ end
end
end
end