]> cat aescling's git repositories - mastodon.git/commitdiff
Support customizing poll option limits
authorleo60228 <leo@60228.dev>
Sat, 23 Jan 2021 18:15:27 +0000 (13:15 -0500)
committerThibG <thib@sitedethib.com>
Tue, 26 Jan 2021 13:07:31 +0000 (14:07 +0100)
.env.production.sample
app/validators/poll_validator.rb

index d51144d969043fc3584a2608e3b08450fa480860..12ca64a0662ef0ebc286a6446694c64116a3d2da 100644 (file)
@@ -254,6 +254,12 @@ MAX_PROFILE_FIELDS=4
 # Maximum allowed display name characters
 MAX_DISPLAY_NAME_CHARS=30
 
+# Maximum allowed poll options
+MAX_POLL_OPTIONS=5
+
+# Maximum allowed poll option characters
+MAX_POLL_OPTION_CHARS=100
+
 # Maximum image and video/audio upload sizes
 # Units are in bytes
 # 1048576 bytes equals 1 megabyte
index 8259a62e5641df1d9c4c9c4ef220c4f119f7bb2a..1aaf5a5d024ff1c21b4b7e59099b0b0ac4a8d511 100644 (file)
@@ -1,8 +1,8 @@
 # frozen_string_literal: true
 
 class PollValidator < ActiveModel::Validator
-  MAX_OPTIONS      = 5
-  MAX_OPTION_CHARS = 100
+  MAX_OPTIONS      = (ENV['MAX_POLL_OPTIONS'] || 5).to_i
+  MAX_OPTION_CHARS = (ENV['MAX_POLL_OPTION_CHARS'] || 100).to_i
   MAX_EXPIRATION   = 1.month.freeze
   MIN_EXPIRATION   = 5.minutes.freeze