2016-10-19 03:11:36 +00:00
|
|
|
# Copyright (C) 2012-2016 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,
|
2016-08-20 19:29:22 +00:00
|
|
|
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.lookup(id: @item[:object_id])
|
|
|
|
return if !ticket
|
|
|
|
if @item[:article_id]
|
|
|
|
article = Ticket::Article.lookup(id: @item[:article_id])
|
|
|
|
end
|
|
|
|
|
2016-05-04 09:45:05 +00:00
|
|
|
original_user_id = UserInfo.current_user_id
|
2016-11-18 07:25:07 +00:00
|
|
|
|
2018-05-29 15:42:14 +00:00
|
|
|
Ticket.perform_triggers(ticket, article, @item, @params)
|
2017-03-03 08:28:45 +00:00
|
|
|
|
2016-05-04 09:45:05 +00:00
|
|
|
UserInfo.current_user_id = original_user_id
|
2016-05-03 00:36:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|