Sha256: 057d5d080771e10f7995aab47fb3866f8311bc247f31dc6d911d46305466b88a

Contents?: true

Size: 869 Bytes

Versions: 69

Compression:

Stored size: 869 Bytes

Contents

module UINotifications
  module RemoteExecutionJobs
    class BaseJobFinish < ::UINotifications::Base
      def initialize(job_invocation)
        @subject = job_invocation
      end

      def deliver!
        ::Notification.create!(
          :audience => Notification::AUDIENCE_USER,
          :notification_blueprint => blueprint,
          :initiator => initiator,
          :message => message,
          :subject => subject
        )
      end

      def initiator
        User.anonymous_admin
      end

      def blueprint
        blueprint = @subject.status == HostStatus::ExecutionStatus::ERROR ? 'rex_job_failed' : 'rex_job_succeeded'
        @blueprint ||= NotificationBlueprint.unscoped.find_by(:name => blueprint)
      end

      def message
        UINotifications::StringParser.new(blueprint.message, { subject: subject })
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
foreman_remote_execution-9.1.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-8.2.1 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-8.2.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-9.0.1 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-9.0.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-8.1.2 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-8.1.1 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-8.1.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-7.2.2 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-7.2.1 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-7.2.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-5.0.8 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-8.0.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-7.1.1 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-7.1.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-7.0.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-5.0.7 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-5.0.6 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-6.2.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-5.0.5 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb