mirror of
https://github.com/discourse/discourse.git
synced 2026-08-05 19:53:47 +08:00
## Summary When `enable_names` is disabled but `show_user_menu_avatars` is enabled, `NotificationSerializer` uses the acting user's full name in notification JSON responses. The fix adds a `SiteSetting.enable_names?` check to `include_acting_user_name?` so that the full name is only serialized when names are enabled. Avatars and usernames remain available per their respective settings. ## Source - Patch Triage: https://patch.discourse.org/patch-triage/1568 Co-authored-by: discourse-patch-triage <272280883+discourse-patch-triage[bot]@users.noreply.github.com>
61 lines
1.2 KiB
Ruby
Vendored
61 lines
1.2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class NotificationSerializer < ApplicationSerializer
|
|
include LocalizedFancyTopicTitleMixin
|
|
|
|
attributes :id,
|
|
:user_id,
|
|
:external_id,
|
|
:notification_type,
|
|
:read,
|
|
:high_priority,
|
|
:created_at,
|
|
:post_number,
|
|
:topic_id,
|
|
:fancy_title,
|
|
:slug,
|
|
:data,
|
|
:is_warning,
|
|
:acting_user_avatar_template,
|
|
:acting_user_name
|
|
|
|
def slug
|
|
Slug.for(object.topic.title) if object.topic.present?
|
|
end
|
|
|
|
def is_warning
|
|
object.topic.present? && object.topic.subtype == TopicSubtype.moderator_warning
|
|
end
|
|
|
|
def include_is_warning?
|
|
is_warning
|
|
end
|
|
|
|
def data
|
|
object.data_hash
|
|
end
|
|
|
|
def external_id
|
|
object.user&.single_sign_on_record&.external_id
|
|
end
|
|
|
|
def include_external_id?
|
|
SiteSetting.enable_discourse_connect
|
|
end
|
|
|
|
def acting_user_avatar_template
|
|
object.acting_user.avatar_template_url
|
|
end
|
|
|
|
def include_acting_user_avatar_template?
|
|
object.acting_user.present?
|
|
end
|
|
|
|
def acting_user_name
|
|
object.acting_user.name
|
|
end
|
|
|
|
def include_acting_user_name?
|
|
object.acting_user.present? && SiteSetting.enable_names?
|
|
end
|
|
end
|