summaryrefslogtreecommitdiff
path: root/app/controllers/projects/issues_controller.rb
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 /app/controllers/projects/issues_controller.rb
parent99ba5d0d5097e3170747d17261bb3b9f60aa49fb (diff)
downloadgitlab-ce-09338e397c95b51a7c515524d7f3eb5f4eed2fb4.tar.gz
Remove cross-references user cannot see from issue discussions JSON
Diffstat (limited to 'app/controllers/projects/issues_controller.rb')
-rw-r--r--app/controllers/projects/issues_controller.rb8
1 files changed, 5 insertions, 3 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