mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 18:52:45 +08:00
DEV: Correct some tl to group site setting changes (#25550)
- Created a new migration for here_mention - Updated existing migration for here_mention - Updated site settings for here_mention, create_tag, and send_email_messages
This commit is contained in:
parent
a764ab5b54
commit
3159522546
|
@ -1744,7 +1744,7 @@ trust:
|
||||||
enum: "TrustLevelAndStaffSetting"
|
enum: "TrustLevelAndStaffSetting"
|
||||||
hidden: true
|
hidden: true
|
||||||
send_email_messages_allowed_groups:
|
send_email_messages_allowed_groups:
|
||||||
default: "3|14" # auto group staff and trust_level_4
|
default: "1|3|14" # auto group admin, staff, and trust_level_4
|
||||||
type: group_list
|
type: group_list
|
||||||
allow_any: false
|
allow_any: false
|
||||||
refresh: true
|
refresh: true
|
||||||
|
@ -3059,7 +3059,7 @@ tags:
|
||||||
enum: "TrustLevelAndStaffSetting"
|
enum: "TrustLevelAndStaffSetting"
|
||||||
hidden: true
|
hidden: true
|
||||||
create_tag_allowed_groups:
|
create_tag_allowed_groups:
|
||||||
default: "3|13" # auto group staff and trust_level_3
|
default: "1|3|13" # auto group admin, staff, and trust_level_3
|
||||||
type: group_list
|
type: group_list
|
||||||
allow_any: false
|
allow_any: false
|
||||||
refresh: true
|
refresh: true
|
||||||
|
|
|
@ -15,17 +15,10 @@ class MigrateMinTrustLevelForHereMentionToGroup < ActiveRecord::Migration[7.0]
|
||||||
when "admin"
|
when "admin"
|
||||||
"1"
|
"1"
|
||||||
when "staff"
|
when "staff"
|
||||||
"3"
|
"1|3"
|
||||||
when "0"
|
# Matches Group::AUTO_GROUPS to the trust levels.
|
||||||
"10"
|
else
|
||||||
when "1"
|
"1|3|1#{min_trust_level_for_here_mention_raw}"
|
||||||
"11"
|
|
||||||
when "2"
|
|
||||||
"12"
|
|
||||||
when "3"
|
|
||||||
"13"
|
|
||||||
when "4"
|
|
||||||
"14"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Data_type 20 is group_list.
|
# Data_type 20 is group_list.
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class FixHereMentionAllowedGroupsSetting < ActiveRecord::Migration[7.0]
|
||||||
|
def up
|
||||||
|
configured_trust_level =
|
||||||
|
DB.query_single(
|
||||||
|
"SELECT value FROM site_settings WHERE name = 'min_trust_level_for_here_mention' LIMIT 1",
|
||||||
|
).first
|
||||||
|
|
||||||
|
configured_groups =
|
||||||
|
DB.query_single(
|
||||||
|
"SELECT value FROM site_settings WHERE name = 'here_mention_allowed_groups' LIMIT 1",
|
||||||
|
).first
|
||||||
|
|
||||||
|
# We only need to do anything if it's been changed in the DB.
|
||||||
|
if configured_trust_level.present? && configured_groups.present?
|
||||||
|
# The previous migration for this, changed it to only
|
||||||
|
# `"1#{configured_trust_level}"`, so if it has been
|
||||||
|
# changed we need to add back in admin & staff if they match.
|
||||||
|
if "1#{configured_trust_level}" == configured_groups
|
||||||
|
corresponding_group = "1|3|1#{configured_trust_level}"
|
||||||
|
end
|
||||||
|
|
||||||
|
if corresponding_group
|
||||||
|
DB.exec(
|
||||||
|
"UPDATE site_settings SET value = :setting, updated_at = NOW() WHERE name = 'here_mention_allowed_groups'",
|
||||||
|
setting: corresponding_group,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
raise ActiveRecord::IrreversibleMigration
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user