By default, Mastodon only gives you four options for your polls. Increasing this number is a frequently requested feature ¹ ² ³ ⁴, and some Mastodon variations already support it.
If you run your own Mastodon server, adding more options yourself is pretty easy. Here’s a quick walkthrough, courtesy of @virtulis. (The original instructions here also show how to lift the limits on the length of posts, account notes, and poll option descriptions.)
Before you make any changes, note that upgrading to a newer version of Mastodon will wipe your edits, so you will have to reapply them.
This hasn’t been my case after making similar changes in the past, but @virtulis also pointed out running into issues with conflicting code, so that might be something to be aware of.
If you prefer not to make these changes, or are unable to, I also made a little tool that lets me link to the poll results and thus free me from having to add a sometimes necessary “View results” option, check it out here.
Now, onto the changes. Edit the file app/javascript/mastodon/features/compose/components/poll_form.jsx
.
<button type='button' disabled={options.size >= 4} className='button button-secondary' onClick={this.handleAddOption}><Icon id='plus' /> <FormattedMessage {...messages.add_option} /></button>
Change options.size >= 4
to a number of options you would like to have available.
Next, change the value of MAX_OPTIONS
inside app/validators/poll_validator.rb
to the same number.
class PollValidator < ActiveModel::Validator
MAX_OPTIONS = 4
MAX_OPTION_CHARS = 50
MAX_EXPIRATION = 1.month.freeze
MIN_EXPIRATION = 5.minutes.freeze
Next, recompile the asset files. As per the official instructions:
RAILS_ENV=production bundle exec rails assets:precompile
And finally, restart the server.
systemctl reload mastodon-web
And there you have it. Enjoy your longer polls!
If your fediverse instance were to shut down today, where would you go?