summaryrefslogtreecommitdiff
path: root/app/serializers/ci/downloadable_artifact_entity.rb
blob: 1f3885f0715059390d501a20e56f82665c74e384 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

module Ci
  class DownloadableArtifactEntity < Grape::Entity
    include RequestAwareEntity

    expose :artifacts do |pipeline, options|
      artifacts = pipeline.downloadable_artifacts

      if Feature.enabled?(:non_public_artifacts)
        artifacts = artifacts.select { |artifact| can?(request.current_user, :read_job_artifacts, artifact.job) }
      end

      BuildArtifactEntity.represent(artifacts, options.merge(project: pipeline.project))
    end
  end
end