mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: allow sending PMs to staff via flag even when PMs are disabled (#6938)
* FIX: allow sending PMs to staff via flag even when PMs are disabled FIX: allow sending PMs to staff via flag even if the user trust level is insufficient * Update lib/topic_creator.rb Co-Authored-By: techAPJ <arpit@techapj.com>
This commit is contained in:
@@ -343,7 +343,7 @@ class Guardian
|
||||
can_send_private_message?(group)
|
||||
end
|
||||
|
||||
def can_send_private_message?(target)
|
||||
def can_send_private_message?(target, notify_moderators: false)
|
||||
is_user = target.is_a?(User)
|
||||
is_group = target.is_a?(Group)
|
||||
|
||||
@@ -351,11 +351,11 @@ class Guardian
|
||||
# User is authenticated
|
||||
authenticated? &&
|
||||
# Have to be a basic level at least
|
||||
@user.has_trust_level?(SiteSetting.min_trust_to_send_messages) &&
|
||||
(@user.has_trust_level?(SiteSetting.min_trust_to_send_messages) || notify_moderators) &&
|
||||
# User disabled private message
|
||||
(is_staff? || is_group || target.user_option.allow_private_messages) &&
|
||||
# PMs are enabled
|
||||
(is_staff? || SiteSetting.enable_personal_messages) &&
|
||||
(is_staff? || SiteSetting.enable_personal_messages || notify_moderators) &&
|
||||
# Can't send PMs to suspended users
|
||||
(is_staff? || is_group || !target.suspended?) &&
|
||||
# Check group messageable level
|
||||
|
@@ -48,7 +48,7 @@ module PostGuardian
|
||||
(!SiteSetting.allow_flagging_staff?) &&
|
||||
post&.user&.staff?
|
||||
|
||||
if [:notify_user, :notify_moderators].include?(action_key) &&
|
||||
if action_key == :notify_user &&
|
||||
(!SiteSetting.enable_personal_messages? ||
|
||||
!@user.has_trust_level?(SiteSetting.min_trust_to_send_messages))
|
||||
|
||||
|
@@ -260,7 +260,10 @@ class TopicCreator
|
||||
end
|
||||
|
||||
def check_can_send_permission!(topic, obj)
|
||||
rollback_with!(topic, :cant_send_pm) unless @opts[:skip_validations] || @guardian.can_send_private_message?(obj)
|
||||
unless @opts[:skip_validations] ||
|
||||
@guardian.can_send_private_message?(obj, notify_moderators: topic&.subtype == TopicSubtype.notify_moderators))
|
||||
rollback_with!(topic, :cant_send_pm)
|
||||
end
|
||||
end
|
||||
|
||||
def find_or_create_user(email, display_name)
|
||||
|
Reference in New Issue
Block a user