mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
FIX: Ensure only edited badge titles update a users title
When editing site texts from /admin/customize/site_texts/ you can edit badge titles (aka name) and this will update any users that have that badge currently set as their title. This fix prevents a badge description text from being set as their title if an admin updates the badge description text or any other badge fields that aren't the title.
This commit is contained in:
parent
cca654fc1a
commit
8a89b7e108
@ -71,7 +71,7 @@ class Admin::SiteTextsController < Admin::AdminController
|
||||
if translation_override.errors.empty?
|
||||
StaffActionLogger.new(current_user).log_site_text_change(id, value, old_value)
|
||||
system_badge_id = Badge.find_system_badge_id_from_translation_key(id)
|
||||
if system_badge_id.present?
|
||||
if system_badge_id.present? && is_badge_title?(id)
|
||||
Jobs.enqueue(
|
||||
:bulk_user_title_update,
|
||||
new_title: value,
|
||||
@ -132,6 +132,11 @@ class Admin::SiteTextsController < Admin::AdminController
|
||||
|
||||
protected
|
||||
|
||||
def is_badge_title?(id = "")
|
||||
badge_parts = id.split('.')
|
||||
badge_parts[0] == 'badges' && badge_parts[2] == 'name'
|
||||
end
|
||||
|
||||
def record_for(key, value = nil)
|
||||
if key.ends_with?("_MF")
|
||||
override = TranslationOverride.where(translation_key: key, locale: I18n.locale).pluck(:value)
|
||||
|
Loading…
Reference in New Issue
Block a user