Skip to content

Cleanup usage of note.visible_for?(user) with the move of the logic to note_policy

Summary

We are filtering notes that should not be visible to users in multiple places throughout the code by calling note.visible_for?(user)

This comes out as a follow up suggestion from https://dev.gitlab.org/gitlab/gitlab-ee/merge_requests/1281#note_184265

Improvements

Moving this rule to the note_policy would help cleanup the in-place calls to filter notes based on user permissions

Risks

We should check and make sure this does not generate N+1 queries when checking permission/policy for each note when a batch of notes is retrieved or filtered.

Involved components

We should check models that include Noteable concern or use notes in any way.

Optional: Intended side effects

Optional: Missing test coverage