Sha256: 0cfdf0737cd2553fc36aad8750771fae3168256ad04af18241a60ef446d0d6d1

Contents?: true

Size: 872 Bytes

Versions: 21

Compression:

Stored size: 872 Bytes

Contents

# frozen_string_literal: true
module ForemanDiscovery
  module UINotifications
    # Adds notification upon newly discovered Hosts
    # This class will only create one notification for newly discovered Hosts
    # and will update notification expiry when new discovered hosts appear.
    class NewHost < ::UINotifications::Base
      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_SUBJECT,
          subject: subject,
          notification_blueprint: blueprint
        )
      end

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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
foreman_discovery-16.3.6 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.3.5 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.1.4 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.1.3 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.3.4 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.3.1 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.1.2 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.2.0 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.1.0 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.0.1 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-16.0.0 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-15.1.0 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-15.0.2 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-15.0.1 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-15.0.0 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-14.0.1 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-14.0.0 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-13.0.1 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-12.0.2 app/services/foreman_discovery/ui_notifications/new_host.rb
foreman_discovery-12.0.1 app/services/foreman_discovery/ui_notifications/new_host.rb