mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 01:36:02 +02:00
parent
97426e001b
commit
fa47eb3ab6
13 changed files with 129 additions and 43 deletions
|
@ -1,10 +1,10 @@
|
|||
class DomainExpirationEmailJob < Que::Job
|
||||
def run(domain_id:)
|
||||
def run(domain_id)
|
||||
domain = Domain.find(domain_id)
|
||||
|
||||
return if domain.registered?
|
||||
|
||||
DomainMailer.expiration(domain: domain).deliver
|
||||
DomainExpireMailer.expired(domain: domain, registrar: domain.registrar).deliver_now
|
||||
destroy
|
||||
end
|
||||
end
|
||||
|
|
9
app/mailers/domain_expire_mailer.rb
Normal file
9
app/mailers/domain_expire_mailer.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class DomainExpireMailer < ApplicationMailer
|
||||
def expired(domain:, registrar:)
|
||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
|
||||
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
mail(to: domain.primary_contact_emails, subject: subject)
|
||||
end
|
||||
end
|
|
@ -83,14 +83,6 @@ class DomainMailer < ApplicationMailer
|
|||
mail(to: domain.primary_contact_emails)
|
||||
end
|
||||
|
||||
def expiration(domain:)
|
||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
||||
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
mail(to: domain.primary_contact_emails, subject: subject)
|
||||
end
|
||||
|
||||
private
|
||||
# app/models/DomainMailModel provides the data for mail that can be composed_from
|
||||
# which ensures that values of objects are captured when they are valid, not later when this method is executed
|
||||
|
|
|
@ -49,7 +49,7 @@ class DomainCron
|
|||
saved = domain.save(validate: false)
|
||||
|
||||
if saved
|
||||
DomainExpirationEmailJob.enqueue(domain_id: domain.id, run_at: send_time)
|
||||
DomainExpirationEmailJob.enqueue(domain.id, run_at: send_time)
|
||||
marked += 1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue