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/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-05-06 13:59:02 +0300
committerSean McGivern <sean@gitlab.com>2019-05-06 21:48:32 +0300
commit00af4c6d6a8ea2997f57d6e872992b9fc72839d8 (patch)
treebab3f5402cb060788713c62040a483fa0cfddda1 /lib
parent0a7c9660e61ad7af24fd3cb93097bf283e5c9b34 (diff)
Allow replying to an individual note in the API
If you can do this in the UI, you should be able to do it in the API. If a discussion is not a single note discussion, or it is replyable, you can reply to it.
Diffstat (limited to 'lib')
-rw-r--r--lib/api/discussions.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/api/discussions.rb b/lib/api/discussions.rb
index 8afe6dda414..5928ee1657b 100644
--- a/lib/api/discussions.rb
+++ b/lib/api/discussions.rb
@@ -134,9 +134,13 @@ module API
post ":id/#{noteables_path}/:noteable_id/discussions/:discussion_id/notes" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
notes = readable_discussion_notes(noteable, params[:discussion_id])
+ first_note = notes.first
break not_found!("Discussion") if notes.empty?
- break bad_request!("Discussion is an individual note.") unless notes.first.part_of_discussion?
+
+ unless first_note.part_of_discussion? || first_note.to_discussion.can_convert_to_discussion?
+ break bad_request!("Discussion can not be replied to.")
+ end
opts = {
note: params[:body],