From 200dd90a9fe716d5a1da322f21eb89e64eb44180 Mon Sep 17 00:00:00 2001 From: fef Date: Mon, 28 Nov 2022 23:16:56 +0000 Subject: [PATCH] make status reaction count limit configurable --- .env.production.sample | 3 +++ app/validators/status_reaction_validator.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.env.production.sample b/.env.production.sample index 7bcce0f7e5..a2f5bdd123 100644 --- a/.env.production.sample +++ b/.env.production.sample @@ -269,6 +269,9 @@ MAX_POLL_OPTIONS=5 # Maximum allowed poll option characters MAX_POLL_OPTION_CHARS=100 +# Maximum number of emoji reactions per toot and user (minimum 1) +MAX_STATUS_REACTIONS=8 + # Maximum image and video/audio upload sizes # Units are in bytes # 1048576 bytes equals 1 megabyte diff --git a/app/validators/status_reaction_validator.rb b/app/validators/status_reaction_validator.rb index 7c1c6983bb..113e9342ba 100644 --- a/app/validators/status_reaction_validator.rb +++ b/app/validators/status_reaction_validator.rb @@ -3,7 +3,7 @@ class StatusReactionValidator < ActiveModel::Validator SUPPORTED_EMOJIS = Oj.load_file(Rails.root.join('app', 'javascript', 'mastodon', 'features', 'emoji', 'emoji_map.json').to_s).keys.freeze - LIMIT = 8 + LIMIT = [1, (ENV['MAX_STATUS_REACTIONS'] || 1).to_i].max def validate(reaction) return if reaction.name.blank?