FEATURE: hide enable_personal_email_messages and min_trust_to_send_email_messages

These site settings are very hard to explain and only applicable for very
specific Discourse setups.

If an admin "enables staged users" which is used in support scenarios then
all staff can send "messages" directly to an "email".

The setting allows you to extend this to TL4 or any trust level.

Actual use case would be a support type setup with restricted staff. It is
quite rare so hiding this for now and re-evaluate keeping the setting in
2019
This commit is contained in:
Sam 2018-08-27 11:38:11 +10:00
parent 2271918be2
commit 4205c528d0
6 changed files with 16 additions and 14 deletions

View File

@ -101,7 +101,7 @@ class CurrentUserSerializer < BasicUserSerializer
end
def can_send_private_email_messages
scope.cand_send_private_messages_to_email?
scope.can_send_private_messages_to_email?
end
def can_edit

View File

@ -1186,8 +1186,6 @@ en:
enable_personal_messages: "Allow trust level 1 (configurable via min trust level to send messages) users to create messages and reply to messages. Note that staff can always send messages no matter what."
enable_system_message_replies: "Allows users to reply to system messages, even if personal messages are disabled"
enable_personal_email_messages: "Allow trust level 4 (configurable via min trust level to send messages) users to send personal email messages. Note that staff can always send messages no matter what."
enable_long_polling: "Message bus used for notification can use long polling"
long_polling_base_url: "Base URL used for long polling (when a CDN is serving dynamic content, be sure to set this to origin pull) eg: http://origin.site.com"
long_polling_interval: "Amount of time the server should wait before responding to clients when there is no data to send (logged on users only)"
@ -1456,9 +1454,6 @@ en:
min_trust_to_allow_self_wiki: "The minimum trust level required to make user's own post wiki."
min_trust_to_send_messages: "The minimum trust level required to create new personal messages."
min_trust_to_send_email_messages: "The minimum trust level required to send new personal messages via email (to staged users)."
min_trust_to_flag_posts: "The minimum trust level required to flag posts"
min_trust_to_post_links: "The minimum trust level required to include links in posts"
min_trust_to_post_images: "The minimum trust level required to include images in a post"

View File

@ -558,6 +558,7 @@ posting:
enable_system_message_replies:
default: true
enable_personal_email_messages:
hidden: true
default: false
client: true
validator: "EnablePrivateEmailMessagesValidator"
@ -1018,6 +1019,7 @@ trust:
default: 1
enum: 'TrustLevelSetting'
min_trust_to_send_email_messages:
hidden: true
default: 4
enum: 'TrustLevelSetting'
min_trust_to_flag_posts:

View File

@ -335,15 +335,20 @@ class Guardian
(!is_silenced? || target.staff?)
end
def cand_send_private_messages_to_email?
def can_send_private_messages_to_email?
# Staged users must be enabled to create a temporary user.
SiteSetting.enable_staged_users &&
# User is authenticated
authenticated? &&
# User is trusted enough
(is_staff? ||
(
# TODO: 2019 evaluate if we need this flexibility
# perhaps we enable this unconditionally to TL4?
@user.has_trust_level?(SiteSetting.min_trust_to_send_email_messages) &&
# PMs to email addresses are enabled
(is_staff? || SiteSetting.enable_personal_email_messages)
SiteSetting.enable_personal_email_messages
)
)
end
def can_see_emails?

View File

@ -183,7 +183,7 @@ class TopicCreator
rollback_with!(topic, :no_user_selected)
end
if @opts[:target_emails].present? && !@guardian.cand_send_private_messages_to_email? then
if @opts[:target_emails].present? && !@guardian.can_send_private_messages_to_email? then
rollback_with!(topic, :reply_by_email_disabled)
end

View File

@ -126,7 +126,7 @@ describe TopicCreator do
end
end
context 'private message' do
context 'personal message' do
context 'success cases' do
before do
@ -146,7 +146,7 @@ describe TopicCreator do
end
it "should be possible for a trusted user to send private messages via email" do
SiteSetting.expects(:enable_personal_email_messages).returns(true)
SiteSetting.enable_personal_email_messages = true
SiteSetting.min_trust_to_send_email_messages = TrustLevel[1]
expect(TopicCreator.create(user, Guardian.new(user), pm_to_email_valid_attrs)).to be_valid
@ -155,7 +155,7 @@ describe TopicCreator do
context 'failure cases' do
it "should be rollback the changes when email is invalid" do
SiteSetting.expects(:enable_personal_email_messages).returns(true)
SiteSetting.enable_personal_email_messages = true
SiteSetting.min_trust_to_send_email_messages = TrustLevel[1]
attrs = pm_to_email_valid_attrs.dup
attrs[:target_emails] = "t" * 256