[Users] Add a size limit to the body of feedback

This commit is contained in:
Earlopain 2023-09-12 19:09:17 +02:00
parent 056ce3e7aa
commit 7c7c2f1870
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
3 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,7 @@ class UserFeedback < ApplicationRecord
belongs_to_creator
validates :body, :category, presence: true
validates :category, inclusion: { in: %w[positive negative neutral] }
validates :body, length: { minimum: 1, maximum: Danbooru.config.user_feedback_max_size }
validate :creator_is_moderator, on: :create
validate :user_is_not_creator
after_save :create_dmail

View File

@ -6,6 +6,6 @@
<% unless user_feedback.new_record? %>
<%= f.input :send_update_dmail, label: "Send update DMail", as: :boolean %>
<% end %>
<%= f.input :body, as: :dtext %>
<%= f.input :body, as: :dtext, limit: Danbooru.config.user_feedback_max_size %>
<%= f.button :submit, "Submit" %>
<% end %>

View File

@ -329,6 +329,10 @@ module Danbooru
250_000
end
def user_feedback_max_size
20_000
end
def discord_site
end