customizations

code enhancements on mountains.social

These code changes have been tested without issues on Mastodon versions 4.3+

Increase maximum number of characters for a post

The maximum number of characters for a post on a Mastodon instance is 500. This can be quite limiting, so the number of characters have been increased to 1000.

Please note that a URL in a post only counts for 23 characters, regardless of the length of the URL. This means as well, that no URL shorteners are needed (which often have the downside of being privacy invasive).

1. Implement the enhancement

As user mastodon:

cd ~/live

cp -p app/validators/status_length_validator.rb app/validators/status_length_validator.rb.orig  

sed -i 's/MAX_CHARS = 500/MAX_CHARS = 1000/g' app/validators/status_length_validator.rb

RAILS_ENV=production bundle exec rails assets:precompile && echo "pass" || echo "fail"

As user root:

service mastodon-web reload

As the code now has been changed, it is wise to revert the code changes (see below) before performing Mastodon upgrades. The upgrade will therefore run without issues. After the upgrade, the enhancement needs to be implemented again.

2. Revert the enhancement

As user mastodon:

cd ~/live

cp -p app/validators/status_length_validator.rb.orig app/validators/status_length_validator.rb

RAILS_ENV=production bundle exec rails assets:precompile && echo "pass" || echo "fail"

As user root:

service mastodon-web reload