mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Add guardian modifier to prevent sending PM (#28282)
This commit is contained in:
@@ -505,6 +505,14 @@ class Guardian
|
||||
# Must be a valid target
|
||||
return false if !(target_is_group || target_is_user)
|
||||
|
||||
can_send_private_message =
|
||||
DiscoursePluginRegistry.apply_modifier(
|
||||
:guardian_can_send_private_message,
|
||||
target: target,
|
||||
user: @user,
|
||||
)
|
||||
return false if !can_send_private_message
|
||||
|
||||
# Users can send messages to certain groups with the `everyone` messageable_level
|
||||
# even if they are not in personal_message_enabled_groups
|
||||
group_is_messageable = target_is_group && Group.messageable(@user).where(id: target.id).exists?
|
||||
|
||||
Reference in New Issue
Block a user