Posted on

Table of Contents

Introduction

Since I run disobey.net and dislike the max character limitations in posts (toots) and in my profile bio, I've documented the changes i've made to increase the limits from 500 to 2000. I self-host Mastodon on a standalone server built from source, not Docker.

  • Mastodon v4.2.x needs steps 1 - 4 below.
  • Mastodon v4.3.x needs steps 1, 3 and 4 only.

Mastodon changes

All file editing below is from my Mastodon root directory, "~/live". Pay attention to any of my lines below that specify "2000", it used to say the default "500":

Post increase

Step 1

vim app/validators/status_length_validator.rb

class StatusLengthValidator < ActiveModel::Validator
  MAX_CHARS = 2000
  URL_PLACEHOLDER_CHARS = 23
  URL_PLACEHOLDER = 'x' * 23

Step 2

Step 2 is not needed in Mastodon 4.3.x! Only steps 1, 3 and 4 are needed. Skip to step 3.

vim app/javascript/mastodon/features/compose/components/compose_form.jsx

  canSubmit = () => {
    const { isSubmitting, isChangingUpload, isUploading, anyMedia } = this.props;
    const fulltext = this.getFulltextForCharacterCounting();
    const isOnlyWhitespace = fulltext.length !== 0 && fulltext.trim().length === 0;

    return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 2000 || (isOnlyWhitespace && !anyMedia));
  };

and in the same compose_form.jsx file:

            <div className='character-counter__wrapper'>
              <CharacterCounter max={2000} text={this.getFulltextForCharacterCounting()} />
            </div>
          </div>
        </div>

Profile bio increase

Step 3

vim app/views/settings/profiles/show.html.haml

  .fields-row
    .fields-row__column.fields-row__column-6
      .fields-group
        = f.input :display_name, wrapper: :with_block_label, input_html: { maxlength: 30, data: { default: @account.username } }

      .fields-group
        = f.input :note, wrapper: :with_block_label, input_html: { maxlength: 2000 }

Step 4

vim app/models/account.rb

  # Local user validations
....
  validates :note, note_length: { maximum: 2000 }, if: -> { local? && will_save_change_to_note? }
....

Finally

As the mastodon user:

RAILS_ENV=production bundle exec rails assets:precompile

As root user:

systemctl restart mastodon-web mastodon-sidekiq mastodon-streaming