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-14.1.2 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-14.1.1 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-14.1.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-14.0.2 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-14.0.1 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-13.2.6 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-14.0.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-13.2.5 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-13.2.4 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-13.2.3 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-13.2.2 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-12.0.7 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-13.2.1 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-13.2.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-10.1.3 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-13.0.0 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-12.0.5 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-12.0.4 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-12.0.1 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb
foreman_remote_execution-12.0.2 app/services/ui_notifications/remote_execution_jobs/base_job_finish.rb