mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: Allow users to disable new PMs.
https://meta.discourse.org/t/is-it-possible-to-disable-private-messaging-for-a-specific-user/46391
This commit is contained in:
parent
814c7ab503
commit
79de10b212
14 changed files with 101 additions and 16 deletions
|
@ -286,17 +286,22 @@ class Guardian
|
|||
end
|
||||
|
||||
def can_send_private_message?(target)
|
||||
(target.is_a?(Group) || target.is_a?(User)) &&
|
||||
is_user = target.is_a?(User)
|
||||
is_group = target.is_a?(Group)
|
||||
|
||||
(is_group || is_user) &&
|
||||
# User is authenticated
|
||||
authenticated? &&
|
||||
# Have to be a basic level at least, or are contacting moderators
|
||||
(@user.has_trust_level?(SiteSetting.min_trust_to_send_messages) ||
|
||||
(target.is_a?(User) && target.moderator?) ||
|
||||
(target.name == Group[:moderators].name)) &&
|
||||
# User disabled private message
|
||||
(is_staff? || is_group || target.user_option.allow_private_messages) &&
|
||||
# PMs are enabled
|
||||
(is_staff? || SiteSetting.enable_private_messages) &&
|
||||
# Can't send PMs to suspended users
|
||||
(is_staff? || target.is_a?(Group) || !target.suspended?) &&
|
||||
(is_staff? || is_group || !target.suspended?) &&
|
||||
# Blocked users can only send PM to staff
|
||||
(!is_blocked? || target.staff?)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue