mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: Site setting to display user avatars in user menu (#24514)
This commit is contained in:

committed by
GitHub

parent
e4c373194d
commit
ee05f57e2d
@ -1897,6 +1897,9 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
if reminder_notifications.present?
|
||||
if SiteSetting.show_user_menu_avatars
|
||||
Notification.populate_acting_user(reminder_notifications)
|
||||
end
|
||||
serialized_notifications =
|
||||
ActiveModel::ArraySerializer.new(
|
||||
reminder_notifications,
|
||||
@ -1967,6 +1970,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
if unread_notifications.present?
|
||||
Notification.populate_acting_user(unread_notifications) if SiteSetting.show_user_menu_avatars
|
||||
serialized_unread_notifications =
|
||||
ActiveModel::ArraySerializer.new(
|
||||
unread_notifications,
|
||||
@ -1978,9 +1982,17 @@ class UsersController < ApplicationController
|
||||
if messages_list
|
||||
serialized_messages =
|
||||
serialize_data(messages_list, TopicListSerializer, scope: guardian, root: false)[:topics]
|
||||
serialized_users =
|
||||
if SiteSetting.show_user_menu_avatars
|
||||
users = messages_list.topics.map { |t| t.posters.last.user }.flatten.compact.uniq(&:id)
|
||||
serialize_data(users, BasicUserSerializer, scope: guardian, root: false)
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
if read_notifications.present?
|
||||
Notification.populate_acting_user(read_notifications) if SiteSetting.show_user_menu_avatars
|
||||
serialized_read_notifications =
|
||||
ActiveModel::ArraySerializer.new(
|
||||
read_notifications,
|
||||
@ -1993,6 +2005,7 @@ class UsersController < ApplicationController
|
||||
unread_notifications: serialized_unread_notifications || [],
|
||||
read_notifications: serialized_read_notifications || [],
|
||||
topics: serialized_messages || [],
|
||||
users: serialized_users || [],
|
||||
}
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user