2014-02-03 19:23:00 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-12-24 13:55:43 +00:00
|
|
|
class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
|
|
|
|
observe 'ticket::_article'
|
|
|
|
|
|
|
|
def before_create(record)
|
|
|
|
|
|
|
|
# return if we run import mode
|
|
|
|
return if Setting.get('import_mode')
|
|
|
|
|
2016-08-20 19:29:22 +00:00
|
|
|
# only do fill of from if article got created via application_server (e. g. not
|
|
|
|
# if article and sender type is set via *.postmaster)
|
|
|
|
return if ApplicationHandleInfo.current.split('.')[1] == 'postmaster'
|
|
|
|
|
2016-08-31 16:17:08 +00:00
|
|
|
# set from on all article types excluding email|twitter status|twitter direct-message|facebook feed post|facebook feed comment
|
2016-08-24 18:29:56 +00:00
|
|
|
return if !record.type_id
|
|
|
|
type = Ticket::Article::Type.lookup(id: record.type_id)
|
|
|
|
return if type['name'] == 'email'
|
2015-04-30 15:25:04 +00:00
|
|
|
|
2016-08-31 16:17:08 +00:00
|
|
|
# from will be set by channel backend
|
|
|
|
return if type['name'] == 'twitter status'
|
|
|
|
return if type['name'] == 'twitter direct-message'
|
|
|
|
return if type['name'] == 'facebook feed post'
|
|
|
|
return if type['name'] == 'facebook feed comment'
|
|
|
|
|
2016-08-23 18:46:04 +00:00
|
|
|
return if !record.created_by_id
|
2016-01-16 00:16:31 +00:00
|
|
|
user = User.find(record.created_by_id)
|
2015-04-30 15:25:04 +00:00
|
|
|
record.from = "#{user.firstname} #{user.lastname}"
|
2012-12-24 13:55:43 +00:00
|
|
|
end
|
2013-06-12 15:59:58 +00:00
|
|
|
end
|