mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 00:08:53 +08:00
FIX: Change UserCommScreener to use user_ids (#17489)
It makes more sense to use user_ids for the UserCommScreener introduced in fa5f3e228c102d4b9f7c6dde6eb07ef1f5880bbd since in most cases the ID will be available, not the username. This was discovered while starting work on a plugin that will use this. In the cases where only usernames are available the extra query is negligble.
This commit is contained in:
@ -113,8 +113,9 @@ class PostCreator
|
||||
|
||||
# Make sure none of the users have muted or ignored the creator or prevented
|
||||
# PMs from being sent to them
|
||||
UserCommScreener.new(acting_user: @user, target_usernames: names).preventing_actor_communication.each do |username|
|
||||
errors.add(:base, I18n.t(:not_accepting_pms, username: username))
|
||||
target_users = User.where(username_lower: names.map(&:downcase)).pluck(:id, :username).to_h
|
||||
UserCommScreener.new(acting_user: @user, target_user_ids: target_users.keys).preventing_actor_communication.each do |user_id|
|
||||
errors.add(:base, I18n.t(:not_accepting_pms, username: target_users[user_id]))
|
||||
end
|
||||
|
||||
return false if errors[:base].present?
|
||||
|
Reference in New Issue
Block a user