rename 'min_private_message_{post/title}_length' to 'min_personal_message_{post/title}_length'
This commit is contained in:
parent
187b0031c5
commit
25ec077eca
|
@ -34,13 +34,13 @@ export default Ember.Component.extend({
|
|||
|
||||
@computed('message.length')
|
||||
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')
|
||||
customMessageLength(messageLength) {
|
||||
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) {
|
||||
return I18n.t("flagging.custom_message.at_least", { count: minLen });
|
||||
} else if (len < minLen) {
|
||||
|
|
|
@ -80,7 +80,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
|
||||
if (selected.get('is_custom_flag')) {
|
||||
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;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -302,7 +302,7 @@ const Composer = RestModel.extend({
|
|||
@computed('privateMessage')
|
||||
minimumTitleLength(privateMessage) {
|
||||
if (privateMessage) {
|
||||
return this.siteSettings.min_private_message_title_length;
|
||||
return this.siteSettings.min_personal_message_title_length;
|
||||
} else {
|
||||
return this.siteSettings.min_topic_title_length;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ const Composer = RestModel.extend({
|
|||
if (pmWithNonHumanUser) {
|
||||
return 1;
|
||||
} else if (privateMessage) {
|
||||
return this.siteSettings.min_private_message_post_length;
|
||||
return this.siteSettings.min_personal_message_post_length;
|
||||
} else if (topicFirstPost) {
|
||||
// first post (topic body)
|
||||
return this.siteSettings.min_first_post_length;
|
||||
|
|
|
@ -38,7 +38,7 @@ class SiteSetting < ActiveRecord::Base
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def self.post_length
|
||||
|
@ -50,7 +50,7 @@ class SiteSetting < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.private_message_post_length
|
||||
min_private_message_post_length..max_post_length
|
||||
min_personal_message_post_length..max_post_length
|
||||
end
|
||||
|
||||
def self.top_menu_items
|
||||
|
|
|
@ -55,7 +55,7 @@ Discourse::Application.configure do
|
|||
s.set_regardless_of_locale(:s3_upload_bucket, 'bucket')
|
||||
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_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(:download_remote_images_to_local, false)
|
||||
s.set_regardless_of_locale(:unique_posts_mins, 0)
|
||||
|
|
|
@ -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)"
|
||||
min_post_length: "Minimum allowed post 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"
|
||||
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."
|
||||
min_topic_title_length: "Minimum 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"
|
||||
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"
|
||||
|
|
|
@ -447,7 +447,7 @@ posting:
|
|||
locale_default:
|
||||
zh_CN: 8
|
||||
zh_TW: 8
|
||||
min_private_message_post_length:
|
||||
min_personal_message_post_length:
|
||||
client: true
|
||||
min: 1
|
||||
default: 10
|
||||
|
@ -490,7 +490,7 @@ posting:
|
|||
zh_CN: false
|
||||
zh_TW: false
|
||||
title_fancy_entities: true
|
||||
min_private_message_title_length:
|
||||
min_personal_message_title_length:
|
||||
client: true
|
||||
default: 2
|
||||
min: 1
|
||||
|
|
|
@ -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
|
|
@ -19,9 +19,9 @@ class TextSentinel
|
|||
def self.body_sentinel(text, opts = {})
|
||||
entropy = SiteSetting.body_min_entropy
|
||||
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 = (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
|
||||
entropy = (SiteSetting.min_post_length.to_f * ENTROPY_SCALE).to_i if entropy > SiteSetting.min_post_length
|
||||
end
|
||||
|
|
|
@ -71,8 +71,8 @@ class ImportScripts::Base
|
|||
min_topic_title_length: 1,
|
||||
min_post_length: 1,
|
||||
min_first_post_length: 1,
|
||||
min_private_message_post_length: 1,
|
||||
min_private_message_title_length: 1,
|
||||
min_personal_message_post_length: 1,
|
||||
min_personal_message_title_length: 1,
|
||||
allow_duplicate_topic_titles: true,
|
||||
disable_emails: true,
|
||||
max_attachment_size_kb: 102400,
|
||||
|
|
|
@ -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
|
||||
SiteSetting.min_post_length = 5
|
||||
SiteSetting.min_private_message_post_length = 3
|
||||
SiteSetting.min_personal_message_post_length = 3
|
||||
SiteSetting.body_min_entropy = 7
|
||||
expect(TextSentinel.body_sentinel('Lol', private_message: true)).to be_valid
|
||||
end
|
||||
|
|
|
@ -52,14 +52,14 @@ describe TopicTitleLengthValidator do
|
|||
describe 'private message' do
|
||||
let(:record) { Fabricate.build(:private_message_topic) }
|
||||
|
||||
it 'adds an error when topic title is shorter than SiteSetting.min_private_message_title_length' do
|
||||
record.title = 'a' * (SiteSetting.min_private_message_title_length - 1)
|
||||
it 'adds an error when topic title is shorter than SiteSetting.min_personal_message_title_length' do
|
||||
record.title = 'a' * (SiteSetting.min_personal_message_title_length - 1)
|
||||
validate
|
||||
expect(record.errors[:title]).to be_present
|
||||
end
|
||||
|
||||
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
|
||||
expect(record.errors[:title]).to_not be_present
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ describe SiteSetting do
|
|||
|
||||
describe 'private_message_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
|
||||
|
||||
|
|
|
@ -215,11 +215,11 @@ describe Topic do
|
|||
context 'private message title' do
|
||||
before do
|
||||
SiteSetting.min_topic_title_length = 15
|
||||
SiteSetting.min_private_message_title_length = 3
|
||||
SiteSetting.min_personal_message_title_length = 3
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
@ -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, 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 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('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 => {
|
||||
|
@ -130,7 +130,7 @@ QUnit.test("Title length for regular topics", 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;
|
||||
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 => {
|
||||
Discourse.SiteSettings.min_private_message_title_length = 5;
|
||||
Discourse.SiteSettings.min_personal_message_title_length = 5;
|
||||
Discourse.SiteSettings.max_topic_title_length = 10;
|
||||
const composer = createComposer({action: Composer.PRIVATE_MESSAGE});
|
||||
|
||||
|
|
Loading…
Reference in New Issue