Sha256: 7e8a7c669a5c50c4ee9c5f53ca9dcdbf66b455e80a57d5fa382b9d9875737415

Contents?: true

Size: 849 Bytes

Versions: 9

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true
module ForemanDiscovery
  module UINotifications
    # Adds notification upon failed discovery
    class FailedDiscovery < ::UINotifications::Base
      def initialize(message)
        @message = message
      end

      private

      def create
        add_notification if update_notifications.zero?
      end

      def update_notifications
        blueprint.mass_update_expiry
      end

      def add_notification
        Notification.create!(
          initiator: initiator,
          audience: ::Notification::AUDIENCE_ADMIN,
          message: _("One or more hosts with failed discovery due to error: %s") % @message,
          notification_blueprint: blueprint,
        )
      end

      def blueprint
        @blueprint ||= NotificationBlueprint.find_by(name: 'failed_discovery')
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_discovery-25.1.0 app/services/foreman_discovery/ui_notifications/failed_discovery.rb
foreman_discovery-25.0.1 app/services/foreman_discovery/ui_notifications/failed_discovery.rb
foreman_discovery-25.0.0 app/services/foreman_discovery/ui_notifications/failed_discovery.rb
foreman_discovery-24.0.2 app/services/foreman_discovery/ui_notifications/failed_discovery.rb
foreman_discovery-23.0.2 app/services/foreman_discovery/ui_notifications/failed_discovery.rb
foreman_discovery-24.0.1 app/services/foreman_discovery/ui_notifications/failed_discovery.rb
foreman_discovery-24.0.0 app/services/foreman_discovery/ui_notifications/failed_discovery.rb
foreman_discovery-23.0.1 app/services/foreman_discovery/ui_notifications/failed_discovery.rb
foreman_discovery-23.0.0 app/services/foreman_discovery/ui_notifications/failed_discovery.rb