core_workflow.rb 972 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class CoreWorkflow < ApplicationModel
  3. include ChecksClientNotification
  4. include CoreWorkflow::Assets
  5. default_scope { order(:priority, :id) }
  6. scope :active, -> { where(active: true) }
  7. scope :changeable, -> { where(changeable: true) }
  8. scope :object, ->(object) { where(object: [object, nil]) }
  9. store :preferences
  10. store :condition_saved
  11. store :condition_selected
  12. store :perform
  13. validates :name, presence: true
  14. def self.perform(payload:, user:, assets: {}, assets_in_result: true, result: {}, form_updater: false)
  15. CoreWorkflow::Result.new(payload: payload, user: user, assets: assets, assets_in_result: assets_in_result, result: result, form_updater: form_updater).run
  16. rescue => e
  17. return {} if e.is_a?(ArgumentError)
  18. raise e if !Rails.env.production?
  19. Rails.logger.error 'Error performing Core Workflow engine.'
  20. Rails.logger.error e
  21. {}
  22. end
  23. end