event.rb 756 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class Sessions::Event
  3. include ApplicationLib
  4. def self.run(params)
  5. begin
  6. backend = "Sessions::Event::#{params[:event].to_classname}".constantize
  7. rescue => e
  8. Rails.logger.error e.inspect
  9. Rails.logger.error e.backtrace
  10. return { event: 'error', data: { error: "No such event #{params[:event]}: #{e.inspect}", payload: params[:payload] } }
  11. end
  12. begin
  13. instance = backend.new(params)
  14. result = instance.run
  15. instance.destroy
  16. result
  17. rescue => e
  18. Rails.logger.error e.inspect
  19. Rails.logger.error e.backtrace
  20. { event: 'error', data: { error: e.message, payload: params[:payload] } }
  21. end
  22. end
  23. end