diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-10-16 11:26:48 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-10-16 11:26:48 +0200 |
commit | 34148d15764898579cc44ea02f439e8359e01233 (patch) | |
tree | f390aff9f58f2f26fab1c99915c9dd73babe6ea0 /lib/api | |
parent | 95f0440a7823a927ebba1557b091c12255e49ac4 (diff) | |
parent | bd3689e9e0aebe43f7c5f787e03a3bbaa8b2ef68 (diff) | |
download | gitlab-ce-34148d15764898579cc44ea02f439e8359e01233.tar.gz |
Merge branch 'master' into rs-redactor-filterrs-redactor-filter
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/merge_requests.rb | 12 | ||||
-rw-r--r-- | lib/api/repositories.rb | 13 |
2 files changed, 11 insertions, 14 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index f3a59fadf24..6eb84baf9cb 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -249,8 +249,16 @@ module API required_attributes! [:note] merge_request = user_project.merge_requests.find(params[:merge_request_id]) - note = merge_request.notes.new(note: params[:note], project_id: user_project.id) - note.author = current_user + + authorize! :create_note, merge_request + + opts = { + note: params[:note], + noteable_type: 'MergeRequest', + noteable_id: merge_request.id + } + + note = ::Notes::CreateService.new(user_project, current_user, opts).execute if note.save present note, with: Entities::MRNote diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index 2d96c9666d2..20d568cf462 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -133,7 +133,7 @@ module API authorize! :download_code, user_project begin - file_path = ArchiveRepositoryService.new( + ArchiveRepositoryService.new( user_project, params[:sha], params[:format] @@ -141,17 +141,6 @@ module API rescue not_found!('File') end - - if file_path && File.exists?(file_path) - data = File.open(file_path, 'rb').read - basename = File.basename(file_path) - header['Content-Disposition'] = "attachment; filename=\"#{basename}\"" - content_type MIME::Types.type_for(file_path).first.content_type - env['api.format'] = :binary - present data - else - redirect request.fullpath - end end # Compare two branches, tags or commits |