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:
authorJarka Kadlecova <jarka@gitlab.com>2017-08-31 13:38:32 +0300
committerJarka Kadlecova <jarka@gitlab.com>2017-09-14 15:50:32 +0300
commit073ba05d315881730de3995042cc4256c116e2c4 (patch)
tree7c8d4f56a8fe9a991b0a03f221ff7fad5332ccd5 /lib/api/notes.rb
parentb9287208523e1a5c05939fe0db038df51a9082fc (diff)
Support discussion lock in the API
Diffstat (limited to 'lib/api/notes.rb')
-rw-r--r--lib/api/notes.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index d6e7203adaf..b3db366d875 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -71,6 +71,8 @@ module API
post ":id/#{noteables_str}/:noteable_id/notes" do
noteable = find_project_noteable(noteables_str, params[:noteable_id])
+ authorize! :create_note, user_project
+
opts = {
note: params[:body],
noteable_type: noteables_str.classify,
@@ -82,6 +84,11 @@ module API
opts[:created_at] = params[:created_at]
end
+ noteable_type = opts[:noteable_type].to_s
+ noteable = Issue.find(opts[:noteable_id]) if noteable_type == 'Issue'
+ noteable = MergeRequest.find(opts[:noteable_id]) if noteable_type == 'MergeRequest'
+ authorize! :create_note, noteable if noteable
+
note = ::Notes::CreateService.new(user_project, current_user, opts).execute
if note.valid?