rename 'min_private_message_{post/title}_length' to 'min_personal_message_{post/title}_length'

This commit is contained in:
Arpit Jalan 2018-01-31 11:26:00 +05:30
parent 187b0031c5
commit 25ec077eca
15 changed files with 43 additions and 27 deletions

View File

@ -34,13 +34,13 @@ export default Ember.Component.extend({
@computed('message.length') @computed('message.length')
customMessageLengthClasses(messageLength) { customMessageLengthClasses(messageLength) {
return (messageLength < Discourse.SiteSettings.min_private_message_post_length) ? "too-short" : "ok"; return (messageLength < Discourse.SiteSettings.min_personal_message_post_length) ? "too-short" : "ok";
}, },
@computed('message.length') @computed('message.length')
customMessageLength(messageLength) { customMessageLength(messageLength) {
const len = messageLength || 0; const len = messageLength || 0;
const minLen = Discourse.SiteSettings.min_private_message_post_length; const minLen = Discourse.SiteSettings.min_personal_message_post_length;
if (len === 0) { if (len === 0) {
return I18n.t("flagging.custom_message.at_least", { count: minLen }); return I18n.t("flagging.custom_message.at_least", { count: minLen });
} else if (len < minLen) { } else if (len < minLen) {

View File

@ -80,7 +80,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
if (selected.get('is_custom_flag')) { if (selected.get('is_custom_flag')) {
const len = this.get('message.length') || 0; const len = this.get('message.length') || 0;
return len >= Discourse.SiteSettings.min_private_message_post_length && return len >= Discourse.SiteSettings.min_personal_message_post_length &&
len <= MAX_MESSAGE_LENGTH; len <= MAX_MESSAGE_LENGTH;
} }
return true; return true;

View File

@ -302,7 +302,7 @@ const Composer = RestModel.extend({
@computed('privateMessage') @computed('privateMessage')
minimumTitleLength(privateMessage) { minimumTitleLength(privateMessage) {
if (privateMessage) { if (privateMessage) {
return this.siteSettings.min_private_message_title_length; return this.siteSettings.min_personal_message_title_length;
} else { } else {
return this.siteSettings.min_topic_title_length; return this.siteSettings.min_topic_title_length;
} }
@ -325,7 +325,7 @@ const Composer = RestModel.extend({
if (pmWithNonHumanUser) { if (pmWithNonHumanUser) {
return 1; return 1;
} else if (privateMessage) { } else if (privateMessage) {
return this.siteSettings.min_private_message_post_length; return this.siteSettings.min_personal_message_post_length;
} else if (topicFirstPost) { } else if (topicFirstPost) {
// first post (topic body) // first post (topic body)
return this.siteSettings.min_first_post_length; return this.siteSettings.min_first_post_length;

View File

@ -38,7 +38,7 @@ class SiteSetting < ActiveRecord::Base
end end
def self.private_message_title_length def self.private_message_title_length
min_private_message_title_length..max_topic_title_length min_personal_message_title_length..max_topic_title_length
end end
def self.post_length def self.post_length
@ -50,7 +50,7 @@ class SiteSetting < ActiveRecord::Base
end end
def self.private_message_post_length def self.private_message_post_length
min_private_message_post_length..max_post_length min_personal_message_post_length..max_post_length
end end
def self.top_menu_items def self.top_menu_items

View File

@ -55,7 +55,7 @@ Discourse::Application.configure do
s.set_regardless_of_locale(:s3_upload_bucket, 'bucket') s.set_regardless_of_locale(:s3_upload_bucket, 'bucket')
s.set_regardless_of_locale(:min_post_length, 5) s.set_regardless_of_locale(:min_post_length, 5)
s.set_regardless_of_locale(:min_first_post_length, 5) s.set_regardless_of_locale(:min_first_post_length, 5)
s.set_regardless_of_locale(:min_private_message_post_length, 10) s.set_regardless_of_locale(:min_personal_message_post_length, 10)
s.set_regardless_of_locale(:crawl_images, false) s.set_regardless_of_locale(:crawl_images, false)
s.set_regardless_of_locale(:download_remote_images_to_local, false) s.set_regardless_of_locale(:download_remote_images_to_local, false)
s.set_regardless_of_locale(:unique_posts_mins, 0) s.set_regardless_of_locale(:unique_posts_mins, 0)

View File

@ -970,13 +970,13 @@ en:
set_locale_from_accept_language_header: "set interface language for anonymous users from their web browser's language headers. (EXPERIMENTAL, does not work with anonymous cache)" set_locale_from_accept_language_header: "set interface language for anonymous users from their web browser's language headers. (EXPERIMENTAL, does not work with anonymous cache)"
min_post_length: "Minimum allowed post length in characters" min_post_length: "Minimum allowed post length in characters"
min_first_post_length: "Minimum allowed first post (topic body) length in characters" min_first_post_length: "Minimum allowed first post (topic body) length in characters"
min_private_message_post_length: "Minimum allowed post length in characters for messages" min_personal_message_post_length: "Minimum allowed post length in characters for messages"
max_post_length: "Maximum allowed post length in characters" max_post_length: "Maximum allowed post length in characters"
topic_featured_link_enabled: "Enable posting a link with topics." topic_featured_link_enabled: "Enable posting a link with topics."
show_topic_featured_link_in_digest: "Show the topic featured link in the digest email." show_topic_featured_link_in_digest: "Show the topic featured link in the digest email."
min_topic_title_length: "Minimum allowed topic title length in characters" min_topic_title_length: "Minimum allowed topic title length in characters"
max_topic_title_length: "Maximum allowed topic title length in characters" max_topic_title_length: "Maximum allowed topic title length in characters"
min_private_message_title_length: "Minimum allowed title length for a message in characters" min_personal_message_title_length: "Minimum allowed title length for a message in characters"
min_search_term_length: "Minimum valid search term length in characters" min_search_term_length: "Minimum valid search term length in characters"
search_tokenize_chinese_japanese_korean: "Force search to tokenize Chinese/Japanese/Korean even on non CJK sites" search_tokenize_chinese_japanese_korean: "Force search to tokenize Chinese/Japanese/Korean even on non CJK sites"
search_prefer_recent_posts: "If searching your large forum is slow, this option tries an index of more recent posts first" search_prefer_recent_posts: "If searching your large forum is slow, this option tries an index of more recent posts first"

View File

@ -447,7 +447,7 @@ posting:
locale_default: locale_default:
zh_CN: 8 zh_CN: 8
zh_TW: 8 zh_TW: 8
min_private_message_post_length: min_personal_message_post_length:
client: true client: true
min: 1 min: 1
default: 10 default: 10
@ -490,7 +490,7 @@ posting:
zh_CN: false zh_CN: false
zh_TW: false zh_TW: false
title_fancy_entities: true title_fancy_entities: true
min_private_message_title_length: min_personal_message_title_length:
client: true client: true
default: 2 default: 2
min: 1 min: 1

View File

@ -0,0 +1,16 @@
class RenamePrivatePersonal < ActiveRecord::Migration[5.1]
def setting(old, new)
execute "UPDATE site_settings SET name='#{new}' where name='#{old}'"
end
def up
setting :min_private_message_post_length, :min_personal_message_post_length
setting :min_private_message_title_length, :min_personal_message_title_length
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
end
end

View File

@ -19,9 +19,9 @@ class TextSentinel
def self.body_sentinel(text, opts = {}) def self.body_sentinel(text, opts = {})
entropy = SiteSetting.body_min_entropy entropy = SiteSetting.body_min_entropy
if opts[:private_message] if opts[:private_message]
scale_entropy = SiteSetting.min_private_message_post_length.to_f / SiteSetting.min_post_length.to_f scale_entropy = SiteSetting.min_personal_message_post_length.to_f / SiteSetting.min_post_length.to_f
entropy = (entropy * scale_entropy).to_i entropy = (entropy * scale_entropy).to_i
entropy = (SiteSetting.min_private_message_post_length.to_f * ENTROPY_SCALE).to_i if entropy > SiteSetting.min_private_message_post_length entropy = (SiteSetting.min_personal_message_post_length.to_f * ENTROPY_SCALE).to_i if entropy > SiteSetting.min_personal_message_post_length
else else
entropy = (SiteSetting.min_post_length.to_f * ENTROPY_SCALE).to_i if entropy > SiteSetting.min_post_length entropy = (SiteSetting.min_post_length.to_f * ENTROPY_SCALE).to_i if entropy > SiteSetting.min_post_length
end end

View File

@ -71,8 +71,8 @@ class ImportScripts::Base
min_topic_title_length: 1, min_topic_title_length: 1,
min_post_length: 1, min_post_length: 1,
min_first_post_length: 1, min_first_post_length: 1,
min_private_message_post_length: 1, min_personal_message_post_length: 1,
min_private_message_title_length: 1, min_personal_message_title_length: 1,
allow_duplicate_topic_titles: true, allow_duplicate_topic_titles: true,
disable_emails: true, disable_emails: true,
max_attachment_size_kb: 102400, max_attachment_size_kb: 102400,

View File

@ -143,7 +143,7 @@ describe TextSentinel do
it "uses a sensible min entropy value when min pm body length is less than min entropy" do it "uses a sensible min entropy value when min pm body length is less than min entropy" do
SiteSetting.min_post_length = 5 SiteSetting.min_post_length = 5
SiteSetting.min_private_message_post_length = 3 SiteSetting.min_personal_message_post_length = 3
SiteSetting.body_min_entropy = 7 SiteSetting.body_min_entropy = 7
expect(TextSentinel.body_sentinel('Lol', private_message: true)).to be_valid expect(TextSentinel.body_sentinel('Lol', private_message: true)).to be_valid
end end

View File

@ -52,14 +52,14 @@ describe TopicTitleLengthValidator do
describe 'private message' do describe 'private message' do
let(:record) { Fabricate.build(:private_message_topic) } let(:record) { Fabricate.build(:private_message_topic) }
it 'adds an error when topic title is shorter than SiteSetting.min_private_message_title_length' do it 'adds an error when topic title is shorter than SiteSetting.min_personal_message_title_length' do
record.title = 'a' * (SiteSetting.min_private_message_title_length - 1) record.title = 'a' * (SiteSetting.min_personal_message_title_length - 1)
validate validate
expect(record.errors[:title]).to be_present expect(record.errors[:title]).to be_present
end end
it 'does not add an error when topic title is shorter than SiteSetting.min_topic_title_length' do it 'does not add an error when topic title is shorter than SiteSetting.min_topic_title_length' do
record.title = 'a' * (SiteSetting.min_private_message_title_length) record.title = 'a' * (SiteSetting.min_personal_message_title_length)
validate validate
expect(record.errors[:title]).to_not be_present expect(record.errors[:title]).to_not be_present
end end

View File

@ -26,7 +26,7 @@ describe SiteSetting do
describe 'private_message_title_length' do describe 'private_message_title_length' do
it 'returns a range of min/max pm topic title length' do it 'returns a range of min/max pm topic title length' do
expect(SiteSetting.private_message_title_length).to eq(SiteSetting.defaults[:min_private_message_title_length]..SiteSetting.defaults[:max_topic_title_length]) expect(SiteSetting.private_message_title_length).to eq(SiteSetting.defaults[:min_personal_message_title_length]..SiteSetting.defaults[:max_topic_title_length])
end end
end end

View File

@ -215,11 +215,11 @@ describe Topic do
context 'private message title' do context 'private message title' do
before do before do
SiteSetting.min_topic_title_length = 15 SiteSetting.min_topic_title_length = 15
SiteSetting.min_private_message_title_length = 3 SiteSetting.min_personal_message_title_length = 3
end end
it 'allows shorter titles' do it 'allows shorter titles' do
pm = Fabricate.build(:private_message_topic, title: 'a' * SiteSetting.min_private_message_title_length) pm = Fabricate.build(:private_message_topic, title: 'a' * SiteSetting.min_personal_message_title_length)
expect(pm).to be_valid expect(pm).to be_valid
end end

View File

@ -38,7 +38,7 @@ QUnit.test('missingReplyCharacters', assert => {
missingReplyCharacters('hi', false, false, Discourse.SiteSettings.min_post_length - 2, 'too short public post'); missingReplyCharacters('hi', false, false, Discourse.SiteSettings.min_post_length - 2, 'too short public post');
missingReplyCharacters('hi', false, true, Discourse.SiteSettings.min_first_post_length - 2, 'too short first post'); missingReplyCharacters('hi', false, true, Discourse.SiteSettings.min_first_post_length - 2, 'too short first post');
missingReplyCharacters('hi', true, false, Discourse.SiteSettings.min_private_message_post_length - 2, 'too short private message'); missingReplyCharacters('hi', true, false, Discourse.SiteSettings.min_personal_message_post_length - 2, 'too short private message');
const link = "http://imgur.com/gallery/grxX8"; const link = "http://imgur.com/gallery/grxX8";
const composer = createComposer({ canEditTopicFeaturedLink: true, title: link, featuredLink: link, reply: link }); const composer = createComposer({ canEditTopicFeaturedLink: true, title: link, featuredLink: link, reply: link });
@ -53,7 +53,7 @@ QUnit.test('missingTitleCharacters', assert => {
}; };
missingTitleCharacters('hi', false, Discourse.SiteSettings.min_topic_title_length - 2, 'too short post title'); missingTitleCharacters('hi', false, Discourse.SiteSettings.min_topic_title_length - 2, 'too short post title');
missingTitleCharacters('z', true, Discourse.SiteSettings.min_private_message_title_length - 1, 'too short pm title'); missingTitleCharacters('z', true, Discourse.SiteSettings.min_personal_message_title_length - 1, 'too short pm title');
}); });
QUnit.test('replyDirty', assert => { QUnit.test('replyDirty', assert => {
@ -130,7 +130,7 @@ QUnit.test("Title length for regular topics", assert => {
}); });
QUnit.test("Title length for private messages", assert => { QUnit.test("Title length for private messages", assert => {
Discourse.SiteSettings.min_private_message_title_length = 5; Discourse.SiteSettings.min_personal_message_title_length = 5;
Discourse.SiteSettings.max_topic_title_length = 10; Discourse.SiteSettings.max_topic_title_length = 10;
const composer = createComposer({action: Composer.PRIVATE_MESSAGE}); const composer = createComposer({action: Composer.PRIVATE_MESSAGE});
@ -145,7 +145,7 @@ QUnit.test("Title length for private messages", assert => {
}); });
QUnit.test("Title length for private messages", assert => { QUnit.test("Title length for private messages", assert => {
Discourse.SiteSettings.min_private_message_title_length = 5; Discourse.SiteSettings.min_personal_message_title_length = 5;
Discourse.SiteSettings.max_topic_title_length = 10; Discourse.SiteSettings.max_topic_title_length = 10;
const composer = createComposer({action: Composer.PRIVATE_MESSAGE}); const composer = createComposer({action: Composer.PRIVATE_MESSAGE});