Don't allow sending private messages to suspended users. Emails to suspended users should tell them how to respond, since they can't.

This commit is contained in:
Neil Lalonde
2014-05-06 15:01:19 -04:00
parent ba68470d5a
commit f44bd4ec28
5 changed files with 37 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
# Builds a Mail::Mesage we can use for sending. Optionally supports using a template
# Builds a Mail::Message we can use for sending. Optionally supports using a template
# for the body and subject
module Email
@@ -26,12 +26,16 @@ module Email
user_preferences_url: "#{Discourse.base_url}/my/preferences" }.merge!(@opts)
if @template_args[:url].present?
@template_args[:respond_instructions] =
if allow_reply_by_email?
I18n.t('user_notifications.reply_by_email', @template_args)
else
I18n.t('user_notifications.visit_link_to_respond', @template_args)
end
if @opts[:include_respond_instructions] == false
@template_args[:respond_instructions] = ''
else
@template_args[:respond_instructions] =
if allow_reply_by_email?
I18n.t('user_notifications.reply_by_email', @template_args)
else
I18n.t('user_notifications.visit_link_to_respond', @template_args)
end
end
end
end

View File

@@ -215,7 +215,9 @@ class Guardian
# PMs are enabled
(SiteSetting.enable_private_messages ||
@user.username == SiteSetting.site_contact_username ||
@user == Discourse.system_user)
@user == Discourse.system_user) &&
# Can't send PMs to suspended users
(is_staff? || target.is_a?(Group) || !target.suspended?)
end
private