Revert "FEATURE: allow end users to opt out of getting any private messages"
This reverts commit 229ecc4f8a
.
This commit is contained in:
parent
229ecc4f8a
commit
1601211617
|
@ -181,7 +181,6 @@ const User = Discourse.Model.extend({
|
||||||
'email_direct',
|
'email_direct',
|
||||||
'email_always',
|
'email_always',
|
||||||
'email_private_messages',
|
'email_private_messages',
|
||||||
'allow_private_messages',
|
|
||||||
'dynamic_favicon',
|
'dynamic_favicon',
|
||||||
'digest_after_days',
|
'digest_after_days',
|
||||||
'new_topic_duration_minutes',
|
'new_topic_duration_minutes',
|
||||||
|
|
|
@ -211,7 +211,6 @@
|
||||||
{{preference-checkbox labelKey="user.enable_quoting" checked=enable_quoting}}
|
{{preference-checkbox labelKey="user.enable_quoting" checked=enable_quoting}}
|
||||||
{{preference-checkbox labelKey="user.dynamic_favicon" checked=dynamic_favicon}}
|
{{preference-checkbox labelKey="user.dynamic_favicon" checked=dynamic_favicon}}
|
||||||
{{preference-checkbox labelKey="user.disable_jump_reply" checked=disable_jump_reply}}
|
{{preference-checkbox labelKey="user.disable_jump_reply" checked=disable_jump_reply}}
|
||||||
{{preference-checkbox labelKey="user.allow_private_messages" checked=allow_private_messages}}
|
|
||||||
{{#unless editHistoryVisible}}
|
{{#unless editHistoryVisible}}
|
||||||
{{preference-checkbox labelKey="user.edit_history_public" checked=edit_history_public}}
|
{{preference-checkbox labelKey="user.edit_history_public" checked=edit_history_public}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
|
@ -95,8 +95,7 @@ class UserSerializer < BasicUserSerializer
|
||||||
:custom_avatar_upload_id,
|
:custom_avatar_upload_id,
|
||||||
:has_title_badges,
|
:has_title_badges,
|
||||||
:card_image_badge,
|
:card_image_badge,
|
||||||
:card_image_badge_id,
|
:card_image_badge_id
|
||||||
:allow_private_messages
|
|
||||||
|
|
||||||
untrusted_attributes :bio_raw,
|
untrusted_attributes :bio_raw,
|
||||||
:bio_cooked,
|
:bio_cooked,
|
||||||
|
@ -158,10 +157,6 @@ class UserSerializer < BasicUserSerializer
|
||||||
object.user_profile.location
|
object.user_profile.location
|
||||||
end
|
end
|
||||||
|
|
||||||
def allow_private_messages
|
|
||||||
object.user_profile.allow_private_messages
|
|
||||||
end
|
|
||||||
|
|
||||||
def can_edit
|
def can_edit
|
||||||
scope.can_edit?(object)
|
scope.can_edit?(object)
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,9 +28,6 @@ class UserUpdater
|
||||||
user_profile = user.user_profile
|
user_profile = user.user_profile
|
||||||
user_profile.website = format_url(attributes.fetch(:website) { user_profile.website })
|
user_profile.website = format_url(attributes.fetch(:website) { user_profile.website })
|
||||||
user_profile.bio_raw = attributes.fetch(:bio_raw) { user_profile.bio_raw }
|
user_profile.bio_raw = attributes.fetch(:bio_raw) { user_profile.bio_raw }
|
||||||
user_profile.allow_private_messages = attributes.fetch(:allow_private_messages) {
|
|
||||||
user_profile.allow_private_messages
|
|
||||||
}
|
|
||||||
|
|
||||||
user.name = attributes.fetch(:name) { user.name }
|
user.name = attributes.fetch(:name) { user.name }
|
||||||
user.locale = attributes.fetch(:locale) { user.locale }
|
user.locale = attributes.fetch(:locale) { user.locale }
|
||||||
|
|
|
@ -335,7 +335,6 @@ en:
|
||||||
dismiss_notifications: "Mark all as Read"
|
dismiss_notifications: "Mark all as Read"
|
||||||
dismiss_notifications_tooltip: "Mark all unread notifications as read"
|
dismiss_notifications_tooltip: "Mark all unread notifications as read"
|
||||||
disable_jump_reply: "Don't jump to my post after I reply"
|
disable_jump_reply: "Don't jump to my post after I reply"
|
||||||
allow_private_messages: "Allow users to send me private messages"
|
|
||||||
dynamic_favicon: "Show incoming message notifications on favicon (experimental)"
|
dynamic_favicon: "Show incoming message notifications on favicon (experimental)"
|
||||||
edit_history_public: "Let other users view my post revisions"
|
edit_history_public: "Let other users view my post revisions"
|
||||||
external_links_in_new_tab: "Open all external links in a new tab"
|
external_links_in_new_tab: "Open all external links in a new tab"
|
||||||
|
|
|
@ -260,8 +260,6 @@ class Guardian
|
||||||
(SiteSetting.enable_private_messages ||
|
(SiteSetting.enable_private_messages ||
|
||||||
@user.username == SiteSetting.site_contact_username ||
|
@user.username == SiteSetting.site_contact_username ||
|
||||||
@user == Discourse.system_user) &&
|
@user == Discourse.system_user) &&
|
||||||
# Only staff can send PMs to users that opt-out
|
|
||||||
(!target.is_a?(User) || is_staff? || target.user_profile.allow_private_messages) &&
|
|
||||||
# Can't send PMs to suspended users
|
# Can't send PMs to suspended users
|
||||||
(is_staff? || target.is_a?(Group) || !target.suspended?)
|
(is_staff? || target.is_a?(Group) || !target.suspended?)
|
||||||
end
|
end
|
||||||
|
|
|
@ -393,30 +393,14 @@ describe PostCreator do
|
||||||
let(:target_user1) { Fabricate(:coding_horror) }
|
let(:target_user1) { Fabricate(:coding_horror) }
|
||||||
let(:target_user2) { Fabricate(:moderator) }
|
let(:target_user2) { Fabricate(:moderator) }
|
||||||
let(:unrelated) { Fabricate(:user) }
|
let(:unrelated) { Fabricate(:user) }
|
||||||
|
let(:post) do
|
||||||
def create_pm(from, to)
|
PostCreator.create(user, title: 'hi there welcome to my topic',
|
||||||
PostCreator.create(from, title: 'hi there welcome to my topic',
|
|
||||||
raw: "this is my awesome message @#{unrelated.username_lower}",
|
raw: "this is my awesome message @#{unrelated.username_lower}",
|
||||||
archetype: Archetype.private_message,
|
archetype: Archetype.private_message,
|
||||||
target_usernames: to.join(','),
|
target_usernames: [target_user1.username, target_user2.username].join(','),
|
||||||
category: 1)
|
category: 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:post) do
|
|
||||||
create_pm(user, [target_user1.username, target_user2.username])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'disallows PM to end users that disable it' do
|
|
||||||
profile = target_user2.user_profile
|
|
||||||
profile.allow_private_messages = false
|
|
||||||
profile.save
|
|
||||||
|
|
||||||
post = create_pm(user, [target_user2.username])
|
|
||||||
|
|
||||||
expect(post).to be_nil
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'acts correctly' do
|
it 'acts correctly' do
|
||||||
# It's not a warning
|
# It's not a warning
|
||||||
expect(post.topic.warning).to be_blank
|
expect(post.topic.warning).to be_blank
|
||||||
|
@ -492,11 +476,10 @@ describe PostCreator do
|
||||||
end
|
end
|
||||||
let(:unrelated) { Fabricate(:user) }
|
let(:unrelated) { Fabricate(:user) }
|
||||||
let(:post) do
|
let(:post) do
|
||||||
PostCreator.new(user, title: 'hi there welcome to my topic',
|
PostCreator.create(user, title: 'hi there welcome to my topic',
|
||||||
raw: "this is my awesome message @#{unrelated.username_lower}",
|
raw: "this is my awesome message @#{unrelated.username_lower}",
|
||||||
archetype: Archetype.private_message,
|
archetype: Archetype.private_message,
|
||||||
target_group_names: group.name).create
|
target_group_names: group.name)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'acts correctly' do
|
it 'acts correctly' do
|
||||||
|
|
Loading…
Reference in New Issue