App: scelta canale YouTube MLTV/società, privacy e condivisione link.

Premium Full può forzare il canale piattaforma; visibilità non in elenco o privato;
share_url unificato per Match Live TV e YouTube.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-02 22:52:07 +02:00
parent 6ac4db98bb
commit 1fb5cd5aa2
14 changed files with 362 additions and 68 deletions

View File

@@ -1,25 +1,61 @@
module Youtube
class CredentialResolver
def self.for_team(team)
new(team).resolve
VALID_CHANNELS = %w[platform team].freeze
def self.for_team(team, channel: nil)
new(team, channel: channel).resolve
end
def initialize(team)
def initialize(team, channel: nil)
@team = team
@status = TeamStatus.new(team)
@mode = team.entitlements.plan.youtube_mode
@channel = channel.to_s.presence
@channel = nil unless VALID_CHANNELS.include?(@channel)
@ent = team.entitlements
@mode = @ent.plan.youtube_mode
end
def resolve
if @status.uses_platform_channel?
PlatformCredential.new
elsif @mode == "team"
case effective_channel
when :platform
PlatformCredential.configured? ? PlatformCredential.new : nil
when :team
@team.youtube_credential
end
end
def uses_platform_channel?
@status.uses_platform_channel?
effective_channel == :platform
end
def platform_available?
@ent.youtube_enabled? && PlatformCredential.configured?
end
def team_channel_available?
@ent.youtube_enabled? && @ent.premium_full? && @mode == "team" && @team.youtube_credential.present?
end
def effective_channel
if @channel == "platform"
return :platform if platform_available?
elsif @channel == "team"
return :team if team_channel_available?
end
auto_channel
end
private
def auto_channel
if @mode == "matchlivetv_light"
return :platform if platform_available?
elsif @mode == "team"
return :team if team_channel_available?
return :platform if platform_available?
end
nil
end
end
end