summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-08-17 18:58:28 +0200
committerDouwe Maan <douwe@selenight.nl>2017-08-17 19:18:20 +0200
commit09338e397c95b51a7c515524d7f3eb5f4eed2fb4 (patch)
treed97d8e76b74df9575b3e0200140255fa8dedb458
parent99ba5d0d5097e3170747d17261bb3b9f60aa49fb (diff)
downloadgitlab-ce-09338e397c95b51a7c515524d7f3eb5f4eed2fb4.tar.gz
Remove cross-references user cannot see from issue discussions JSON
-rw-r--r--app/controllers/projects/issues_controller.rb8
-rw-r--r--app/models/concerns/noteable.rb2
2 files changed, 6 insertions, 4 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index dfde6a23c07..e0fb070a841 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -97,9 +97,11 @@ class Projects::IssuesController < Projects::ApplicationController
end
def discussions
- @discussions = @issue.discussions
- @discussions.reject! { |d| d.individual_note? && d.first_note.cross_reference_not_visible_for?(current_user) }
- prepare_notes_for_rendering(@discussions.flat_map(&:notes))
+ notes = @issue.notes.inc_relations_for_view.includes(:noteable).fresh.to_a
+ notes.reject! { |n| n.cross_reference_not_visible_for?(current_user) }
+ prepare_notes_for_rendering(notes)
+
+ @discussions = Discussion.build_collection(notes, @issue)
render json: DiscussionSerializer.new(project: @project, noteable: @issue, current_user: current_user).represent(@discussions)
end
diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb
index c7bdc997eca..a30deffec7b 100644
--- a/app/models/concerns/noteable.rb
+++ b/app/models/concerns/noteable.rb
@@ -38,7 +38,7 @@ module Noteable
def grouped_diff_discussions(*args)
# Doesn't use `discussion_notes`, because this may include commit diff notes
- # besides MR diff notes, that we do no want to display on the MR Changes tab.
+ # besides MR diff notes, that we do not want to display on the MR Changes tab.
notes.inc_relations_for_view.grouped_diff_discussions(*args)
end