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.
This commit is contained in:
Ted Johansson 2023-09-06 17:35:11 +08:00 committed by GitHub
parent 5e7287eba5
commit ede73f923f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -1934,7 +1934,9 @@ spam:
auto_respond_to_flag_actions: true auto_respond_to_flag_actions: true
min_first_post_typing_time: 3000 min_first_post_typing_time: 3000
auto_silence_fast_typers_on_first_post: true 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: "" auto_silence_first_post_regex: ""
high_trust_flaggers_auto_hide_posts: true high_trust_flaggers_auto_hide_posts: true
cooldown_hours_until_reflag: cooldown_hours_until_reflag:

View File

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