diff --git a/app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6 b/app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6 index d5ae0f8b0ad..af05e670fac 100644 --- a/app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-footer-buttons.js.es6 @@ -8,12 +8,12 @@ export default Ember.Component.extend({ @computed('topic.isPrivateMessage') canArchive(isPM) { - return this.siteSettings.enable_private_messages && isPM; + return this.siteSettings.enable_personal_messages && isPM; }, @computed('topic.isPrivateMessage') showNotificationsButton(isPM) { - return (!isPM) || this.siteSettings.enable_private_messages; + return (!isPM) || this.siteSettings.enable_personal_messages; }, @computed('topic.details.can_invite_to') diff --git a/app/assets/javascripts/discourse/controllers/user.js.es6 b/app/assets/javascripts/discourse/controllers/user.js.es6 index c11210ee8ba..c8fce33d5a4 100644 --- a/app/assets/javascripts/discourse/controllers/user.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user.js.es6 @@ -52,7 +52,7 @@ export default Ember.Controller.extend(CanCheckEmails, { @computed('viewingSelf', 'currentUser.admin') showPrivateMessages(viewingSelf, isAdmin) { - return this.siteSettings.enable_private_messages && (viewingSelf || isAdmin); + return this.siteSettings.enable_personal_messages && (viewingSelf || isAdmin); }, @computed('viewingSelf', 'currentUser.staff') diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 index 367e6aa3048..e65240981e0 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 @@ -71,7 +71,7 @@ export default { let siteSettings = this.container.lookup('site-settings:main'); // Disable the shortcut if private messages are disabled - if (!siteSettings.enable_private_messages) { + if (!siteSettings.enable_personal_messages) { delete bindings['g m']; } diff --git a/app/assets/javascripts/discourse/widgets/user-menu.js.es6 b/app/assets/javascripts/discourse/widgets/user-menu.js.es6 index 115c3deb34c..9b5502e91a8 100644 --- a/app/assets/javascripts/discourse/widgets/user-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/user-menu.js.es6 @@ -40,7 +40,7 @@ createWidget('user-menu-links', { icon: 'bookmark', href: `${path}/activity/bookmarks` }); - if (siteSettings.enable_private_messages) { + if (siteSettings.enable_personal_messages) { glyphs.push({ label: 'user.private_messages', className: 'user-pms-link', icon: 'envelope', diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d4fe579a123..a2d4ca232fe 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1036,7 +1036,7 @@ en: summary_percent_filter: "When a user clicks 'Summarize This Topic', show the top % of posts" summary_max_results: "Maximum posts returned by 'Summary This Topic'" - enable_private_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_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 private messages are disabled" enable_private_email_messages: "Allow trust level 4 (configurable via min trust level to send messages) users to send private email messages. Note that staff can always send messages no matter what." diff --git a/config/site_settings.yml b/config/site_settings.yml index 22bc2846b0d..d9e6cd9a9ef 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -505,7 +505,7 @@ posting: locale_default: zh_CN: 4 zh_TW: 4 - enable_private_messages: + enable_personal_messages: default: true client: true enable_system_message_replies: diff --git a/db/migrate/20180131052859_rename_private_personal.rb b/db/migrate/20180131052859_rename_private_personal.rb index d1b9dc44677..b97478f6894 100644 --- a/db/migrate/20180131052859_rename_private_personal.rb +++ b/db/migrate/20180131052859_rename_private_personal.rb @@ -7,10 +7,12 @@ class RenamePrivatePersonal < ActiveRecord::Migration[5.1] def up setting :min_private_message_post_length, :min_personal_message_post_length setting :min_private_message_title_length, :min_personal_message_title_length + setting :enable_private_messages, :enable_personal_messages end def down setting :min_private_message_post_length, :min_personal_message_post_length setting :min_private_message_title_length, :min_personal_message_title_length + setting :enable_private_messages, :enable_personal_messages end end diff --git a/lib/guardian.rb b/lib/guardian.rb index 82f66a70160..789d479ec00 100644 --- a/lib/guardian.rb +++ b/lib/guardian.rb @@ -247,7 +247,7 @@ class Guardian def can_invite_to?(object, groups = nil) return false unless authenticated? return true if is_admin? - return false unless SiteSetting.enable_private_messages? + return false unless SiteSetting.enable_personal_messages? return false if (SiteSetting.max_invites_per_day.to_i == 0 && !is_staff?) return false unless can_see?(object) return false if groups.present? @@ -303,7 +303,7 @@ class Guardian # User disabled private message (is_staff? || is_group || target.user_option.allow_private_messages) && # PMs are enabled - (is_staff? || SiteSetting.enable_private_messages) && + (is_staff? || SiteSetting.enable_personal_messages) && # Can't send PMs to suspended users (is_staff? || is_group || !target.suspended?) && # Check group messageable level diff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rb index 5996f84812c..e5e4e010f85 100644 --- a/lib/guardian/post_guardian.rb +++ b/lib/guardian/post_guardian.rb @@ -17,7 +17,7 @@ module PostGuardian result = if authenticated? && post && !@user.anonymous? return false if [:notify_user, :notify_moderators].include?(action_key) && - !SiteSetting.enable_private_messages? + !SiteSetting.enable_personal_messages? # we allow flagging for trust level 1 and higher # always allowed for private messages diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 1556e085fc6..34ca3f32ddc 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -104,7 +104,7 @@ class TopicQuery # Don't suggest messages unless we have a user, and private messages are # enabled. return if topic.private_message? && - (@user.blank? || !SiteSetting.enable_private_messages?) + (@user.blank? || !SiteSetting.enable_personal_messages?) builder = SuggestedTopicsBuilder.new(topic) diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index 09d4dc042d4..0aa745ed9e7 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -70,14 +70,14 @@ describe Guardian do end it "returns false for notify_user if private messages are disabled" do - SiteSetting.enable_private_messages = false + SiteSetting.enable_personal_messages = false user.trust_level = TrustLevel[2] expect(Guardian.new(user).post_can_act?(post, :notify_user)).to be_falsey expect(Guardian.new(user).post_can_act?(post, :notify_moderators)).to be_falsey end it "returns false for notify_user and notify_moderators if private messages are enabled but threshold not met" do - SiteSetting.enable_private_messages = true + SiteSetting.enable_personal_messages = true SiteSetting.min_trust_to_send_messages = 2 user.trust_level = TrustLevel[1] expect(Guardian.new(user).post_can_act?(post, :notify_user)).to be_falsey @@ -170,8 +170,8 @@ describe Guardian do expect(Guardian.new(user).can_send_private_message?(another_user)).to be_falsey end - context "enable_private_messages is false" do - before { SiteSetting.enable_private_messages = false } + context "enable_personal_messages is false" do + before { SiteSetting.enable_personal_messages = false } it "returns false if user is not staff member" do expect(Guardian.new(trust_level_4).can_send_private_message?(another_user)).to be_falsey @@ -451,7 +451,7 @@ describe Guardian do context "when private messages are disabled" do before do - SiteSetting.enable_private_messages = false + SiteSetting.enable_personal_messages = false end it "doesn't allow a regular user to invite" do diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb index 4ca84492b35..7d400cd5d44 100644 --- a/spec/components/topic_query_spec.rb +++ b/spec/components/topic_query_spec.rb @@ -696,7 +696,7 @@ describe TopicQuery do eq([new_pm.id, unread_pm.id, related_by_user_pm.id]) ) - SiteSetting.enable_private_messages = false + SiteSetting.enable_personal_messages = false expect(TopicQuery.new(user).list_suggested_for(pm_to_group)).to be_blank expect(TopicQuery.new(user).list_suggested_for(pm_to_user)).to be_blank end diff --git a/test/javascripts/widgets/user-menu-test.js.es6 b/test/javascripts/widgets/user-menu-test.js.es6 index 8b26410e0fa..19b4640a658 100644 --- a/test/javascripts/widgets/user-menu-test.js.es6 +++ b/test/javascripts/widgets/user-menu-test.js.es6 @@ -35,7 +35,7 @@ widgetTest('log out', { widgetTest('private messages - disabled', { template: '{{mount-widget widget="user-menu"}}', beforeEach() { - this.siteSettings.enable_private_messages = false; + this.siteSettings.enable_personal_messages = false; }, test(assert) { @@ -46,7 +46,7 @@ widgetTest('private messages - disabled', { widgetTest('private messages - enabled', { template: '{{mount-widget widget="user-menu"}}', beforeEach() { - this.siteSettings.enable_private_messages = true; + this.siteSettings.enable_personal_messages = true; }, test(assert) {