提交 c9b4dc67 编写于 作者: P Patrick Derichs

Filter out old system notes for epics

上级 20920f80
...@@ -110,7 +110,7 @@ module IssuableActions ...@@ -110,7 +110,7 @@ module IssuableActions
end end
notes = prepare_notes_for_rendering(notes) notes = prepare_notes_for_rendering(notes)
notes = notes.reject { |n| n.cross_reference_not_visible_for?(current_user) } notes = notes.select { |n| n.visible_for?(current_user) }
discussions = Discussion.build_collection(notes, issuable) discussions = Discussion.build_collection(notes, issuable)
......
...@@ -29,7 +29,7 @@ module NotesActions ...@@ -29,7 +29,7 @@ module NotesActions
end end
notes = prepare_notes_for_rendering(notes) notes = prepare_notes_for_rendering(notes)
notes = notes.reject { |n| n.cross_reference_not_visible_for?(current_user) } notes = notes.select { |n| n.visible_for?(current_user) }
notes_json[:notes] = notes_json[:notes] =
if use_note_serializer? if use_note_serializer?
......
...@@ -331,6 +331,10 @@ class Note < ApplicationRecord ...@@ -331,6 +331,10 @@ class Note < ApplicationRecord
cross_reference? && !all_referenced_mentionables_allowed?(user) cross_reference? && !all_referenced_mentionables_allowed?(user)
end end
def visible_for?(user)
!cross_reference_not_visible_for?(user)
end
def award_emoji? def award_emoji?
can_be_award_emoji? && contains_emoji_only? can_be_award_emoji? && contains_emoji_only?
end end
......
---
title: Filter out old system notes for epics in notes api endpoint response
merge_request:
author:
type: security
...@@ -239,7 +239,7 @@ module API ...@@ -239,7 +239,7 @@ module API
# because notes are redacted if they point to projects that # because notes are redacted if they point to projects that
# cannot be accessed by the user. # cannot be accessed by the user.
notes = prepare_notes_for_rendering(notes) notes = prepare_notes_for_rendering(notes)
notes.reject { |n| n.cross_reference_not_visible_for?(current_user) } notes.select { |n| n.visible_for?(current_user) }
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
end end
......
...@@ -12,7 +12,7 @@ module API ...@@ -12,7 +12,7 @@ module API
end end
def update_note(noteable, note_id) def update_note(noteable, note_id)
note = noteable.notes.find(params[:note_id]) note = noteable.notes.find(note_id)
authorize! :admin_note, note authorize! :admin_note, note
...@@ -61,8 +61,8 @@ module API ...@@ -61,8 +61,8 @@ module API
end end
def get_note(noteable, note_id) def get_note(noteable, note_id)
note = noteable.notes.with_metadata.find(params[:note_id]) note = noteable.notes.with_metadata.find(note_id)
can_read_note = !note.cross_reference_not_visible_for?(current_user) can_read_note = note.visible_for?(current_user)
if can_read_note if can_read_note
present note, with: Entities::Note present note, with: Entities::Note
......
...@@ -42,7 +42,7 @@ module API ...@@ -42,7 +42,7 @@ module API
# array returned, but this is really a edge-case. # array returned, but this is really a edge-case.
notes = paginate(raw_notes) notes = paginate(raw_notes)
notes = prepare_notes_for_rendering(notes) notes = prepare_notes_for_rendering(notes)
notes = notes.reject { |n| n.cross_reference_not_visible_for?(current_user) } notes = notes.select { |note| note.visible_for?(current_user) }
present notes, with: Entities::Note present notes, with: Entities::Note
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册