2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2015-11-10 14:01:04 +00:00
|
|
|
class Sessions::Event
|
|
|
|
include ApplicationLib
|
|
|
|
|
2015-12-09 13:09:37 +00:00
|
|
|
def self.run(params)
|
2015-11-10 14:05:29 +00:00
|
|
|
begin
|
2019-01-06 18:41:29 +00:00
|
|
|
backend = "Sessions::Event::#{params[:event].to_classname}".constantize
|
2015-11-10 14:05:29 +00:00
|
|
|
rescue => e
|
2018-12-03 14:10:36 +00:00
|
|
|
Rails.logger.error e.inspect
|
|
|
|
Rails.logger.error e.backtrace
|
2018-11-02 17:42:57 +00:00
|
|
|
return { event: 'error', data: { error: "No such event #{params[:event]}: #{e.inspect}", payload: params[:payload] } }
|
2015-11-10 14:05:29 +00:00
|
|
|
end
|
2015-11-10 14:01:04 +00:00
|
|
|
|
2017-04-20 11:15:40 +00:00
|
|
|
begin
|
|
|
|
instance = backend.new(params)
|
|
|
|
result = instance.run
|
|
|
|
instance.destroy
|
|
|
|
result
|
|
|
|
rescue => e
|
2018-12-03 14:10:36 +00:00
|
|
|
Rails.logger.error e.inspect
|
|
|
|
Rails.logger.error e.backtrace
|
2020-02-18 19:51:31 +00:00
|
|
|
{ event: 'error', data: { error: e.message, payload: params[:payload] } }
|
2017-04-20 11:15:40 +00:00
|
|
|
end
|
2015-11-10 14:01:04 +00:00
|
|
|
end
|
|
|
|
|
2015-11-10 14:05:29 +00:00
|
|
|
end
|