module Recordings
  class PostProcessJob
    include Sidekiq::Job
    sidekiq_options retry: 2, queue: "default"

    def perform(recording_id)
      recording = Recording.find_by(id: recording_id)
      return unless recording&.ready?

      Recordings::NotifyReady.new(recording).call

      return unless recording.auto_publish_youtube?
      return if recording.youtube_video_id.present?

      Recordings::PublishToYoutubeJob.perform_async(recording.id)
    end
  end
end
