From 3d60708508c6bfc5b6635aff0482d640a5f318ca Mon Sep 17 00:00:00 2001 From: Claire Date: Sat, 26 Feb 2022 16:28:28 +0100 Subject: [PATCH 1/2] Fix crash in EmailDomainBlockRefreshScheduler (#17649) --- app/workers/scheduler/email_domain_block_refresh_scheduler.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/workers/scheduler/email_domain_block_refresh_scheduler.rb b/app/workers/scheduler/email_domain_block_refresh_scheduler.rb index c67be68438..e0ad89866b 100644 --- a/app/workers/scheduler/email_domain_block_refresh_scheduler.rb +++ b/app/workers/scheduler/email_domain_block_refresh_scheduler.rb @@ -15,7 +15,8 @@ class Scheduler::EmailDomainBlockRefreshScheduler if ip?(email_domain_block.domain) [email_domain_block.domain] else - dns.getresources(email_domain_block.domain, Resolv::DNS::Resource::IN::A).to_a + dns.getresources(email_domain_block.domain, Resolv::DNS::Resource::IN::AAAA).to_a.map { |resource| resource.address.to_s } + resources = dns.getresources(email_domain_block.domain, Resolv::DNS::Resource::IN::A).to_a + dns.getresources(email_domain_block.domain, Resolv::DNS::Resource::IN::AAAA).to_a + resources.map { |resource| resource.address.to_s } end end From 6aef76b5cde2315135d53215d13a9b2ec0a1adaa Mon Sep 17 00:00:00 2001 From: Claire Date: Sat, 26 Feb 2022 17:26:28 +0100 Subject: [PATCH 2/2] Fix error when a MX is shared across blocked domains (#17650) --- app/controllers/admin/email_domain_blocks_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/admin/email_domain_blocks_controller.rb b/app/controllers/admin/email_domain_blocks_controller.rb index 33ee079f36..a4bbbba5ba 100644 --- a/app/controllers/admin/email_domain_blocks_controller.rb +++ b/app/controllers/admin/email_domain_blocks_controller.rb @@ -38,6 +38,8 @@ module Admin log_action :create, @email_domain_block (@email_domain_block.other_domains || []).uniq.each do |domain| + next if EmailDomainBlock.where(domain: domain).exists? + other_email_domain_block = EmailDomainBlock.create!(domain: domain, parent: @email_domain_block) log_action :create, other_email_domain_block end