diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-03 09:54:12 +0200 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-03 09:54:12 +0200 |
commit | d39b3d4b8d2d4c5ded46182a5353c68a8f5bb5cd (patch) | |
tree | e8f2fac760b252928ff23074dea9d1f209838a33 /lib/api/notes.rb | |
parent | dcb67951a817db262ddcd3b777fafc4e1995fc04 (diff) | |
parent | 2c9568edeea7d95b6e4ec3c23cdc1c027bf86d5f (diff) | |
download | gitlab-ce-d39b3d4b8d2d4c5ded46182a5353c68a8f5bb5cd.tar.gz |
Merge branch 'master' into feature/runner-per-group
Diffstat (limited to 'lib/api/notes.rb')
-rw-r--r-- | lib/api/notes.rb | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/lib/api/notes.rb b/lib/api/notes.rb index 69f1df6b341..39923e6d5b5 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -31,23 +31,19 @@ module API get ":id/#{noteables_str}/:noteable_id/notes" do noteable = find_noteable(parent_type, noteables_str, params[:noteable_id]) - if can?(current_user, noteable_read_ability_name(noteable), noteable) - # We exclude notes that are cross-references and that cannot be viewed - # by the current user. By doing this exclusion at this level and not - # at the DB query level (which we cannot in that case), the current - # page can have less elements than :per_page even if - # there's more than one page. - raw_notes = noteable.notes.with_metadata.reorder(params[:order_by] => params[:sort]) - notes = - # paginate() only works with a relation. This could lead to a - # mismatch between the pagination headers info and the actual notes - # array returned, but this is really a edge-case. - paginate(raw_notes) - .reject { |n| n.cross_reference_not_visible_for?(current_user) } - present notes, with: Entities::Note - else - not_found!("Notes") - end + # We exclude notes that are cross-references and that cannot be viewed + # by the current user. By doing this exclusion at this level and not + # at the DB query level (which we cannot in that case), the current + # page can have less elements than :per_page even if + # there's more than one page. + raw_notes = noteable.notes.with_metadata.reorder(params[:order_by] => params[:sort]) + notes = + # paginate() only works with a relation. This could lead to a + # mismatch between the pagination headers info and the actual notes + # array returned, but this is really a edge-case. + paginate(raw_notes) + .reject { |n| n.cross_reference_not_visible_for?(current_user) } + present notes, with: Entities::Note end desc "Get a single #{noteable_type.to_s.downcase} note" do |