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:
@@ -2,9 +2,9 @@ module Youtube
|
||||
class BroadcastService
|
||||
class Error < StandardError; end
|
||||
|
||||
def initialize(team)
|
||||
def initialize(team, youtube_channel: nil)
|
||||
@team = team
|
||||
@resolver = CredentialResolver.new(team)
|
||||
@resolver = CredentialResolver.new(team, channel: youtube_channel)
|
||||
@credential = @resolver.resolve
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user