Commit 09338e39 authored by Douwe Maan's avatar Douwe Maan
Browse files

Remove cross-references user cannot see from issue discussions JSON

parent 3f82f4346646
......@@ -97,9 +97,11 @@ def show
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
......
......@@ -38,7 +38,7 @@ def discussions
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment