Skip to content

Commit

Permalink
Merge pull request #2344 from internetee/fix-fd-poll-message-after-va…
Browse files Browse the repository at this point in the history
…lidation

fix poll message spam after validation email
  • Loading branch information
vohmar authored Apr 18, 2022
2 parents fd9b71d + e320a7c commit 253da80
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
26 changes: 17 additions & 9 deletions app/interactions/domains/force_delete/notify_registrar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@ def execute
end

def notify_without_email
domain.registrar.notifications.create!(text: I18n.t('force_delete_set_on_domain',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date))
template = I18n.t('force_delete_set_on_domain',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date)

return if domain.registrar.notifications.last.text.include? template

domain.registrar.notifications.create!(text: template)
end

def notify_with_email
domain.registrar.notifications.create!(text: I18n.t('force_delete_auto_email',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date,
email: email))
template = I18n.t('force_delete_auto_email',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date,
email: email)

return if domain.registrar.notifications.last.text.include? template

domain.registrar.notifications.create!(text: template)
end
end
end
Expand Down
17 changes: 11 additions & 6 deletions app/interactions/domains/force_delete_email/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ def expired_or_hold_domains_exists?(domains)
def before_execute_force_delete(domain)
if domain.force_delete_scheduled? && !domain.status_notes[DomainStatus::FORCE_DELETE].nil?
added_additional_email_into_notes(domain)
notify_registrar(domain)
else
process_force_delete(domain)
end
end

def notify_registrar(domain)
domain.registrar.notifications.create!(text: I18n.t('force_delete_auto_email',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date,
email: domain.status_notes[DomainStatus::FORCE_DELETE]))
template = I18n.t('force_delete_auto_email',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date,
email: domain.status_notes[DomainStatus::FORCE_DELETE])

return if domain.registrar.notifications.last.text.include? template

domain.registrar.notifications.create!(text: template)
end

def process_force_delete(domain)
Expand All @@ -56,6 +59,8 @@ def process_force_delete(domain)
def added_additional_email_into_notes(domain)
return if domain.status_notes[DomainStatus::FORCE_DELETE].include? email

# notify_registrar(domain)

domain.status_notes[DomainStatus::FORCE_DELETE].concat(" #{email}")
domain.save(validate: false)
end
Expand Down
2 changes: 1 addition & 1 deletion test/models/domain/force_delete_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def test_add_invalid_email_to_domain_status_notes

assert_equal domain.status_notes[DomainStatus::FORCE_DELETE], invalid_emails
notification = domain.registrar.notifications.last
assert notification.text.include? asserted_text
assert_not notification.text.include? asserted_text
end

def test_remove_invalid_email_from_domain_status_notes
Expand Down

0 comments on commit 253da80

Please sign in to comment.