trabajo-afectivo/app/models/transaction/trigger.rb

45 lines
974 B
Ruby
Raw Permalink Normal View History

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
2016-05-03 00:36:44 +00:00
class Transaction::Trigger
=begin
{
object: 'Ticket',
type: 'update',
object_id: 123,
interface_handle: 'application_server', # application_server|websocket|scheduler
2016-05-03 00:36:44 +00:00
changes: {
'attribute1' => [before, now],
'attribute2' => [before, now],
2016-07-16 21:43:08 +00:00
},
created_at: Time.zone.now,
2016-05-03 00:36:44 +00:00
user_id: 123,
},
=end
def initialize(item, params = {})
@item = item
@params = params
end
def perform
# return if we run import mode
return if Setting.get('import_mode')
return if @item[:object] != 'Ticket'
ticket = Ticket.find_by(id: @item[:object_id])
2016-05-03 00:36:44 +00:00
return if !ticket
2016-05-03 00:36:44 +00:00
if @item[:article_id]
article = Ticket::Article.find_by(id: @item[:article_id])
2016-05-03 00:36:44 +00:00
end
original_user_id = UserInfo.current_user_id
Ticket.perform_triggers(ticket, article, @item, @params)
UserInfo.current_user_id = original_user_id
2016-05-03 00:36:44 +00:00
end
end