summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-09-01 14:03:57 +0200
committerJarka Kadlecova <jarka@gitlab.com>2017-09-14 14:50:32 +0200
commit994e7d135947ca162c147c5e0992a0190de22808 (patch)
treecd9ea4d93269c8597541f8c59e89a83ca2b56d2b /lib/api
parent2b82f907abf2074ac332531d6142893d081f44b9 (diff)
downloadgitlab-ce-994e7d135947ca162c147c5e0992a0190de22808.tar.gz
Create system notes for MR too, improve doc + clean up code
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/issues.rb2
-rw-r--r--lib/api/notes.rb9
2 files changed, 3 insertions, 8 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index 88b592083db..0df41dcc903 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -48,7 +48,7 @@ module API
optional :labels, type: String, desc: 'Comma-separated list of label names'
optional :due_date, type: String, desc: 'Date string in the format YEAR-MONTH-DAY'
optional :confidential, type: Boolean, desc: 'Boolean parameter if the issue should be confidential'
- optional :discussion_locked, type: Boolean, desc: "Boolean parameter if the issue's discussion should be locked"
+ optional :discussion_locked, type: Boolean, desc: " Boolean parameter indicating if the issue's discussion is locked"
end
params :issue_params do
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index b3db366d875..0b9ab4eeb05 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -71,8 +71,6 @@ 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,
@@ -80,15 +78,12 @@ module API
}
if can?(current_user, noteable_read_ability_name(noteable), noteable)
+ authorize! :create_note, noteable
+
if params[:created_at] && (current_user.admin? || user_project.owner == current_user)
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?