Visibilità pubblico/link-only su tutte le piattaforme di streaming.
Default pubblico; opzione unica privato/non in elenco per Match Live TV, YouTube piattaforma e canale società. Elenco dirette solo sessioni pubbliche. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,6 +11,7 @@ module Public
|
||||
|
||||
sessions = StreamSession
|
||||
.broadcasting
|
||||
.publicly_listed
|
||||
.includes(:score_state, match: { team: :club })
|
||||
sessions = sessions.joins(:match).where(matches: { team_id: team_ids }) if team_ids.present?
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ class StreamSession < ApplicationRecord
|
||||
|
||||
PLATFORMS = %w[matchlivetv youtube facebook twitch].freeze
|
||||
STATUSES = %w[idle connecting live reconnecting paused ended error].freeze
|
||||
PRIVACY_STATUSES = %w[public unlisted private].freeze
|
||||
|
||||
belongs_to :match
|
||||
belongs_to :user
|
||||
@@ -12,10 +13,13 @@ class StreamSession < ApplicationRecord
|
||||
|
||||
validates :platform, inclusion: { in: PLATFORMS }
|
||||
validates :status, inclusion: { in: STATUSES }
|
||||
validates :privacy_status, inclusion: { in: PRIVACY_STATUSES }
|
||||
|
||||
before_validation :normalize_privacy_status
|
||||
before_validation :ensure_publish_token, on: :create
|
||||
|
||||
scope :broadcasting, -> { where(status: %w[live connecting reconnecting]) }
|
||||
scope :publicly_listed, -> { where(privacy_status: "public") }
|
||||
scope :search_by_team_or_opponent, lambda { |query|
|
||||
q = query.to_s.strip
|
||||
return all if q.blank?
|
||||
@@ -105,6 +109,14 @@ class StreamSession < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def link_only?
|
||||
privacy_status.in?(%w[unlisted private])
|
||||
end
|
||||
|
||||
def publicly_listed?
|
||||
privacy_status == "public"
|
||||
end
|
||||
|
||||
def terminal?
|
||||
status.in?(%w[ended error])
|
||||
end
|
||||
@@ -151,6 +163,11 @@ class StreamSession < ApplicationRecord
|
||||
self.publish_token ||= SecureRandom.urlsafe_base64(32)
|
||||
end
|
||||
|
||||
def normalize_privacy_status
|
||||
self.privacy_status = "public" if privacy_status.blank?
|
||||
self.privacy_status = "unlisted" if privacy_status == "private"
|
||||
end
|
||||
|
||||
def record_ended_timestamps!
|
||||
now = Time.current
|
||||
update!(ended_at: now) if ended_at.nil?
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
module Sessions
|
||||
class Create
|
||||
def self.normalize_privacy(value)
|
||||
value.to_s == "public" ? "public" : "unlisted"
|
||||
end
|
||||
|
||||
def initialize(user:, match:, params:)
|
||||
@user = user
|
||||
@match = match
|
||||
@@ -16,7 +20,7 @@ module Sessions
|
||||
match: @match,
|
||||
user: @user,
|
||||
platform: platform,
|
||||
privacy_status: @params[:privacy_status] || "unlisted",
|
||||
privacy_status: Sessions::Create.normalize_privacy(@params[:privacy_status]),
|
||||
quality_preset: @params[:quality_preset] || "720p_30_2.5mbps",
|
||||
target_bitrate: @params[:target_bitrate] || 2_500_000,
|
||||
target_fps: @params[:target_fps] || 30,
|
||||
|
||||
@@ -8,7 +8,7 @@ module Youtube
|
||||
@credential = @resolver.resolve
|
||||
end
|
||||
|
||||
def create_broadcast!(title:, privacy_status: "unlisted", scheduled_at: nil)
|
||||
def create_broadcast!(title:, privacy_status: "public", scheduled_at: nil)
|
||||
return mock_broadcast if @credential.blank? || missing_oauth_config?
|
||||
|
||||
client = authorized_client
|
||||
|
||||
Reference in New Issue
Block a user