From e9bbb063f95a47f5d11c4e3a08ae7d2d33ff2871 Mon Sep 17 00:00:00 2001 From: AndriiMysko Date: Fri, 14 Oct 2022 11:20:31 +0300 Subject: [PATCH] Create log token for public repos with log access enabled --- lib/travis/api/v3/models/log.rb | 4 ++++ lib/travis/api/v3/renderer/log.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/v3/models/log.rb b/lib/travis/api/v3/models/log.rb index 5f40f89c4d..2989d63124 100644 --- a/lib/travis/api/v3/models/log.rb +++ b/lib/travis/api/v3/models/log.rb @@ -27,6 +27,10 @@ def repository_private? job.repository.private? end + def repository + @repository ||= Travis::API::V3::Models::Repository.find(job.repository.id) + end + private def archived_log_part diff --git a/lib/travis/api/v3/renderer/log.rb b/lib/travis/api/v3/renderer/log.rb index 99f94d8e7c..459f3e7f1e 100644 --- a/lib/travis/api/v3/renderer/log.rb +++ b/lib/travis/api/v3/renderer/log.rb @@ -25,7 +25,7 @@ def render(representation) if raw_log_href !~ /^\/v3/ raw_log_href = "/v3#{raw_log_href}" end - if enterprise? || model.repository_private? + if enterprise? || model.repository_private? || model.repository.user_settings.job_log_access_based_limit token = LogToken.create(model.job, access_control&.user&.id) raw_log_href += "?log.token=#{token}" end