Remove cross-references user cannot see from issue discussions JSON
This commit is contained in:
parent
99ba5d0d50
commit
09338e397c
|
|
@ -97,9 +97,11 @@ class Projects::IssuesController < Projects::ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def discussions
|
def discussions
|
||||||
@discussions = @issue.discussions
|
notes = @issue.notes.inc_relations_for_view.includes(:noteable).fresh.to_a
|
||||||
@discussions.reject! { |d| d.individual_note? && d.first_note.cross_reference_not_visible_for?(current_user) }
|
notes.reject! { |n| n.cross_reference_not_visible_for?(current_user) }
|
||||||
prepare_notes_for_rendering(@discussions.flat_map(&:notes))
|
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)
|
render json: DiscussionSerializer.new(project: @project, noteable: @issue, current_user: current_user).represent(@discussions)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ module Noteable
|
||||||
|
|
||||||
def grouped_diff_discussions(*args)
|
def grouped_diff_discussions(*args)
|
||||||
# Doesn't use `discussion_notes`, because this may include commit diff notes
|
# 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)
|
notes.inc_relations_for_view.grouped_diff_discussions(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue