mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 03:06:14 +02:00
improve notification feature
This commit is contained in:
parent
053382ffa3
commit
35f60e53e5
5 changed files with 37 additions and 16 deletions
|
@ -95,27 +95,27 @@ class NameserverRecordValidationJob < ApplicationJob
|
|||
end
|
||||
|
||||
logger.info text
|
||||
failed_log(text: text, nameserver: nameserver)
|
||||
failed_log(text: text, nameserver: nameserver, domain: domain)
|
||||
add_nameserver_to_failed(nameserver: nameserver, reason: text)
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def failed_log(text:, nameserver:)
|
||||
inform_to_tech_contact(text)
|
||||
def failed_log(text:, nameserver:, domain:)
|
||||
inform_to_tech_contact(domain: domain, text: text)
|
||||
inform_to_registrar(text: text, nameserver: nameserver)
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def inform_to_tech_contact(text)
|
||||
"NEED TO DO!"
|
||||
text
|
||||
def inform_to_tech_contact(domain:, text:)
|
||||
ContactNotification.notify_tech_contact(domain: domain, text: text)
|
||||
end
|
||||
|
||||
def inform_to_registrar(text:, nameserver:)
|
||||
# nameserver.domain.registrar.notifications.create!(text: text)
|
||||
"NEED TO DO!"
|
||||
# text = "DNSKEYS for #{domain.name} are invalid!"
|
||||
logger.info text
|
||||
ContactNotification.notify_registrar(domain: nameserver.domain, text: text)
|
||||
end
|
||||
|
||||
def logger
|
||||
|
|
|
@ -49,8 +49,7 @@ class ValidateDnssecJob < ApplicationJob
|
|||
text = "DNSKEYS for #{domain.name} are invalid!"
|
||||
logger.info text
|
||||
ContactNotification.notify_registrar(domain: domain, text: text)
|
||||
ContactNotification.notify_tech_contact(domain: domain)
|
||||
|
||||
ContactNotification.notify_tech_contact(domain: domain, text: text)
|
||||
end
|
||||
|
||||
def validate(hostname:, domain:, type: 'DNSKEY', klass: 'IN')
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
class ContactInformMailer < ApplicationMailer
|
||||
helper_method :address_processing
|
||||
|
||||
def notify(contact:, subject:)
|
||||
@contact = email
|
||||
def notify(contact:, domain:, subject:)
|
||||
@contact = contact
|
||||
@subject = subject
|
||||
@domain = domain
|
||||
|
||||
mail(to: contact.email, subject: subject)
|
||||
end
|
||||
|
|
|
@ -5,13 +5,12 @@ module ContactNotification
|
|||
domain.registrar.notifications.create(text: text)
|
||||
end
|
||||
|
||||
def notify_tech_contact(domain:)
|
||||
text = "DNSKEYS for #{domain.name} are invalid!"
|
||||
def notify_tech_contact(domain:, text:)
|
||||
# text = "DNSKEYS for #{domain.name} are invalid!"
|
||||
domain.tech_contacts.each do |tech|
|
||||
contact = Contact.find(tech.id)
|
||||
|
||||
ContactInformMailer.notify(contact: contact, subject: text)
|
||||
ContactInformMailer.notify(contact: contact, domain: domain, subject: text).deliver_now
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
22
test/services/contact_notification_test.rb
Normal file
22
test/services/contact_notification_test.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContactNotificationTest < ActionMailer::TestCase
|
||||
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
@text = 'text'
|
||||
end
|
||||
|
||||
def test_notify_registrar
|
||||
assert_difference -> { @domain.registrar.notifications.count } do
|
||||
ContactNotification.notify_registrar(domain: @domain, text: @text)
|
||||
end
|
||||
end
|
||||
|
||||
def test_notify_tech_contacts
|
||||
ContactNotification.notify_tech_contact(domain: @domain, text: @text)
|
||||
assert_equal @domain.tech_contacts.count, 2
|
||||
assert_emails 2
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue