FEATURE: Site setting to display user avatars in user menu (#24514)

This commit is contained in:
Mark VanLandingham
2023-12-07 11:30:44 -06:00
committed by GitHub
parent e4c373194d
commit ee05f57e2d
26 changed files with 314 additions and 15 deletions

View File

@ -1,6 +1,9 @@
# frozen_string_literal: true
class Notification < ActiveRecord::Base
attr_accessor :acting_user
attr_accessor :acting_username
belongs_to :user
belongs_to :topic
@ -349,6 +352,25 @@ class Notification < ActiveRecord::Base
end
end
def self.populate_acting_user(notifications)
usernames =
notifications.map do |notification|
notification.acting_username =
(
notification.data_hash[:username] || notification.data_hash[:display_username] ||
notification.data_hash[:mentioned_by_username] ||
notification.data_hash[:invited_by_username]
)&.downcase
end
users = User.where(username_lower: usernames.uniq).index_by(&:username_lower)
notifications.each do |notification|
notification.acting_user = users[notification.acting_username]
end
notifications
end
def unread_high_priority?
self.high_priority? && !read
end