Remove cross-references user cannot see from issue discussions JSON
This commit is contained in:
parent
99ba5d0d50
commit
09338e397c
2 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue