diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-02-10 21:07:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-10 21:07:48 +0100 |
commit | 776e337b8d2aa66440bc4565617b5440ca781e1a (patch) | |
tree | d9d30c63622c58a343cea58a3509337630491609 /app/models/report.rb | |
parent | d602c92b310545eb733a58caed49717341abe27c (diff) | |
parent | 642b5a621acdcae091f8bdb0f367018309616f71 (diff) |
Merge pull request #1683 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models/report.rb')
-rw-r--r-- | app/models/report.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/report.rb b/app/models/report.rb index ceb15133b..3dd8a6fdd 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -39,6 +39,9 @@ class Report < ApplicationRecord scope :with_accounts, -> { includes([:account, :target_account, :action_taken_by_account, :assigned_account].index_with({ user: [:invite_request, :invite] })) } validates :comment, length: { maximum: 1_000 } + validates :rule_ids, absence: true, unless: :violation? + + validate :validate_rule_ids enum category: { other: 0, @@ -122,4 +125,10 @@ class Report < ApplicationRecord def set_uri self.uri = ActivityPub::TagManager.instance.generate_uri_for(self) if uri.nil? && account.local? end + + def validate_rule_ids + return unless violation? + + errors.add(:rule_ids, I18n.t('reports.errors.invalid_rules')) unless rules.size == rule_ids.size + end end |