app/models/plan.rb
# Callback that will notify scubscribers of a new version of the Plan
Callback that will notify scubscribers of a new version of the Plan
Callback that will notify scubscribers of a new version of the Plan
def notify_subscribers
    return true unless doi.present? && subscriptions.any?
    api_client = ApiClient.where(name: DoiService.scheme_name).first
    subscription = subscriptions.select do |s|
      s.subscriber_id == api_client.id && s.subscriber_type == 'ApiClient'
    end
    return true unless api_client.present? && subscription.present?
    DoiService.update_doi(plan: self)
  rescue StandardError => e
    Rails.logger.error "Failure on Plan.notify_subscribers for id - #{id} & client - '#{api_client&.name}'"
    return true
  end
def notify_subscribers return true unless doi . present? && subscriptions . any? api_client = ApiClient . where ( name : DoiService . scheme_name ) . first subscription = subscriptions . select do | s | s . subscriber_id == api_client . id && s . subscriber_type == 'ApiClient' end return true unless api_client . present? && subscription . present? DoiService . update_doi ( plan : self ) rescue StandardError => e Rails . logger . error "Failure on Plan.notify_subscribers for id - #{id} & client - '#{api_client&.name}'" return true end
Callback that will notify scubscribers of a new version of the Plan
Callback that will notify scubscribers of a new version of the Plan
# If the registered DOI Service is subscribed then continue # TODO: eventually consider setting this up as a Job and using the ApiClient's callback_url #       and callback_method as the targets to process other subscribers # UpdateDoiJob.perform_later(plan: self) # Log the error and continue. We do not want this to disrupt the save!