about summary refs log tree commit diff
diff options
context:
space:
mode:
authorchr <chr@cybre.space>2019-06-23 13:58:33 -0700
committerchr <chr@cybre.space>2021-03-01 21:29:33 -0800
commitb75a99e16b5370a71889be607389676388377a3a (patch)
treee2bfda272a951c65d591c610383467473bec15d6
parent633d175146d6acaf2cc4bfbfcfdee4c85ef20ed1 (diff)
Feature: 1024-character posts in server and client
-rw-r--r--app/javascript/mastodon/features/compose/components/compose_form.js15
-rw-r--r--app/serializers/rest/instance_serializer.rb6
-rw-r--r--app/validators/status_length_validator.rb2
3 files changed, 20 insertions, 3 deletions
diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js
index 8af806ec4..137a30506 100644
--- a/app/javascript/mastodon/features/compose/components/compose_form.js
+++ b/app/javascript/mastodon/features/compose/components/compose_form.js
@@ -96,7 +96,15 @@ class ComposeForm extends ImmutablePureComponent {
       this.props.onChange(this.autosuggestTextarea.textarea.value);
     }
 
+<<<<<<< HEAD
     if (!this.canSubmit()) {
+=======
+    // Submit disabled:
+    const { isSubmitting, isChangingUpload, isUploading, anyMedia } = this.props;
+    const fulltext = [this.props.spoilerText, countableText(this.props.text)].join('');
+
+    if (isSubmitting || isUploading || isChangingUpload || length(fulltext) > 1024 || (fulltext.length !== 0 && fulltext.trim().length === 0 && !anyMedia)) {
+>>>>>>> Feature: 1024-character posts in server and client
       return;
     }
 
@@ -188,6 +196,11 @@ class ComposeForm extends ImmutablePureComponent {
   render () {
     const { intl, onPaste, showSearch } = this.props;
     const disabled = this.props.isSubmitting;
+<<<<<<< HEAD
+=======
+    const text     = [this.props.spoilerText, countableText(this.props.text)].join('');
+    const disabledButton = disabled || this.props.isUploading || this.props.isChangingUpload || length(text) > 1024 || (text.length !== 0 && text.trim().length === 0 && !anyMedia);
+>>>>>>> Feature: 1024-character posts in server and client
     let publishText = '';
 
     if (this.props.privacy === 'private' || this.props.privacy === 'direct') {
@@ -249,7 +262,7 @@ class ComposeForm extends ImmutablePureComponent {
             <PrivacyDropdownContainer />
             <SpoilerButtonContainer />
           </div>
-          <div className='character-counter__wrapper'><CharacterCounter max={500} text={this.getFulltextForCharacterCounting()} /></div>
+          <div className='character-counter__wrapper'><CharacterCounter max={1024} text={this.getFulltextForCharacterCounting()} /></div>
         </div>
 
         <div className='compose-form__publish'>
diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb
index b388e448e..e2aa35c4e 100644
--- a/app/serializers/rest/instance_serializer.rb
+++ b/app/serializers/rest/instance_serializer.rb
@@ -5,7 +5,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
 
   attributes :uri, :title, :short_description, :description, :email,
              :version, :urls, :stats, :thumbnail,
-             :languages, :registrations, :approval_required, :invites_enabled
+             :languages, :registrations, :approval_required, :invites_enabled, :max_toot_chars
 
   has_one :contact_account, serializer: REST::AccountSerializer
 
@@ -39,6 +39,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer
     instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('media/images/preview.jpg')
   end
 
+  def max_toot_chars
+    StatusLengthValidator::MAX_CHARS
+  end
+
   def stats
     {
       user_count: instance_presenter.user_count,
diff --git a/app/validators/status_length_validator.rb b/app/validators/status_length_validator.rb
index 93bae2fa8..e67b794ab 100644
--- a/app/validators/status_length_validator.rb
+++ b/app/validators/status_length_validator.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 class StatusLengthValidator < ActiveModel::Validator
-  MAX_CHARS = 500
+  MAX_CHARS = 1024
 
   def validate(status)
     return unless status.local? && !status.reblog?