mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Change UserCommScreener to use user_ids (#17489)
It makes more sense to use user_ids for the UserCommScreener
introduced in fa5f3e228c 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:
@@ -1040,8 +1040,8 @@ class Topic < ActiveRecord::Base
|
||||
raise UserExists.new(I18n.t("topic_invite.user_exists"))
|
||||
end
|
||||
|
||||
comm_screener = UserCommScreener.new(acting_user: invited_by, target_usernames: target_user.username)
|
||||
if comm_screener.ignoring_or_muting_actor?(target_user.username)
|
||||
comm_screener = UserCommScreener.new(acting_user: invited_by, target_user_ids: target_user.id)
|
||||
if comm_screener.ignoring_or_muting_actor?(target_user.id)
|
||||
raise NotAllowed.new(I18n.t("not_accepting_pms", username: target_user.username))
|
||||
end
|
||||
|
||||
@@ -1053,11 +1053,11 @@ class Topic < ActiveRecord::Base
|
||||
raise NotAllowed.new(I18n.t("topic_invite.muted_topic"))
|
||||
end
|
||||
|
||||
if comm_screener.disallowing_pms_from_actor?(target_user.username)
|
||||
if comm_screener.disallowing_pms_from_actor?(target_user.id)
|
||||
raise NotAllowed.new(I18n.t("topic_invite.receiver_does_not_allow_pm"))
|
||||
end
|
||||
|
||||
if UserCommScreener.new(acting_user: target_user, target_usernames: invited_by.username).disallowing_pms_from_actor?(invited_by.username)
|
||||
if UserCommScreener.new(acting_user: target_user, target_user_ids: invited_by.id).disallowing_pms_from_actor?(invited_by.id)
|
||||
raise NotAllowed.new(I18n.t("topic_invite.sender_does_not_allow_pm"))
|
||||
end
|
||||
|
||||
@@ -1759,7 +1759,7 @@ class Topic < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def create_invite_notification!(target_user, notification_type, invited_by, post_number: 1)
|
||||
if UserCommScreener.new(acting_user: invited_by, target_usernames: target_user.username).ignoring_or_muting_actor?(target_user.username)
|
||||
if UserCommScreener.new(acting_user: invited_by, target_user_ids: target_user.id).ignoring_or_muting_actor?(target_user.id)
|
||||
raise NotAllowed.new(I18n.t("not_accepting_pms", username: target_user.username))
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user