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
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/notes/create_service.rb')
-rw-r--r--app/services/notes/create_service.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb
index 4074b1d1182..b7e6a50fa5c 100644
--- a/app/services/notes/create_service.rb
+++ b/app/services/notes/create_service.rb
@@ -88,8 +88,13 @@ module Notes
return if quick_actions_service.commands_executed_count.to_i == 0
if update_params.present?
- quick_actions_service.apply_updates(update_params, note)
- note.commands_changes = update_params
+ if check_for_reviewer_validity(message, update_params)
+ quick_actions_service.apply_updates(update_params, note)
+ note.commands_changes = update_params
+ else
+ message = "Reviewers #{MergeRequest.max_number_of_assignees_or_reviewers_message}"
+ note.errors.add(:validation, message)
+ end
end
# We must add the error after we call #save because errors are reset
@@ -109,6 +114,18 @@ module Notes
}
end
+ def check_for_reviewer_validity(message, update_params)
+ return true unless Feature.enabled?(:limit_reviewer_and_assignee_size)
+
+ if update_params.key?(:reviewer_ids)
+ possible_reviewers = update_params[:reviewer_ids]&.uniq&.size
+
+ return false if possible_reviewers > MergeRequest::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS
+ end
+
+ true
+ end
+
def track_event(note, user)
track_note_creation_usage_for_issues(note) if note.for_issue?
track_note_creation_usage_for_merge_requests(note) if note.for_merge_request?
@@ -130,7 +147,8 @@ module Notes
end
def track_note_creation_usage_for_issues(note)
- Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_added_action(author: note.author)
+ Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_added_action(author: note.author,
+ project: project)
end
def track_note_creation_usage_for_merge_requests(note)