Skip to content

Commit

Permalink
change compose from 500 to 5000 ... maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
flipboardops committed Jan 25, 2024
1 parent d52de78 commit 5516322
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -297,7 +297,7 @@ class ComposeForm extends ImmutablePureComponent {
</div>

<div className='character-counter__wrapper'>
<CharacterCounter max={500} text={this.getFulltextForCharacterCounting()} />
<CharacterCounter max={5000} text={this.getFulltextForCharacterCounting()} />
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/account_moderation_note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/models/report_note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions spec/models/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions spec/validators/note_length_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
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)
expect(account.errors).to have_received(:add)
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)
expect(account.errors).to_not have_received(:add)
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)
Expand Down
12 changes: 6 additions & 6 deletions spec/validators/status_length_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5516322

Please sign in to comment.