flags/appeals: limit flag/appeal reasons to 140 characters.

This commit is contained in:
evazion
2020-04-17 00:13:06 -05:00
parent e848011080
commit 99e7e359af
2 changed files with 2 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ class PostAppeal < ApplicationRecord
belongs_to :creator, :class_name => "User"
belongs_to :post
validates_presence_of :reason
validates :reason, presence: true, length: { in: 1..140 }
validate :validate_post_is_inactive
validate :validate_creator_is_not_limited
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post"

View File

@@ -10,7 +10,7 @@ class PostFlag < ApplicationRecord
belongs_to :creator, class_name: "User"
belongs_to :post
validates_presence_of :reason
validates :reason, presence: true, length: { in: 1..140 }
validate :validate_creator_is_not_limited, on: :create
validate :validate_post
validates_uniqueness_of :creator_id, :scope => :post_id, :on => :create, :unless => :is_deletion, :message => "have already flagged this post"