From ede73f923f93ea252873647fe73975a5f4c2e155 Mon Sep 17 00:00:00 2001 From: Ted Johansson Date: Wed, 6 Sep 2023 17:35:11 +0800 Subject: [PATCH] DEV: Change fast typer trust level setting to enum type (#23429) We have one site setting, `auto_silence_fast_typers_max_trust_level`, which expects a trust level. However, the type is set to integer, which makes it very hard for a layman to enter the correct thing. This PR changes the type of the site setting to the `TrustLevelSetting` enum. The use of these are interchangeable in the back-end, since `SiteSetting.auto_silence_fast_typers_max_trust_level` still returns the integer value with the enum. --- config/site_settings.yml | 4 ++- ...ilence_fast_typers_setting_to_enum_type.rb | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230906030920_change_auto_silence_fast_typers_setting_to_enum_type.rb diff --git a/config/site_settings.yml b/config/site_settings.yml index f82c04e2c8d..20bd8a9e022 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -1934,7 +1934,9 @@ spam: auto_respond_to_flag_actions: true min_first_post_typing_time: 3000 auto_silence_fast_typers_on_first_post: true - auto_silence_fast_typers_max_trust_level: 0 + auto_silence_fast_typers_max_trust_level: + default: 0 + enum: "TrustLevelSetting" auto_silence_first_post_regex: "" high_trust_flaggers_auto_hide_posts: true cooldown_hours_until_reflag: diff --git a/db/migrate/20230906030920_change_auto_silence_fast_typers_setting_to_enum_type.rb b/db/migrate/20230906030920_change_auto_silence_fast_typers_setting_to_enum_type.rb new file mode 100644 index 00000000000..5b23e51bd0a --- /dev/null +++ b/db/migrate/20230906030920_change_auto_silence_fast_typers_setting_to_enum_type.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class ChangeAutoSilenceFastTypersSettingToEnumType < ActiveRecord::Migration[7.0] + def up + execute <<~SQL + UPDATE + "site_settings" + SET + "data_type" = 7 + WHERE + "name" = 'auto_silence_fast_typers_max_trust_level' AND + "data_type" = 3 + SQL + end + + def down + execute <<~SQL + UPDATE + "site_settings" + SET + "data_type" = 3 + WHERE + "name" = 'auto_silence_fast_typers_max_trust_level' AND + "data_type" = 7 + SQL + end +end