From 5516322ad7b4a2c3f5fe9fd69a794d29c3818117 Mon Sep 17 00:00:00 2001 From: Flipboard Operations Date: Thu, 25 Jan 2024 11:14:36 +0000 Subject: [PATCH] change compose from 500 to 5000 ... maybe --- .../features/compose/components/compose_form.jsx | 4 ++-- app/models/account.rb | 2 +- app/models/account_moderation_note.rb | 2 +- app/models/report_note.rb | 2 +- spec/models/account_spec.rb | 8 ++++---- spec/validators/note_length_validator_spec.rb | 10 +++++----- spec/validators/status_length_validator_spec.rb | 12 ++++++------ 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/compose_form.jsx b/app/javascript/mastodon/features/compose/components/compose_form.jsx index 9222b2dc87703b..962310a284a6bc 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.jsx +++ b/app/javascript/mastodon/features/compose/components/compose_form.jsx @@ -100,7 +100,7 @@ class ComposeForm extends ImmutablePureComponent { const fulltext = this.getFulltextForCharacterCounting(); const isOnlyWhitespace = fulltext.length !== 0 && fulltext.trim().length === 0; - return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (isOnlyWhitespace && !anyMedia)); + return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 5000 || (isOnlyWhitespace && !anyMedia)); }; handleSubmit = (e) => { @@ -297,7 +297,7 @@ class ComposeForm extends ImmutablePureComponent {
- +
diff --git a/app/models/account.rb b/app/models/account.rb index a25ebc4aaf15d3..2564fc86bb74c1 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -100,7 +100,7 @@ class Account < ApplicationRecord validates :username, format: { with: /\A[a-z0-9_]+\z/i }, length: { maximum: 30 }, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' } validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' } validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? } - validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? } + validates :note, note_length: { maximum: 5000 }, if: -> { local? && will_save_change_to_note? } validates :fields, length: { maximum: 4 }, if: -> { local? && will_save_change_to_fields? } validates :uri, absence: true, if: :local?, on: :create validates :inbox_url, absence: true, if: :local?, on: :create diff --git a/app/models/account_moderation_note.rb b/app/models/account_moderation_note.rb index ff399bab0c0edf..be2aa4144e5416 100644 --- a/app/models/account_moderation_note.rb +++ b/app/models/account_moderation_note.rb @@ -18,5 +18,5 @@ class AccountModerationNote < ApplicationRecord scope :latest, -> { reorder('created_at DESC') } - validates :content, presence: true, length: { maximum: 500 } + validates :content, presence: true, length: { maximum: 5000 } end diff --git a/app/models/report_note.rb b/app/models/report_note.rb index 74b46027e8bb42..6a2d8a7fd60145 100644 --- a/app/models/report_note.rb +++ b/app/models/report_note.rb @@ -18,5 +18,5 @@ class ReportNote < ApplicationRecord scope :latest, -> { reorder(created_at: :desc) } - validates :content, presence: true, length: { maximum: 500 } + validates :content, presence: true, length: { maximum: 5000 } end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index fc7a43110b20e4..3019de4398789e 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -772,8 +772,8 @@ expect(account).to model_have_error_on_field(:display_name) end - it 'is invalid if the note is longer than 500 characters' do - account = Fabricate.build(:account, note: Faker::Lorem.characters(number: 501)) + it 'is invalid if the note is longer than 5000 characters' do + account = Fabricate.build(:account, note: Faker::Lorem.characters(number: 5001)) account.valid? expect(account).to model_have_error_on_field(:note) end @@ -818,8 +818,8 @@ expect(account).to_not model_have_error_on_field(:display_name) end - it 'is valid even if the note is longer than 500 characters' do - account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(number: 501)) + it 'is valid even if the note is longer than 5000 characters' do + account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(number: 5001)) account.valid? expect(account).to_not model_have_error_on_field(:note) end diff --git a/spec/validators/note_length_validator_spec.rb b/spec/validators/note_length_validator_spec.rb index 66fccad3ece3be..5068b2ddcbade5 100644 --- a/spec/validators/note_length_validator_spec.rb +++ b/spec/validators/note_length_validator_spec.rb @@ -3,11 +3,11 @@ require 'rails_helper' describe NoteLengthValidator do - subject { described_class.new(attributes: { note: true }, maximum: 500) } + subject { described_class.new(attributes: { note: true }, maximum: 5000) } describe '#validate' do - it 'adds an error when text is over 500 characters' do - text = 'a' * 520 + it 'adds an error when text is over 5000 characters' do + text = 'a' * 5020 account = instance_double(Account, note: text, errors: activemodel_errors) subject.validate_each(account, 'note', text) @@ -15,7 +15,7 @@ end it 'counts URLs as 23 characters flat' do - text = ('a' * 476) + " http://#{'b' * 30}.com/example" + text = ('a' * 4976) + " http://#{'b' * 30}.com/example" account = instance_double(Account, note: text, errors: activemodel_errors) subject.validate_each(account, 'note', text) @@ -23,7 +23,7 @@ end it 'does not count non-autolinkable URLs as 23 characters flat' do - text = ('a' * 476) + "http://#{'b' * 30}.com/example" + text = ('a' * 4976) + "http://#{'b' * 30}.com/example" account = instance_double(Account, note: text, errors: activemodel_errors) subject.validate_each(account, 'note', text) diff --git a/spec/validators/status_length_validator_spec.rb b/spec/validators/status_length_validator_spec.rb index 98ea15e03bb398..6557874d21dc70 100644 --- a/spec/validators/status_length_validator_spec.rb +++ b/spec/validators/status_length_validator_spec.rb @@ -16,20 +16,20 @@ expect(status).to_not receive(:errors) end - it 'adds an error when content warning is over 500 characters' do - status = instance_double(Status, spoiler_text: 'a' * 520, text: '', errors: activemodel_errors, local?: true, reblog?: false) + it 'adds an error when content warning is over 5000 characters' do + status = instance_double(Status, spoiler_text: 'a' * 5020, text: '', errors: activemodel_errors, local?: true, reblog?: false) subject.validate(status) expect(status.errors).to have_received(:add) end - it 'adds an error when text is over 500 characters' do - status = instance_double(Status, spoiler_text: '', text: 'a' * 520, errors: activemodel_errors, local?: true, reblog?: false) + it 'adds an error when text is over 5000 characters' do + status = instance_double(Status, spoiler_text: '', text: 'a' * 5020, errors: activemodel_errors, local?: true, reblog?: false) subject.validate(status) expect(status.errors).to have_received(:add) end - it 'adds an error when text and content warning are over 500 characters total' do - status = instance_double(Status, spoiler_text: 'a' * 250, text: 'b' * 251, errors: activemodel_errors, local?: true, reblog?: false) + it 'adds an error when text and content warning are over 5000 characters total' do + status = instance_double(Status, spoiler_text: 'a' * 2500, text: 'b' * 2501, errors: activemodel_errors, local?: true, reblog?: false) subject.validate(status) expect(status.errors).to have_received(:add) end