Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-12 00:05:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-12 00:05:59 +0300
commitac062237da66db75b22f5dab2cc5766ee62a44d1 (patch)
treeae5a7eb248ddbf5c8c32c29a269127a936356364 /app
parent0dfbcd8f8b1587a7e10eb79940a8dc13bd72c664 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/noteable.rb2
-rw-r--r--app/models/note.rb8
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')