mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 20:44:40 +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:
@ -15,17 +15,10 @@ class MigrateMinTrustLevelForHereMentionToGroup < ActiveRecord::Migration[7.0]
|
||||
when "admin"
|
||||
"1"
|
||||
when "staff"
|
||||
"3"
|
||||
when "0"
|
||||
"10"
|
||||
when "1"
|
||||
"11"
|
||||
when "2"
|
||||
"12"
|
||||
when "3"
|
||||
"13"
|
||||
when "4"
|
||||
"14"
|
||||
"1|3"
|
||||
# Matches Group::AUTO_GROUPS to the trust levels.
|
||||
else
|
||||
"1|3|1#{min_trust_level_for_here_mention_raw}"
|
||||
end
|
||||
|
||||
# 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
|
Reference in New Issue
Block a user