Class: RailsOnboarding::OnboardingNotificationJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
lib/rails_onboarding/background_jobs.rb

Instance Method Summary collapse

Methods inherited from ApplicationJob

queue_name

Instance Method Details

#perform(user_id, notification_type, data = {}) ⇒ Object



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/rails_onboarding/background_jobs.rb', line 251

def perform(user_id, notification_type, data = {})
  user = find_user(user_id)
  return unless user

  # Create notification record if notification system exists
  if defined?(Noticed) && user.respond_to?(:notifications)
    # Using Noticed gem
    create_noticed_notification(user, notification_type, data)
  elsif user.respond_to?(:notify)
    # Custom notification system
    user.notify(notification_type, data)
  else
    # Fallback: log notification
    Rails.logger.info "Onboarding notification for user #{user_id}: #{notification_type}"
  end
rescue StandardError => e
  Rails.logger.error "Failed to send notification: #{e.message}"
  raise e if should_retry?
end