From d2ba53bc3f6582a4c66bae2bfa3360ea1a6029ef Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 24 Sep 2024 20:20:58 +1000 Subject: [PATCH] Retain 640 character limit --- .../mastodon/features/compose/components/compose_form.jsx | 4 ++-- app/serializers/rest/instance_serializer.rb | 6 +++++- spec/validators/note_length_validator_spec.rb | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/compose_form.jsx b/app/javascript/mastodon/features/compose/components/compose_form.jsx index 9222b2dc8..289730265 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) > 640 || (isOnlyWhitespace && !anyMedia)); }; handleSubmit = (e) => { @@ -297,7 +297,7 @@ class ComposeForm extends ImmutablePureComponent {
- +
diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index 14aeda946..d6baa4908 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -11,7 +11,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer attributes :domain, :title, :version, :source_url, :description, :usage, :thumbnail, :languages, :configuration, - :registrations + :registrations, :max_post_chars has_one :contact, serializer: ContactSerializer has_many :rules, serializer: REST::RuleSerializer @@ -89,6 +89,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer } end + def max_post_chars + 640 + end + private def registrations_enabled? diff --git a/spec/validators/note_length_validator_spec.rb b/spec/validators/note_length_validator_spec.rb index 66fccad3e..d3626637c 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: 640) } 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 640 characters' do + text = 'a' * 650 account = instance_double(Account, note: text, errors: activemodel_errors) subject.validate_each(account, 'note', text)