debian-mirror-gitlab/lib/banzai/reference_parser/project_parser.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
804 B
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
module Banzai
module ReferenceParser
class ProjectParser < BaseParser
include Gitlab::Utils::StrongMemoize
self.reference_type = :project
def references_relation
Project
end
private
# Returns an Array of Project ids that can be read by the given user.
#
# user - The User for which to check the projects
def readable_project_ids_for(user)
@project_ids_by_user ||= {}
@project_ids_by_user[user] ||=
2021-06-08 01:23:25 +05:30
Project.public_or_visible_to_user(user).where(projects: { id: @projects_for_nodes.values.map(&:id) }).pluck(:id)
2018-11-20 20:47:30 +05:30
end
def can_read_reference?(user, ref_project, node)
readable_project_ids_for(user).include?(ref_project.try(:id))
end
end
end
end