mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: Block muted users from sending you PMs
This commit is contained in:
parent
b58a6804c2
commit
cf7774bdd9
3 changed files with 47 additions and 0 deletions
|
@ -92,6 +92,17 @@ class PostCreator
|
|||
return false
|
||||
end
|
||||
|
||||
# Make sure none of the users have muted the creator
|
||||
names = @opts[:target_usernames]
|
||||
if names.present? && !skip_validations? && !@user.staff?
|
||||
users = User.where(username: names.split(',').flatten).pluck(:id, :username).to_h
|
||||
|
||||
MutedUser.where(user_id: users.keys, muted_user_id: @user.id).pluck(:user_id).each do |m|
|
||||
errors[:base] << I18n.t(:not_accepting_pms, username: users[m])
|
||||
end
|
||||
return false if errors[:base].present?
|
||||
end
|
||||
|
||||
if new_topic?
|
||||
topic_creator = TopicCreator.new(@user, guardian, @opts)
|
||||
return false unless skip_validations? || validate_child(topic_creator)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue