From 4f6b09de3d53ea2edc0a4fabd01b0a7ce57c9d15 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Wed, 21 Feb 2024 13:16:44 +0100 Subject: [PATCH 1/2] Fixes #37192 - Use with_enabled_email scope Instead of typing out the same query explicitly. --- app/lib/actions/katello/capsule_content/sync.rb | 2 +- app/lib/actions/katello/content_view/promote.rb | 2 +- app/lib/actions/katello/content_view/publish.rb | 2 +- app/lib/actions/katello/repository/sync.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/lib/actions/katello/capsule_content/sync.rb b/app/lib/actions/katello/capsule_content/sync.rb index 88b8813ac36..ee283827e85 100644 --- a/app/lib/actions/katello/capsule_content/sync.rb +++ b/app/lib/actions/katello/capsule_content/sync.rb @@ -52,7 +52,7 @@ def notify_on_failure(_plan) notification = MailNotification[:proxy_sync_failure] proxy = SmartProxy.find(input.fetch(:smart_proxy, {})[:id]) subjects = subjects(input[:options]).merge(smart_proxy: proxy) - notification.users.where(disabled: [nil, false], mail_enabled: true).each do |user| + notification.users.with_enabled_email.each do |user| notification.deliver(subjects.merge(user: user, task: task)) end end diff --git a/app/lib/actions/katello/content_view/promote.rb b/app/lib/actions/katello/content_view/promote.rb index cdfaccd2f69..a8162179a16 100644 --- a/app/lib/actions/katello/content_view/promote.rb +++ b/app/lib/actions/katello/content_view/promote.rb @@ -27,7 +27,7 @@ def plan(version, environments, is_force = false, description = nil, incremental def notify_on_failure(_plan) notification = MailNotification[:content_view_promote_failure] view = ::Katello::ContentView.find(input.fetch(:content_view, {})[:id]) - notification.users.where(disabled: [nil, false], mail_enabled: true).each do |user| + notification.users.with_enabled_email.each do |user| notification.deliver(user: user, content_view: view, task: task) end end diff --git a/app/lib/actions/katello/content_view/publish.rb b/app/lib/actions/katello/content_view/publish.rb index d0257a6690e..cf3969dc74f 100644 --- a/app/lib/actions/katello/content_view/publish.rb +++ b/app/lib/actions/katello/content_view/publish.rb @@ -136,7 +136,7 @@ def trigger_capsule_sync(_execution_plan) def notify_on_failure(_plan) notification = MailNotification[:content_view_publish_failure] view = ::Katello::ContentView.find(input.fetch(:content_view, {})[:id]) - notification.users.where(disabled: [nil, false], mail_enabled: true).each do |user| + notification.users.with_enabled_email.each do |user| notification.deliver(user: user, content_view: view, task: task) end end diff --git a/app/lib/actions/katello/repository/sync.rb b/app/lib/actions/katello/repository/sync.rb index c5686b2af82..6ff1384e139 100644 --- a/app/lib/actions/katello/repository/sync.rb +++ b/app/lib/actions/katello/repository/sync.rb @@ -100,7 +100,7 @@ def rescue_strategy def notify_on_failure(_plan) notification = MailNotification[:repository_sync_failure] repo = ::Katello::Repository.find(input.fetch(:repository, {})[:id]) - notification.users.where(disabled: [nil, false], mail_enabled: true).each do |user| + notification.users.with_enabled_email.each do |user| notification.deliver(user: user, repo: repo, task: task) end end From 88eaf19c34fa723eb76ef029b711d6f178623b26 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Wed, 21 Feb 2024 13:18:45 +0100 Subject: [PATCH 2/2] Refs #37192 - Bump required foreman version --- lib/katello/plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/katello/plugin.rb b/lib/katello/plugin.rb index 9f5099c1620..3ab49ecd176 100644 --- a/lib/katello/plugin.rb +++ b/lib/katello/plugin.rb @@ -4,7 +4,7 @@ # rubocop:disable Metrics/BlockLength Foreman::Plugin.register :katello do - requires_foreman '>= 3.7' + requires_foreman '>= 3.11' register_gettext sub_menu :top_menu, :content_menu, :caption => N_('Content'),