Files
MatchLiveTv/backend/app/services/recordings/notify_expiring.rb
T
eminuxandCursor 645807b853 Evita 500 senza SMTP e chiude gli incidenti overflow stale.
Reset password e mail replay usano deliver_mail; il health check overflow risolve tutte le fingerprint del kind, non solo quella sana.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-31 08:55:36 +02:00

40 lines
1.1 KiB
Ruby

module Recordings
class NotifyExpiring
WINDOW_DAYS = 7
def initialize(recording)
@recording = recording
end
def call
return @recording if @recording.expiry_warning_sent_at.present?
return @recording unless @recording.ready?
return @recording if @recording.expires_at.blank?
return @recording unless @recording.expires_at <= WINDOW_DAYS.days.from_now
recipients.each do |user|
deliver_expiring_soon(user)
end
@recording.update!(expiry_warning_sent_at: Time.current)
@recording
end
private
def deliver_expiring_soon(user)
MatchLiveTv.deliver_mail(Recordings::ReplayMailer.replay_expiring_soon(recording: @recording, recipient: user))
rescue EOFError => e
Rails.logger.warn("[Recordings::NotifyExpiring] SMTP EOF on close for #{user.email}: #{e.message}")
end
def recipients
club = @recording.team.club
owner = club.owner
users = club.users.distinct.to_a
users << owner if owner && users.none? { |u| u.id == owner.id }
users.uniq.select { |u| u.email.present? }
end
end
end