module Recordings
  class ReplayMailer < ApplicationMailer
    default from: -> { MatchLiveTv.mail_from }

    def replay_ready(recording:, recipient:)
      @recording = recording
      @team = recording.team
      @club = @team.club
      @recipient = recipient
      @replay_url = recording.replay_url
      @expires_at = recording.expires_at

      mail(
        to: recipient.email,
        subject: "Replay pronto — #{recording.title_or_default}"
      )
    end

    def replay_expiring_soon(recording:, recipient:)
      @recording = recording
      @team = recording.team
      @club = @team.club
      @recipient = recipient
      @replay_url = recording.replay_url
      @expires_at = recording.expires_at
      @days_left = ((recording.expires_at - Time.current) / 1.day).ceil

      mail(
        to: recipient.email,
        subject: "Replay in scadenza tra #{@days_left} giorni — #{recording.title_or_default}"
      )
    end
  end
end
