Mastodon Character Limit and Poll Options Increase for 4.5.1 on Yunohost

Increasing or Modifying the Character Limit

At our church Mastodon instance, the character limit is set to 5000 (up from the 500 originally allowed by Mastodon).

You will need to use the root account to modify these files. You can do this by SSH by issuing the following command in the terminal:

sudo su -

To customize this limit, you need to modify two files:

live/app/javascript/mastodon/features/compose/containers/compose_form_container.js – find the line that contains:

maxChars: state.getIn(['server', 'server', 'configuration', 'statuses', 'max_characters'], 500),

and change 500 to your desired value.

Next, you need to modify another file: live/app/validators/status_length_validator.rb – find the line that contains:

MAX_CHARS = 500

and change it accordingly.

To run the next command you will need to first issue this command:

sudo yunohost app shell mastodon

Once done, run the following command:

RAILS_ENV=production bundle exec rails assets:precompile

Exit the shell by typing:

exit

and restart the Mastodon services to apply the changes:

systemctl restart mastodon-web.service mastodon-sidekiq.service

Increasing or Modifying the Number of Poll Options

Edit the file live/app/validators/poll_options_validator.rb and modify the line:

MAX_OPTIONS = 4

to the value you want. There are also other customizable options in this file.

Again, once done, you will need to first issue this command:

sudo yunohost app shell mastodon

Once done, run the following command:

RAILS_ENV=production bundle exec rails assets:precompile

Exit the shell by typing:

exit

and restart the Mastodon services to apply the changes:

systemctl restart mastodon-web.service mastodon-sidekiq.service

These modifications might be overridden by subsequent Mastodon updates, so be sure to check after every update that they are still valid.

Mastodon: Permission error and increase post limit

After upgrading to Mastodon 4.3.7 on Yunohost 12, I started having an issue with images not displaying. I tried everything and finally stumbled on this solution.

It seems an older bug has creeped into the system. So, here is how I fixed the issue.

First of all, mastodon was not in the www-data group. Not sure why, but this matters for some reason. I fixed that by using the following:

sudo su -usermod -aG mastodon www-datanginx -s reload

Then to finish the permission error, I ran the following inside /var/www/mastodon:

chmod -R 750 /var/www/mastodon

Now the images display as expected. Not sure if this is a wide-spread problem, but good to know for the future if anyone else has this issue.

To increase the character limit on Mastodon, I used the following instructions. (This works on Yunohost install of Mastodon up to 4.3.8)

1. Switch to your Mastodon user

Start by logging into your server and going into the root access using:

sudo su -

Then use the following to become Mastodon user. It will not work unless you are root user first.

su - mastodon

and switch to your Mastodon installation directory. For most people, this should be /home/mastodon.

2. Edit the file compose_form_container.js

nano -w live/app/javascript/mastodon/features/compose/containers/compose_form_container.js

Look for the line

maxChars: state.getIn(['server', 'server', 'configuration', 'statuses', 'max_characters'], 500),

and change the number 500 to 2500.

3. Edit the file status_length_validator.rb

nano -w live/app/validators/status_length_validator.rb

Find the line

MAX_CHARS = 500

and change the number to 2500.

4. (Optionally, to change the poll limit) Edit the file poll_options_validator.rb

nano -w live/app/validators/poll_options_validator.rb

Find the line

MAX_OPTIONS = 4

and change the number to your desired limit.

5. Rebuild assets and restart services

You are now done editing and can rebuild the live assets. Do so with the following commands:

cd live
RAILS_ENV=production bundle exec rails assets:precompile <- DOES NOT WORK. No idea why, it just doesn't.

Afterwards, exit the mastodon user, and restart the Mastodon services as root:

systemctl restart mastodon-sidekiq
systemctl reload mastodon-web
systemctl restart mastodon-streaming

Congratulations, you should now have an increased character (and poll) limit on your instance. Have fun posting!