diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-12 00:05:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-12 00:05:59 +0300 |
commit | ac062237da66db75b22f5dab2cc5766ee62a44d1 (patch) | |
tree | ae5a7eb248ddbf5c8c32c29a269127a936356364 /app | |
parent | 0dfbcd8f8b1587a7e10eb79940a8dc13bd72c664 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/noteable.rb | 2 | ||||
-rw-r--r-- | app/models/note.rb | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb index 6caa23ef9b7..3065e0ba6c5 100644 --- a/app/models/concerns/noteable.rb +++ b/app/models/concerns/noteable.rb @@ -7,6 +7,8 @@ module Noteable # avoiding n+1 queries and improving performance. NoteableMeta = Struct.new(:user_notes_count) + MAX_NOTES_LIMIT = 5_000 + class_methods do # `Noteable` class names that support replying to individual notes. def replyable_types diff --git a/app/models/note.rb b/app/models/note.rb index edc4a332581..34736482387 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -104,6 +104,8 @@ class Note < ApplicationRecord end end + validate :does_not_exceed_notes_limit?, on: :create, unless: [:system?, :importing?] + # @deprecated attachments are handler by the MarkdownUploader mount_uploader :attachment, AttachmentUploader @@ -525,6 +527,12 @@ class Note < ApplicationRecord system_note_metadata&.cross_reference_types&.include?(system_note_metadata&.action) end + + def does_not_exceed_notes_limit? + return unless noteable + + errors.add(:base, _('Maximum number of comments exceeded')) if noteable.notes.count >= Noteable::MAX_NOTES_LIMIT + end end Note.prepend_if_ee('EE::Note') |